int main() { Container01 c1("test1"); Container01 c2(c1); Container01 c3(std::move(c1)); Container01 c4 = c0(); // Container01 c5 = std::string("tttt"); #if 0 Container01 c2 = c1; Container01 c3(c2); ConstContainer01Ptr ptr; ptr = boost::make_shared<Container01>("test"); ConstContainer01Ptr ptr2 = boost::make_shared<Container01>(*ptr); ptr2 = boost::make_shared<Container01>(*c()); //Container01 c4(std::move(c0())); Container01 c5(c0()); #endif return 0; }
int main(void) { static const struct st3 a = {1, 2, 3, 4, 5, 6}; l1(100); l2(100, 200); l3(100, 200, 300); l4(100, 200, 300, 400); l5(100, 200, 300, 400, 500); l6(100, 200, 300, 400, 500, 600); l7(100, 200, 300, 400, 500, 600, 700); l8(100, 200, 300, 400, 500, 600, 700, 800); d1(); d2(43); d3(100, 200); d4(a); d5('a', 43, a); d6('a', 1); c1(44); c2(100, 'a', 3.4); c3(200, 2.777, 'q'); c4(200, 1); c5(1.1, 2.2); c6(1.23, 45.6); c7('z', 0x200); a1('a'); a2(10); a3(20); a4(102030405060LL); b1('a', 20); b2(30, 'b'); b3(10, 20, 30, 40, 50, 60); s1(sx); s1p(&sx); s2(sy); s3(sz); s4(sq); s5(sa); s6(sb); r1(); r3(); r4(); q1(200, sx); q2(300, 't', sx); q3(400, 410, sy); q4(500, 510, sq); q5(600, 610, 'z', 'q', sq); real1("fresh air"); real2(); return 0; }
void ordering() { Category c1 (AUDIO); Category c2 (VIDEO); Category c3 (EFFECT); Category c4 (CODEC); Category c5 (STRUCT); Category c6 (META); CHECK (0 > c1.compare(c2)); CHECK (0 > c2.compare(c3)); CHECK (0 > c3.compare(c4)); CHECK (0 > c4.compare(c5)); CHECK (0 > c5.compare(c6)); CHECK (0 ==c1.compare(c1)); CHECK (0 > c1.compare(c6)); Category c21 (VIDEO,"bin1"); Category c22 (VIDEO,"bin2"); Category c23 (VIDEO,"bin2/sub"); CHECK (0 > c1.compare(c21)); CHECK (0 > c2.compare(c21)); CHECK (0 < c22.compare(c21)); CHECK (0 < c23.compare(c22)); CHECK (0 < c23.compare(c21)); CHECK ( 0==c22.compare(c22)); CHECK ( c2 == c2 ); CHECK ( c2 != c22 ); CHECK ( c2 != c3 ); }
int main () { Container<int> c1; Container<int> c2(c1); Container<std::unique_ptr<int>> c3; // This would give compile error: // Container<std::unique_ptr<int>> c4(c3); Container<std::unique_ptr<int>> c5(makeNonCopyableContainer()); return 0; }
static void TestCounter() { #if !defined (ACE_WIN32) long l = LONG_MAX, nl = LONG_MIN; // limits.h unsigned long ul = ULONG_MAX, def = 0; int i = INT_MAX, ni = INT_MIN; unsigned int ui = UINT_MAX; unsigned short us = 10; short si = static_cast<short> (65535); // constructors Counter32 c1; ACE_ASSERT(c1 == def); Counter32 c2(l); ACE_ASSERT(c2 == static_cast<unsigned long> (l)); Counter32 c3(nl); ACE_ASSERT(c3 == static_cast<unsigned long> (nl)); Counter32 c4(ul); ACE_ASSERT(c4 == ul); Counter32 c5(i); ACE_ASSERT(c5 == static_cast<unsigned long> (i)); Counter32 c6(ni); ACE_ASSERT(c6 == static_cast<unsigned long> (ni)); Counter32 c7(ui); ACE_ASSERT(c7 == ui); Counter32 *c8 = new Counter32(c5); ACE_ASSERT(c8 != 0); delete c8; ACE_DEBUG ((LM_DEBUG, "(%P|%t) c1(\"\") [%u]\n", (unsigned long)c1)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) c2(\"%u\") [%u]\n", l, (unsigned long)c2)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) c3(\"%u\") [%u]\n", nl, (unsigned long)c3)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) c4(\"%u\") [%u]\n", ul, (unsigned long)c4)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) c5(\"%u\") [%u]\n", i, (unsigned long)c5)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) c6(\"%u\") [%u]\n", ni, (unsigned long)c6)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) c7(\"%u\") [%u]\n", ui, (unsigned long)c7)); // assignent c1 = c2; // obj ACE_ASSERT(c1 == c2); c1 = c1; // self ACE_ASSERT(c1 == c1); c1 = def; // unsigned long ACE_ASSERT(c1 == def); c1 = us; // unsigned short ACE_ASSERT(c1 == static_cast<unsigned long> (us)); c1 = si; // unsigned short ACE_ASSERT(c1 == static_cast<unsigned long> (si)); #endif /*ACE_WIN32*/ }
void h5 (void) { sizeof(*c5()); { extern IA *c5 (void); sizeof(*c5()); { int c5; { extern A10 *c5 (void); sizeof(*c5()); } } sizeof(*c5()); } sizeof(*c5()); }
int main (void) { x r; s<x, &x::test1> c4 (r); s<x, &x::test2> c5 (r); return 0; }
hMatrix Jacobian_hMatrix(double *theta, double *alpha, double *a, double *d) { hMatrix T01(4,4), T02(4,4), T03(4,4), T04(4,4), T05(4,4), T06(4,4), T07(4,4); T01 = T_hMatrix(&theta[0], &alpha[0], &a[0], &d[0], 1); T02 = T_hMatrix(&theta[0], &alpha[0], &a[0], &d[0], 2); T03 = T_hMatrix(&theta[0], &alpha[0], &a[0], &d[0], 3); T04 = T_hMatrix(&theta[0], &alpha[0], &a[0], &d[0], 4); T05 = T_hMatrix(&theta[0], &alpha[0], &a[0], &d[0], 5); T06 = T_hMatrix(&theta[0], &alpha[0], &a[0], &d[0], 6); T07 = T_hMatrix(&theta[0], &alpha[0], &a[0], &d[0], 7); double k[3] = {0,0,1}; double z1[3] = { T01.element(0,2),T01.element(1,2), T01.element(2,2)}; double z2[3] = { T02.element(0,2),T02.element(1,2), T02.element(2,2)}; double z3[3] = { T03.element(0,2),T03.element(1,2), T03.element(2,2)}; double z4[3] = { T04.element(0,2),T04.element(1,2), T04.element(2,2)}; double z5[3] = { T05.element(0,2),T05.element(1,2), T05.element(2,2)}; double z6[3] = { T06.element(0,2),T06.element(1,2), T06.element(2,2)}; double o1[3] = {T01.element(0,3), T01.element(1,3), T01.element(2,3)}; double o2[3] = {T02.element(0,3), T02.element(1,3), T02.element(2,3)}; double o3[3] = {T03.element(0,3), T03.element(1,3), T03.element(2,3)}; double o4[3] = {T04.element(0,3), T04.element(1,3), T04.element(2,3)}; double o5[3] = {T05.element(0,3), T05.element(1,3), T05.element(2,3)}; double o6[3] = {T06.element(0,3), T06.element(1,3), T06.element(2,3)}; double o7[3] = {T07.element(0,3), T07.element(1,3), T07.element(2,3)}; double O1[3] ={o7[0],o7[1],o7[2]}; double O2[3] ={o7[0]-o1[0],o7[1]-o1[1],o7[2]-o1[2]}; double O3[3] ={o7[0]-o2[0],o7[1]-o2[1],o7[2]-o2[2]}; double O4[3] ={o7[0]-o3[0],o7[1]-o3[1],o7[2]-o3[2]}; double O5[3] ={o7[0]-o4[0],o7[1]-o4[1],o7[2]-o4[2]}; double O6[3] ={o7[0]-o5[0],o7[1]-o5[1],o7[2]-o5[2]}; double O7[3] ={o7[0]-o6[0],o7[1]-o6[1],o7[2]-o6[2]}; hMatrix c1(1,3),c2(1,3),c3(1,3),c4(1,3),c5(1,3),c6(1,3),c7(1,3); c1 = cross(&k[0],&O1[0]); c2 = cross(&z1[0],&O2[0]); c3 = cross(&z2[0],&O3[0]); c4 = cross(&z3[0],&O4[0]); c5 = cross(&z4[0],&O5[0]); c6 = cross(&z5[0],&O6[0]); c7 = cross(&z6[0],&O7[0]); double J[42] = { c1.element(0,0), c2.element(0,0), c3.element(0,0), c4.element(0,0), c5.element(0,0), c6.element(0,0), c7.element(0,0), c1.element(0,1), c2.element(0,1), c3.element(0,1), c4.element(0,1), c5.element(0,1), c6.element(0,1), c7.element(0,1), c1.element(0,2), c2.element(0,2), c3.element(0,2), c4.element(0,2), c5.element(0,2), c6.element(0,2), c7.element(0,2), k[0],z1[0],z2[0],z3[0],z4[0],z5[0],z6[0], k[1],z1[1],z2[1],z3[1],z4[1],z5[1],z6[1], k[2],z1[2],z2[2],z3[2],z4[2],z5[2],z6[2]}; hMatrix Jacobian(6,7); Jacobian.SET(6,7,&J[0]); return Jacobian; }
int main( int argc, char *argv[] ) { // Here is how to initialize color from constant lavander ::color::rgb<::color::type::split422_t> c1( ::color::constant::lavender_type{} ); ::color::rgb<::color::type::split655_t > c2( ::color::constant::lavender_type{} ); ::color::rgb<std::uint8_t> c3( ::color::constant::lavender_type{} ); ::color::rgb<std::uint64_t> c4( ::color::constant::lavender_type{} ); ::color::rgb<float> c5( ::color::constant::lavender_type{} ); std::cout << c1[0] << ", " << c1[1] << ", " << c1[2] << std::endl; std::cout << c2[0] << ", " << c2[1] << ", " << c2[2] << std::endl; std::cout << c3[0] << ", " << c3[1] << ", " << c3[2] << std::endl; std::cout << c4[0] << ", " << c4[1] << ", " << c4[2] << std::endl; std::cout << c5[0] << ", " << c5[1] << ", " << c5[2] << std::endl; return EXIT_SUCCESS; }
int main(void){ std::cout << "HI" << std::endl; Complex c1(1,2), c2(3,1), c3(4,2), c4(2,2); std::vector<Complex> coeff; coeff.push_back(c1); coeff.push_back(c2); coeff.push_back(c3); ComplexPoly poly(coeff, 2); Complex res = poly.evaluate(c4); std::cout << res << std::endl; Complex c5(2,3), c6(3,4), c7(8,2); Complex data[3] = {c5,c6,c7}; ComplexPoly cp(data, 2); Complex result = cp.evaluate(c4); std::cout << result << std::endl; std::cout << cp << std::endl; return 0; }
int main( int argc, char *argv[] ) { ::color::cmy<std::uint8_t> c1( { 64, 127 , 192 } ); ::color::cmy<std::uint16_t> c2( { 280, 350 , 1000 } ); ::color::cmy<std::uint32_t> c3( { 640, 127 , 192 } ); ::color::cmy<std::uint64_t> c4( { 64000, 1270 , 1920 } ); ::color::cmy<float> c5( { 0.5, 0.6, 0.7} ); ::color::cmy<double> c6( { 0.5, 0.6, 0.7} ); std::cout << c1[0] << ", " << c1[1] << ", " << c1[2] << std::endl; std::cout << c2[0] << ", " << c2[1] << ", " << c2[2] << std::endl; std::cout << c3[0] << ", " << c3[1] << ", " << c3[2] << std::endl; std::cout << c4[0] << ", " << c4[1] << ", " << c4[2] << std::endl; std::cout << c5[0] << ", " << c5[1] << ", " << c5[2] << std::endl; std::cout << c6[0] << ", " << c6[1] << ", " << c6[2] << std::endl; return EXIT_SUCCESS; }
int main( int argc, char *argv[] ) { ::color::rgb<::color::type::split422_t> c1( { 7, 6 , 3} ); ::color::rgb<::color::type::split655_t > c2( { 6, 12 , 19} ); ::color::rgb<std::uint8_t> c3( { 64, 127 , 192 } ); ::color::rgb<std::uint64_t> c4( { 64000, 1270 , 1920 } ); ::color::rgb<float> c5( { 0.5, 0.6, 0.7} ); ::color::rgb<double> c6( { 0.5, 0.6, 0.7} ); std::cout << c1[0] << ", " << c1[1] << ", " << c1[2] << std::endl; std::cout << c2[0] << ", " << c2[1] << ", " << c2[2] << std::endl; std::cout << c3[0] << ", " << c3[1] << ", " << c3[2] << std::endl; std::cout << c4[0] << ", " << c4[1] << ", " << c4[2] << std::endl; std::cout << c5[0] << ", " << c5[1] << ", " << c5[2] << std::endl; std::cout << c6[0] << ", " << c6[1] << ", " << c6[2] << std::endl; return EXIT_SUCCESS; }
/** * \fn main * \brief fonction main permettant de creer les chaines et de tester les fonctions * */ int main (int agc, char* argv[]){ printf("Debut de la fonction main\n"); // Creation de tableaux de caractères char test[] = "test test"; char test2[] = "test"; char test3[] = "ananas"; char test4[] = "hello world"; char c = 's'; // creation de chaines de caractères avec les différents constructeurs Chaine c1; Chaine c2(test); Chaine c3(c2); Chaine c4(test2); Chaine c5(test3); Chaine c6(test4); // test des fonctions de chaine.cpp c1.afficherChaine(); // empty chaine c2.afficherChaine(); // "test test" c3.afficherChaine(); // test test" cout << (c1 == c3) <<endl; // false cout << (c2 == c3) <<endl; // true cout << (c4 == c3) <<endl; // false cout << (c4 > c5) <<endl; // true cout << (c4 < c5) <<endl; // false cout << (c5 < c4) <<endl; // true (c4+c5).afficherChaine(); // "testananas" (c2 += c5).afficherChaine(); // c2 : "test testananas" c2.afficherChaine(); // "test testananas" cout << "Indexe du caractere s dans la chaine "; c5.afficherChaine(); // "ananas" cout << " : " ; cout << c5.index_char(c) <<endl; // the first occurence of s is at the position 6 c6.sous_chaine(6,10).afficherChaine(); // "word" printf("fin du main\n"); }
void renderPolygons(void) { // set clearing color glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); // first polygon - triangle - yellow Point c1(100,50,0); Color fc1(1.0, 1.0, 0.0, 0.0); Polygon tri(40, c1, 3, 1, GL_LINE_LOOP, fc1); tri.draw(); // square - hollow - light blue(cyan) Point c2(100,150,0); Color fc2(0.0, 1.0, 1.0, 0.0); Polygon squ(40, c2, 4, 8, GL_LINE_LOOP, fc2); squ.draw(); // pentagon - hollow - gray Point c3(100,250,0); Color fc3(0.5, 0.5, 0.5, 0.0); Polygon pent(40, c3, 5, 3, GL_LINE_LOOP, fc3); pent.draw(); //hexagon - not hollow - red Point c4(200,50,0); Color fc4(1.0, 0.0, 0.0, 0.0); Polygon hex(40, c4, 6, 3, GL_POLYGON, fc4); hex.draw(); // nonagon - hollow - green Point c5(200,150,0); Color fc5(0.0, 1.0, 0.0, 0.0); Polygon nin(40, c5, 9, 5, GL_LINE_LOOP, fc5); nin.draw(); // tridecagon - hollow - purple Point c6(300,300,0); Color fc6(1.0, 0.0, 1.0, 0.0); Polygon thri(90, c6, 13, 3, GL_LINE_LOOP, fc6); thri.draw(); glutSwapBuffers(); }
int main( int argc, char *argv[] ) { color::gray<bool> c0( { true } ); color::gray<std::uint8_t> c1( { 120 } ); color::gray<std::uint16_t> c2( { 6 } ); color::gray<std::uint32_t> c3( { 64000} ); color::gray<std::uint64_t> c4( { 6400000u } ); color::gray<float> c5( { 0.5 } ); color::gray<double> c6( { 0.5 } ); color::gray<long double> c7( { 0.5 } ); std::cout << c1[0] << std::endl; std::cout << c2[0] << std::endl; std::cout << c3[0] << std::endl; std::cout << c4[0] << std::endl; std::cout << c5[0] << std::endl; std::cout << c6[0] << std::endl; return EXIT_SUCCESS; }
void TestRgb::TestSet() { TRgb c1; TRgb c2(128,128,128); TRgb c3(500,500,500); TRgb c4(iR,iG,iB); TRgb c5(500,600,700); iTest->TEST(c2.Red()==128); iTest->TEST(c2.Green()==128); iTest->TEST(c2.Blue()==128); iTest->TEST(c3.Red()<256); iTest->TEST(c3.Green()<256); iTest->TEST(c3.Blue()<256); iTest->TEST(c4.Red()==iR && c4.Green()==iG && c4.Blue()==iB); iTest->TEST(c5.Red()<256); iTest->TEST(c5.Green()<256); iTest->TEST(c5.Blue()<256); c1=c4; iTest->TEST(c1.Red()==iR && c1.Green()==iG && c1.Blue()==iB); c1=TRgb(64,128,192); iTest->TEST(c1.Red()==64); iTest->TEST(c1.Green()==128); iTest->TEST(c1.Blue()==192); c1=c5; iTest->TEST(c1.Red()<256); iTest->TEST(c1.Green()<256); iTest->TEST(c1.Blue()<256); c1=TRgb::Gray4(3); iTest->TEST(c1.Red()==255 && c1.Green()==255 && c1.Blue()==255); c1=TRgb::Gray16(15); iTest->TEST(c1.Red()==255 && c1.Green()==255 && c1.Blue()==255); c1=TRgb::Gray256(255); iTest->TEST(c1.Red()==255 && c1.Green()==255 && c1.Blue()==255); c1=TRgb::Gray4(4); iTest->TEST(c1.Red()<256 && c1.Green()<256 && c1.Blue()<256); c1=TRgb::Gray16(16); iTest->TEST(c1.Red()<256 && c1.Green()<256 && c1.Blue()<256); c1=TRgb::Gray256(256); iTest->TEST(c1.Red()<256 && c1.Green()<256 && c1.Blue()<256); iTest->TEST(c4.Red()==iR && c4.Green()==iG && c4.Blue()==iB); }
int sc_main( int, char*[] ) { sc_time t1( 8, SC_NS ); sc_time t2( 2, SC_NS ); sc_clock c1( "c1", t1, 0.1, t2 ); cout << "m_cur_val for c1( \"c1\", t1, 0.1, t2 ) is: "; c1.print(cout); cout << "\n"; sc_clock c2( "c2", t1, 0.1, t2, false ); cout << "m_cur_val for c2( \"c2\", t1, 0.1, t2, false ) is: "; c2.print(cout); cout << "\n"; sc_clock c3( "c3", 8, SC_NS, 0.1 ); cout << "m_cur_val for c3( \"c3\", t1, 0.1, t2 ) is: "; c3.print(cout); cout << "\n"; sc_clock c4( "c4", 8, SC_NS, 0.1, false ); cout << "m_cur_val for c4( \"c4\", t1, 0.1, t2, false ) is: "; c4.print(cout); cout << "\n"; sc_clock c5( "c5", 8, SC_NS, 0.1, 2, SC_NS ); cout << "m_cur_val for c5( \"c5\", t1, 0.1, t2 ) is: "; c5.print(cout); cout<< "\n"; sc_clock c6( "c6", 8, SC_NS, 0.1, 2, SC_NS, false ); cout << "m_cur_val for c6( \"c6\", t1, 0.1, t2, false ) is: "; c6.print(cout); cout<< "\n"; return 0; }
TEST(CommandManagerTest, TestPriorities) { MockListener listener; MojRefCountedPtr<CommandManager> managerRef(new CommandManager(1)); CommandManager& manager = *managerRef; CommandManager::CommandPtr c1(new MockCommand(listener, Command::HighPriority)); CommandManager::CommandPtr c2(new MockCommand(listener, Command::NormalPriority)); CommandManager::CommandPtr c3(new MockCommand(listener, Command::LowPriority)); CommandManager::CommandPtr c4(new MockCommand(listener, Command::NormalPriority)); CommandManager::CommandPtr c5(new MockCommand(listener, Command::HighPriority)); manager.QueueCommand(c1, false); manager.QueueCommand(c2, false); manager.QueueCommand(c3, false); manager.QueueCommand(c4, false); manager.QueueCommand(c5, false); CommandManager::CommandPtr dequeued = manager.Top(); ASSERT_EQ(c1.get(), dequeued.get()); manager.Pop(); dequeued = manager.Top(); ASSERT_EQ( c5.get(), dequeued.get() ); manager.Pop(); dequeued = manager.Top(); ASSERT_EQ( c2.get(), dequeued.get() ); manager.Pop(); dequeued = manager.Top(); ASSERT_EQ( c4.get(), dequeued.get() ); manager.Pop(); dequeued = manager.Top(); ASSERT_EQ( c3.get(), dequeued.get() ); manager.Pop(); }
void HUD::setup(){ //Colors for HUDSpinners below ofColor c(36,96,150); ofColor c2(36,180,150); ofColor c3(93,5,255); ofColor c4(254,173,69); ofColor c5(5,209,245); ofColor c6(40,240,60); spinner1.setup(10 /*count*/, 200.0 /*avgRotSpd*/, 100 /*rotVariation*/, c /*color*/, 30 /*resolution*/, 20 /*minRad*/, 55 /*maxRad*/, 15 /*minWidth*/, 30 /*maxWidth*/); spinner2.setup(10 /*count*/, 150 /*avgRotSpd*/, 50 /*rotVariation*/, c2 /*color*/, 40 /*resolution*/, 15 /*minRad*/, 55 /*maxRad*/, 10 /*minWidth*/, 20 /*maxWidth*/); spinner3.setup(15 /*count*/, 150 /*avgRotSpd*/, 140 /*rotVariation*/, c3 /*color*/, 40 /*resolution*/, 20 /*minRad*/, 55 /*maxRad*/, 10 /*minWidth*/, 20 /*maxWidth*/); spinner4.setup(15 /*count*/, 150 /*avgRotSpd*/, 140 /*rotVariation*/, c4 /*color*/, 40 /*resolution*/, 30 /*minRad*/, 55 /*maxRad*/, 10 /*minWidth*/, 20 /*maxWidth*/); spinner5.setup(20 /*count*/, 150 /*avgRotSpd*/, 140 /*rotVariation*/, c5 /*color*/, 40 /*resolution*/, 20 /*minRad*/, 80 /*maxRad*/, 10 /*minWidth*/, 20 /*maxWidth*/); spinner6.setup(15 /*count*/, -150 /*avgRotSpd*/, 100 /*rotVariation*/, c6 /*color*/, 40 /*resolution*/, 30 /*minRad*/, 200 /*maxRad*/, 20 /*minWidth*/, 100 /*maxWidth*/); HUDimg.loadImage("HUD3.png"); singleBlink = false; doubleBlink = false; }
int U_EXPORT main (int argc, char* argv[]) { U_ULIB_INIT(argv); U_TRACE(5,"main(%d)",argc) UString value, path, domain, port, not_found; HttpCookie c1(U_CONSTANT_TO_PARAM("Cookie"), U_CONSTANT_TO_PARAM("Name=value")), c2(U_CONSTANT_TO_PARAM("Cookie"), U_CONSTANT_TO_PARAM(COOKIE_2)), c5(U_CONSTANT_TO_PARAM("Cookie"), U_CONSTANT_TO_PARAM(COOKIE_5)); U_ASSERT( c5.find(U_STRING_FROM_CONSTANT("otptoken"), value, path, domain, port) == true ) U_ASSERT( value == U_STRING_FROM_CONSTANT("pluto") ) U_ASSERT( c1.count(U_STRING_FROM_CONSTANT("Name")) == 1 ) U_ASSERT( c2.count(U_STRING_FROM_CONSTANT("$Domain")) == 2 ) U_ASSERT( c1.find(U_STRING_FROM_CONSTANT("Name"), value, path, domain, port) == true ) U_ASSERT( value == U_STRING_FROM_CONSTANT("value") ) U_ASSERT( path == not_found ) U_ASSERT( domain == not_found ) U_ASSERT( port == not_found ) U_ASSERT( c2.find(U_STRING_FROM_CONSTANT("NameB"), value, path, domain, port) == true ) U_ASSERT( value == U_STRING_FROM_CONSTANT("ValueB") ) U_ASSERT( domain == U_STRING_FROM_CONSTANT("domain1") ) U_ASSERT( port == not_found ) #ifdef SERGIO U_ASSERT( path == U_STRING_FROM_CONSTANT("/") ) #else U_ASSERT( path == U_STRING_FROM_CONSTANT("\"/\"") ) #endif U_ASSERT( c2.del(U_STRING_FROM_CONSTANT("NameB")) == true ) value = path = domain = port = not_found; U_ASSERT( c2.find(U_STRING_FROM_CONSTANT("Name"), value, path, domain, port) == false ) U_ASSERT( value == not_found ) U_ASSERT( path == not_found ) U_ASSERT( domain == not_found ) U_ASSERT( port == not_found ) U_ASSERT( c2.find(U_STRING_FROM_CONSTANT("NameC"), value, path, domain, port) == true ) U_ASSERT( value == U_STRING_FROM_CONSTANT("ValueC") ) U_ASSERT( path == U_STRING_FROM_CONSTANT("domain1") ) #ifdef SERGIO U_ASSERT( port == U_STRING_FROM_CONSTANT("123") ) U_ASSERT( domain == U_STRING_FROM_CONSTANT("/") ) #else U_ASSERT( port == U_STRING_FROM_CONSTANT("\"123\"") ) U_ASSERT( domain == U_STRING_FROM_CONSTANT("\"/\"") ) #endif HttpSetCookie s1(U_CONSTANT_TO_PARAM("Set-Cookie"), U_CONSTANT_TO_PARAM(SETCOOKIE_1)), s2(U_CONSTANT_TO_PARAM("Set-Cookie2"), U_CONSTANT_TO_PARAM(SETCOOKIE_2)); U_ASSERT( s1.count(U_STRING_FROM_CONSTANT("Domain")) == 2 ) U_ASSERT( s2.count(U_STRING_FROM_CONSTANT("Port")) == 1 ) HttpCookie c3(U_CONSTANT_TO_PARAM("Cookie"), U_CONSTANT_TO_PARAM(COOKIE_AUTH) ); U_ASSERT( c3.count(U_STRING_FROM_CONSTANT("AUTHTOKEN")) == 1 ) value = path = domain = port = not_found; U_ASSERT( c3.find(U_STRING_FROM_CONSTANT("AUTHTOKEN"), value, path, domain, port) == true ) U_ASSERT( path == not_found ) U_ASSERT( domain == not_found ) U_ASSERT( port == not_found ) value.erase(value.size()-1, 1); value.erase(0, 1); #ifdef U_PROXY_UNIT DES3engine eng("pippo"); OtpAuthToken a(&eng, value); #else u_des3_key("pippo"); OtpAuthToken a(0, value); #endif U_ASSERT( a.tid == U_STRING_FROM_CONSTANT("Current_Server_ID") ) U_ASSERT( a.uid == U_STRING_FROM_CONSTANT("User_ID") ) U_ASSERT( a.sid == U_STRING_FROM_CONSTANT("Session_ID") ) U_ASSERT( a.ts == U_STRING_FROM_CONSTANT("20031125131800") ) U_ASSERT( a.cf == U_STRING_FROM_CONSTANT("codicefiscale1") ) U_ASSERT( a.migrate == true ) HttpHeader h; HttpField* f = new HttpField(U_STRING_FROM_CONSTANT("Content-Type"), U_STRING_FROM_CONSTANT(" application/x-www-form-urlencoded")); HttpBaAuthorization* ba = new HttpBaAuthorization(U_CONSTANT_TO_PARAM("Authorization"), U_CONSTANT_TO_PARAM(" Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")); HttpBaAuthorization* ba1 = new HttpBaAuthorization(U_CONSTANT_TO_PARAM("Authorization"), U_CONSTANT_TO_PARAM(" Basic dXRlbnRlMTpzaWQx")); h.add(ba); h.add(f); h.add(ba1); HttpOtpPostLogin p(U_CONSTANT_TO_PARAM(POST_BODY), U_STRING_FROM_CONSTANT("user"), U_STRING_FROM_CONSTANT("pin"), U_STRING_FROM_CONSTANT("token"), U_STRING_FROM_CONSTANT("password"), U_STRING_FROM_CONSTANT("cf"), h); U_ASSERT( p.user == U_STRING_FROM_CONSTANT("stefano casazza") ) U_ASSERT( p.pin == U_STRING_FROM_CONSTANT("12345") ) U_ASSERT( p.token == U_STRING_FROM_CONSTANT("autorizzativo") ) HttpField* p1 = h.del(U_STRING_FROM_CONSTANT("Content-Type")); U_ASSERT( p1 != 0 ) U_ASSERT( p1 == f ) HttpBaAuthorization* p2 = (HttpBaAuthorization*) h.find(U_STRING_FROM_CONSTANT("Authorization")); U_ASSERT( p2 != 0 ) U_ASSERT( p2 == ba ) U_ASSERT( p2->user == U_STRING_FROM_CONSTANT("Aladdin") ) U_ASSERT( p2->passwd == U_STRING_FROM_CONSTANT("open sesame") ) HttpBaAuthorization* p3 = (HttpBaAuthorization*) h.find(U_STRING_FROM_CONSTANT("Authorization"), 1); U_ASSERT( p3 != 0 ) U_ASSERT( p3 == ba1 ) U_ASSERT( p3->user == U_STRING_FROM_CONSTANT("utente1") ) U_ASSERT( p3->passwd == U_STRING_FROM_CONSTANT("sid1") ) h.clear(); UString result; a.stringify(result); // TID=trustACCESS1;UID=utente1;SID=;TS=20031201174127;CF=codicefiscale1 # define COOKIE_AUTH_1 \ "U2FsdGVkX1/QsrBvmsVHx0rrX78ldh6IJu1+4GhKoJ9O5ETSbfSiDip1gszkZX7w5ah6vkYfRWI8271LcNKhUsZVehRoscudLO8uotQgeiiF1B46ITphGw==" // TID=trustACCESS1;UID=utente1;SID=sid;TS=20031201174127;CF=codicefiscale1;HP1=Profile_Header1;HPn=Profile_Headern;MIGRATE # define COOKIE_AUTH_2 \ "U2FsdGVkX1+tUkpPi14NVlKhm5KUFbSH0JFvi23+8B75MnKgtyD/sc0hc0ESmSahiYozVbS6a3OoZfWDHX3G3zuUwCP7n1+3jXK0wu6niifYUW+cKBk1WUdpJZd0xjJernDsWtPfq9j30uatAhHULG57vdrKlbtxM/EIaiaUow1AeLuDiZDcTRonghpI/aaz" #ifdef U_PROXY_UNIT DES3engine eng1("password"); OtpAuthToken c(&eng1, U_STRING_FROM_CONSTANT(COOKIE_AUTH_2)); DES3engine eng2("password"); OtpAuthToken b(&eng2, U_STRING_FROM_CONSTANT(COOKIE_AUTH_1)); #else u_des3_key("password"); OtpAuthToken c(0, U_STRING_FROM_CONSTANT(COOKIE_AUTH_2)); u_des3_reset(); OtpAuthToken b(0, U_STRING_FROM_CONSTANT(COOKIE_AUTH_1)); #endif U_ASSERT( b.is_valid() == false ) U_ASSERT( c.is_valid() == true ) U_ASSERT( c.tid == U_STRING_FROM_CONSTANT("trustACCESS1") ) U_ASSERT( c.uid == U_STRING_FROM_CONSTANT("utente1") ) U_ASSERT( c.sid == U_STRING_FROM_CONSTANT("sid") ) U_ASSERT( c.ts == U_STRING_FROM_CONSTANT("20031201174127") ) U_ASSERT( c.cf == U_STRING_FROM_CONSTANT("codicefiscale1") ) U_ASSERT( c.migrate == true ) value = not_found; U_ASSERT( c.find(U_STRING_FROM_CONSTANT("HP1"), value) == true ) U_ASSERT( value == U_STRING_FROM_CONSTANT("Profile_Header1") ) U_ASSERT( c.del(U_STRING_FROM_CONSTANT("HP1")) == true ) value = not_found; U_ASSERT( c.find(U_STRING_FROM_CONSTANT("HPn"), value) == true ) U_ASSERT( value == U_STRING_FROM_CONSTANT("Profile_Headern") ) HttpCookie c4(U_CONSTANT_TO_PARAM("Cookie"), U_CONSTANT_TO_PARAM(COOKIE_PROBLEM) ); U_ASSERT( c4.count(U_STRING_FROM_CONSTANT("otptoken")) == 1 ) value = path = domain = port = not_found; U_ASSERT( c4.find(U_STRING_FROM_CONSTANT("otptoken"), value, path, domain, port) == true ) value.erase(value.size()-1, 1); value.erase(0, 1); #ifdef U_PROXY_UNIT DES3engine eng3("password"); OtpAuthToken d(&eng3, value); #else u_des3_reset(); OtpAuthToken d(0, value); #endif U_ASSERT( d.is_valid() == false ) result.erase(result.size()-1, 1); result.erase(0, 1); cout.write(result.data(), result.size()); }
int test0 (void) { int ret = 0; printf ("TEST: CBString constructor\n"); try { printf ("\tCBString c;\n"); CBString c0; ret += (0 != c0.length()); ret += '\0' != ((const char *)c0)[c0.length()]; printf ("\tCBString c(\"test\");\n"); CBString c1 ("test"); ret += (c1 != "test"); ret += '\0' != ((const char *)c1)[c1.length()]; printf ("\tCBString c(25, \"test\");\n"); CBString c8 (25, "test"); ret += (c8 != "test"); ret += c8.mlen < 25; ret += '\0' != ((const char *)c8)[c8.length()]; printf ("\tCBString c('t');\n"); CBString c2 ('t'); ret += (c2 != "t"); ret += '\0' != ((const char *)c2)[c2.length()]; printf ("\tCBString c('\\0');\n"); CBString c3 ('\0'); ret += (1 != c3.length()) || ('\0' != c3[0]); ret += '\0' != ((const char *)c3)[c3.length()]; printf ("\tCBString c(bstr[\"test\"]);\n"); struct tagbstring t = bsStatic ("test"); CBString c4 (t); ret += (c4 != t.data); ret += '\0' != ((const char *)c4)[c4.length()]; printf ("\tCBString c(CBstr[\"test\"]);\n"); CBString c5 (c1); ret += (c1 != c5); ret += '\0' != ((const char *)c5)[c5.length()]; printf ("\tCBString c('x',5);\n"); CBString c6 ('x',5); ret += (c6 != "xxxxx"); ret += '\0' != ((const char *)c6)[c6.length()]; printf ("\tCBString c(\"123456\",4);\n"); CBString c7 ((void *)"123456",4); ret += (c7 != "1234"); ret += '\0' != ((const char *)c7)[c7.length()]; } catch (struct CBStringException err) { printf ("Exception thrown [%d]: %s\n", __LINE__, err.what()); ret ++; } printf ("\t# failures: %d\n", ret); return ret; }
void snoopy() { TGeoManager *geom = new TGeoManager("snoopy", "Snoopy Detector"); // define some materials TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0, 0, 0); TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98, 13, 2.7); TGeoMaterial *matFe = new TGeoMaterial("Fe", 55.84, 26, 7.9); // define some media TGeoMedium *Vacuum = new TGeoMedium("Vacuum", 1, matVacuum); TGeoMedium *Al = new TGeoMedium("Al", 2, matAl); TGeoMedium *Fe = new TGeoMedium("Fe", 3, matFe); // create top volume TGeoVolume *top = geom->MakeBox("top", Vacuum, 600, 600, 2500); geom->SetTopVolume(top); geom->SetTopVisible(0); // first part of vacuum chamber up to veto station TGeoVolume *tub1 = geom->MakeTube("tub1", Al, 245, 250, 50); tub1->SetLineColor(18); // silver/gray top->AddNode(tub1, 1, new TGeoTranslation(0, 0, -2450)); // veto station TGeoBBox *detbox1 = new TGeoBBox("detbox1", 250, 250, 10); TGeoBBox *detbox2 = new TGeoBBox("detbox2", 245, 245, 10); TGeoCompositeShape *detcomp1 = new TGeoCompositeShape("detcomp1", "detbox1-detbox2"); TGeoVolume *det1 = new TGeoVolume("det1", detcomp1,Vacuum); det1->SetLineColor(kRed); top->AddNode(det1, 1, new TGeoTranslation(0, 0, -2390)); TGeoRotation r0; r0.SetAngles(15,0,0); TGeoTranslation t0(0, 0, -2370); TGeoCombiTrans c0(t0, r0); TGeoHMatrix *h0 = new TGeoHMatrix(c0); top->AddNode(det1, 11, h0); // second part of vacuum chamber up to first tracking station TGeoVolume *tub2 = geom->MakeTube("tub2", Al, 245, 250, 3880/2); // 1890 tub2->SetLineColor(18); top->AddNode(tub2, 1, new TGeoTranslation(0, 0, -440)); // tracking station 1 top->AddNode(det1, 2, new TGeoTranslation(0, 0, 1510)); TGeoRotation r1; r1.SetAngles(15,0,0); TGeoTranslation t1(0, 0, 1530); TGeoCombiTrans c1(t1, r1); TGeoHMatrix *h1 = new TGeoHMatrix(c1); top->AddNode(det1, 3, h1); // third part of vacuum chamber up to second tracking station TGeoVolume *tub3 = geom->MakeTube("tub3", Al, 245, 250, 80); tub3->SetLineColor(18); top->AddNode(tub3, 1, new TGeoTranslation(0, 0, 1620)); // tracking station 2 top->AddNode(det1, 4, new TGeoTranslation(0, 0, 1710)); TGeoRotation r2; r2.SetAngles(15,0,0); TGeoTranslation t2(0, 0, 1730); TGeoCombiTrans c2(t2, r2); TGeoHMatrix *h2 = new TGeoHMatrix(c2); top->AddNode(det1, 5, h2); // fourth part of vacuum chamber up to third tracking station and being covered by magnet TGeoVolume *tub4 = geom->MakeTube("tub4", Al, 245, 250, 200); tub4->SetLineColor(18); top->AddNode(tub4, 1, new TGeoTranslation(0, 0, 1940)); // magnet yoke TGeoBBox *magyoke1 = new TGeoBBox("magyoke1", 350, 350, 125); TGeoBBox *magyoke2 = new TGeoBBox("magyoke2", 250, 250, 126); TGeoCompositeShape *magyokec = new TGeoCompositeShape("magyokec", "magyoke1-magyoke2"); TGeoVolume *magyoke = new TGeoVolume("magyoke", magyokec, Fe); magyoke->SetLineColor(kBlue); //magyoke->SetTransparency(50); top->AddNode(magyoke, 1, new TGeoTranslation(0, 0, 1940)); // magnet TGeoTubeSeg *magnet1a = new TGeoTubeSeg("magnet1a", 250, 300, 35, 45, 135); TGeoTubeSeg *magnet1b = new TGeoTubeSeg("magnet1b", 250, 300, 35, 45, 135); TGeoTubeSeg *magnet1c = new TGeoTubeSeg("magnet1c", 250, 270, 125, 45, 60); TGeoTubeSeg *magnet1d = new TGeoTubeSeg("magnet1d", 250, 270, 125, 120, 135); // magnet composite shape matrices TGeoTranslation *m1 = new TGeoTranslation(0, 0, 160); m1->SetName("m1"); m1->RegisterYourself(); TGeoTranslation *m2 = new TGeoTranslation(0, 0, -160); m2->SetName("m2"); m2->RegisterYourself(); TGeoCompositeShape *magcomp1 = new TGeoCompositeShape("magcomp1", "magnet1a:m1+magnet1b:m2+magnet1c+magnet1d"); TGeoVolume *magnet1 = new TGeoVolume("magnet1", magcomp1, Fe); magnet1->SetLineColor(kYellow); top->AddNode(magnet1, 1, new TGeoTranslation(0, 0, 1940)); TGeoRotation m3; m3.SetAngles(180, 0, 0); TGeoTranslation m4(0, 0, 1940); TGeoCombiTrans m5(m4, m3); TGeoHMatrix *m6 = new TGeoHMatrix(m5); top->AddNode(magnet1, 2, m6); // tracking station 3 top->AddNode(det1, 6, new TGeoTranslation(0, 0, 2150)); TGeoRotation r3; r3.SetAngles(15,0,0); TGeoTranslation t3(0, 0, 2170); TGeoCombiTrans c3(t3, r3); TGeoHMatrix *h3 = new TGeoHMatrix(c3); top->AddNode(det1, 7, h3); // fifth part of vacuum chamber up to fourth tracking station TGeoVolume *tub5 = geom->MakeTube("tub5", Al, 245, 250, 90); tub5->SetLineColor(18); top->AddNode(tub5, 1, new TGeoTranslation(0, 0, 2270)); // tracking station 4 top->AddNode(det1, 8, new TGeoTranslation(0, 0, 2370)); TGeoRotation r4; r4.SetAngles(15,0,0); TGeoTranslation t4(0, 0, 2390); TGeoCombiTrans c4(t4, r4); TGeoHMatrix *h4 = new TGeoHMatrix(c4); top->AddNode(det1, 9, h4); // ecal TGeoVolume *ecal = geom->MakeBox("ecal", Al, 250, 250, 40); ecal->SetLineColor(6); // purple top->AddNode(ecal, 1, new TGeoTranslation(0, 0, 2440)); // muon filter TGeoVolume *muonfilter = geom->MakeBox("muonfilter", Al, 250, 250, 20); muonfilter->SetLineColor(kGreen); top->AddNode(muonfilter, 1, new TGeoTranslation(0, 0, 2500)); // sixth part of vacuum chamber up to muon detector TGeoVolume *tub6 = geom->MakeTube("tub6", Al, 245, 250, 20); tub6->SetLineColor(18); top->AddNode(tub6, 1, new TGeoTranslation(0, 0, 2540)); // muon detector top->AddNode(det1, 10, new TGeoTranslation(0, 0, 2570)); TGeoRotation r5; r5.SetAngles(15,0,0); TGeoTranslation t5(0, 0, 2590); TGeoCombiTrans c5(t5, r5); TGeoHMatrix *h5 = new TGeoHMatrix(c5); top->AddNode(det1, 12, h5); geom->CloseGeometry(); top->Draw("ogl"); geom->Export("snoopy.gdml"); }
void Scene::init(){ primitives = new Primitive*[25]; nrOfPrimitives = 0; //wall at0,0,1 Vec3 v121( 0,0, 1 ); primitives[nrOfPrimitives] = new PlanePrim( v121, -13.0f ); primitives[nrOfPrimitives]->getMaterial()->setReflection( 1 ); primitives[nrOfPrimitives]->getMaterial()->setDiffuse( 0.0f ); primitives[nrOfPrimitives]->getMaterial()->setSpecular(1.0f); Color c121( 1,1,1 ); primitives[nrOfPrimitives++]->getMaterial()->setColor(c121); //wall at 0 0 -1 Vec3 v12( 0,0, -1 ); primitives[nrOfPrimitives] = new PlanePrim( v12, 13.0f ); primitives[nrOfPrimitives]->getMaterial()->setReflection( 1.0f ); primitives[nrOfPrimitives]->getMaterial()->setDiffuse( 0.0f ); primitives[nrOfPrimitives]->getMaterial()->setSpecular(1.0f); Color c12( 0.3f,0.3f,0.7f ); primitives[nrOfPrimitives++]->getMaterial()->setColor(c12); //- //the ground Vec3 v1( 0,1, 0 ); primitives[nrOfPrimitives] = new CheckerBoard( v1, 3.4f ); primitives[nrOfPrimitives]->getMaterial()->setReflection( 0.7f ); primitives[nrOfPrimitives]->getMaterial()->setDiffuse( 1.0f ); primitives[nrOfPrimitives]->getMaterial()->setSpecular(0.0f); Color c1( 0.3f, 0.3f, 0.7f ); primitives[nrOfPrimitives++]->getMaterial()->setColor(c1); // // 0 -1 0 Vec3 v13( 0,-1, 0 ); primitives[nrOfPrimitives] = new PlanePrim( v13, -3.4f ); primitives[nrOfPrimitives]->getMaterial()->setReflection( 1 ); primitives[nrOfPrimitives]->getMaterial()->setDiffuse( 1.0f ); primitives[nrOfPrimitives]->getMaterial()->setSpecular(1.0f - primitives[nrOfPrimitives]->getMaterial()->getDiffuse()); Color c13( 1,1,1 ); primitives[nrOfPrimitives++]->getMaterial()->setColor(c13); // //middle sphere Vec3 v2( 0, 1, 8 ); primitives[nrOfPrimitives] = new Sphere( v2, 1.0f ); primitives[nrOfPrimitives]->getMaterial()->setReflection( 1 ); primitives[nrOfPrimitives]->getMaterial()->setDiffuse( 0.2 ); primitives[nrOfPrimitives]->getMaterial()->setSpecular(1.0f - primitives[nrOfPrimitives]->getMaterial()->getDiffuse()); Color c2( 1,1,1); primitives[nrOfPrimitives++]->getMaterial()->setColor( c2 ); //- //left sphere Vec3 v3( -5.5f, -0.5, 7 ); Color c3( 0.7f, 0.7f, 0 ); primitives[nrOfPrimitives] = new Sphere( v3, 2 ); primitives[nrOfPrimitives]->getMaterial()->setReflection( 0.6f ); primitives[nrOfPrimitives]->getMaterial()->setDiffuse( 0.9f ); primitives[nrOfPrimitives]->getMaterial()->setSpecular(1.0f - primitives[nrOfPrimitives]->getMaterial()->getDiffuse()); primitives[nrOfPrimitives++]->getMaterial()->setColor( c3 ); //- //right sphere Vec3 v31( 5.5f, -0.5, 7 ); Color c31( 0.7f, 0.0f, 0 ); primitives[nrOfPrimitives] = new Sphere( v31, 2 ); primitives[nrOfPrimitives]->getMaterial()->setReflection( 0.6f ); primitives[nrOfPrimitives]->getMaterial()->setDiffuse( 0.9f ); primitives[nrOfPrimitives]->getMaterial()->setSpecular(1.0f); primitives[nrOfPrimitives++]->getMaterial()->setColor( c31 ); //- //a light Vec3 v4( 3, 2.5f, 3 ); Color c4(0.7f,0.7f,0.7f); primitives[nrOfPrimitives] = new Sphere( v4, 0.5f ); primitives[nrOfPrimitives]->isLight = true; primitives[nrOfPrimitives++]->getMaterial()->setColor( c4 ); //-- //another light Vec3 v5( 0, 5, 10 ); Color c5( 0.6f, 0.6f, 0.8f ); primitives[nrOfPrimitives] = new Sphere( v5, 0.5f ); primitives[nrOfPrimitives]->isLight = true; primitives[nrOfPrimitives++]->getMaterial()->setColor( c5 ); //-- }
void Sputnik::Launch() { cout << "starting RhoToolsTest" << endl; // the tests are organized as blocks to let variables // go out of scope. In the output, each block is // separated by a lines of ---- // start testing OpAdd4 ostream& theStream = cerr; theStream << "Before Testing OpAdd4 " << endl; theStream << endl; TOpAdd4 b4; { cout << "create a pair of objects:" << endl; TCandidate c1(TLorentzVector(1,0,0,0),0); TCandidate c2(TLorentzVector(0,2,0,0),0); TCandidate c3(TLorentzVector(0,0,3,0),0); PC("c1",c1); PC("c2",c2); PC("c3",c3); cout << "after OpAdd4.Fill(c3, c1, c2); "<<endl; b4.Fill(c3,c1,c2); PC("c1",c1); PC("c2",c2); PC("c3",c3); TCandidate c4(TLorentzVector(0,0,3,0),0); cout <<endl<< "c4(); c4 = OpAdd4().combine( c1, c2); "<<endl; c4 = TOpAdd4().Combine(c1,c2); PC("c1",c1); PC("c2",c2); PC("c3",c3); PC("c4",c4); cout << "---------------------------------------------------"<<endl; } { cout << "create objects:" << endl; TCandidate c1(TLorentzVector(1,0,0,0),0); TCandidate c2(TLorentzVector(0,2,0,0),0); TCandidate c3(TLorentzVector(0,0,3,0),0); TCandidate c4(TLorentzVector(0,0,0,4),0); PC("c1",c1); PC("c2",c2); PC("c3",c3); PC("c4",c4); cout <<endl<< "OpAdd4.Fill(c4,c1,c2,c3); "<<endl; b4.Fill(c4,c3,c2,c1); PC("c1",c1); PC("c2",c2); PC("c3",c3); PC("c4",c4); cout << "---------------------------------------------------"<<endl; } { cout << "create objects:" << endl; TCandidate c1(TLorentzVector(1,0,0,0),1); TCandidate c2(TLorentzVector(0,2,0,0),-1); TCandidate c3(TLorentzVector(0,0,3,0),0); TCandidate c4(TLorentzVector(0,0,0,4),0); TCandidate c5(TLorentzVector(0,0,0,0),5); TCandidate c6(TLorentzVector(0,0,0,0),6); TCandidate c7(TLorentzVector(0,0,0,0),7); PC("c1",c1); PC("c2",c2); PC("c3",c3); PC("c4",c4); PC("c5",c5); PC("c6",c6); PC("c7",c7); cout <<endl<< "after Add4::Fill(c5,c1,c2); Add4::Fill(c6,c3,c4); "<<endl; b4.Fill(c5,c1,c2); b4.Fill(c6,c3,c4); PC("c1",c1); PC("c2",c2); PC("c3",c3); PC("c4",c4); PC("c5",c5); PC("c6",c6); PC("c7",c7); cout <<endl<< "after Add4::Fill(c7,c5,c6); "<<endl; b4.Fill(c7,c5,c6); PC("c1",c1); PC("c2",c2); PC("c3",c3); PC("c4",c4); PC("c5",c5); PC("c6",c6); PC("c7",c7); // do some additional checks of copying, etc cout <<endl<< "after c8(c7);"<<endl; TCandidate c8(c7); PC("c1",c1); PC("c2",c2); PC("c3",c3); PC("c4",c4); PC("c5",c5); PC("c6",c6); PC("c7",c7); PC("c8",c8); cout <<endl<< "create c9(c1); then c9 = c7;"<<endl; TCandidate c9(c1); c9 = c7; PC("c1",c1); PC("c2",c2); PC("c3",c3); PC("c4",c4); PC("c5",c5); PC("c6",c6); PC("c7",c7); PC("c8",c8); PC("c9",c9); cout <<endl<< "c9 = c5;"<<endl; c9 = c5; PC("c1",c1); PC("c2",c2); PC("c3",c3); PC("c4",c4); PC("c5",c5); PC("c6",c6); PC("c7",c7); PC("c8",c8); PC("c9",c9); cout << endl; cout << "testing Overlaps:"<<endl; cout << "c1 and c2: "<<(c1.Overlaps(c2)?"t":"f")<<endl; cout << "c9 and c5: "<<(c9.Overlaps(c5)?"t":"f")<<endl; cout << "c8 and c5: "<<(c8.Overlaps(c5)?"t":"f")<<endl; cout << "c7 and c5: "<<(c7.Overlaps(c5)?"t":"f")<<endl; cout << "c6 and c5: "<<(c6.Overlaps(c5)?"t":"f")<<endl; cout << "c5 and c5: "<<(c5.Overlaps(c5)?"t":"f")<<endl; cout << "c5 and c9: "<<(c5.Overlaps(c9)?"t":"f")<<endl; cout << "c5 and c8: "<<(c5.Overlaps(c8)?"t":"f")<<endl; cout << "c5 and c7: "<<(c5.Overlaps(c7)?"t":"f")<<endl; cout << "c5 and c6: "<<(c5.Overlaps(c6)?"t":"f")<<endl; cout << "c5 and c5: "<<(c5.Overlaps(c5)?"t":"f")<<endl; cout << "---------------------------------------------------"<<endl; } // // start testing OpMakeTree theStream << "Before Making Tree " << endl; theStream << endl; { cout << "Initialization of Pdt " << endl; //Pdt::readMCppTable("PARENT/PDT/pdt.table"); TDatabasePDG *Pdt = TRho::Instance()->GetPDG(); cout << "done." << endl; // now let's consider the Y(4S) double beamAngle = 0.0204; double beamDeltaP = 9.-3.1; TVector3 pY4S( -beamDeltaP*sin(beamAngle),0, beamDeltaP*cos(beamAngle) ); TCandidate Y4S( pY4S, Pdt->GetParticle("Upsilon(4S)") ); TTreeNavigator::PrintTree( Y4S ); cout << "theta " << Y4S.P3().Theta() << endl; cout << "phi " << Y4S.P3().Phi() << endl; // instanciate a Booster TBooster cmsBooster( &Y4S , kTRUE); // Let's imagine a photon with a certain angle in the CMS frame // a photon double ePhot = 1.; double photAngle = 30*3.1416/180.; double photPhi = 45*3.1416/180.; TCandidate photon( TVector3( ePhot*sin(photAngle)*cos(photPhi), ePhot*sin(photAngle)*sin(photPhi), ePhot*cos(photAngle) ), Pdt->GetParticle("gamma") ); cout << endl << "The original photon in the CMS frame " << endl; TTreeNavigator::PrintTree( photon ); cout << "theta " << photon.P3().Theta() << endl; cout << "phi " << photon.P3().Phi() << endl; // the same photon in the LAB frame : TCandidate boostedPhoton = cmsBooster.BoostFrom( photon ); TLorentzVector theLabP4 = cmsBooster.BoostedP4( photon, TBooster::From ); cout << "the lab Four-Vector (" << theLabP4.X() << "," << theLabP4.Y() << "," << theLabP4.Z() << ";" << theLabP4.E() << ")" << endl; cout << endl << "The lab boosted photon " << endl; TTreeNavigator::PrintTree( boostedPhoton ); cout << "theta " << boostedPhoton.P3().Theta() << endl; cout << "phi " << boostedPhoton.P3().Phi() << endl; // now boost back in the CMS frame TLorentzVector theP4 = cmsBooster.BoostedP4( boostedPhoton, TBooster::To ); cout << "the Four-Vector in CMS frame (" << theP4.X() << "," << theP4.Y() << "," << theP4.Z() << ";" << theP4.E() << ")" << endl; cout << " from cand : (" << photon.P4().X() << "," << photon.P4().Y() << "," << photon.P4().Z() << ";" <<photon.P4().E() << ")" << endl; double mPsi = Pdt->GetParticle("J/psi")->Mass(); double mMu = Pdt->GetParticle("mu+")->Mass(); double mPi = Pdt->GetParticle("pi+")->Mass(); double mK = Pdt->GetParticle("K+")->Mass(); double mB = Pdt->GetParticle("B+")->Mass(); double mDst = Pdt->GetParticle("D*+")->Mass(); double mD0 = Pdt->GetParticle("D0")->Mass(); double mRho = Pdt->GetParticle("rho+")->Mass(); // // Let's start with a simple example : B+ -> J/Psi K+ // // muons in the J/Psi frame double E(0.), P(0.), th(0.), ph(0.); TVector3 p3; th = 0.3; ph = 1.3; P = 0.5*sqrt( pow(mPsi,2) - 4*pow(mMu,2) ); E = sqrt( pow(mMu,2) + pow(P,2) ); p3 = TVector3( sin(th)*cos(ph)*P, sin(th)*sin(ph)*P, cos(th)*P ); TLorentzVector mu1P4( p3, E ); TLorentzVector mu2P4( -p3, E ); // J/psi in the B frame th = 1.1; ph = 0.5; P = 0.5*sqrt((pow(mB,2)-pow(mPsi-mK,2))*(pow(mB,2)-pow(mPsi+mK,2)))/mB; p3 = TVector3( sin(th)*cos(ph)*P, sin(th)*sin(ph)*P, cos(th)*P ); E = sqrt( pow(mPsi,2) + pow(P,2) ); TVector3 boostVector( p3.X()/E, p3.Y()/E,p3.Z()/E ); mu1P4.Boost( boostVector ); mu2P4.Boost( boostVector ); E = sqrt( pow(mK,2) + pow(P,2) ); TLorentzVector KP4( -p3, E ); // create the TCandidates TCandidate* mu1 = new TCandidate( mu1P4.Vect(), Pdt->GetParticle("mu+") ); TCandidate* mu2 = new TCandidate( mu2P4.Vect(), Pdt->GetParticle("mu-") ); TCandidate* K = new TCandidate( KP4.Vect(), Pdt->GetParticle("K+") ); // now create the Make Tree operator TOpMakeTree op; // now create the J/Psi TCandidate psi = op.Combine( *mu1, *mu2 ); psi.SetType( "J/psi" ); psi.SetMassConstraint(); cout << endl << "The original psi " << endl; TTreeNavigator::PrintTree( psi ); // now create the B+ TCandidate B = op.Combine( psi, *K ); B.SetType( "B+" ); B.SetMassConstraint(); cout << endl << "The B " << endl; TTreeNavigator::PrintTree( B ); // create a TTreeNavigator TTreeNavigator treeNavigator( B ); TTreeNavigator::PrintTree( psi ); theStream << "After tree making" << endl; theStream << endl; //instanciate the fitter with the B Candidate VAbsFitter* fitter = new TDummyFitter( psi ); theStream << "After fitter construction " << endl; theStream << endl; // get the "fitted" TCandidates TCandidate fittedPsi = fitter->GetFitted( psi ); TTreeNavigator::PrintTree( fittedPsi ); TCandListIterator iterDau = psi.DaughterIterator(); TCandidate* dau=0; while( dau=iterDau.Next() ) { TCandidate fittedDau = fitter->GetFitted( *dau ); TTreeNavigator::PrintTree( fittedDau ); } delete fitter; fitter = new TDummyFitter( B ); // get the "fitted" TCandidates TCandidate fittedB = fitter->GetFitted( B ); TTreeNavigator::PrintTree( fittedB ); iterDau.Rewind(); dau=0; while( dau=iterDau.Next() ) { TCandidate fittedDau = fitter->GetFitted( *dau ); TTreeNavigator::PrintTree( fittedDau ); } TCandidate hello = fitter->GetFitted( psi ); TTreeNavigator::PrintTree( hello ); delete fitter; theStream << "After fitter deletion " << endl; theStream << endl; // first let's boost the kaon TCandidate boostedKaon = cmsBooster.BoostTo( *K ); cout << endl << "The boosted Kaon " << endl; TTreeNavigator::PrintTree( *K ); // let's boost the psi TCandidate boostedPsi = cmsBooster.BoostTo( psi ); cout << endl << "The boosted Psi " << endl; TTreeNavigator::PrintTree( boostedPsi ); theStream << "before tree boosting " << endl; theStream << endl; // now let's boost the B in the Y4S frame TCandidate boostedB = cmsBooster.BoostTo( B ); // let's see the tree cout << endl << "The boosted B " << endl; TTreeNavigator::PrintTree( boostedB ); theStream << "after tree boosting " << endl; theStream << endl; // now let's boost a list TCandList theList; theList.Add( psi ); theList.Add( *K ); theList.Add( B ); TCandList theBoostedList; cmsBooster.BoostTo( theList, theBoostedList ); TCandListIterator iter(theBoostedList); TCandidate* c(0); while( c=iter.Next() ) { cout << "boosted cand " << c->PdtEntry()->GetName() << endl; TTreeNavigator::PrintTree( *c ); } theBoostedList.Cleanup(); PrintAncestors( *mu1 ); delete mu1; delete mu2; delete K; cout << "---------------------------------------------------"<<endl; } theStream << "At the end of the test program " << endl; theStream << endl; }
int main() { // check that it'll find nodes exactly MAX away { tree_type exact_dist(std::ptr_fun(tac)); triplet c0(5, 4, 0); exact_dist.insert(c0); triplet target(7,4,0); std::pair<tree_type::const_iterator,double> found = exact_dist.find_nearest(target,2); assert(found.first != exact_dist.end()); assert(found.second == 2); std::cout << "Test find_nearest(), found at exact distance away from " << target << ", found " << *found.first << std::endl; } // do the same test, except use alternate_triplet as the search key { // NOTE: stores triplet, but we search with alternate_triplet typedef KDTree::KDTree<3, triplet, alternate_tac> alt_tree; triplet actual_target(7,0,0); alt_tree tree; tree.insert( triplet(0, 0, 7) ); tree.insert( triplet(0, 0, 7) ); tree.insert( triplet(0, 0, 7) ); tree.insert( triplet(3, 0, 0) ); tree.insert( actual_target ); tree.optimise(); alternate_triplet target( actual_target ); std::pair<alt_tree::const_iterator,double> found = tree.find_nearest(target); assert(found.first != tree.end()); std::cout << "Test with alternate search type, found: " << *found.first << ", wanted " << actual_target << std::endl; assert(found.second == 0); assert(*found.first == actual_target); } { tree_type exact_dist(std::ptr_fun(tac)); triplet c0(5, 2, 0); exact_dist.insert(c0); triplet target(7,4,0); // call find_nearest without a range value - it found a compile error earlier. std::pair<tree_type::const_iterator,double> found = exact_dist.find_nearest(target); assert(found.first != exact_dist.end()); std::cout << "Test find_nearest(), found at exact distance away from " << target << ", found " << *found.first << " @ " << found.second << " should be " << std::sqrt(8) << std::endl; assert(found.second == std::sqrt(8)); } { tree_type exact_dist(std::ptr_fun(tac)); triplet c0(5, 2, 0); exact_dist.insert(c0); triplet target(7,4,0); std::pair<tree_type::const_iterator,double> found = exact_dist.find_nearest(target,std::sqrt(8)); assert(found.first != exact_dist.end()); std::cout << "Test find_nearest(), found at exact distance away from " << target << ", found " << *found.first << " @ " << found.second << " should be " << std::sqrt(8) << std::endl; assert(found.second == std::sqrt(8)); } tree_type src(std::ptr_fun(tac)); triplet c0(5, 4, 0); src.insert(c0); triplet c1(4, 2, 1); src.insert(c1); triplet c2(7, 6, 9); src.insert(c2); triplet c3(2, 2, 1); src.insert(c3); triplet c4(8, 0, 5); src.insert(c4); triplet c5(5, 7, 0); src.insert(c5); triplet c6(3, 3, 8); src.insert(c6); triplet c7(9, 7, 3); src.insert(c7); triplet c8(2, 2, 6); src.insert(c8); triplet c9(2, 0, 6); src.insert(c9); std::cout << src << std::endl; src.erase(c0); src.erase(c1); src.erase(c3); src.erase(c5); src.optimise(); // test the efficient_replace_and_optimise() tree_type eff_repl = src; { std::vector<triplet> vec; // erased above as part of test vec.push_back(triplet(5, 4, 0)); // erased above as part of test vec.push_back(triplet(4, 2, 1)); vec.push_back(triplet(7, 6, 9)); // erased above as part of test vec.push_back(triplet(2, 2, 1)); vec.push_back(triplet(8, 0, 5)); // erased above as part of test vec.push_back(triplet(5, 7, 0)); vec.push_back(triplet(3, 3, 8)); vec.push_back(triplet(9, 7, 3)); vec.push_back(triplet(2, 2, 6)); vec.push_back(triplet(2, 0, 6)); eff_repl.clear(); eff_repl.efficient_replace_and_optimise(vec); } std::cout << std::endl << src << std::endl; tree_type copied(src); std::cout << copied << std::endl; tree_type assigned; assigned = src; std::cout << assigned << std::endl; for (int loop = 0; loop != 4; ++loop) { tree_type * target; switch (loop) { case 0: std::cout << "Testing plain construction" << std::endl; target = &src; break; case 1: std::cout << "Testing copy-construction" << std::endl; target = &copied; break; case 2: std::cout << "Testing assign-construction" << std::endl; target = &assigned; break; default: case 4: std::cout << "Testing efficient-replace-and-optimise" << std::endl; target = &eff_repl; break; } tree_type & t = *target; int i=0; for (tree_type::const_iterator iter=t.begin(); iter!=t.end(); ++iter, ++i); std::cout << "iterator walked through " << i << " nodes in total" << std::endl; if (i!=6) { std::cerr << "Error: does not tally with the expected number of nodes (6)" << std::endl; return 1; } i=0; for (tree_type::const_reverse_iterator iter=t.rbegin(); iter!=t.rend(); ++iter, ++i); std::cout << "reverse_iterator walked through " << i << " nodes in total" << std::endl; if (i!=6) { std::cerr << "Error: does not tally with the expected number of nodes (6)" << std::endl; return 1; } triplet s(5, 4, 3); std::vector<triplet> v; unsigned int const RANGE = 3; size_t count = t.count_within_range(s, RANGE); std::cout << "counted " << count << " nodes within range " << RANGE << " of " << s << ".\n"; t.find_within_range(s, RANGE, std::back_inserter(v)); std::cout << "found " << v.size() << " nodes within range " << RANGE << " of " << s << ":\n"; std::vector<triplet>::const_iterator ci = v.begin(); for (; ci != v.end(); ++ci) std::cout << *ci << " "; std::cout << "\n" << std::endl; std::cout << std::endl << t << std::endl; // search for all the nodes at exactly 0 dist away for (tree_type::const_iterator target = t.begin(); target != t.end(); ++target) { std::pair<tree_type::const_iterator,double> found = t.find_nearest(*target,0); assert(found.first != t.end()); assert(*found.first == *target); std::cout << "Test find_nearest(), found at exact distance away from " << *target << ", found " << *found.first << std::endl; } { const double small_dist = 0.0001; std::pair<tree_type::const_iterator,double> notfound = t.find_nearest(s,small_dist); std::cout << "Test find_nearest(), nearest to " << s << " within " << small_dist << " should not be found" << std::endl; if (notfound.first != t.end()) { std::cout << "ERROR found a node at dist " << notfound.second << " : " << *notfound.first << std::endl; std::cout << "Actual distance = " << s.distance_to(*notfound.first) << std::endl; } assert(notfound.first == t.end()); } { std::pair<tree_type::const_iterator,double> nif = t.find_nearest_if(s,std::numeric_limits<double>::max(),Predicate()); std::cout << "Test find_nearest_if(), nearest to " << s << " @ " << nif.second << ": " << *nif.first << std::endl; std::pair<tree_type::const_iterator,double> cantfind = t.find_nearest_if(s,std::numeric_limits<double>::max(),FalsePredicate()); std::cout << "Test find_nearest_if(), nearest to " << s << " should never be found (predicate too strong)" << std::endl; assert(cantfind.first == t.end()); } { std::pair<tree_type::const_iterator,double> found = t.find_nearest(s,std::numeric_limits<double>::max()); std::cout << "Nearest to " << s << " @ " << found.second << " " << *found.first << std::endl; std::cout << "Should be " << found.first->distance_to(s) << std::endl; // NOTE: the assert does not check for an exact match, as it is not exact when -O2 or -O3 is // switched on. Some sort of optimisation makes the math inexact. assert( fabs(found.second - found.first->distance_to(s)) < std::numeric_limits<double>::epsilon() ); } { triplet s2(10, 10, 2); std::pair<tree_type::const_iterator,double> found = t.find_nearest(s2,std::numeric_limits<double>::max()); std::cout << "Nearest to " << s2 << " @ " << found.second << " " << *found.first << std::endl; std::cout << "Should be " << found.first->distance_to(s2) << std::endl; // NOTE: the assert does not check for an exact match, as it is not exact when -O2 or -O3 is // switched on. Some sort of optimisation makes the math inexact. assert( fabs(found.second - found.first->distance_to(s2)) < std::numeric_limits<double>::epsilon() ); } std::cout << std::endl; std::cout << t << std::endl; // Testing iterators { std::cout << "Testing iterators" << std::endl; t.erase(c2); t.erase(c4); t.erase(c6); t.erase(c7); t.erase(c8); // t.erase(c9); std::cout << std::endl << t << std::endl; std::cout << "Forward iterator test..." << std::endl; std::vector<triplet> forwards; for (tree_type::iterator i = t.begin(); i != t.end(); ++i) { std::cout << *i << " " << std::flush; forwards.push_back(*i); } std::cout << std::endl; std::cout << "Reverse iterator test..." << std::endl; std::vector<triplet> backwards; for (tree_type::reverse_iterator i = t.rbegin(); i != t.rend(); ++i) { std::cout << *i << " " << std::flush; backwards.push_back(*i); } std::cout << std::endl; std::reverse(backwards.begin(),backwards.end()); assert(backwards == forwards); } } // Walter reported that the find_within_range() wasn't giving results that were within // the specified range... this is the test. { tree_type tree(std::ptr_fun(tac)); tree.insert( triplet(28.771200,16.921600,-2.665970) ); tree.insert( triplet(28.553101,18.649700,-2.155560) ); tree.insert( triplet(28.107500,20.341400,-1.188940) ); tree.optimise(); std::deque< triplet > vectors; triplet sv(18.892500,20.341400,-1.188940); tree.find_within_range(sv, 10.0f, std::back_inserter(vectors)); std::cout << std::endl << "Test find_with_range( " << sv << ", 10.0f) found " << vectors.size() << " candidates." << std::endl; // double-check the ranges for (std::deque<triplet>::iterator v = vectors.begin(); v != vectors.end(); ++v) { double dist = sv.distance_to(*v); std::cout << " " << *v << " dist=" << dist << std::endl; if (dist > 10.0f) std::cout << " This point is too far! But that is by design, its within a 'box' with a 'radius' of 10, not a sphere with a radius of 10" << std::endl; // Not a valid test, it can be greater than 10 if the point is in the corners of the box. // assert(dist <= 10.0f); } } return 0; }
void test01() { // class MyClass : YourClass // { // string message = "Hello"; // } try { CIMName a = "A_class1"; CIMName b = "A_class2"; CIMClass c0(a, b); CIMClass c1(a, CIMName("A_class2")); CIMClass c2(CIMName("A_class1"), b); CIMClass c3(b, a); } catch (InvalidNameException & ine) { if (verbose) { cout << "Caught unexpected exception: " << ine.getMessage() << endl; } } try { // // Invalid class name // CIMClass class0(CIMName ("//localhost/root/cimv2:MyClass"), CIMName ("YourClass")); PEGASUS_TEST_ASSERT(class0.getPath() == CIMObjectPath("//localhost/root/cimv2:MyClass")); } catch (InvalidNameException & ine) { if (verbose) { cout << "Caught expected exception: " << ine.getMessage() << endl; } } CIMClass class1(CIMName ("MyClass"), CIMName ("YourClass")); class1 .addQualifier(CIMQualifier(CIMName ("association"), true)) .addQualifier(CIMQualifier(CIMName ("q1"), Uint32(55))) .addQualifier(CIMQualifier(CIMName ("q2"), String("Hello"))) .addProperty(CIMProperty(CIMName ("message"), String("Hello"))) .addProperty(CIMProperty(CIMName ("count"), Uint32(77), 0, CIMName(), CIMName("YourClass"), true)) .addMethod(CIMMethod(CIMName ("isActive"), CIMTYPE_BOOLEAN) .addParameter(CIMParameter(CIMName ("hostname"), CIMTYPE_STRING)) .addParameter(CIMParameter(CIMName ("port"), CIMTYPE_UINT32))); // Test the method count function PEGASUS_TEST_ASSERT(class1.getClassName().equal(CIMName ("myclass"))); PEGASUS_TEST_ASSERT(class1.getSuperClassName() == CIMName ("YourClass")); PEGASUS_TEST_ASSERT(class1.getMethodCount() ==1); // Test the findMethod and isMethod functions PEGASUS_TEST_ASSERT(class1.findMethod( CIMName ("isActive")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findMethod( CIMName ("DoesNotExist")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findMethod( CIMName ("isActive")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findMethod( CIMName ("DoesNotExist")) == PEG_NOT_FOUND); // Test the manipulation of an embeddedObjectProperty CIMClass embedClass(CIMName ("embedObj"), CIMName ()); class1.addProperty(CIMProperty(CIMName ("embedObj"), CIMObject(embedClass), 0, CIMName(), CIMName(), false)); PEGASUS_TEST_ASSERT(class1.findProperty( CIMName ("embedObj")) != PEG_NOT_FOUND); Uint32 posProp = class1.findProperty(CIMName ("embedObj")); CIMConstProperty constprop1 = class1.getProperty(posProp); PEGASUS_TEST_ASSERT(constprop1.getClassOrigin() == CIMName()); PEGASUS_TEST_ASSERT(constprop1.getType() == CIMTYPE_OBJECT); class1.removeProperty(posProp); // Now add another method and reconfirm. class1.addMethod(CIMMethod(CIMName ("makeActive"), CIMTYPE_BOOLEAN) .addParameter(CIMParameter(CIMName ("hostname"), CIMTYPE_STRING)) .addParameter(CIMParameter(CIMName ("port"), CIMTYPE_UINT32))); PEGASUS_TEST_ASSERT(class1.getMethodCount() == 2); // Test the findMethod and isMethod functions // with two methods defined PEGASUS_TEST_ASSERT(class1.findMethod( CIMName ("isActive")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findMethod( CIMName ("makeActive")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findMethod( CIMName ("DoesNotExist")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findMethod( CIMName ("isActive")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findMethod( CIMName ("makeActive")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findMethod( CIMName ("DoesNotExist")) == PEG_NOT_FOUND); // Test RemoveMethod function Uint32 posMethod; posMethod = class1.findMethod(CIMName ("isActive")); PEGASUS_TEST_ASSERT(posMethod != PEG_NOT_FOUND); class1.removeMethod(posMethod); PEGASUS_TEST_ASSERT(class1.findMethod( CIMName ("isActive")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.getMethodCount() == 1); //ATTN: P3 TODO add tests for different case names //Qualifier manipulation tests (find, remove) PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q1")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q2")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("qx")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q1")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q2")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findQualifier( CIMName ("association")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.isAssociation()); // Remove middle Qualifier "q2" Uint32 posQualifier; posQualifier = class1.findQualifier(CIMName ("q2")); CIMConstQualifier qconst = class1.getQualifier(posQualifier); PEGASUS_TEST_ASSERT(class1.getQualifierCount() == 3); PEGASUS_TEST_ASSERT(posQualifier <= class1.getQualifierCount()); class1.removeQualifier(posQualifier); PEGASUS_TEST_ASSERT(class1.getQualifierCount() == 2); PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q2")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q1")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.isAssociation()); // Remove the first parameter "q1" posQualifier = class1.findQualifier(CIMName ("q1")); PEGASUS_TEST_ASSERT(class1.getQualifierCount() == 2); CIMQualifier cq = class1.getQualifier( class1.findQualifier( CIMName ("q1"))); PEGASUS_TEST_ASSERT(posQualifier <= class1.getQualifierCount()); class1.removeQualifier(posQualifier); PEGASUS_TEST_ASSERT(class1.getQualifierCount() == 1); PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q1")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q2")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.isAssociation()); // ATTH: P3 Add tests for try block for outofbounds //The property manipulation tests. PEGASUS_TEST_ASSERT(class1.findProperty( CIMName ("count")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findProperty( CIMName ("message")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findProperty( CIMName ("isActive")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.getPropertyCount() == 2); Uint32 posProperty; posProperty = class1.findProperty(CIMName ("count")); CIMConstProperty constprop = class1.getProperty(posProperty); PEGASUS_TEST_ASSERT(constprop.getClassOrigin() == CIMName("YourClass")); PEGASUS_TEST_ASSERT(constprop.getPropagated()); class1.removeProperty(posProperty); PEGASUS_TEST_ASSERT(class1.findProperty( CIMName ("message")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.findProperty( CIMName ("count")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(class1.getPropertyCount() == 1); CIMProperty cp = class1.getProperty( class1.findProperty (CIMName ("message"))); PEGASUS_TEST_ASSERT(cp.getClassOrigin().isNull()); PEGASUS_TEST_ASSERT(!cp.getPropagated()); if(verbose) { XmlWriter::printClassElement(class1); MofWriter::printClassElement(class1); } Buffer out; MofWriter::appendClassElement(out, class1); out.clear(); XmlWriter::appendClassElement(out, class1); PEGASUS_TEST_ASSERT(!class1.isAbstract()); CIMName squal("q1"); PEGASUS_TEST_ASSERT(class1.findQualifier(squal) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(!class1.hasKeys()); Array<CIMName> keyNames; class1.getKeyNames(keyNames); CIMClass c2(CIMName ("MyClass")); PEGASUS_TEST_ASSERT(c2.getClassName().equal(CIMName ("myclass"))); // Error uninitialized handle c2.setSuperClassName(CIMName ("CIM_Element")); PEGASUS_TEST_ASSERT(c2.getSuperClassName() == CIMName ("CIM_Element")); CIMClass c3 = c2.clone(); c3 = c2; try { CIMMethod cm = c2.getMethod(0); } catch(IndexOutOfBoundsException& e) { if(verbose) cout << "Exception: " << e.getMessage() << endl; } const CIMClass c4(CIMName ("MyClass"), CIMName ("YourClass")); CIMConstClass c5(CIMName ("MyClass"), CIMName ("YourClass")); CIMConstClass c6(CIMName ("MyClass")); CIMConstClass cc7(c6); CIMClass c7 = c5.clone(); const CIMClass c8(class1); // Test the findMethod and isMethod functions PEGASUS_TEST_ASSERT(c7.findMethod( CIMName ("DoesNotExist")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(c7.findQualifier(CIMName ("dummy")) == PEG_NOT_FOUND); try { CIMConstMethod cm = c8.getMethod(0); } catch(IndexOutOfBoundsException& e) { if(verbose) cout << "Exception: " << e.getMessage() << endl; } try { CIMConstProperty ccp = c8.getProperty(c8.findProperty (CIMName ("count"))); } catch(IndexOutOfBoundsException& e) { if(verbose) cout << "Exception: " << e.getMessage() << endl; } if(verbose) { XmlWriter::printClassElement(c5); } try { CIMConstMethod cm = cc7.getMethod(0); } catch(IndexOutOfBoundsException& e) { if(verbose) cout << "Exception: " << e.getMessage() << endl; } // Test the findMethod and isMethod functions PEGASUS_TEST_ASSERT(c4.findMethod( CIMName ("DoesNotExist")) == PEG_NOT_FOUND); //Qualifier manipulation tests (find, remove) PEGASUS_TEST_ASSERT(c4.findQualifier(CIMName ("qx")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(c4.findQualifier(CIMName ("q1")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(c4.findQualifier(CIMName ("q2")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(c4.findQualifier( CIMName ("association")) == PEG_NOT_FOUND); posProperty = c4.findProperty(CIMName ("count")); try { CIMConstQualifier ccq = c4.getQualifier(c4.findQualifier (CIMName ("q1"))); } catch (IndexOutOfBoundsException& e) { if(verbose) cout << "Exception: " << e.getMessage() << endl; } PEGASUS_TEST_ASSERT(c4.findProperty(CIMName ("count")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(c4.getClassName() == CIMName ("MyClass")); PEGASUS_TEST_ASSERT(c4.getClassName().equal(CIMName ("MyClass"))); PEGASUS_TEST_ASSERT(c4.getClassName().equal(CIMName ("MYCLASS"))); PEGASUS_TEST_ASSERT(c4.getClassName().equal(CIMName ("myclass"))); PEGASUS_TEST_ASSERT(!c4.getClassName().equal(CIMName ("blob"))); PEGASUS_TEST_ASSERT(c4.getSuperClassName() == CIMName ("YourClass")); // test the setSuperClassName function /* ATTN KS 29 April. This test has problems. Relook later. Think test, not code. c4.setSuperClassName(CIMName ("JunkClass")); PEGASUS_TEST_ASSERT(c4.getSuperClassName() == CIMName ("JunkClass")); c4.setSuperClassName(CIMName ("YourClass")); */ PEGASUS_TEST_ASSERT(c5.getSuperClassName() == CIMName ("YourClass")); PEGASUS_TEST_ASSERT(c5.getQualifierCount() == 0); posQualifier = c5.findQualifier(CIMName ("q2")); // throws out of bounds try { CIMConstQualifier qconst1 = c5.getQualifier(posQualifier); } catch(IndexOutOfBoundsException& e) { if(verbose) cout << "Exception: " << e.getMessage() << endl; } if(verbose) { cout << "All tests" << endl; } }
void drive_operation() { // Uint64 tests CQLValue a1(Uint64(10)); CQLValue a2(Uint64(15)); CQLValue a3(Uint64(25)); CQLValue a4(Uint64(30)); CQLValue a5(Uint64(150)); PEGASUS_TEST_ASSERT(a1 != a2); PEGASUS_TEST_ASSERT(a5 == a5); PEGASUS_TEST_ASSERT(a1 < a2); PEGASUS_TEST_ASSERT(a2 >= a1); PEGASUS_TEST_ASSERT(a1 <= a2); PEGASUS_TEST_ASSERT(a2 > a1); // Sint64 tests CQLValue b1(Sint64(10)); CQLValue b2(Sint64(15)); CQLValue b3(Sint64(25)); CQLValue b4(Sint64(30)); CQLValue b5(Sint64(150)); PEGASUS_TEST_ASSERT(b1 != b2); PEGASUS_TEST_ASSERT(b5 == b5); PEGASUS_TEST_ASSERT(b1 < b2); PEGASUS_TEST_ASSERT(b2 >= b1); PEGASUS_TEST_ASSERT(b1 <= b2); PEGASUS_TEST_ASSERT(b2 > b1); // Real64 tests CQLValue c1(Real64(10.00)); CQLValue c2(Real64(15.00)); CQLValue c3(Real64(25.00)); CQLValue c4(Real64(30.00)); CQLValue c5(Real64(150.00)); PEGASUS_TEST_ASSERT(c1 != c2); PEGASUS_TEST_ASSERT(c5 == c5); PEGASUS_TEST_ASSERT(c1 < c2); PEGASUS_TEST_ASSERT(c2 >= c1); PEGASUS_TEST_ASSERT(c1 <= c2); PEGASUS_TEST_ASSERT(c2 > c1); // Misc PEGASUS_TEST_ASSERT(a1 == b1); PEGASUS_TEST_ASSERT(a1 == c1); PEGASUS_TEST_ASSERT(b1 == a1); PEGASUS_TEST_ASSERT(b1 == c1); PEGASUS_TEST_ASSERT(c1 == a1); PEGASUS_TEST_ASSERT(c1 == b1); PEGASUS_TEST_ASSERT(a2 != b1); PEGASUS_TEST_ASSERT(a2 != c1); PEGASUS_TEST_ASSERT(b2 != a1); PEGASUS_TEST_ASSERT(b2 != c1); PEGASUS_TEST_ASSERT(c2 != a1); PEGASUS_TEST_ASSERT(c2 != b1); PEGASUS_TEST_ASSERT(a2 >= b1); PEGASUS_TEST_ASSERT(a2 >= c1); PEGASUS_TEST_ASSERT(b2 >= a1); PEGASUS_TEST_ASSERT(b2 >= c1); PEGASUS_TEST_ASSERT(c2 >= a1); PEGASUS_TEST_ASSERT(c2 >= b1); PEGASUS_TEST_ASSERT(a2 <= b3); PEGASUS_TEST_ASSERT(a2 <= c3); PEGASUS_TEST_ASSERT(b2 <= a3); PEGASUS_TEST_ASSERT(b2 <= c3); PEGASUS_TEST_ASSERT(c2 <= a3); PEGASUS_TEST_ASSERT(c2 <= b3); PEGASUS_TEST_ASSERT(a2 > b1); PEGASUS_TEST_ASSERT(a2 > c1); PEGASUS_TEST_ASSERT(b2 > a1); PEGASUS_TEST_ASSERT(b2 > c1); PEGASUS_TEST_ASSERT(c2 > a1); PEGASUS_TEST_ASSERT(c2 > b1); PEGASUS_TEST_ASSERT(a2 < b3); PEGASUS_TEST_ASSERT(a2 < c3); PEGASUS_TEST_ASSERT(b2 < a3); PEGASUS_TEST_ASSERT(b2 < c3); PEGASUS_TEST_ASSERT(c2 < a3); PEGASUS_TEST_ASSERT(c2 < b3); //Overflow testing CQLValue real1(Real64(0.00000001)); CQLValue sint1(Sint64(-1)); CQLValue uint1(Sint64(1)); CQLValue uint2(Uint64(0)); PEGASUS_TEST_ASSERT(uint1 > sint1); PEGASUS_TEST_ASSERT(real1 > sint1); PEGASUS_TEST_ASSERT(uint2 > sint1); PEGASUS_TEST_ASSERT(real1 > uint2); CQLValue real2(Real64(25.00000000000001)); CQLValue real3(Real64(24.99999999999999)); CQLValue sint2(Sint64(25)); CQLValue uint3(Uint64(25)); PEGASUS_TEST_ASSERT(real2 > real3); PEGASUS_TEST_ASSERT(real2 > sint2); PEGASUS_TEST_ASSERT(real2 > uint3); PEGASUS_TEST_ASSERT(real3 < sint2); PEGASUS_TEST_ASSERT(real3 < uint3); // String tests CQLValue d1(String("HELLO")); CQLValue d2(String("HEL")); CQLValue d3(String("LO")); CQLValue d4(String("AHELLO")); CQLValue d5(String("ZHELLO")); PEGASUS_TEST_ASSERT(d1 == d2 + d3); PEGASUS_TEST_ASSERT(d1 != d2 + d4); PEGASUS_TEST_ASSERT(d1 <= d5); PEGASUS_TEST_ASSERT(d1 < d5); PEGASUS_TEST_ASSERT(d1 >= d4); PEGASUS_TEST_ASSERT(d1 > d4); String str1("0x10"); String str2("10"); String str3("10B"); String str4("10.10"); CQLValue e1( str1, CQLValue::Hex); CQLValue e2( str2, CQLValue::Decimal); CQLValue e3( str3, CQLValue::Binary); CQLValue e4( str4, CQLValue::Real); CQLValue e5(Uint64(16)); CQLValue e6(Uint64(10)); CQLValue e7(Uint64(2)); CQLValue e8(Real64(10.10)); PEGASUS_TEST_ASSERT(e1 == e5); PEGASUS_TEST_ASSERT(e2 == e6); PEGASUS_TEST_ASSERT(e3 == e7); PEGASUS_TEST_ASSERT(e4 == e8); Array<Uint64> array1; array1.append(1); array1.append(2); array1.append(3); array1.append(4); array1.append(5); array1.append(6); array1.append(7); array1.append(8); array1.append(9); array1.append(10); Array<Sint64> array2; array2.append(1); array2.append(2); array2.append(3); array2.append(4); array2.append(5); array2.append(6); array2.append(7); array2.append(8); array2.append(9); array2.append(10); array2.append(3); Array<Real64> array3; array3.append(1.00); array3.append(2.00); array3.append(3.00); array3.append(9.00); array3.append(10.00); array3.append(3.00); array3.append(4.00); array3.append(5.00); array3.append(6.00); array3.append(7.00); array3.append(8.00); Array<Uint64> array4; array4.append(1); array4.append(23); array4.append(3); array4.append(4); array4.append(5); array4.append(6); array4.append(7); array4.append(88); array4.append(9); array4.append(10); Array<Sint64> array5; array5.append(-1); array5.append(2); array5.append(3); array5.append(4); array5.append(5); array5.append(-6); array5.append(7); array5.append(8); array5.append(9); array5.append(10); array5.append(-3); Array<Real64> array6; array6.append(1.23); array6.append(2.00); array6.append(3.00); array6.append(9.00); array6.append(10.00); array6.append(3.00); array6.append(4.14); array6.append(5.00); array6.append(6.00); array6.append(7.00); array6.append(8.00); CIMValue cv1(array1); CIMValue cv2(array2); CIMValue cv3(array3); CIMValue cv4(array4); CIMValue cv5(array5); CIMValue cv6(array6); CQLValue vr1(cv1); CQLValue vr2(cv1); CQLValue vr3(cv2); CQLValue vr4(cv3); CQLValue vr5(cv4); CQLValue vr6(cv5); CQLValue vr7(cv6); PEGASUS_TEST_ASSERT(vr1 == vr2); PEGASUS_TEST_ASSERT(vr1 == vr3); PEGASUS_TEST_ASSERT(vr1 == vr4); PEGASUS_TEST_ASSERT(vr4 == vr3); PEGASUS_TEST_ASSERT(vr1 != vr5); PEGASUS_TEST_ASSERT(vr3 != vr6); PEGASUS_TEST_ASSERT(vr4 != vr7); const CIMName _cimName(String("CIM_OperatingSystem")); CIMInstance _i1(_cimName); CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules"))); CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2))); CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600))); CIMProperty _p4(CIMName("TimeOfLastStateChange"), CIMValue(CIMDateTime(String("20040811105625.000000-360")))); _i1.addProperty(_p1); _i1.addProperty(_p2); _i1.addProperty(_p3); _i1.addProperty(_p4); CIMInstance _i2(_cimName); CIMProperty _p5(CIMName("Description"), CIMValue(String("Dave Rules Everything"))); CIMProperty _p6(CIMName("EnabledState"),CIMValue(Uint16(2))); CIMProperty _p7(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600))); CIMProperty _p8(CIMName("TimeOfLastStateChange"), CIMValue(CIMDateTime(String("20040811105625.000000-360")))); _i2.addProperty(_p5); _i2.addProperty(_p6); _i2.addProperty(_p7); _i2.addProperty(_p8); CQLValue cql1(_i1); CQLValue cql2(_i1); CQLValue cql3(_i2); CQLValue cql4(_i2); //PEGASUS_TEST_ASSERT(cql1 == cql1); return; }
int read_multiplet_data(int lineno, char filename[], opt* opts, vector<string> *listname, vector<metab_template> *Tems, vector<double> *x, char chemshift[], int s, char inputdir[]) // read in metabolite multiplet data, note at present this assumes the file // is ordered in groups corresponding to different metabolites { vector<string> names(lineno);// name characters the first line matrix c1(lineno); matrix c2(lineno); matrix c3(lineno); matrix c4(lineno); matrix c5(lineno); //matrix c6(lineno); matrix c7(lineno); matrixI c8(lineno); // for ph vector<string> names2(lineno); matrix c11(lineno); matrix c12(lineno); int count = 0; double pst, ped; int nl = read_datf(&names,&c1, &c2, &c3, &c4, &c5, &c7, &c8, filename); if (nl < 0) { return nl; } if ((*opts).usechemshift == 1) { int nl2 = read_dat_chemshift(&names2, &c11,&c12, chemshift, s); if (nl2 < 0) { return nl2; } if (nl != nl2) { printf("Different number of multiplets, exiting ...\n"); system("PAUSE"); exit(1); //return -999; } for (unsigned int j = 0; j < nl2; j++) { if (!((c12[j][0]+50)<0.0000001)) { // if(names[j].compare(names2[j]) == 0 && c11[j][0] == c1[j][0]) //{ c1[j][0] = c12[j][0]; //}else{ // printf("something wrong with multi chemshift, exiting ...\n"); // system("PAUSE"); // exit(1); //} } } } char prevname[80]=" "; char name[80] = {'\0'}; char lis[80] = {'\0'}; metab_template templa("",(*x).size()); for (unsigned int i = 0; i < (*listname).size(); i++) { strcpy(lis,(*listname)[i].c_str()); for (int it = 0; it < nl; it++) { strcpy(name,names[it].c_str()); if (!strcmp(lis,name) && c8[it][0]==1) // find a match in the list { if (!strcmp(prevname, " ")&& c8[it][0]==1)//first prevname do not match prevname { metab_template templa1(name,(*x).size()); templa = templa1; } if (strcmp(prevname,name) && strcmp(prevname, " ") && c8[it][0]==1) // make a new template { metab_template templa1(name,(*x).size()); templa = templa1; } strcpy(prevname,name); for (unsigned int n2 = 0; n2<(*opts).st.size(); n2++) { if ((*opts).st[n2]>(*opts).ed[n2]) { pst = (*opts).ed[n2]; ped = (*opts).st[n2]; } else { ped = (*opts).ed[n2]; pst = (*opts).st[n2]; } if ((c5[it][0]+50)<0.0000001) { if (!((c7[it][0]+50)<0.0000001)) { if (c1[it][0]<ped+(15.0*(*opts).log_fwhh_prop_var)+c7[it][0] && c1[it][0]>pst-(15.0*(*opts).log_fwhh_prop_var)-c7[it][0]) { count = 1; } } else { if (c1[it][0]<ped+(15.0*(*opts).log_fwhh_prop_var)+(*opts).rdelta && c1[it][0]>pst-(15.0*(*opts).log_fwhh_prop_var)-(*opts).rdelta) { count = 1; } } } else { if (!((c7[it][0]+50)<0.0000001)) { if (c5[it][0]<ped+(15.0*(*opts).log_fwhh_prop_var)+c7[it][0] && c5[it][0]>pst-(15.0*(*opts).log_fwhh_prop_var)-c7[it][0]) { count = 1; } } else { if (c5[it][0]<ped+(15.0*(*opts).log_fwhh_prop_var)+(*opts).rdelta && c5[it][0]>pst-(15.0*(*opts).log_fwhh_prop_var)-(*opts).rdelta) { count = 1; } } } } if (count == 1) { if((c2[it][0]+1 <0.0000001) && (c2[it][0]+1 > -0.0000001)) { if (c3[it].size()!=c4[it].size()) { cout<<"\nNo. of protons do not match no. of J constant for metabolite "<<names[it]<<", exiting ...\n"; //system("PAUSE"); exit(1); } double prot=0; for(unsigned int locit=0;locit<c4[it].size();locit++) prot+=c4[it][locit]; vector<double> weights(c4[it]); for(unsigned int locit=0;locit<c4[it].size();locit++) weights[locit]/=prot; //multiplet_site ms(prot, c1[it][0]); multiplet_site ms(&c2[it], c1[it][0], &c3[it], prot, x, c5[it][0],-50, c7[it][0], opts); // vector<unsigned int> c2int(c2[it].size(),0); //vecftoi(c2[it], c2int); ms.setup_param_extra(c3[it],weights); templa.add_multiplet(ms); } else if ((c2[it][0]+2 <0.0000001) && (c2[it][0]+2 > -0.0000001)) { //multiplet_site new_mult2(&pos_vec,&nprot_vec, &x); //cout << "c2 "<<c2[it][0] << endl; vector<double> raster(0.0); double vec_el; multiplet_site ms(&c2[it], c1[it][0], &c3[it], c4[it][0], x, c5[it][0], -50, c7[it][0], opts); if (c3[it].size() == 2) { // raster //printf("find input raster\n"); raster.clear(); char fdirR[3000]={'\0'}; strcpy(fdirR,inputdir); strcat(fdirR,name); strcat(fdirR,".txt"); ifstream inA3_str(fdirR); //cout<<"route "<< fdirR<<endl; //cout<<"file is "<< inA3_str<< endl; //if (!inA3_str) //cout<<"empty, no file "<< inA3_str<< endl; //int tst = 1; int tst2 = 0; while(inA3_str.good()) { tst2 = tst2 +1; inA3_str>>vec_el; //cout<<"vec_el ppm "<<vec_el<<",tst2 " <<tst2<<endl; inA3_str.ignore(1); inA3_str.peek(); if (tst2%2 != 0) { //cout<<"tst2 " <<tst2<<endl; if(vec_el<=max(c3[it][1],c3[it][0]) && vec_el>=min(c3[it][1],c3[it][0])) { inA3_str>>vec_el; raster.push_back(vec_el); tst2 = tst2 +1; } } } /*cout<<"tst = " <<tst<<endl; cout<<"raster1 = "<< raster[0]<<"rasterE = "<<raster[raster.size()-1]<<endl; //cout << "c3 "<<c3[it].size()<<endl; //for (int ii = 0; ii <raster.size(); ii++) //cout<<"raster "<< raster[ii] << " "; FILE *outM; outM = fopen("raster.txt","w"); // wirte to file the metabolites in range for anaylsis for (unsigned int cv = 0; cv <raster.size(); cv++) { fprintf(outM, "%f",raster[cv]); if (cv <=(raster.size()-1)) { fprintf(outM, "\n"); } } fclose(outM);*/ ms.raster_setup(abs(c3[it][1]-c3[it][0]), &raster); } else { printf("Wrong ppm ranges for raster (-2) in J_constant, exiting ...\n"); system("PAUSE"); exit(1); } templa.add_multiplet(ms); } else {
void HUD::setup(){ //Colors for HUDSpinners below ofColor c5(12,60,104); ofColor stepGraphColor(39,39,34); spinner5.setup(15 /*count*/, 0 /*avgRotSpd*/, 3 /*rotVariation*/, c5 /*color*/, 40 /*resolution*/, (22.0/1280.0)*ofGetWidth() /*minRad*/, (85.0/1280.0) * ofGetWidth() /*maxRad*/, (7.0/1280)*ofGetWidth() /*minWidth*/, (30.0/1280.0)*ofGetWidth() /*maxWidth*/, false); HUDimg.loadImage("HUD_AGUS_3.png"); //Lower Right Inner for (int i = 0; i < 3; i++){ HUDUnit tempy; tempy.setup(.5 /*rotSpeed*/, c5 /*color*/, 40 /*numSeg*/, .333 *i /*startSweep*/, .1 /*sweep (0-1)*/, (90.0/1680)*ofGetWidth() /*innerRad*/, (93.0/1680)*ofGetWidth()/*outerRad*/, true /*hasTail*/); unit1_1.push_back(tempy); } //Lower RIght Outer for (int i = 0; i < 4; i++){ HUDUnit tempy; tempy.setup(-.7 /*rotSpeed*/, c5 /*color*/, 40 /*numSeg*/, 0.25*i + .125 /*startSweep*/, .1 /*sweep (0-1)*/, (105.0/1680)*ofGetWidth() /*innerRad*/, (109.0/1680)*ofGetWidth()/*outerRad*/, true/*hasTail*/); unit1_2.push_back(tempy); } //Left inner for (int i = 0; i < 4; i++){ HUDUnit tempy; tempy.setup(.5 /*rotSpeed*/, c5 /*color*/, 40 /*numSeg*/, 0.25*i + ofRandom(-.03,.03) /*startSweep*/, ofRandom(.06, .08) /*sweep (0-1)*/, (51.0/1680)*ofGetWidth() /*innerRad*/, (54.0/1680)*ofGetWidth()/*outerRad*/, true/*hasTail*/); unit2_1.push_back(tempy); } //Left Outer for (int i = 0; i < 4; i++){ HUDUnit tempy; tempy.setup(-.5 /*rotSpeed*/, c5 /*color*/, 40 /*numSeg*/, 0.25*i + ofRandom(-.03,.03) /*startSweep*/, ofRandom(.07, .1) /*sweep (0-1)*/, (65.0/1680)*ofGetWidth() /*innerRad*/, (69.0/1680)*ofGetWidth()/*outerRad*/, true/*hasTail*/); unit2_2.push_back(tempy); } //Setup of Signal Quality Graph on Left of Screen stepGraph1.setup(100/*maxBlocks*/, (38.0/1280.0)*ofGetWidth()/*graphWidth*/, (388.0/768.0)*ofGetHeight()/*graphHeight*/, (2.5/1280.0)*ofGetWidth()/*distBetBlocks*/, stepGraphColor/*color*/, (0.019)*ofGetWindowWidth()/*xLoc*/, (0.768) *ofGetWindowHeight() /*yLoc*/); //Setup of ticker beneath central graph on right rangeMarker1Img.loadImage("RangeMarker_North.png"); rangeMarker1Color.set(100, 102, 90); ofVec3f v1((.9123)*ofGetWindowWidth(), (.6125)*ofGetWindowHeight(), 0); ofVec3f v2((.9773)*ofGetWindowWidth(), (.6125)*ofGetWindowHeight(), 0); rangeMarker1.setup(v1/*VEC3,rangeBound1*/, v2/*VEC3,rangeBound2*/, 10/*numIncrements*/, rangeMarker1Img/*img*/, (10.0/1680)*ofGetWidth()/*imgW*/, (12.0/1660)*ofGetWidth()/*imgH*/, rangeMarker1Color/*color*/, .005/*chanceToUpdate(0-1)*/); // Setup of ticker to the left of graph on top rangeMarker2Img.loadImage("RangeMarker_East.png"); rangeMarker2Color.set(100, 102, 90); ofVec3f v3((1040.0/1280.0)*ofGetWindowWidth(), (11.5/768.0)*ofGetWindowHeight(), 0); ofVec3f v4((1040.0/1280.0)*ofGetWindowWidth(), (76.0/768.0)*ofGetWindowHeight(), 0); rangeMarker2.setup(v3/*VEC3,rangeBound1*/, v4/*VEC3,rangeBound2*/, 10/*numIncrements*/, rangeMarker2Img/*img*/, (12.0/1680)*ofGetWidth()/*imgW*/, (8.0/1660)*ofGetWidth()/*imgH*/, rangeMarker2Color/*color*/, .005/*chanceToUpdate(0-1)*/); // Setup array of tickers in graph on right markerGraphImg.loadImage("RangeMarker_RectVert.png"); markerGraphColor.set(100, 102, 90); for(int i = 0; i < 15; i++){ HUDRangeMarker temp; ofVec3f v5((1168.5/1280.0)*ofGetWindowWidth()+((7.8/1680.0)*ofGetWidth())*(float)i, (300.0/768.0)*ofGetWindowHeight(), 0); ofVec3f v6((1168.5/1280.0)*ofGetWindowWidth()+((7.8/1680.0)*ofGetWidth())*(float)i, (322.0/768.0)*ofGetWindowHeight(), 0); temp.setup(v5/*VEC3,rangeBound1*/, v6/*VEC3,rangeBound2*/, 6/*numIncrements*/, markerGraphImg/*img*/, (3.0/1680)*ofGetWidth()/*imgW*/, (7.0/1680)*ofGetWidth()/*imgH*/, markerGraphColor/*color*/, 0.001*i /*chanceToUpdate(0-1)*/); markerGraph.push_back(temp); } singleBlink = false; doubleBlink = false; }
int main(int argc, char** argv) { CallbackContainer stubs; Consumer c1(Name("/q/w/e"), RDR); c1.setContextOption(MUST_BE_FRESH_S, true); //c1.setContextOption(FORWARDING_STRATEGY, BROADCAST); c1.setContextOption(INTEREST_LEAVE_CNTX, (ConsumerInterestCallback)bind(&CallbackContainer::processLeavingInterest, &stubs, _1, _2)); c1.setContextOption(DATA_ENTER_CNTX, (ConsumerDataCallback)bind(&CallbackContainer::processData, &stubs, _1, _2)); c1.setContextOption(CONTENT_RETRIEVED, (ConsumerContentCallback)bind(&CallbackContainer::processPayload, &stubs, _1, _2, _3)); Consumer c2(Name("/t/y/u"), RDR); c2.setContextOption(MUST_BE_FRESH_S, true); //c2.setContextOption(FORWARDING_STRATEGY, BROADCAST); c2.setContextOption(INTEREST_LEAVE_CNTX, (ConsumerInterestCallback)bind(&CallbackContainer::processLeavingInterest, &stubs, _1, _2)); c2.setContextOption(DATA_ENTER_CNTX, (ConsumerDataCallback)bind(&CallbackContainer::processData, &stubs, _1, _2)); c2.setContextOption(CONTENT_RETRIEVED, (ConsumerContentCallback)bind(&CallbackContainer::processPayload, &stubs, _1, _2, _3)); Consumer c3(Name("/a/s/d"), RDR); c3.setContextOption(MUST_BE_FRESH_S, true); //c3.setContextOption(FORWARDING_STRATEGY, BROADCAST); c3.setContextOption(INTEREST_LEAVE_CNTX, (ConsumerInterestCallback)bind(&CallbackContainer::processLeavingInterest, &stubs, _1, _2)); c3.setContextOption(DATA_ENTER_CNTX, (ConsumerDataCallback)bind(&CallbackContainer::processData, &stubs, _1, _2)); c3.setContextOption(CONTENT_RETRIEVED, (ConsumerContentCallback)bind(&CallbackContainer::processPayload, &stubs, _1, _2, _3)); Consumer c4(Name("/g/h/j"), RDR); c4.setContextOption(MUST_BE_FRESH_S, true); //c4.setContextOption(FORWARDING_STRATEGY, BROADCAST); c4.setContextOption(INTEREST_LEAVE_CNTX, (ConsumerInterestCallback)bind(&CallbackContainer::processLeavingInterest, &stubs, _1, _2)); c4.setContextOption(DATA_ENTER_CNTX, (ConsumerDataCallback)bind(&CallbackContainer::processData, &stubs, _1, _2)); c4.setContextOption(CONTENT_RETRIEVED, (ConsumerContentCallback)bind(&CallbackContainer::processPayload, &stubs, _1, _2, _3)); Consumer c5(Name("/b/n/m"), RDR); c5.setContextOption(MUST_BE_FRESH_S, true); //c5.setContextOption(FORWARDING_STRATEGY, BROADCAST); c5.setContextOption(INTEREST_LEAVE_CNTX, (ConsumerInterestCallback)bind(&CallbackContainer::processLeavingInterest, &stubs, _1, _2)); c5.setContextOption(DATA_ENTER_CNTX, (ConsumerDataCallback)bind(&CallbackContainer::processData, &stubs, _1, _2)); c5.setContextOption(CONTENT_RETRIEVED, (ConsumerContentCallback)bind(&CallbackContainer::processPayload, &stubs, _1, _2, _3)); c1.asyncConsume(Name()); c2.asyncConsume(Name()); c3.asyncConsume(Name()); c4.asyncConsume(Name()); c5.asyncConsume(Name()); Consumer::consumeAll(); // blocks until both contexts finish their work in parallel sleep(10); return 0; }