Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Portable_Interceptors / Slot / driver.cpp
blobd2d70067138348d9d7ec74366995970622521e67
1 // author : Boris Kolpackov <boris@kolpackov.net>
2 #include "tao/PI/PI.h"
3 #include "tao/LocalObject.h"
4 #include "tao/ORBInitializer_Registry.h"
6 PortableInterceptor::SlotId slot_id;
8 class ORB_Initializer : public virtual PortableInterceptor::ORBInitializer,
9 public virtual ::CORBA::LocalObject
11 public:
12 virtual void
13 pre_init (PortableInterceptor::ORBInitInfo_ptr)
17 virtual void
18 post_init (PortableInterceptor::ORBInitInfo_ptr info)
20 slot_id = info->allocate_slot_id ();
21 ACE_DEBUG ((LM_DEBUG, "Allocated slot with id %d.\n", slot_id));
25 int
26 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
28 try
30 PortableInterceptor::ORBInitializer_var orb_initializer = new ORB_Initializer ();
31 PortableInterceptor::register_orb_initializer (orb_initializer.in ());
33 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
35 CORBA::Object_var pic_obj = orb->resolve_initial_references ("PICurrent");
36 PortableInterceptor::Current_var pic (
37 PortableInterceptor::Current::_narrow (pic_obj.in ()));
39 CORBA::Any in;
40 in <<= CORBA::ULong (1);
41 pic->set_slot (slot_id, in);
43 CORBA::ULong v (0);
44 CORBA::Any_var out = pic->get_slot (slot_id);
45 out >>= v;
47 if (v != 1)
49 ACE_ERROR ((LM_ERROR, "ERROR: Slot value was not preserved.\n"));
50 return 1;
53 orb->destroy ();
55 catch (PortableInterceptor::InvalidSlot const&)
57 ACE_ERROR ((LM_ERROR, "ERROR: Caught InvalidSlot exception.\n"));
58 return 1;
60 catch (const CORBA::Exception& ex)
62 ex._tao_print_exception ("Exception caught:");
63 return 1;
66 return 0;