Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
FromPopulation.cs
1using System;
2using System.Threading.Tasks;
3using System.Xml;
6
8{
13 {
14 private IActor actor;
15 private string actorId;
16
23 : base(Parent, Model)
24 {
25 }
26
30 public override string LocalName => nameof(FromPopulation);
31
35 public string ActorId => this.actorId;
36
40 public IActor Actor => this.actor;
41
49 {
50 return new FromPopulation(Parent, Model);
51 }
52
57 public override Task FromXml(XmlElement Definition)
58 {
59 this.actorId = XML.Attribute(Definition, "actor");
60 return Task.CompletedTask;
61 }
62
66 public override Task Initialize()
67 {
68 if (!this.Model.TryGetActor(this.actorId, out this.actor))
69 throw new Exception("Actor not found: " + this.actorId);
70
71 if (this.Parent is IActors Actors)
72 Actors.Register(this.actor);
73
74 return base.Initialize();
75 }
76 }
77}
Root node of a simulation model
Definition: Model.cs:49
bool TryGetActor(string Id, out IActor Actor)
Tries to get a registered actor from the model.
Definition: Model.cs:336
Abstract base class for actors
Definition: Actor.cs:15
void Register(IActor Actor)
Registers an actor with the collection of actors.
Definition: Actors.cs:42
References a specific population of actors.
override Task Initialize()
Initialized the node before simulation.
override ISimulationNode Create(ISimulationNode Parent, Model Model)
Creates a new instance of the node.
override Task FromXml(XmlElement Definition)
Sets properties and attributes of class in accordance with XML definition.
string ActorId
Name of actor defining the population.
FromPopulation(ISimulationNode Parent, Model Model)
References a specific population of actors.
override string LocalName
Local name of XML element defining contents of class.
Abstract base class for simulation nodes
ISimulationNode Parent
Parent node in the simulation model.
Helps with common XML-related tasks.
Definition: XML.cs:19
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Definition: XML.cs:914
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
Definition: IActor.cs:11
Interface for collections of actors.
Definition: IActors.cs:7