00001 // -*- C++ -*- 00002 00003 /** 00004 * @file POA_Helper.h 00005 * 00006 * POA_Helper.h,v 1.14 2006/03/14 06:14:34 jtc Exp 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, 00044 const char* poa_name 00045 ACE_ENV_ARG_DECL); 00046 00047 /// Create a new PortableServer::POA. The name is chosen at random. 00048 void init (PortableServer::POA_ptr parent_poa ACE_ENV_ARG_DECL); 00049 00050 /// Destructor 00051 virtual ~TAO_Notify_POA_Helper (); 00052 00053 /// Get underlying POA 00054 PortableServer::POA_ptr poa (void); 00055 00056 /// Destroy underlying POA. 00057 void destroy (ACE_ENV_SINGLE_ARG_DECL); 00058 00059 /// Activate Object, the POA will assign an ID and return its value. 00060 CORBA::Object_ptr activate (PortableServer::Servant servant, 00061 CORBA::Long& id 00062 ACE_ENV_ARG_DECL); 00063 00064 /// Activate Object, using existing ID 00065 CORBA::Object_ptr activate_with_id (PortableServer::Servant servant, CORBA::Long id ACE_ENV_ARG_DECL); 00066 00067 /// Deactivate Object with ID 00068 void deactivate (CORBA::Long id 00069 ACE_ENV_ARG_DECL) const; 00070 00071 /// Convert ID to reference. 00072 CORBA::Object_ptr id_to_reference (CORBA::Long id 00073 ACE_ENV_ARG_DECL) const; 00074 00075 /// Convert reference to pointer to servant 00076 PortableServer::ServantBase * reference_to_servant (CORBA::Object_ptr ptr 00077 ACE_ENV_ARG_DECL) const; 00078 00079 CORBA::Object_ptr servant_to_reference (PortableServer::ServantBase * servant ACE_ENV_ARG_DECL) const; 00080 00081 protected: 00082 /// Set default POA policies. 00083 virtual void set_policy (PortableServer::POA_ptr parent_poa, 00084 CORBA::PolicyList &policy_list 00085 ACE_ENV_ARG_DECL); 00086 00087 /// Apply the polices and create child POA. 00088 void create_i (PortableServer::POA_ptr parent_poa, 00089 const char* poa_name, 00090 CORBA::PolicyList &policy_list ACE_ENV_ARG_DECL); 00091 00092 /// Generate a unique id for each POA created. 00093 ACE_CString get_unique_id (void); 00094 00095 /// Convert id to ObjectID 00096 PortableServer::ObjectId* long_to_ObjectId (CORBA::Long id 00097 ACE_ENV_ARG_DECL) const; 00098 00099 protected: 00100 /// POA 00101 PortableServer::POA_var poa_; 00102 00103 /// ID Factory for objects. 00104 TAO_Notify_ID_Factory id_factory_; 00105 }; 00106 00107 TAO_END_VERSIONED_NAMESPACE_DECL 00108 00109 #if defined (__ACE_INLINE__) 00110 #include "orbsvcs/Notify/POA_Helper.inl" 00111 #endif /* __ACE_INLINE__ */ 00112 00113 #include /**/ "ace/post.h" 00114 00115 #endif /* TAO_Notify_POA_Helper_H */