Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / OBV / Indirection / MessengerClient.cpp
blob78b97b1efd804a6ed1eeb12aeb24ac0b90cf8d7e
1 #include "MessengerC.h"
2 #include "Factory.h"
3 #include <iostream>
5 const char* server_ior = "file://server.ior";
6 using namespace demo::value::idl;
7 const char* IOR = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
9 int ACE_TMAIN (int ac, ACE_TCHAR* av[]) {
10 try {
11 CORBA::ORB_var orb = CORBA::ORB_init(ac, av);
13 NodeFactory::register_new_factory(* orb.in());
14 BoxedValueFactory::register_new_factory(* orb.in());
15 BaseValueFactory::register_new_factory(* orb.in());
16 TValueFactory::register_new_factory(* orb.in());
17 ConfigValueFactory::register_new_factory(* orb.in());
19 CORBA::Object_var obj = orb->string_to_object(server_ior);
20 ValueServer_var tst = ValueServer::_narrow(obj.in());
21 ACE_ASSERT(! CORBA::is_nil(tst.in()));
23 // invoke operations and print the results
24 boxedLong* p1 = new boxedLong (774);
25 boxedLong* p2 = new boxedLong (775);
26 boxedString* s1 = new boxedString ("hello");
27 boxedString* s2 = new boxedString ("world");
28 boxedString* null = 0;
29 boxedValue* b = new OBV_demo::value::idl::boxedValue ();
30 b->b1 (p1);
31 b->b2 (p2);
32 boxedValue* bb = new OBV_demo::value::idl::boxedValue ();
33 bb->b1 (p1);
34 bb->b2 (p1);
36 ACE_DEBUG ((LM_DEBUG, "(%P|%t)Passing two boxed values in one valuetype: %s\n",
37 tst->receive_boxedvalue (b)));
38 ACE_DEBUG ((LM_DEBUG, "(%P|%t)Passing one boxed values twice in one valuetype: %s\n",
39 tst->receive_boxedvalue (bb)));
40 ACE_DEBUG ((LM_DEBUG, "(%P|%t)Passing two integers: %s\n",
41 tst->receive_long (p1, p2)));
42 ACE_DEBUG ((LM_DEBUG, "(%P|%t)Passing one integer twice: %s\n",
43 tst->receive_long (p1, p1)));
44 ACE_DEBUG ((LM_DEBUG, "(%P|%t)Passing two strings: %s\n",
45 tst->receive_string (s1, s2)));
46 ACE_DEBUG ((LM_DEBUG, "(%P|%t)Passing null: %s\n",
47 tst->receive_string (s1, null)));
49 Node* n4 = new OBV_demo::value::idl::Node (4, 0);
50 Node* n3 = new OBV_demo::value::idl::Node (3, n4);
51 Node* n2 = new OBV_demo::value::idl::Node (2, n3);
52 Node* n1 = new OBV_demo::value::idl::Node (1, n2);
54 n4->next(n1);
56 ACE_DEBUG ((LM_DEBUG, "(%P|%t)Passing a list structure: %s\n",
57 tst->receive_list (n1)));
59 #if 1
60 TValue* t = new OBV_demo::value::idl::TValue ();
61 t->data (20);
62 t->basic_data (10);
64 ACE_DEBUG ((LM_DEBUG, "(%P|%t)Passing inout truncatable: %s\n",
65 tst->receive_truncatable (t)));
66 if (t->data () != 21 || t->basic_data () != 11)
68 std::cerr << "Received incorrect truncatable data" << std::endl;
69 return 1;
71 #endif
73 const CORBA::ULong sz = 50;
74 ::demo::value::idl::ConfigValues configs (sz);
75 configs.length (sz);
76 for (CORBA::ULong i = 0; i < sz; ++i)
78 configs[i] = new ConfigValueImpl ("IOR", IOR);
81 ACE_DEBUG ((LM_DEBUG, "(%P|%t)Passing sequence: %s\n",
82 tst->receive_sequence (configs)));
84 while (orb->work_pending()) {
85 orb->perform_work();
88 orb->destroy();
89 } catch(const CORBA::Exception& e) {
90 std::cerr << e << std::endl;
91 return 1;
94 return 0;