server.cpp
Go to the documentation of this file.
00001 
00002 #include "ModelLoader_impl.h"
00003 
00004 #ifdef _WIN32
00005 #include "winbase.h"
00006 #else
00007 #include <unistd.h>
00008 #endif /* _WIN32 */
00009 
00010 #include <iostream>
00011 
00012 using namespace std;
00013 
00014 
00015 int main(int argc, char* argv[])
00016 {
00017     
00018     CORBA::ORB_var orb = CORBA::ORB::_nil();
00019   
00020     try {
00021 
00022         orb = CORBA::ORB_init(argc, argv);
00023         
00024         CORBA::Object_var obj;
00025         
00026         obj = orb->resolve_initial_references("RootPOA");
00027         PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
00028         if(CORBA::is_nil(poa)){
00029             throw string("error: failed to narrow root POA.");
00030         }
00031         
00032         PortableServer::POAManager_var poaManager = poa->the_POAManager();
00033         if(CORBA::is_nil(poaManager)){
00034             throw string("error: failed to narrow root POA manager.");
00035         }
00036         
00037         ModelLoader_impl* modelLoaderImpl = new ModelLoader_impl(orb, poa);
00038         poa->activate_object(modelLoaderImpl);
00039         ModelLoader_var modelLoader = modelLoaderImpl->_this();
00040         modelLoaderImpl->_remove_ref();
00041 
00042         obj = orb->resolve_initial_references("NameService");
00043         CosNaming::NamingContext_var namingContext = CosNaming::NamingContext::_narrow(obj);
00044         if(CORBA::is_nil(namingContext)){
00045             throw string("error: failed to narrow naming context.");
00046         }
00047         
00048         CosNaming::Name name;
00049         name.length(1);
00050         name[0].id = CORBA::string_dup("ModelLoader");
00051         name[0].kind = CORBA::string_dup("");
00052         namingContext->rebind(name, modelLoader);
00053 
00054         poaManager->activate();
00055         
00056         cout << "ready" << endl;
00057 
00058         orb->run();
00059 
00060     }
00061     catch (CORBA::SystemException& ex) {
00062         cerr << ex._rep_id() << endl;
00063     }
00064     catch (const string& error){
00065         cerr << error << endl;
00066     }
00067 
00068     try {
00069         orb->destroy();
00070     }
00071     catch(...){
00072 
00073     }
00074     
00075     return 0;
00076 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:19