00001 // -*- C++ -*- 00002 00003 /** 00004 * @file POA_Helper.h 00005 * 00006 * $Id: POA_Helper.h 81420 2008-04-24 12:13:54Z johnnyw $ 00007 * 00008 * @author Pradeep Gore <pradeep@oomworks.com> 00009 */ 00010 00011 #ifndef TAO_Notify_POA_Helper_H 00012 #define TAO_Notify_POA_Helper_H 00013 00014 #include /**/ "ace/pre.h" 00015 00016 #include "orbsvcs/Notify/notify_serv_export.h" 00017 00018 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00019 # pragma once 00020 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00021 00022 #include "orbsvcs/Notify/ID_Factory.h" 00023 00024 #include "tao/PortableServer/PortableServer.h" 00025 00026 #include "ace/Copy_Disabled.h" 00027 00028 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00029 00030 /** 00031 * @class TAO_Notify_POA_Helper 00032 * 00033 * @brief POA Abstraction. 00034 * 00035 */ 00036 class TAO_Notify_Serv_Export TAO_Notify_POA_Helper : private ACE_Copy_Disabled 00037 { 00038 public: 00039 /// Default Constructor 00040 TAO_Notify_POA_Helper (void); 00041 00042 /// Create a new PortableServer::POA. 00043 void init (PortableServer::POA_ptr parent_poa, const char* poa_name); 00044 00045 #if !defined (CORBA_E_MICRO) 00046 /// Create a new persistent PortableServer::POA. 00047 void init_persistent (PortableServer::POA_ptr parent_poa, 00048 const char* poa_name); 00049 #endif /* !CORBA_E_MICRO */ 00050 00051 /// Create a new PortableServer::POA. The name is chosen at random. 00052 void init (PortableServer::POA_ptr parent_poa); 00053 00054 /// Destructor 00055 virtual ~TAO_Notify_POA_Helper (); 00056 00057 /// Get underlying POA 00058 PortableServer::POA_ptr poa (void); 00059 00060 /// Destroy underlying POA. 00061 void destroy (void); 00062 00063 /// Activate Object, the POA will assign an ID and return its value. 00064 CORBA::Object_ptr activate (PortableServer::Servant servant, 00065 CORBA::Long& id); 00066 00067 /// Activate Object, using existing ID 00068 CORBA::Object_ptr activate_with_id (PortableServer::Servant servant, CORBA::Long id); 00069 00070 /// Deactivate Object with ID 00071 void deactivate (CORBA::Long id) const; 00072 00073 /// Convert ID to reference. 00074 CORBA::Object_ptr id_to_reference (CORBA::Long id) const; 00075 00076 /// Convert reference to pointer to servant 00077 PortableServer::ServantBase * reference_to_servant (CORBA::Object_ptr ptr) const; 00078 00079 CORBA::Object_ptr servant_to_reference (PortableServer::ServantBase * servant) const; 00080 00081 /// Generate a unique id for each POA created. 00082 ACE_CString get_unique_id (void); 00083 00084 protected: 00085 /// Set default POA policies. 00086 virtual void set_policy (PortableServer::POA_ptr parent_poa, 00087 CORBA::PolicyList &policy_list); 00088 00089 #if !defined (CORBA_E_MICRO) 00090 /// Set persistent POA policies. 00091 virtual void set_persistent_policy (PortableServer::POA_ptr parent_poa, 00092 CORBA::PolicyList &policy_list); 00093 #endif /* !CORBA_E_MICRO */ 00094 00095 /// Apply the polices and create child POA. 00096 void create_i (PortableServer::POA_ptr parent_poa, 00097 const char* poa_name, 00098 CORBA::PolicyList &policy_list); 00099 00100 /// Convert id to ObjectID 00101 PortableServer::ObjectId* long_to_ObjectId (CORBA::Long id) const; 00102 00103 protected: 00104 /// POA 00105 PortableServer::POA_var poa_; 00106 00107 /// ID Factory for objects. 00108 TAO_Notify_ID_Factory id_factory_; 00109 }; 00110 00111 TAO_END_VERSIONED_NAMESPACE_DECL 00112 00113 #if defined (__ACE_INLINE__) 00114 #include "orbsvcs/Notify/POA_Helper.inl" 00115 #endif /* __ACE_INLINE__ */ 00116 00117 #include /**/ "ace/post.h" 00118 00119 #endif /* TAO_Notify_POA_Helper_H */