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 Project Download Mailing lists
|
icegridsession.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2009 Alex Brooks, Alex Makarenko 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 ORCAICEGRID_ICEGRID_SESSION_H 00012 #define ORCAICEGRID_ICEGRID_SESSION_H 00013 00014 #include <IceGrid/Registry.h> 00015 #include <gbxsickacfr/gbxiceutilacfr/safethread.h> 00016 #include <gbxsickacfr/gbxiceutilacfr/store.h> 00017 #include <orcaice/context.h> 00018 #include <IceUtil/Time.h> 00019 00020 namespace orcaicegrid 00021 { 00022 00024 class SessionNotConnectedException : public gbxutilacfr::Exception 00025 { 00026 public: 00027 SessionNotConnectedException(const char *file, const char *line, const char *message) 00028 : Exception( file, line, message ) {}; 00029 SessionNotConnectedException(const char *file, const char *line, const std::string &message) 00030 : Exception( file, line, message ) {}; 00031 }; 00032 00038 class IceGridSession : public gbxiceutilacfr::SafeThread 00039 { 00040 public: 00046 IceGridSession( const orcaice::Context& context, 00047 const IceGrid::RegistryObserverPrx& reg =IceGrid::RegistryObserverPrx(), 00048 const IceGrid::NodeObserverPrx& node=IceGrid::NodeObserverPrx(), 00049 const IceGrid::ApplicationObserverPrx& app=IceGrid::ApplicationObserverPrx(), 00050 const IceGrid::AdapterObserverPrx& adpt=IceGrid::AdapterObserverPrx(), 00051 const IceGrid::ObjectObserverPrx& obj=IceGrid::ObjectObserverPrx() ); 00052 00053 ~IceGridSession() {}; 00054 00056 enum SessionState 00057 { 00059 Disconnected, 00061 Connecting, 00063 Connected, 00065 Disconnecting 00066 }; 00067 00069 SessionState getState(); 00070 00077 void setObservers( 00078 const IceGrid::RegistryObserverPrx& reg =IceGrid::RegistryObserverPrx(), 00079 const IceGrid::NodeObserverPrx& node=IceGrid::NodeObserverPrx(), 00080 const IceGrid::ApplicationObserverPrx& app=IceGrid::ApplicationObserverPrx(), 00081 const IceGrid::AdapterObserverPrx& adpt=IceGrid::AdapterObserverPrx(), 00082 const IceGrid::ObjectObserverPrx& obj=IceGrid::ObjectObserverPrx() ); 00083 00086 virtual bool connectedEvent() { return true; }; 00087 00090 virtual void disconnectedEvent() {}; 00091 00092 // from SafeThread 00093 virtual void walk(); 00094 00095 static std::string toString( SessionState state ); 00096 00097 protected: 00098 IceGrid::AdminSessionPrx session_; 00099 // IceUtil::Mutex sessionMutex_; 00100 00101 bool tryCreateSession(); 00102 00103 private: 00104 00105 gbxiceutilacfr::Store<SessionState> stateStore_; 00106 int timeoutSec_; 00107 IceUtil::Time lastKeepaliveTime_; 00108 00109 IceGrid::RegistryObserverPrx registryObserverPrx_; 00110 IceGrid::NodeObserverPrx nodeObserverPrx_; 00111 IceGrid::ApplicationObserverPrx applicationObserverPrx_; 00112 IceGrid::AdapterObserverPrx adapterObserverPrx_; 00113 IceGrid::ObjectObserverPrx objectObserverPrx_; 00114 00115 // this actually tries to set observers as defined by member variables 00116 // if the session is not Connected, does nothing 00117 void trySetObservers(); 00118 IceUtil::Mutex observerMutex_; 00119 00120 orcaice::Context context_; 00121 }; 00122 00123 } // namespace 00124 00125 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)