00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef OMNIEVENTS__SERVANT_H
00025 #define OMNIEVENTS__SERVANT_H
00026
00027 #ifdef HAVE_CONFIG_H
00028 # include "config.h"
00029 #endif
00030
00031 #ifdef HAVE_OMNIORB3
00032 # include <omniORB3/CORBA.h>
00033 #endif
00034
00035 #ifdef HAVE_OMNIORB4
00036 # include <omniORB4/CORBA.h>
00037 #endif
00038
00039
00040
00041
00042
00043 #if OMNIEVENTS__DEBUG_ALL
00044 # define OMNIEVENTS__DEBUG_REF_COUNTS 1
00045 # define OMNIEVENTS__DEBUG_SERVANT 1
00046 #else
00047
00049 # define OMNIEVENTS__DEBUG_REF_COUNTS 0
00050
00052 # define OMNIEVENTS__DEBUG_SERVANT 0
00053 #endif
00054
00055 #if OMNIEVENTS__DEBUG_REF_COUNTS
00056 # define OMNIEVENTS__DEBUG_REF_COUNTS__DECL void _add_ref();void _remove_ref();
00057 # define OMNIEVENTS__DEBUG_REF_COUNTS__DEFN(C) \
00058 void C::_add_ref() { \
00059 DB(20,#C "::_add_ref()") \
00060 PortableServer::RefCountServantBase::_add_ref(); \
00061 } \
00062 void C::_remove_ref() { \
00063 DB(20,#C "::_remove_ref()") \
00064 PortableServer::RefCountServantBase::_remove_ref(); \
00065 }
00066 #else
00067
00068 # define OMNIEVENTS__DEBUG_REF_COUNTS__DECL
00069
00070 # define OMNIEVENTS__DEBUG_REF_COUNTS__DEFN(C)
00071 #endif
00072
00073
00074 namespace OmniEvents {
00075
00082 CORBA::Object_ptr
00083 createReference(PortableServer::POA_ptr poa, const char* repositoryId);
00084
00094 template<class T>
00095 typename T::_ptr_type
00096 createNarrowedReference(PortableServer::POA_ptr poa, const char* repositoryId)
00097 {
00098 CORBA::Object_var obj =createReference(poa,repositoryId);
00099 #ifdef HAVE_OMNIORB4
00100 return T::_unchecked_narrow(obj.in());
00101 #else
00102 return T::_narrow(obj.in());
00103 #endif
00104 }
00105
00107 char* newUniqueId();
00108
00109
00113 class Servant : public virtual PortableServer::ServantBase
00114 {
00115 public:
00116 virtual PortableServer::POA_ptr _default_POA();
00117 virtual ~Servant();
00118
00119 #if OMNIEVENTS__DEBUG_SERVANT
00120 static int _objectCount;
00121 #endif
00122
00123 protected:
00124 Servant(PortableServer::POA_ptr poa);
00125
00127 void activateObjectWithId(const char* oidStr);
00129 void deactivateObject();
00130
00131 PortableServer::POA_var _poa;
00132
00133 private:
00135 Servant();
00136 };
00137
00138 };
00139
00140 #endif // OMNIEVENTS__SERVANT_H