fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Test / SystemLib / testFieldConnectors.cpp
blobe00c10377938e77f32f33dfa515eb06fc8e69409
2 #include "OSGTestFC.h"
3 #include "OSGBaseInitFunctions.h"
5 void dump(OSG::TestFC *pT)
7 fprintf(stderr, "%d %d\n",
8 pT->getSFField2()->getValue(),
9 pT->getSFField4()->getValue());
12 void testSimple(void)
14 OSG::TestFCUnrecPtr pT1 = OSG::TestFC::create();
15 OSG::TestFCUnrecPtr pT2 = OSG::TestFC::create();
17 OSG::Thread::getCurrentChangeList()->clear();
19 dump(pT1);
20 dump(pT2);
22 addConnection(pT1, "field2",
23 pT2, "field4");
25 pT1->editSFField2()->setValue(42);
27 OSG::commitChanges();
29 dump(pT1);
30 dump(pT2);
32 pT1 = NULL;
33 pT2 = NULL;
36 void testTargetDestroyed(void)
38 OSG::TestFCUnrecPtr pT1 = OSG::TestFC::create();
39 OSG::TestFCUnrecPtr pT2 = OSG::TestFC::create();
41 OSG::Thread::getCurrentChangeList()->clear();
43 dump(pT1);
44 dump(pT2);
46 addConnection(pT1, "field2",
47 pT2, "field4");
49 pT1->editSFField2()->setValue(42);
51 OSG::commitChanges();
53 dump(pT1);
54 dump(pT2);
56 pT2 = NULL;
58 pT1->editSFField2()->setValue(1199);
60 OSG::commitChanges();
62 pT1 = NULL;
65 void testSubConnection(void)
67 OSG::TestFCUnrecPtr pT1 = OSG::TestFC::create();
68 OSG::TestFCUnrecPtr pT2 = OSG::TestFC::create();
70 OSG::Thread::getCurrentChangeList()->clear();
72 dump(pT1);
73 dump(pT2);
75 addConnection(pT1, "field2",
76 pT2, "field4");
78 pT1->editSFField2()->setValue(42);
80 OSG::commitChanges();
82 dump(pT1);
83 dump(pT2);
85 subConnection(pT1, "field2",
86 pT2, "field4");
89 pT1->editSFField2()->setValue(1199);
91 OSG::commitChanges();
93 dump(pT1);
94 dump(pT2);
97 pT1 = NULL;
98 pT2 = NULL;
101 void testSubConnectionSrcOnly(void)
103 OSG::TestFCUnrecPtr pT1 = OSG::TestFC::create();
104 OSG::TestFCUnrecPtr pT2 = OSG::TestFC::create();
106 OSG::Thread::getCurrentChangeList()->clear();
108 dump(pT1);
109 dump(pT2);
111 addConnection(pT1, "field2",
112 pT2, "field4");
114 pT1->editSFField2()->setValue(42);
116 OSG::commitChanges();
118 dump(pT1);
119 dump(pT2);
121 subConnection(pT1, "field2",
122 NULL, NULL);
125 pT1->editSFField2()->setValue(1199);
127 OSG::commitChanges();
129 dump(pT1);
130 dump(pT2);
133 pT1 = NULL;
134 pT2 = NULL;
137 void testSubConnectionSrcAll(void)
139 OSG::TestFCUnrecPtr pT1 = OSG::TestFC::create();
140 OSG::TestFCUnrecPtr pT2 = OSG::TestFC::create();
142 OSG::Thread::getCurrentChangeList()->clear();
144 dump(pT1);
145 dump(pT2);
147 addConnection(pT1, "field2",
148 pT2, "field4");
150 pT1->editSFField2()->setValue(42);
152 OSG::commitChanges();
154 dump(pT1);
155 dump(pT2);
157 subConnection(pT1, "field2",
158 NULL, NULL);
161 pT1->editSFField2()->setValue(1199);
163 OSG::commitChanges();
165 dump(pT1);
166 dump(pT2);
169 pT1 = NULL;
170 pT2 = NULL;
173 int main (int argc, char **argv)
175 OSG::osgInit(argc, argv);
177 fprintf(stderr, "TestSimple\n");
178 testSimple();
180 fprintf(stderr, "TestTargetDestroyed\n");
181 testTargetDestroyed();
183 fprintf(stderr, "TestSubConnection\n");
184 testSubConnection();
186 fprintf(stderr, "TestSubConnectionSrcOnly\n");
187 testSubConnectionSrcOnly();
189 fprintf(stderr, "TestSubConnectionSrcAll\n");
190 testSubConnectionSrcAll();