Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "OnlineViewerUtil.h"
00011
00012
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 }