Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Smart_Proxies / Collocation / Coll_Tester.cpp
blob93e35c3630859052b4be24119ac0a14c9fed2573
1 //============================================================================
2 //
3 // =FILENAME
4 // Collocation_Test.h
5 //
6 // =DESCRIPTION
7 // Server class to perform testing of TAO's collocation mechanism.
8 //
9 // =AUTHOR
10 // Nanbor Wang
12 //=============================================================================
14 #include "Coll_Tester.h"
15 #include "Smart_Proxy_Impl.h"
17 Collocation_Test::Collocation_Test ()
21 int
22 Collocation_Test::init (int argc, ACE_TCHAR *argv[])
24 // Initialize the ORB.
25 this->orb_ = CORBA::ORB_init (argc, argv);
27 int result = this->parse_args (argc, argv);
28 if (result != 0)
29 return result;
31 // Get an Object reference to RootPOA.
32 CORBA::Object_var obj =
33 this->orb_->resolve_initial_references ("RootPOA");
35 // Narrow the Object reference to a POA reference
36 this->root_poa_ =
37 PortableServer::POA::_narrow (obj.in ());
39 // Get the POAManager of RootPOA
40 this->poa_manager_ =
41 this->root_poa_->the_POAManager ();
43 // Activate the diamond servant and its base classes under RootPOA.
44 PortableServer::ObjectId_var id =
45 this->root_poa_->activate_object (&this->top_servant_);
47 // // We only care about the most derived class here.
48 // this->diamond_obj_ = this->diamond_servant_._this ();
50 id =
51 this->root_poa_->activate_object (&this->diamond_servant_);
53 // We only care about the most derived class here.
54 this->diamond_obj_ = this->root_poa_->id_to_reference (id.in ());
56 id =
57 this->root_poa_->activate_object (&this->left_servant_);
59 id =
60 this->root_poa_->activate_object (&this->right_servant_);
62 CORBA::String_var str =
63 this->orb_->object_to_string (this->diamond_obj_.in ());
65 ACE_DEBUG ((LM_DEBUG, "Diamond Servant activated:\n %s\n",
66 str.in()));
68 return 0;
72 int
73 Collocation_Test::parse_args (int, ACE_TCHAR *[])
75 return 0;
78 int
79 Collocation_Test::test_narrow ()
81 // Ensure that the smart proxy is the one which is used by registering
82 // the user-defined factory. Its necessary to create one on the heap so
83 // the lifetime of the factory object can be managed by the framework.
84 Smart_Diamond_Top_Factory *factory = 0;
85 ACE_NEW_RETURN (factory,
86 Smart_Diamond_Top_Factory,
87 -1);
89 Diamond::Top_var top =
90 Diamond::Top::_narrow (this->diamond_obj_.in());
92 Diamond::Left_var left =
93 Diamond::Left::_narrow (this->diamond_obj_.in());
95 Diamond::Right_var right =
96 Diamond::Right::_narrow (this->diamond_obj_.in());
98 Diamond::Buttom_var buttom =
99 Diamond::Buttom::_narrow (this->diamond_obj_.in());
101 CORBA::String_var str = top->shape ();
102 ACE_DEBUG ((LM_DEBUG, "Calling top->shape: %s\n", str.in ()));
104 str = left->shape ();
105 ACE_DEBUG ((LM_DEBUG, "Calling left->shape: %s\n", str.in ()));
107 str = right->shape ();
108 ACE_DEBUG ((LM_DEBUG, "Calling right->shape: %s\n", str.in ()));
110 str = buttom->shape ();
111 ACE_DEBUG ((LM_DEBUG, "Calling buttom->shape: %s\n", str.in ()));
113 return 0;
117 Collocation_Test::run ()
119 this->poa_manager_->activate ();
121 this->test_narrow ();
123 return 0;