00001 // -*- C++ -*- 00002 00003 /** 00004 * @file Object.h 00005 * 00006 * $Id: Object.h 81420 2008-04-24 12:13:54Z johnnyw $ 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 true if shutdown. 00074 bool 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 if 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 00142 /// <qos_properties_> have been modified. 00143 virtual void qos_changed (const TAO_Notify_QoSProperties& qos_properties); 00144 00145 /// Called by derived types to save their attributes. Each 00146 /// derived type should call its superclass version before 00147 /// saving its own attrs. 00148 virtual void save_attrs(TAO_Notify::NVPList& attrs); 00149 00150 ///= Protected data members. 00151 00152 /// QoS Properties. 00153 TAO_Notify_QoSProperties qos_properties_; 00154 00155 private: 00156 /// Set Worker Task. This object assume ownership of the set object. 00157 void set_worker_task (TAO_Notify_Worker_Task* worker_task); 00158 00159 /// Setting the proxy_poa_ gives ownership to this class. 00160 void set_proxy_poa (TAO_Notify_POA_Helper* proxy_poa); 00161 00162 /// Setting the object_poa_ gives ownership to this class. 00163 void set_object_poa (TAO_Notify_POA_Helper* object_poa); 00164 00165 /// Setting the object_poa_ gives ownership to this class. 00166 void set_poa (TAO_Notify_POA_Helper* object_poa); 00167 00168 /// Shutdown the current worker task and delete it if we own it. 00169 void shutdown_worker_task (void); 00170 00171 /// Shutdown the current proxy poa. 00172 void destroy_proxy_poa (void); 00173 00174 /// Shutdown the current object poa. 00175 void destroy_object_poa (void); 00176 00177 /// Shutdown the current poa. 00178 void destroy_poa (void); 00179 00180 protected: 00181 00182 /// The mutex to serialize access to state variables. 00183 TAO_SYNCH_MUTEX lock_; 00184 00185 private: 00186 00187 /// The POA in which the object is activated. 00188 TAO_Notify_POA_Helper* poa_; 00189 00190 /// The POA in which the proxys are activated. 00191 TAO_Notify_POA_Helper* proxy_poa_; 00192 bool own_proxy_poa_; 00193 00194 /// The POA in which the object's children are activated. 00195 TAO_Notify_POA_Helper* object_poa_; 00196 bool own_object_poa_; 00197 00198 /// Id assigned to this object 00199 ID id_; 00200 00201 /// The event manager. 00202 /// TAO_Notify_Event_Manager inl includes Object.h 00203 TAO_Notify_Refcountable_Guard_T< TAO_Notify_Event_Manager > event_manager_; 00204 00205 /// Admin Properties. 00206 TAO_Notify_AdminProperties::Ptr admin_properties_; 00207 00208 /// Worker Task. 00209 TAO_Notify_Worker_Task::Ptr worker_task_; 00210 bool own_worker_task_; 00211 00212 /// Are we shutdown (i,e. scheduled for destroy). 00213 bool shutdown_; 00214 }; 00215 00216 TAO_END_VERSIONED_NAMESPACE_DECL 00217 00218 #if defined (__ACE_INLINE__) 00219 #include "orbsvcs/Notify/Object.inl" 00220 #endif /* __ACE_INLINE__ */ 00221 00222 #include /**/ "ace/post.h" 00223 00224 #endif /* TAO_Notify_OBJECT_H */