![]() |
Sigma
|
A sigma environment, where all the magic happens. More...
Public Member Functions | |
void | SetRandomSeed (int seed) |
Set the random seed used for all randomised computations for reproducibility. More... | |
TMonitor | AddMonitor< TMonitor > (TMonitor monitor) |
Add a monitor to this environment. More... | |
void | Prepare () |
Prepare this environment for execution. Start all monitors. More... | |
ITrainer | CreateTrainer (string name) |
Create a trainer with a certain unique name and add it to this environment. More... | |
TTrainer | AddTrainer< TTrainer > (TTrainer trainer) |
Add a trainer to this environment. More... | |
void | RemoveTrainer (ITrainer trainer) |
Remove a trainer (and its associated operator) from this environment. Note: Warning, this is probably not what you want. Trainer removal may cause inconsistent behaviour during execution. If the operator is currently running and cannot be disassociated this method will throw an exception. More... | |
async Task | RunAsync () |
void | Run () |
Run this environment. Execute all registered options until stop is requested. Note: This method is blocking and executes in the calling thread. More... | |
void | SignalStop () |
Signal this environment to stop execution as soon as possible (if running). More... | |
void | RequestAttachGlobalHook (IHook hook, string trainerName) |
Request for a hook to be attached to a certain trainer's operator (identified by its name). More... | |
void | RequestAttachGlobalHook (IHook hook, ITrainer trainer) |
Request for a hook to be attached to a certain trainer's operator. More... | |
void | RequestAttachGlobalHook (IHook hook, IOperator operatorToAttachTo) |
Request for a hook to be attached to a certain operator. More... | |
void | RequestAttachLocalHook (IHook hook, string trainerName) |
Request for a hook to be attached to a certain trainer's operator (identified by its name). More... | |
void | RequestAttachLocalHook (IHook hook, ITrainer trainer) |
Request for a hook to be attached to a certain trainer's operator. More... | |
void | RequestAttachLocalHook (IHook hook, IOperator operatorToAttachTo) |
Request for a hook to be attached to a certain operator. More... | |
T [] | ResolveGet< T > (string matchIdentifier, out string[] fullMatchedIdentifierArray, T[] values=null) |
Resolve all matching identifiers in this registry. For the detailed supported syntax IRegistryResolver. More... | |
T [] | ResolveGet< T > (string matchIdentifier, T[] values=null) |
Resolve all matching identifiers in this registry. For the detailed supported syntax IRegistryResolver. More... | |
string [] | ResolveSet< T > (string matchIdentifier, T value, bool addIdentifierIfNotExists=false, Type associatedType=null) |
Set a single given value of a certain type to all matching identifiers. For the detailed supported syntax IRegistryResolver. Note: The individual registries might throw an exception if a type-protected value is set to the wrong type. More... | |
Static Public Member Functions | |
static void | EnableLogging () |
Loads the log4net configuration from the corresponding xml file. See log4net for more details. More... | |
static SigmaEnvironment | Create (string environmentName) |
Create an environment with a certain name. More... | |
static SigmaEnvironment | GetOrCreate (string environmentName) |
Get environment if it already exists, create and return new one if it does not. More... | |
static SigmaEnvironment | Get (string environmentName) |
Gets an environment with a given name, if previously created (null otherwise). More... | |
static bool | Exists (string environmentName) |
Checks whether an environment exists with the given name. More... | |
static void | Remove (string environmentName) |
Removes an environment with a given name. More... | |
static void | Clear () |
Removes all active environments. More... | |
Protected Member Functions | |
void | FetchRunningOperators () |
Properties | |
bool | StartOperatorsOnRun [get, set] |
If the IOperators should automatically start when calling Run. More... | |
bool | Running = true [get, private set] |
If the SigmaEnvironment is currently running. More... | |
string | Name [get] |
The unique name of this environment. More... | |
IRegistry | Registry [get] |
The root registry of this environment where all exposed parameters are stored hierarchically. More... | |
IRegistryResolver | RegistryResolver [get] |
The registry resolver corresponding to the registry used in this environment. For easier notation and faster access you can retrieve and using regex-style registry names and dot notation. More... | |
Random | Random [get, private set] |
The random number generator to use for randomised operations for reproducibility. More... | |
static ITaskManager | TaskManager [get, set] |
The task manager for this environment. More... | |
static IRegistry | Globals [get] |
A global variable pool for globally relevant constants (e.g. workspace path). More... | |
Private Member Functions | |
SigmaEnvironment (string name) | |
void | InitialiseTrainers () |
void | StartRunningOperators () |
void | StopRunningOperators () |
void | ProcessHooksToAttach () |
Static Private Member Functions | |
static void | SetDefaultCulture (CultureInfo culture) |
This method sets the default culture. More... | |
static void | RegisterGlobals () |
Register all global parameters with an initial value and required associated type. More... | |
Private Attributes | |
readonly ISet< IMonitor > | _monitors |
readonly IDictionary< string, ITrainer > | _trainersByName |
readonly IDictionary< ITrainer, IOperator > | _runningOperatorsByTrainer |
readonly ConcurrentQueue< KeyValuePair< IHook, IOperator > > | _globalHooksToAttach |
readonly ConcurrentQueue< KeyValuePair< IHook, IOperator > > | _localHooksToAttach |
ManualResetEvent | _processQueueEvent |
bool | _requestedStop |
readonly ILog | _logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) |
Static Private Attributes | |
static readonly ILog | ClazzLogger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) |
A sigma environment, where all the magic happens.
TMonitor Sigma.Core.SigmaEnvironment.AddMonitor< TMonitor > | ( | TMonitor | monitor | ) |
Add a monitor to this environment.
TMonitor | The type of the monitor to be added. |
monitor | The monitor to add. |
TMonitor | : | IMonitor |
TTrainer Sigma.Core.SigmaEnvironment.AddTrainer< TTrainer > | ( | TTrainer | trainer | ) |
Add a trainer to this environment.
TTrainer | The type of the trainer to add. |
trainer | The trainer to add. |
TTrainer | : | ITrainer |
|
static |
Removes all active environments.
|
static |
Create an environment with a certain name.
environmentName |
ITrainer Sigma.Core.SigmaEnvironment.CreateTrainer | ( | string | name | ) |
Create a trainer with a certain unique name and add it to this environment.
name | The trainer name. |
|
static |
Loads the log4net configuration from the corresponding xml file. See log4net for more details.
|
static |
Checks whether an environment exists with the given name.
environmentName | The environment name. |
|
static |
Gets an environment with a given name, if previously created (null otherwise).
environmentName | The environment name. |
|
static |
Get environment if it already exists, create and return new one if it does not.
environmentName |
void Sigma.Core.SigmaEnvironment.Prepare | ( | ) |
Prepare this environment for execution. Start all monitors.
|
staticprivate |
Register all global parameters with an initial value and required associated type.
|
static |
Removes an environment with a given name.
environmentName | The environment name. |
void Sigma.Core.SigmaEnvironment.RemoveTrainer | ( | ITrainer | trainer | ) |
Remove a trainer (and its associated operator) from this environment. Note: Warning, this is probably not what you want. Trainer removal may cause inconsistent behaviour during execution. If the operator is currently running and cannot be disassociated this method will throw an exception.
trainer | The trainer to remove. |
void Sigma.Core.SigmaEnvironment.RequestAttachGlobalHook | ( | IHook | hook, |
string | trainerName | ||
) |
Request for a hook to be attached to a certain trainer's operator (identified by its name).
hook | The hook to attach. |
trainerName | The trainer name whose trainer's operator the hook should be attached to. |
Request for a hook to be attached to a certain trainer's operator.
hook | The hook to attach. |
trainer | The trainer whose operator the hook should be attached to. |
void Sigma.Core.SigmaEnvironment.RequestAttachGlobalHook | ( | IHook | hook, |
IOperator | operatorToAttachTo | ||
) |
Request for a hook to be attached to a certain operator.
hook | The hook to attach. |
operatorToAttachTo | The operator to attach to. |
void Sigma.Core.SigmaEnvironment.RequestAttachLocalHook | ( | IHook | hook, |
string | trainerName | ||
) |
Request for a hook to be attached to a certain trainer's operator (identified by its name).
hook | The hook to attach. |
trainerName | The trainer name whose trainer's operator the hook should be attached to. |
Request for a hook to be attached to a certain trainer's operator.
hook | The hook to attach. |
trainer | The trainer whose operator the hook should be attached to. |
void Sigma.Core.SigmaEnvironment.RequestAttachLocalHook | ( | IHook | hook, |
IOperator | operatorToAttachTo | ||
) |
Request for a hook to be attached to a certain operator.
hook | The hook to attach. |
operatorToAttachTo | The operator to attach to. |
T [] Sigma.Core.SigmaEnvironment.ResolveGet< T > | ( | string | matchIdentifier, |
out string [] | fullMatchedIdentifierArray, | ||
T [] | values = null |
||
) |
Resolve all matching identifiers in this registry. For the detailed supported syntax IRegistryResolver.
T | The most specific common type of the variables to retrieve. |
matchIdentifier | The full match identifier. |
fullMatchedIdentifierArray | The fully matched identifiers corresponding to the given match identifier. |
values | An array of values found at the matching identifiers, filled with the values found at all matching identifiers (for reuse and optimisation if request is issued repeatedly). |
T [] Sigma.Core.SigmaEnvironment.ResolveGet< T > | ( | string | matchIdentifier, |
T [] | values = null |
||
) |
Resolve all matching identifiers in this registry. For the detailed supported syntax IRegistryResolver.
T | The most specific common type of the variables to retrieve. |
matchIdentifier | The full match identifier. |
values | An array of values found at the matching identifiers, filled with the values found at all matching identifiers (for reuse and optimisation if request is issued repeatedly). |
string [] Sigma.Core.SigmaEnvironment.ResolveSet< T > | ( | string | matchIdentifier, |
T | value, | ||
bool | addIdentifierIfNotExists = false , |
||
Type | associatedType = null |
||
) |
Set a single given value of a certain type to all matching identifiers. For the detailed supported syntax IRegistryResolver. Note: The individual registries might throw an exception if a type-protected value is set to the wrong type.
T | The type of the value. |
matchIdentifier | The full match identifier. |
value | The value to set. |
addIdentifierIfNotExists | Indicate if the last (local) identifier should be added if it doesn't exist yet. |
associatedType | Optionally set the associated type (IRegistry). If no associated type is set, the one of the registry will be used (if set). |
void Sigma.Core.SigmaEnvironment.Run | ( | ) |
Run this environment. Execute all registered options until stop is requested. Note: This method is blocking and executes in the calling thread.
|
staticprivate |
This method sets the default culture.
culture | The culture that will be the new default. |
void Sigma.Core.SigmaEnvironment.SetRandomSeed | ( | int | seed | ) |
Set the random seed used for all randomised computations for reproducibility.
seed |
void Sigma.Core.SigmaEnvironment.SignalStop | ( | ) |
Signal this environment to stop execution as soon as possible (if running).
|
staticget |
A global variable pool for globally relevant constants (e.g. workspace path).
|
get |
The unique name of this environment.
|
getprivate set |
The random number generator to use for randomised operations for reproducibility.
|
get |
The root registry of this environment where all exposed parameters are stored hierarchically.
|
get |
The registry resolver corresponding to the registry used in this environment. For easier notation and faster access you can retrieve and using regex-style registry names and dot notation.
|
getprivate set |
If the SigmaEnvironment is currently running.
|
getset |
If the IOperators should automatically start when calling Run.
|
staticgetset |
The task manager for this environment.