Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OptimizationNetworks/HeuristicLab.Networks/3.3/Programmable/ProgrammableNodeCode.cs @ 11713

Last change on this file since 11713 was 11602, checked in by swagner, 10 years ago

#2205: Continued working on programmable network items

  • added VariableStore to all programmable network items
File size: 1.4 KB
Line 
1using HeuristicLab.Common;
2using HeuristicLab.Core;
3using HeuristicLab.Core.Networks;
4using System;
5using System.Threading;
6
7#region How to use the variable store?
8// use "Vars" to access variables in the variable store (e.g. Vars.x = 5)
9// use "Vars[string]" to access variables using runtime strings (e.g. Vars["x"] = 5)
10// use "Vars.Contains(string)" to check if a variable exists
11// use "Vars.Clear()" to remove all variables
12// use "foreach (KeyValuePair<string, object> v in Vars) { ... }" to iterate over all variables
13// use "Variables" to work with IEnumerable<T> extension methods on the variable store
14#endregion
15
16namespace HeuristicLab.Networks.Programmable {
17  [Item("MyProgrammableNode", "A programmable node of a network.")]
18  public class MyProgrammableNode : ProgrammableNode.CompiledProgrammableNode {
19    protected MyProgrammableNode(MyProgrammableNode original, Cloner cloner) : base(original, cloner) { }
20    public MyProgrammableNode(ProgrammableNode context) : base(context) { }
21
22    public override IDeepCloneable Clone(Cloner cloner) {
23      return new MyProgrammableNode(this, cloner);
24    }
25
26    public override void Initialize() {
27      base.Initialize();
28      // implement initialization here
29    }
30
31    protected override void ProcessMessage(IMessage message, IMessagePort port, CancellationToken token) {
32      // implement processing of messages here
33    }
34  }
35}
Note: See TracBrowser for help on using the repository browser.