9 #ifndef CARMA_REMOTE_OBJ_HANDLE_T_H
10 #define CARMA_REMOTE_OBJ_HANDLE_T_H
14 #include "carma/corba/corba.h"
15 #include "carma/corba/Client.h"
16 #include "carma/util/Program.h"
24 class MonitorPointBool;
25 class MonitorSubsystem;
34 template <
typename T >
35 class RemoteObjMethodFunctorBase;
64 const ::std::string &
doName,
68 bool defaultLogIfNotReachable,
69 bool defaultLogSentCommands );
75 ::std::string
doName( )
const;
98 bool getDefaultLogIfNotReachable( )
const;
100 bool getDefaultLogSentCommands( )
const;
102 void markObjRefValid( );
103 void invalidateObjRef( );
105 void throwIfObjRefIsNotValid( )
const;
107 virtual bool resolveObjRef( ) = 0;
109 void throwBadRemoteObjAccess( )
const;
111 void logException( const ::std::string & callString,
112 const ::std::string & exString )
const;
114 void logSentCommand( const ::std::string & callString,
115 const double mjd )
const;
116 void logSentCommand( const ::std::string & callString,
118 const ::std::string & subDoName )
const;
120 void logSentCommandIfNeeded( const ::std::string & callString,
121 const double mjd )
const;
122 void logSentCommandIfNeeded( const ::std::string & callString,
124 const ::std::string & subDoName )
const;
126 void processException( const ::std::string & callString,
127 const ::CORBA::Exception & corbaException ) ;
129 void invalidateObjRefIfNeededForCaught( );
132 void setReachableMpValue(
bool value );
134 const ::std::string doName_;
136 const bool defaultLogIfNotReachable_;
137 const bool defaultLogSentCommands_;
145 OBJ_REF_VALIDITY_NEVER_SET,
146 OBJ_REF_VALIDITY_BAD,
147 OBJ_REF_VALIDITY_GOOD
150 ObjRefValidity objRefValidity_;
155 template <
typename T >
157 friend class RemoteObjMethodFunctorBase< T >;
174 const ::std::string &
doName,
178 bool defaultLogIfNotReachable,
179 bool defaultLogSentCommands );
192 typename T::_var_type
remoteObj( )
const;
199 template <
typename S >
200 typename S::_var_type
203 return S::_narrow( objRef_ );
207 virtual bool resolveObjRef( );
210 typename T::_var_type objRef_;
226 carma::control::RemoteObjHandleBase::getDefaultLogIfNotReachable( )
const
228 return defaultLogIfNotReachable_;
233 carma::control::RemoteObjHandleBase::getDefaultLogSentCommands( )
const
235 return defaultLogSentCommands_;
247 template <
typename T >
249 const ::std::string & doName,
253 const bool defaultLogIfNotReachable,
254 const bool defaultLogSentCommands ) :
259 defaultLogIfNotReachable,
260 defaultLogSentCommands ),
266 template <
typename T >
276 template <
typename T >
277 typename T::_var_type
280 throwIfObjRefIsNotValid();
282 if ( CORBA::is_nil( objRef_ ) )
283 throwBadRemoteObjAccess();
293 template <
typename T >
298 bool validatedObjRef =
false;
300 const int maxAttempts = 1;
303 CPTRACE( util::Trace::TRACE1,
" resolveObjRef(), doName()=" << doName() );
305 while ( (done ==
false) && (attemptNo < maxAttempts) ) {
309 const typename T::_var_type newObjRef =
312 if ( CORBA::is_nil( newObjRef ) == false ) {
317 if ( CORBA::is_nil( objRef_ ) == false ) {
318 validatedObjRef =
true;
324 "Resolve attempt #" << attemptNo <<
" failed" );
330 if ( validatedObjRef ==
false )
333 return validatedObjRef;
#define CARMA_CPTRACE(priorityLevel, message)
Macro for people who just want to use the Trace object created for them in carma::util::Program.
virtual ~RemoteObjHandleT()
Destructor.
void forceFullReconnect()
Force a full re-lookup of the DO by name.
virtual ~RemoteObjHandleBase()
Destructor.
bool isObjReachable()
If state is 'not reachable' and monitor system is current, tries to reconnect.
static Program & getProgram()
Class static method to get the process-wide singleton instance of Program.
Common base class for managing connections to DOs.
T::_var_type resolveName(const ::std::string &name, bool initialRef=false)
Resolve specified name to a CORBA object of the templatized output type.
RemoteObjHandleT(const ::std::string &doName, monitor::MonitorPointBool *mpReachable, const monitor::MonitorSubsystem *subsystem, monitor::MonitorSystem *system, bool defaultLogIfNotReachable, bool defaultLogSentCommands)
Constructor.
#define CPTRACE(priorityLevel, message)
Old deprecated macro name for CARMA_CPTRACE.
RemoteObjHandleBase(const ::std::string &doName, monitor::MonitorPointBool *mpReachable, const monitor::MonitorSubsystem *subsystem, monitor::MonitorSystem *system, bool defaultLogIfNotReachable, bool defaultLogSentCommands)
Constructor.
Boolean value monitor point.
Interface file for the carma::util::Trace class and related macros.
bool attemptToReconnectIfNeeded()
Try reconnect to the DO if needed.
S::_var_type narrowedRemoteObj() const
Returns remote object handle as var.
T::_var_type remoteObj() const
Returns remote object handle as var.
Typed class for managing connections to DOs.
Monitor system base class.
::std::string doName() const
get the DO name
Abstract MonitorSubsystem base class.