BGC Tools
Public Member Functions | Static Public Member Functions | Data Fields | Private Member Functions | Static Private Attributes
BGC.Study.Session Class Reference
Inheritance diagram for BGC.Study.Session:
Inheritance graph
[legend]
Collaboration diagram for BGC.Study.Session:
Collaboration graph
[legend]

Public Member Functions

 Session ()
 
 Session (JsonObject sessionData)
 Deserialization Constructor Deserialized Sessions are not added to the Session dictionary More...
 
void Add (SessionElement element)
 
void AddRange (IEnumerable< SessionElement > elements)
 
JsonObject SerializeSession ()
 

Static Public Member Functions

static void HardClear ()
 

Data Fields

readonly int id
 
List< SessionElementIDsessionElements
 
JsonObject envVals
 
int Count => sessionElements.Count
 
SessionElement this[int i] => sessionElements[i].Element
 

Private Member Functions

IEnumerator< SessionElementID > IEnumerable< SessionElementID >. GetEnumerator ()
 
IEnumerator IEnumerable. GetEnumerator ()
 

Static Private Attributes

static int nextSessionID = 1
 

Detailed Description

Definition at line 75 of file Protocol.cs.

Constructor & Destructor Documentation

◆ Session() [1/2]

BGC.Study.Session.Session ( )
inline

Definition at line 84 of file Protocol.cs.

References BGC.Study.ProtocolManager.sessionDictionary.

85  {
86  id = nextSessionID++;
87  sessionElements = new List<SessionElementID>();
88  envVals = new JsonObject();
89 
90  ProtocolManager.sessionDictionary.Add(id, this);
91  }
JsonObject envVals
Definition: Protocol.cs:81
List< SessionElementID > sessionElements
Definition: Protocol.cs:80
Represents a key-value pair collection of JsonValue objects.
Definition: JsonObject.cs:13
static int nextSessionID
Definition: Protocol.cs:77

◆ Session() [2/2]

BGC.Study.Session.Session ( JsonObject  sessionData)
inline

Deserialization Constructor Deserialized Sessions are not added to the Session dictionary

Definition at line 97 of file Protocol.cs.

References LightJson.JsonObject.Add(), BGC.Study.ProtocolKeys.Session.EnvironmentValues, BGC.Study.ProtocolKeys.Session.Id, and BGC.Study.ProtocolKeys.Session.SessionElementIDs.

98  {
99  id = sessionData[ProtocolKeys.Session.Id];
100 
101  if (nextSessionID <= id)
102  {
103  nextSessionID = id + 1;
104  }
105 
106  sessionElements = new List<SessionElementID>();
107  foreach (int sessionElementID in sessionData[ProtocolKeys.Session.SessionElementIDs].AsJsonArray)
108  {
109  sessionElements.Add(sessionElementID);
110  }
111 
112  if (sessionData.ContainsKey(ProtocolKeys.Session.EnvironmentValues))
113  {
114  envVals = sessionData[ProtocolKeys.Session.EnvironmentValues].AsJsonObject;
115  }
116  else
117  {
118  envVals = new JsonObject();
119  }
120  }
JsonObject envVals
Definition: Protocol.cs:81
List< SessionElementID > sessionElements
Definition: Protocol.cs:80
Represents a key-value pair collection of JsonValue objects.
Definition: JsonObject.cs:13
static int nextSessionID
Definition: Protocol.cs:77
Here is the call graph for this function:

Member Function Documentation

◆ Add()

void BGC.Study.Session.Add ( SessionElement  element)
inline

Definition at line 125 of file Protocol.cs.

126  {
127  //It was supremely convenient for constructing tasks to allow for (and block)
128  // null session elements
129  if (element != null)
130  {
131  sessionElements.Add(element);
132  }
133  }
List< SessionElementID > sessionElements
Definition: Protocol.cs:80

◆ AddRange()

void BGC.Study.Session.AddRange ( IEnumerable< SessionElement elements)
inline

Definition at line 135 of file Protocol.cs.

136  {
137  foreach (SessionElement element in elements)
138  {
139  //It was supremely convenient for constructing tasks to allow for (and block)
140  // null session elements
141  if (element != null)
142  {
143  sessionElements.Add(element);
144  }
145  }
146  }
List< SessionElementID > sessionElements
Definition: Protocol.cs:80

◆ GetEnumerator() [1/2]

IEnumerator<SessionElementID> IEnumerable<SessionElementID>. BGC.Study.Session.GetEnumerator ( )
private

◆ GetEnumerator() [2/2]

IEnumerator IEnumerable. BGC.Study.Session.GetEnumerator ( )
private

◆ HardClear()

static void BGC.Study.Session.HardClear ( )
inlinestatic

Definition at line 170 of file Protocol.cs.

Referenced by BGC.Study.ProtocolManager.HardClearAll().

171  {
172  nextSessionID = 1;
173  }
static int nextSessionID
Definition: Protocol.cs:77
Here is the caller graph for this function:

◆ SerializeSession()

JsonObject BGC.Study.Session.SerializeSession ( )
inline

Definition at line 148 of file Protocol.cs.

References LightJson.JsonObject.Add(), LightJson.JsonObject.Count, BGC.Study.ProtocolKeys.Session.EnvironmentValues, BGC.Study.ProtocolKeys.Session.Id, BGC.Study.SessionElementID.id, and BGC.Study.ProtocolKeys.Session.SessionElementIDs.

Referenced by BGC.Study.ProtocolManager.SerializeSessions().

149  {
150  JsonArray jsonElementsIDs = new JsonArray();
151  foreach (SessionElementID elementID in sessionElements)
152  {
153  jsonElementsIDs.Add(elementID.id);
154  }
155 
156  JsonObject newSession = new JsonObject()
157  {
158  { ProtocolKeys.Session.Id, id },
159  { ProtocolKeys.Session.SessionElementIDs, jsonElementsIDs }
160  };
161 
162  if (envVals.Count > 0)
163  {
164  newSession.Add(ProtocolKeys.Session.EnvironmentValues, envVals);
165  }
166 
167  return newSession;
168  }
Represents an ordered collection of JsonValues.
Definition: JsonArray.cs:11
int Count
The number of properties in this JsonObject.
Definition: JsonObject.cs:18
JsonObject envVals
Definition: Protocol.cs:81
List< SessionElementID > sessionElements
Definition: Protocol.cs:80
JsonArray Add(JsonValue value)
Adds the given value to this collection.
Definition: JsonArray.cs:65
Represents a key-value pair collection of JsonValue objects.
Definition: JsonObject.cs:13
JsonObject Add(string key)
Adds a key with a null value to this collection.
Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ Count

int BGC.Study.Session.Count => sessionElements.Count

◆ envVals

JsonObject BGC.Study.Session.envVals

Definition at line 81 of file Protocol.cs.

Referenced by BGC.Study.ProtocolManager.GetEnvValue().

◆ id

readonly int BGC.Study.Session.id

◆ nextSessionID

int BGC.Study.Session.nextSessionID = 1
staticprivate

Definition at line 77 of file Protocol.cs.

◆ sessionElements

List<SessionElementID> BGC.Study.Session.sessionElements

Definition at line 80 of file Protocol.cs.

◆ this[int i]

SessionElement BGC.Study.Session.this[int i] => sessionElements[i].Element

Definition at line 123 of file Protocol.cs.


The documentation for this class was generated from the following file: