Go to the documentation of this file.00001 #ifndef baciCORBA_h
00002 #define baciCORBA_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00036 #ifndef __cplusplus
00037 #error This is a C++ include file and cannot be used from plain C
00038 #endif
00039
00040 #include <acsutil.h>
00041 #include <baciExport.h>
00042
00043 #include <tao/corba.h>
00044 #include <tao/PortableServer/PortableServer.h>
00045
00052 class baci_EXPORT BACI_CORBA
00053 {
00054
00055 protected:
00056
00063 BACI_CORBA(
00064 CORBA::ORB_ptr orb_m,
00065 PortableServer::POAManager_ptr poaManager,
00066 PortableServer::POA_ptr poaRoot_m,
00067 PortableServer::POA_ptr poaPersistent_m,
00068 PortableServer::POA_ptr poaTransient_m);
00069
00071 ~BACI_CORBA();
00072
00073 public:
00074
00079 static BACI_CORBA * getInstance();
00080
00088 static BACI_CORBA * createInstance(
00089 CORBA::ORB_ptr orb_m,
00090 PortableServer::POAManager_ptr poaManager,
00091 PortableServer::POA_ptr poaRoot_m,
00092 PortableServer::POA_ptr poaPersistent_m,
00093 PortableServer::POA_ptr poaTransient_m);
00094
00098 static void destroyInstance();
00099
00100
00105 static CORBA::ORB_ptr getORB();
00106
00111 static PortableServer::POAManager_ptr getPOAManager();
00112
00117 static PortableServer::POA_ptr getPOARoot();
00118
00123 static PortableServer::POA_ptr getPOA();
00124
00129 static CORBA::Object_ptr ActivateCORBAObject(PortableServer::Servant srvnt, const ACE_CString &id);
00130 static CORBA::Object_ptr ActivateCORBAObject(PortableServer::Servant srvnt, const char * id);
00131
00136 template<class T> static T* ActivateTransientCORBAObject(PortableServer::Servant servant)
00137 {
00138 if ((instance_mp==0) ||
00139 CORBA::is_nil(instance_mp->poaTransient_m.ptr()))
00140 {
00141 return T::_nil();
00142 }
00143 else
00144 {
00145 try
00146 {
00147 PortableServer::ObjectId_var tID = instance_mp->poaTransient_m->activate_object(servant);
00148 CORBA::Object_var corbRef = instance_mp->poaTransient_m->id_to_reference(tID.in());
00149 return T::_narrow(corbRef.in());
00150 }
00151 catch(...)
00152 {
00153 return T::_nil();
00154 }
00155 }
00156 }
00157
00162 static bool DestroyCORBAObject(CORBA::Object_ptr obj);
00163
00168 static bool DestroyCORBAObject(PortableServer::Servant srvnt);
00169
00170
00175 static bool DestroyTransientCORBAObject(CORBA::Object_ptr obj);
00176
00181 static bool DestroyTransientCORBAObject(PortableServer::Servant srvnt);
00182
00189 static bool InitCORBA(int argc, char* argv[]);
00190
00195 static bool DoneCORBA();
00196
00197 private:
00198
00199 static BACI_CORBA * instance_mp;
00200
00201 PortableServer::POAManager_var poaManager_m;
00202 PortableServer::POA_var poaRoot_m;
00203 PortableServer::POA_var poaPersistent_m;
00204 PortableServer::POA_var poaTransient_m;
00205 CORBA::ORB_var orb_m;
00206
00210 void operator=(const BACI_CORBA&);
00211
00215 BACI_CORBA(const BACI_CORBA&);
00216
00217 };
00218
00219 #endif
00220
00221
00222
00223
00224
00225
00226
00227