ModelLoader/server.cpp
Go to the documentation of this file.
1 
2 #include "ModelLoader_impl.h"
3 
4 #ifdef _WIN32
5 #include "winbase.h"
6 #else
7 #include <unistd.h>
8 #endif /* _WIN32 */
9 
10 #include <iostream>
11 
12 using namespace std;
13 
14 
15 int main(int argc, char* argv[])
16 {
17 
18  CORBA::ORB_var orb = CORBA::ORB::_nil();
19 
20  try {
21 
22  orb = CORBA::ORB_init(argc, argv);
23 
24  CORBA::Object_var obj;
25 
26  obj = orb->resolve_initial_references("RootPOA");
27  PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
28  if(CORBA::is_nil(poa)){
29  throw string("error: failed to narrow root POA.");
30  }
31 
32  PortableServer::POAManager_var poaManager = poa->the_POAManager();
33  if(CORBA::is_nil(poaManager)){
34  throw string("error: failed to narrow root POA manager.");
35  }
36 
37  ModelLoader_impl* modelLoaderImpl = new ModelLoader_impl(orb, poa);
38  poa->activate_object(modelLoaderImpl);
39  ModelLoader_var modelLoader = modelLoaderImpl->_this();
40  modelLoaderImpl->_remove_ref();
41 
42  obj = orb->resolve_initial_references("NameService");
43  CosNaming::NamingContext_var namingContext = CosNaming::NamingContext::_narrow(obj);
44  if(CORBA::is_nil(namingContext)){
45  throw string("error: failed to narrow naming context.");
46  }
47 
48  CosNaming::Name name;
49  name.length(1);
50  name[0].id = CORBA::string_dup("ModelLoader");
51  name[0].kind = CORBA::string_dup("");
52  namingContext->rebind(name, modelLoader);
53 
54  poaManager->activate();
55 
56  cout << "ready" << endl;
57 
58  orb->run();
59 
60  }
61  catch (CORBA::SystemException& ex) {
62  cerr << ex._rep_id() << endl;
63  }
64  catch (const string& error){
65  cerr << error << endl;
66  }
67 
68  try {
69  orb->destroy();
70  }
71  catch(...){
72 
73  }
74 
75  return 0;
76 }
png_infop png_charpp name
Definition: png.h:2382
int main(int argc, char *argv[])
void error(char *msg) const
Definition: minigzip.c:87


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:41