OnlineViewerUtil.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  * General Robotix Inc.
00008  * National Institute of Advanced Industrial Science and Technology (AIST) 
00009  */
00010 #include "OnlineViewerUtil.h"
00011 
00012 //using namespace hrp;
00013 using namespace OpenHRP;
00014 
00015 OnlineViewer_var hrp::getOnlineViewer(CosNaming::NamingContext_var cxt)
00016 {  
00017     CosNaming::Name ncName;
00018     ncName.length(1);
00019     ncName[0].id = CORBA::string_dup("OnlineViewer");
00020     ncName[0].kind = CORBA::string_dup("");
00021     OnlineViewer_var onlineViewer = NULL;
00022     try {
00023         onlineViewer = OnlineViewer::_narrow(cxt->resolve(ncName));
00024     } catch(const CosNaming::NamingContext::NotFound &exc) {
00025         std::cerr << "OnlineViewer not found: ";
00026         switch(exc.why) {
00027         case CosNaming::NamingContext::missing_node:
00028             std::cerr << "Missing Node" << std::endl;
00029         case CosNaming::NamingContext::not_context:
00030             std::cerr << "Not Context" << std::endl;
00031             break;
00032         case CosNaming::NamingContext::not_object:
00033             std::cerr << "Not Object" << std::endl;
00034             break;
00035         }
00036         return 0;
00037     } catch(CosNaming::NamingContext::CannotProceed &exc) {
00038         std::cerr << "Resolve OnlineViewer CannotProceed" << std::endl;
00039         return 0;
00040     } catch(CosNaming::NamingContext::AlreadyBound &exc) {
00041         std::cerr << "Resolve OnlineViewer InvalidName" << std::endl;
00042         return 0;
00043     }
00044     return onlineViewer;
00045 }
00046 
00047 OnlineViewer_var hrp::getOnlineViewer(CORBA_ORB_var orb)
00048 {
00049     CosNaming::NamingContext_var cxt;
00050     try {
00051         CORBA::Object_var nS = orb->resolve_initial_references("NameService");
00052         cxt = CosNaming::NamingContext::_narrow(nS);
00053     } catch(CORBA::SystemException& ex) {
00054         std::cerr << "NameService doesn't exist" << std::endl;
00055         return 0;
00056     }
00057 
00058     return getOnlineViewer(cxt);
00059 }
00060 
00061 OnlineViewer_var hrp::getOnlineViewer(int argc, char **argv)
00062 {
00063     CORBA_ORB_var orb = CORBA::ORB_init(argc, argv);
00064     return getOnlineViewer(orb);
00065 }


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