• Classes
  • Modules
  • Namespaces
  • Files
  • Related Pages
  • File List
  • File Members

baciCORBA.h

Go to the documentation of this file.
00001 #ifndef baciCORBA_h
00002 #define baciCORBA_h
00003 
00004 /*******************************************************************
00005 * ALMA - Atacama Large Millimiter Array
00006 * (c) European Southern Observatory, 2003
00007 *
00008 *This library is free software; you can redistribute it and/or
00009 *modify it under the terms of the GNU Lesser General Public
00010 *License as published by the Free Software Foundation; either
00011 *version 2.1 of the License, or (at your option) any later version.
00012 *
00013 *This library is distributed in the hope that it will be useful,
00014 *but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 *Lesser General Public License for more details.
00017 *
00018 *You should have received a copy of the GNU Lesser General Public
00019 *License along with this library; if not, write to the Free Software
00020 *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00021 *
00022 * "@(#) $Id: baciCORBA.h,v 1.95 2008/07/14 12:50:19 bjeram Exp $"
00023 *
00024 * who       when      what
00025 * --------  --------  ----------------------------------------------
00026 * gchiozzi 2001-12-20 Added getPOAManager() and getPOARoot() methods.
00027 * msekoran  2001/03/07 modified
00028 * msekoran  2001/08/26 added InitCORBA, DoneCORBA for BACI modular tests
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  /* baciCORBA_h */
00220 
00221 
00222 
00223 
00224 
00225 
00226 
00227 

Generated on Thu Jan 12 2012 23:13:50 for ACS-10.0 C++ API by  doxygen 1.7.0