forked from cschladetsch/CsharpFlow
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNode.cs
More file actions
47 lines (36 loc) · 947 Bytes
/
Node.cs
File metadata and controls
47 lines (36 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// (C) 2012 Christian Schladetsch. See http://www.schladetsch.net/flow/license.txt for Licensing information.
using System.Collections.Generic;
using System;
namespace Flow
{
/// <summary>
/// A flow Node contains a collection of other Transients. When the Node is stepped, it steps all referenced Generators.
/// </summary>
internal class Node : Group, INode
{
/// <inheritdoc />
public override void Step()
{
if (_stepping)
throw new ReentrancyException();
_stepping = true;
base.Step();
foreach (var gen in Generators)
gen.Step();
_stepping = false;
}
/// <inheritdoc />
public override void Post()
{
base.Post();
// make a copy so that contents can be changed during iteration
var list = new List<IGenerator>();
foreach (var gen in Generators)
list.Add(gen);
// do post for all contained generators
foreach (var gen in list)
gen.Post();
}
bool _stepping;
}
}