1 static class Test : TNode!(Test,"","XX")
2 {
3 mixin TNodeHelperXX!(true,true);
4
5 string name;
6 this( string name ) { this.name = name; }
7
8 void append( string kk )
9 {
10 name ~= kk;
11 foreach( ch; childsXX )
12 ch.append( kk );
13 }
14 }
15
16 auto e0 = new Test("a");
17 auto e1 = new Test("b");
18 auto e2 = new Test("c");
19 auto e3 = new Test("d");
20
21 e1.parentXX = e0;
22 e2.parentXX = e1;
23
24 e0.append( "ok" );
25
26 e1.attachChildsXX( e3 );
27
28 assertEq( e0.childsXX, [ e1 ] );
29 assertEq( e0.name, "aok" );
30 assertEq( e1.name, "bok" );
31 assertEq( e3.name, "d" );
32 assertEq( e3.parentXX, e1 );
1 static class Test : TNode!(Test,"a_"), TNode!(Test,"b_")
2 {
3 mixin a_TNodeHelper!(true,true);
4 mixin b_TNodeHelper!(true,true);
5
6 string name;
7 this( string name ) { this.name = name; }
8
9 void append( string kk )
10 {
11 name ~= kk;
12 foreach( ch; b_childs )
13 ch.append( kk );
14 }
15 }
16
17 auto e0 = new Test("e0");
18 auto e1 = new Test("e1");
19 auto e2 = new Test("e2");
20 auto e3 = new Test("e3");
21
22 e2.a_parent = e0;
23 e2.b_parent = e1;
24
25 e0.append( "ok" );
26
27 assert( e0.name == "e0ok" );
28 assert( e2.name == "e2" );
1 static interface Node : TNode!Node
2 {
3 mixin template NodeHelper() { mixin TNodeHelper!true; }
4 void inc_self();
5
6 final void inc()
7 {
8 inc_self();
9 foreach( ch; childs )
10 ch.inc();
11 }
12 }
13
14 static class Test : Node
15 {
16 mixin NodeHelper;
17
18 int i;
19 this( int i ) { this.i = i; }
20 void inc_self() { i++; }
21 }
22
23 auto a0 = new Test(10);
24 auto a1 = new Test(15);
25 a0.attachChilds( a1 );
26
27 a0.inc();
28
29 assert( a0.i == 11 );
30 assert( a1.i == 16 );
1 static class Test : TNode!Test { mixin TNodeHelper!(true, true); }
2
3 auto a0 = new Test;
4 auto a1 = new Test;
5 auto a2 = new Test;
6
7 assert( a0.parent is null );
8 assert( a1.parent is null );
9 assert( a2.parent is null );
10
11 a0.attachChilds( a1 );
12 a1.attachChilds( a2 );
13
14 assert( a0.childs.length == 1 );
15 assert( a1.childs.length == 1 );
16
17 assert( mustExcept!TNodeCycleException({ a2.attachChilds(a0); }) );
18 assert( mustExcept!TNodeNullChildException({ a2.attachChilds(null); }) );