INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

NONFRAMEWORK CODE
Driver Interfaces
Drivers
Libraries
Utilities

FRAMEWORK CODE
Interfaces
Components
Libraries
Utilities

Full Software Listings

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

icegridutils.h

00001 /*
00002  * Orca-Robotics Project: Components for robotics
00003  *               http://orca-robotics.sf.net/
00004  * Copyright (c) 2004-2009 Alex Brooks, Alexei Makarenko, Tobias Kaupp
00005  *
00006  * This copy of Orca is licensed to you under the terms described in
00007  * the LICENSE file included in this distribution.
00008  *
00009  */
00010 
00011 #ifndef ORCAICE_ICEGRID_UTILITIES_H
00012 #define ORCAICE_ICEGRID_UTILITIES_H
00013 
00014 #include <IceGrid/Query.h>
00015 
00016 #include <orcaice/context.h>
00017 #include <orcaice/configutils.h>
00018 #include <orcaice/exceptions.h>
00019 // #include <orcaice/stringutils.h>  // just for debugging
00020 #include <orcaice/printutils.h>
00021 
00022 namespace orcaice
00023 {
00028 
00033 bool isRegistryReachable( const Context& context );
00034 
00037 IceGrid::QueryPrx getDefaultQuery( const orcaice::Context& context );
00038 
00040 Ice::Identity toAdminIdentity( const orca::FQComponentName& );
00041 
00047 orca::FQComponentName toComponentName( const Ice::Identity& adminId );
00048 
00050 orca::FQComponentName toComponentName( const Ice::ObjectPrx& homePrx );
00051 
00058 Ice::ObjectPrx getComponentAdmin( const orcaice::Context& context, const orca::FQComponentName& fqName );
00059 
00063 Ice::ObjectProxySeq getAllComponentAdmins( const orcaice::Context& context );
00064 
00081 std::string toAdminFacet( const orca::FQComponentName& fqName, const std::string& interfaceType );
00082 
00096 bool isAdminInterfaceReachable( const Context& context, const orca::FQComponentName& fqName, const std::string& interfaceType,
00097                            std::string& diagnostic );
00098 
00117 void createAdminInterface( const Context& context, Ice::ObjectPtr& object, const orca::FQComponentName& fqname );
00118 
00146 // template<class InterfaceProxyType>
00147 // void connectToAdminInterfaceWithFacet( const Context& context, InterfaceProxyType interfacePrx, const std::string& facet,
00148 template<class InterfaceType, class InterfaceProxyType>
00149 void connectToAdminInterface( const Context& context, InterfaceProxyType& interfacePrx, const orca::FQComponentName& fqname )
00150 {
00151     orca::FQComponentName resolvedFqname = orcaice::resolveLocalPlatform( context, fqname );
00152 
00153 // std::cout<<"DEBUG: "<<__func__<<"(): will look for Admin interface of ="<<orcaice::toString(resolvedFqname)<<std::endl;
00154 
00155     const std::string interfaceType = InterfaceType::ice_staticId();
00156     const std::string facetName = orcaice::toAdminFacet( resolvedFqname, interfaceType );
00157 
00158 // std::cout<<"DEBUG: "<<__func__<<"(): will connect to facet="<<facetName<<std::endl;
00159 
00160     //
00161     // This is the generic proxy to the Admin object. Cannot be used as such because it does not have a default facet.
00162     //
00163     Ice::ObjectPrx objectPrx = orcaice::getComponentAdmin( context, resolvedFqname );
00164 
00165     if ( !objectPrx )
00166         throw gbxutilacfr::Exception( ERROR_INFO,
00167             "Registry returned null admin proxy for component "+resolvedFqname.platform+"/"+resolvedFqname.component );
00168 
00169 // std::cout<<"DEBUG: "<<__func__<<"(): got admin proxy ="<<objectPrx->ice_toString()<<std::endl;
00170 
00171     //
00172     // Change proxy to the user-supplied facet name.
00173     //
00174     objectPrx = objectPrx->ice_facet( facetName );
00175 
00176     // check with the server that the one we found is of the right type
00177     // the check operation is remote and may fail (see sec.6.11.2)
00178     try {
00179         interfacePrx = InterfaceProxyType::checkedCast( objectPrx );
00180         // got some answer, check that it's the right type
00181         if ( !interfacePrx ) {
00182             // contains another remote call ice_id() !!!
00183             std::string errString = "Admin interface with facet '" + facetName + "' is of wrong type."+
00184                 "  Tried to connect proxy of type "+InterfaceType::ice_staticId()+
00185                 " to remote interface of type "+objectPrx->ice_id();
00186             orcaice::initTracerWarning( context, errString );
00187             throw orcaice::TypeMismatchException( ERROR_INFO, errString );
00188         }
00189     }
00190     catch ( const Ice::ConnectionRefusedException& e )
00191     {
00192         std::stringstream ss;
00193         ss << "(while connecting to Admin interface with facet '" << facetName << "') cannot reach the adaptor: "<<e.what();
00194         orcaice::initTracerWarning( context, ss.str() );
00195         throw orcaice::NetworkException( ERROR_INFO, ss.str() );
00196     }
00197     catch ( const Ice::ObjectNotExistException& e )
00198     {
00199         std::stringstream ss;
00200         ss << "(while connecting to Admin interface with facet '" << facetName << "') reached the adaptor but not the interface: "<<e.what();
00201         orcaice::initTracerWarning( context, ss.str() );
00202         throw orcaice::NetworkException( ERROR_INFO, ss.str() );
00203     }
00204     catch ( const Ice::FacetNotExistException& e )
00205     {
00206         std::stringstream ss;
00207         ss << "(while connecting to Admin interface with facet '" << facetName << "') reached the adaptor and the interface but not the facet: "<<e.what();
00208         orcaice::initTracerWarning( context, ss.str() );
00209         throw orcaice::NetworkException( ERROR_INFO, ss.str() );
00210     }
00211     catch ( const std::exception& e )
00212     {
00213         std::stringstream ss;
00214         ss << "(while connecting to Admin interface with facet '" << facetName << "') something unexpected: "<<e.what();
00215         orcaice::initTracerWarning( context, ss.str() );
00216         throw orcaice::NetworkException( ERROR_INFO, ss.str() );
00217     }
00218 }
00219 
00221 
00222 } // namespace
00223 
00224 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5