00001 // -*- C++ -*- 00002 00003 /** 00004 * @file Object.h 00005 * 00006 * $Id: Object.h 79084 2007-07-30 13:13:45Z elliott_c $ 00007 * 00008 * @author Pradeep Gore <pradeep@oomworks.com> 00009 * 00010 * 00011 */ 00012 00013 #ifndef TAO_Notify_OBJECT_H 00014 #define TAO_Notify_OBJECT_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 #include "orbsvcs/Notify/notify_serv_export.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #include "orbsvcs/Notify/QoSProperties.h" 00025 #include "orbsvcs/Notify/AdminProperties.h" 00026 #include "orbsvcs/Notify/Worker_Task.h" 00027 #include "orbsvcs/Notify/Refcountable.h" 00028 #include "orbsvcs/Notify/Name_Value_Pair.h" 00029 #include "orbsvcs/Notify/Event_Manager.h" 00030 00031 #include "orbsvcs/NotifyExtC.h" 00032 00033 #include "tao/PortableServer/Servant_Base.h" 00034 00035 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00036 00037 class TAO_Notify_POA_Helper; 00038 class TAO_Notify_Timer; 00039 class TAO_Notify_RT_Builder; 00040 00041 /** 00042 * @class TAO_Notify_Object 00043 * 00044 * @brief Base Object for RT_Notify's CORBA Objects. 00045 * 00046 */ 00047 class TAO_Notify_Serv_Export TAO_Notify_Object : public TAO_Notify_Refcountable 00048 { 00049 friend class TAO_Notify_Builder; 00050 friend class TAO_Notify_RT_Builder; 00051 00052 public: 00053 /// Id for Objects. 00054 typedef CORBA::Long ID; 00055 00056 /// Destructor 00057 virtual ~TAO_Notify_Object (void); 00058 00059 /// This Object's ID 00060 ID id (void) const; 00061 00062 /// Activate 00063 virtual CORBA::Object_ptr activate (PortableServer::Servant servant); 00064 00065 /// Activate with existing id 00066 virtual CORBA::Object_ptr activate ( 00067 PortableServer::Servant servant, 00068 CORBA::Long id); 00069 00070 /// Deactivate 00071 void deactivate (void); 00072 00073 /// Have we been shutdown. returns 1 if shutdown. 00074 int has_shutdown (void); 00075 00076 void execute_task (TAO_Notify_Method_Request& method_request); 00077 00078 /// Get CORBA Ref. 00079 CORBA::Object_ptr ref (void); 00080 00081 /// Set the QoS Properties. 00082 virtual void set_qos (const CosNotification::QoSProperties & qos); 00083 00084 /// Get the QoS Properties. 00085 CosNotification::QoSProperties* get_qos (void); 00086 00087 bool find_qos_property_value ( 00088 const char * name, 00089 CosNotification::PropertyValue & value)const; 00090 00091 /// Obtain the Timer manager associated with this object. 00092 virtual TAO_Notify_Timer* timer (void); 00093 00094 /// Accessor for the Event Manager 00095 TAO_Notify_Event_Manager& event_manager (void); 00096 00097 /// shutdown. Returns 1 ifif the shutdown was already run once before. 00098 virtual int shutdown (void); 00099 00100 /// Load our attributes. Each derived type should call the superclass 00101 /// load first before loading its own attributes. 00102 virtual void load_attrs(const TAO_Notify::NVPList& attrs); 00103 00104 /// Allow access to the underlying worker task. 00105 TAO_Notify_Worker_Task* get_worker_task (void); 00106 00107 protected: 00108 /// Constructor 00109 TAO_Notify_Object (void); 00110 00111 /// Init this object with data from <rhs>. 00112 void initialize (TAO_Notify_Object* parent); 00113 00114 /// Uses the poas from the supplied object 00115 void inherit_poas (TAO_Notify_Object& parent); 00116 00117 /// Adopts the supplied poa as all are poas 00118 void adopt_poa (TAO_Notify_POA_Helper* single); 00119 00120 /// Changes the primary poa to the current proxy poa 00121 void set_primary_as_proxy_poa(); 00122 00123 /// Accessor for the proxy_poa_ 00124 TAO_Notify_POA_Helper* proxy_poa (void); 00125 00126 /// Accessor for the object_poa_ 00127 TAO_Notify_POA_Helper* object_poa (void); 00128 00129 /// Get the POA assigned to us. 00130 TAO_Notify_POA_Helper* poa (void); 00131 00132 // Sets the admin properties 00133 void set_event_manager( TAO_Notify_Event_Manager* event_manager ); 00134 00135 // Sets the admin properties 00136 void set_admin_properties( TAO_Notify_AdminProperties* admin_properties ); 00137 00138 /// Accessor for the Admin Properties 00139 TAO_Notify_AdminProperties& admin_properties (void); 00140 00141 /// Notification that can be overridden by subclasses to be informed that <qos_properties_> have been modified. 00142 virtual void qos_changed (const TAO_Notify_QoSProperties& qos_properties); 00143 00144 /// Called by derived types to save their attributes. Each 00145 /// derived type should call its superclass version before 00146 /// saving its own attrs. 00147 virtual void save_attrs(TAO_Notify::NVPList& attrs); 00148 00149 ///= Protected data members. 00150 00151 /// QoS Properties. 00152 TAO_Notify_QoSProperties qos_properties_; 00153 00154 private: 00155 /// Set Worker Task. This object assume ownership of the set object. 00156 void set_worker_task (TAO_Notify_Worker_Task* worker_task); 00157 00158 /// Setting the proxy_poa_ gives ownership to this class. 00159 void set_proxy_poa (TAO_Notify_POA_Helper* proxy_poa); 00160 00161 /// Setting the object_poa_ gives ownership to this class. 00162 void set_object_poa (TAO_Notify_POA_Helper* object_poa); 00163 00164 /// Setting the object_poa_ gives ownership to this class. 00165 void set_poa (TAO_Notify_POA_Helper* object_poa); 00166 00167 /// Shutdown the current worker task and delete it if we own it. 00168 void shutdown_worker_task (void); 00169 00170 /// Shutdown the current proxy poa. 00171 void destroy_proxy_poa (void); 00172 00173 /// Shutdown the current object poa. 00174 void destroy_object_poa (void); 00175 00176 /// Shutdown the current poa. 00177 void destroy_poa (void); 00178 00179 protected: 00180 00181 /// The mutex to serialize access to state variables. 00182 TAO_SYNCH_MUTEX lock_; 00183 00184 private: 00185 00186 /// The POA in which the object is activated. 00187 TAO_Notify_POA_Helper* poa_; 00188 00189 /// The POA in which the proxys are activated. 00190 TAO_Notify_POA_Helper* proxy_poa_; 00191 bool own_proxy_poa_; 00192 00193 /// The POA in which the object's children are activated. 00194 TAO_Notify_POA_Helper* object_poa_; 00195 bool own_object_poa_; 00196 00197 /// Id assigned to this object 00198 ID id_; 00199 00200 /// The event manager. 00201 //TAO_Notify_Event_Manager inl includes Object.h 00202 TAO_Notify_Refcountable_Guard_T< TAO_Notify_Event_Manager > event_manager_; 00203 00204 /// Admin Properties. 00205 TAO_Notify_AdminProperties::Ptr admin_properties_; 00206 00207 /// Worker Task. 00208 TAO_Notify_Worker_Task::Ptr worker_task_; 00209 bool own_worker_task_; 00210 00211 /// Are we shutdown (i,e. scheduled for destroy). 00212 bool shutdown_; 00213 }; 00214 00215 TAO_END_VERSIONED_NAMESPACE_DECL 00216 00217 #if defined (__ACE_INLINE__) 00218 #include "orbsvcs/Notify/Object.inl" 00219 #endif /* __ACE_INLINE__ */ 00220 00221 #include /**/ "ace/post.h" 00222 00223 #endif /* TAO_Notify_OBJECT_H */