MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / SyncServer_i

Method SyncServer_i

performance-tests/DCPS/Sync/SyncServer_i.cpp:11–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include <fstream>
10
11SyncServer_i::SyncServer_i (size_t pub_count, size_t sub_count
12 , CORBA::ORB_ptr orb, bool write_ior)
13 : count_ (0), pub_count_(pub_count), sub_count_(sub_count)
14 , shutdown_ (false), ior_file_("sync.ior")
15{
16 try
17 {
18 // Get an ORB
19 if (CORBA::is_nil (orb))
20 {
21 // create new ORB
22 int argc = 0;
23 //ACE_TCHAR* argv[] = {"-ORBEndpoint", "iiop://localhost:12345"};
24 orb_ = CORBA::ORB_init (argc, (ACE_TCHAR **)0, "SyncServer");
25 if (CORBA::is_nil (orb_.in())) {
26 throw InitError ("SyncServer_i::ctr> Orb init failed.");
27 }
28 }
29 else {
30 orb_ = CORBA::ORB::_duplicate (orb);
31 }
32
33 CORBA::Object_var poaObj = orb_->resolve_initial_references ("RootPOA");
34 root_poa_ = PortableServer::POA::_narrow (poaObj.in ());
35
36 poa_manager_ = root_poa_->the_POAManager ();
37 poa_manager_->activate ();
38
39 PortableServer::ObjectId_var oid = root_poa_->activate_object (this);
40 CORBA::Object_var obj = root_poa_->id_to_reference (oid);
41 ::Sync::Server_var sync_server_obj = Sync::Server::_narrow (obj.in());
42
43 CORBA::String_var ior = orb_->object_to_string (sync_server_obj.in ());
44 CORBA::Object_var table_obj =
45 orb_->resolve_initial_references("IORTable");
46 table_ = IORTable::Table::_narrow(table_obj.in());
47 table_->bind ("SyncServer", ior.in());
48
49 // activate task
50 if (this->activate (THR_NEW_LWP | THR_JOINABLE |THR_INHERIT_SCHED
51 , 1) != 0) {
52 throw InitError ("SyncServer_i::ctr> Task activation failed.");
53 }
54
55 if (write_ior) {
56 std::ofstream ior_stream (ior_file_.c_str());
57 if (!ior_stream) {
58 throw InitError ("SyncServer_i::ctr> Unable to open IOR file.");
59 }
60 ior_stream << ior.in() << std::endl;
61 }
62 }
63 catch (const CORBA::SystemException& ex)
64 {
65 throw InitError (ex._info().c_str());
66 }
67}
68

Callers

nothing calls this directly

Calls 5

activateMethod · 0.80
object_to_stringMethod · 0.80
_infoMethod · 0.80
inMethod · 0.45
bindMethod · 0.45

Tested by

no test coverage detected