Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / examples / RTScheduling / Starter.cpp
bloba072dbc2b4e392c70e0c8862abe780137496ca27
1 #include "Starter.h"
3 #include "ace/OS_NS_sys_time.h"
5 Starter::Starter (CORBA::ORB_ptr orb)
7 // Initialize the naming service
8 if (this->naming_client_.init (orb) != 0)
9 ACE_ERROR ((LM_ERROR,
10 " (%P|%t) Unable to initialize "
11 "the TAO_Naming_Client.\n"));
14 void
15 Starter::init ()
17 this->resolve_synch_objs ();
19 this->fire ();
22 void
23 Starter::fire ()
25 ACE_Time_Value base_time = ACE_OS::gettimeofday ();
26 for (Synchs::iterator iterator = this->synchs_.begin ();
27 iterator != this->synchs_.end ();
28 ++iterator)
30 (*iterator).int_id_.in ()->go (static_cast<CORBA::Long> (base_time.sec ()));
34 void
35 Starter::resolve_synch_objs ()
37 CosNaming::Name name (1);
38 name.length (1);
40 // Get the sender context.
41 name [0].id =
42 CORBA::string_dup ("Synch");
44 CORBA::Object_var object =
45 this->naming_client_->resolve (name);
47 this->synch_context_ =
48 CosNaming::NamingContext::_narrow (object.in ());
51 CosNaming::BindingIterator_var iterator;
52 CosNaming::BindingList_var binding_list;
53 const CORBA::ULong chunk = 100;
55 // Get the list of synchs registered for this sender.
56 this->synch_context_->list (chunk,
57 binding_list,
58 iterator);
60 // Add the receivers found in the bindinglist to the <receivers>.
61 this->add_to_synchs (binding_list);
63 if (!CORBA::is_nil (iterator.in ()))
65 CORBA::Boolean more = 1;
67 // Check to see if there are more receivers listed.
68 while (more)
70 more = iterator->next_n (chunk,
71 binding_list);
73 this->add_to_synchs (binding_list);
80 void
81 Starter::add_to_synchs (CosNaming::BindingList &binding_list)
83 ACE_Time_Value base_time = ACE_OS::gettimeofday ();
84 for (CORBA::ULong i = 0;
85 i < binding_list.length ();
86 i++)
88 // Get the receiver name from the binding list.
89 ACE_CString synch_name =
90 binding_list [i].binding_name [0].id.in ();
92 ACE_DEBUG ((LM_DEBUG,
93 "Synch Name %C\n",
94 synch_name.c_str ()));
96 CosNaming::Name name (1);
97 name.length (1);
98 name [0].id =
99 CORBA::string_dup (synch_name.c_str ());
101 // Resolve the reference of the receiver from the receiver
102 // context.
103 CORBA::Object_var obj =
104 this->synch_context_->resolve (name);
106 Synch_var synch_obj =
107 Synch::_narrow (obj.in ());
110 synch_obj->go (static_cast<CORBA::Long> (base_time.sec ()));
112 // // Add this receiver to the receiver map.
113 // this->synchs_.bind (synch_name,
114 // synch_obj);
120 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
124 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
126 Starter starter (orb.in ());
128 starter.init ();
130 catch (const CORBA::Exception& ex)
132 ex._tao_print_exception ("Caught exception:");
133 return 1;
135 return 0;