server.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * The University of Tokyo
00008  * National Institute of Advanced Industrial Science and Technology (AIST)
00009  * General Robotix Inc. 
00010  */
00018 #include "DynamicsSimulator_impl.h"
00019 
00020 #ifdef _WIN32
00021 #include "winbase.h"
00022 #else
00023 #include <unistd.h>
00024 #endif /* _WIN32 */
00025 
00026 #include <iostream>
00027 
00028 using namespace std;
00029 using namespace OpenHRP;
00030 
00031 
00039 int main(int argc, char* argv[])
00040 {
00041   CORBA::ORB_var orb;
00042   try {
00043     orb = CORBA::ORB_init(argc, argv);
00044     //
00045     // Resolve Root POA
00046     //
00047     CORBA::Object_var poaObj = orb -> resolve_initial_references("RootPOA");
00048     PortableServer::POA_var rootPOA = PortableServer::POA::_narrow(poaObj);
00049 
00050     //
00051     // Get a reference to the POA manager
00052     //
00053     PortableServer::POAManager_var manager = rootPOA -> the_POAManager();
00054 
00055     CosNaming::NamingContext_var cxT;
00056     CORBA::Object_var   nS = orb->resolve_initial_references("NameService");
00057     cxT = CosNaming::NamingContext::_narrow(nS);
00058 
00059     CORBA::Object_var integratorFactory;
00060     DynamicsSimulatorFactory_impl* integratorFactoryImpl = new DynamicsSimulatorFactory_impl(orb);
00061     integratorFactory = integratorFactoryImpl -> _this();
00062     CosNaming::Name nc;
00063     nc.length(1);
00064     nc[0].id = CORBA::string_dup("DynamicsSimulatorFactory");
00065     nc[0].kind = CORBA::string_dup("");
00066     cxT -> rebind(nc, integratorFactory);
00067 
00068     // クライアント側からの接続待ち //
00069     manager -> activate();
00070     cout << "ready" << endl;
00071 
00072     orb -> run();
00073   } catch (CORBA::SystemException& ex) {
00074     cerr << ex._rep_id() << endl;
00075     return 1;
00076   }
00077   orb->destroy();
00078   return 0;
00079 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:57