CollisionDetector/server.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * National Institute of Advanced Industrial Science and Technology (AIST)
8  * General Robotix Inc.
9  */
16 #include "CollisionDetector_impl.h"
17 
18 #ifdef _WIN32
19 #include "winbase.h"
20 #else
21 #include <unistd.h>
22 #endif /* _WIN32 */
23 
24 #include <iostream>
25 
26 using namespace std;
27 
35 int main(int argc, char* argv[]) {
36  CORBA::ORB_var orb;
37  try {
38  orb = CORBA::ORB_init(argc, argv);
39  //
40  // Resolve Root POA
41  //
42  CORBA::Object_var poaObj = orb -> resolve_initial_references("RootPOA");
43  PortableServer::POA_var rootPOA = PortableServer::POA::_narrow(poaObj);
44 
45  //
46  // Get a reference to the POA manager
47  //
48  PortableServer::POAManager_var manager = rootPOA -> the_POAManager();
49 
50  // ネームサーバへの参照取得 //
52  try {
53  ns = orb -> resolve_initial_references("NameService");
54  } catch (const CORBA_ORB::InvalidName&) {
55  cerr << argv[0] << ": can't resolve `NameService'" << endl;
56  return 1;
57  }
58  if(CORBA_is_nil(ns)) {
59  cerr << argv[0]
60  << ": `NameService' is a nil object reference"
61  << endl;
62  return 1;
63  }
64 
65  // ルートネーミングコンテキスト取得 //
66  CosNaming_NamingContext_var rootnc = CosNaming_NamingContext::_narrow(ns);
67  if(CORBA_is_nil(rootnc)) {
68  cerr << argv[0]
69  << ": `NameService' is not a NamingContext object reference"
70  << endl;
71  return 1;
72  }
73 
74  CORBA_Object_var cdFactory;
76  cdFactory = cdFactoryImpl -> _this();
77  CosNaming_Name nc;
78  nc.length(1);
79  nc[0].id = CORBA_string_dup("CollisionDetectorFactory");
80  nc[0].kind = CORBA_string_dup("");
81  rootnc -> rebind(nc, cdFactory);
82 
83  // クライアント側からの接続待ち //
84  manager -> activate();
85  cout << "ready" << endl;
86 
87  orb -> run();
88  } catch (CORBA_SystemException& ex) {
89  cerr << ex._rep_id() << endl;
90  orb->destroy();
91  return 1;
92  }
93  orb->destroy();
94  return 0;
95 }
rootnc
Definition: hrp.py:10
int main(int argc, char *argv[])
#define CORBA_SystemException
Definition: ORBwrap.h:30
ns
manager
#define CORBA_string_dup
Definition: ORBwrap.h:29
def run(tree, args)
#define CORBA_Object_var
Definition: ORBwrap.h:14
#define CosNaming_NamingContext_var
Definition: ORBwrap.h:27
#define CORBA_is_nil
Definition: ORBwrap.h:18
#define CosNaming_Name
Definition: ORBwrap.h:28


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat Apr 13 2019 02:14:25