hrpUtil/OnlineViewerUtil.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  * General Robotix Inc.
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  */
10 #include "OnlineViewerUtil.h"
11 
12 //using namespace hrp;
13 using namespace OpenHRP;
14 
15 OnlineViewer_var hrp::getOnlineViewer(CosNaming::NamingContext_var cxt)
16 {
17  CosNaming::Name ncName;
18  ncName.length(1);
19  ncName[0].id = CORBA::string_dup("OnlineViewer");
20  ncName[0].kind = CORBA::string_dup("");
21  OnlineViewer_var onlineViewer = NULL;
22  try {
23  onlineViewer = OnlineViewer::_narrow(cxt->resolve(ncName));
24  } catch(const CosNaming::NamingContext::NotFound &exc) {
25  std::cerr << "OnlineViewer not found: ";
26  switch(exc.why) {
27  case CosNaming::NamingContext::missing_node:
28  std::cerr << "Missing Node" << std::endl;
29  case CosNaming::NamingContext::not_context:
30  std::cerr << "Not Context" << std::endl;
31  break;
32  case CosNaming::NamingContext::not_object:
33  std::cerr << "Not Object" << std::endl;
34  break;
35  }
36  return 0;
37  } catch(CosNaming::NamingContext::CannotProceed &exc) {
38  std::cerr << "Resolve OnlineViewer CannotProceed" << std::endl;
39  return 0;
40  } catch(CosNaming::NamingContext::AlreadyBound &exc) {
41  std::cerr << "Resolve OnlineViewer InvalidName" << std::endl;
42  return 0;
43  }
44  return onlineViewer;
45 }
46 
47 OnlineViewer_var hrp::getOnlineViewer(CORBA_ORB_var orb)
48 {
49  CosNaming::NamingContext_var cxt;
50  try {
51  CORBA::Object_var nS = orb->resolve_initial_references("NameService");
52  cxt = CosNaming::NamingContext::_narrow(nS);
53  } catch(CORBA::SystemException& ex) {
54  std::cerr << "NameService doesn't exist" << std::endl;
55  return 0;
56  }
57 
58  return getOnlineViewer(cxt);
59 }
60 
61 OnlineViewer_var hrp::getOnlineViewer(int argc, char **argv)
62 {
63  CORBA_ORB_var orb = CORBA::ORB_init(argc, argv);
64  return getOnlineViewer(orb);
65 }
NotFound
Definition: hrpPrep.py:129
#define CORBA_ORB_var
Definition: ORBwrap.h:17
HRP_UTIL_EXPORT OpenHRP::OnlineViewer_var getOnlineViewer(int argc, char **argv)


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:39