PG_ObjectGroupManager.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  * @file PG_ObjectGroupManager.h
00006  *
00007  * $Id: PG_ObjectGroupManager.h 77001 2007-02-12 07:54:49Z johnnyw $
00008  *
00009  * @author Ossama Othman <ossama@uci.edu>
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef TAO_PG_OBJECT_GROUP_MANAGER_H
00015 #define TAO_PG_OBJECT_GROUP_MANAGER_H
00016 
00017 #include /**/ "ace/pre.h"
00018 
00019 #include "orbsvcs/PortableGroup/portablegroup_export.h"
00020 #include "orbsvcs/PortableGroupS.h"
00021 
00022 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 #pragma once
00024 #endif /* ACE_LACKS_PRAGMA_ONCE */
00025 
00026 #include "orbsvcs/PortableGroup/PG_ObjectGroup_Map.h"
00027 #include "orbsvcs/PortableGroup/PG_Location_Map.h"
00028 
00029 #include "tao/PortableServer/Key_Adapters.h"
00030 #include "tao/PortableServer/PortableServerC.h"
00031 
00032 
00033 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00034 
00035 /// Forward declarations
00036 class TAO_PG_GenericFactory;
00037 
00038 
00039 /**
00040  * @class TAO_PG_ObjectGroupManager
00041  *
00042  * @brief PortableGroup::ObjectGroupManager implementation.
00043  *
00044  * The ObjectGroupManager provides the interface necessary to
00045  * facilitate application-controlled object group membership.
00046  */
00047 class TAO_PortableGroup_Export TAO_PG_ObjectGroupManager
00048   : public virtual POA_PortableGroup::ObjectGroupManager
00049 {
00050 public:
00051 
00052   /// Constructor.
00053   TAO_PG_ObjectGroupManager (void);
00054 
00055   /// Destructor.
00056   ~TAO_PG_ObjectGroupManager (void);
00057 
00058   /**
00059    * @name PortableGroup::ObjectGroupManager methods
00060    *
00061    * Methods required by the PortableGroup::ObjectGroupManager
00062    * interface.
00063    */
00064   //@{
00065 
00066   /// Create a member and add it to the given object group.
00067   virtual PortableGroup::ObjectGroup_ptr create_member (
00068       PortableGroup::ObjectGroup_ptr object_group,
00069       const PortableGroup::Location & the_location,
00070       const char * type_id,
00071       const PortableGroup::Criteria & the_criteria);
00072 
00073   /// Add an existing object to the ObjectGroup.
00074   virtual PortableGroup::ObjectGroup_ptr add_member (
00075       PortableGroup::ObjectGroup_ptr object_group,
00076       const PortableGroup::Location & the_location,
00077       CORBA::Object_ptr member);
00078 
00079   /**
00080    * Remove an object at a specific location from the given
00081    * ObjectGroup.  Deletion of application created objects must be
00082    * deleted by the application.  Objects created by the
00083    * infrastructure (load balancer) will be deleted by the
00084    * infrastructure.
00085    */
00086   virtual PortableGroup::ObjectGroup_ptr remove_member (
00087       PortableGroup::ObjectGroup_ptr object_group,
00088       const PortableGroup::Location & the_location);
00089 
00090   /// Return the locations of the members in the given ObjectGroup.
00091   virtual PortableGroup::Locations * locations_of_members (
00092       PortableGroup::ObjectGroup_ptr object_group);
00093 
00094   /// Return the locations of the members in the given ObjectGroup.
00095   virtual PortableGroup::ObjectGroups * groups_at_location (
00096       const PortableGroup::Location & the_location);
00097 
00098   /// Return the ObjectGroupId for the given ObjectGroup.
00099   /// @note Does this method make sense for load balanced objects?
00100   virtual PortableGroup::ObjectGroupId get_object_group_id (
00101       PortableGroup::ObjectGroup_ptr object_group);
00102 
00103   /// @note Does this method make sense for load balanced objects?
00104   virtual PortableGroup::ObjectGroup_ptr get_object_group_ref (
00105       PortableGroup::ObjectGroup_ptr object_group);
00106 
00107   /// Return the reference corresponding to the member of a given
00108   /// ObjectGroup at the given location.
00109   virtual CORBA::Object_ptr get_member_ref (
00110       PortableGroup::ObjectGroup_ptr object_group,
00111       const PortableGroup::Location & loc);
00112   /**
00113    * TAO-specific extension.
00114    * Return the ObjectGroup reference for the given ObjectGroupId.
00115    */
00116    virtual PortableGroup::ObjectGroup_ptr get_object_group_ref_from_id (
00117         PortableGroup::ObjectGroupId group_id
00118       );
00119 
00120   //@}
00121 
00122   /// TAO-specific member addition method.
00123   /**
00124    * This method is meant to be invoked by TAO's GenericFactory
00125    * implementation.  It is designed to allow only certain exceptions
00126    * to be propagated to the caller, and to prevent redundant remote
00127    * RepositoryId checking.
00128    */
00129   PortableGroup::ObjectGroup_ptr _tao_add_member (
00130       PortableGroup::ObjectGroup_ptr object_group,
00131       const PortableGroup::Location & the_location,
00132       CORBA::Object_ptr member,
00133       const char * type_id,
00134       const CORBA::Boolean propagate_member_already_present);
00135 
00136   /// Create object group hash map entry that represents an actual
00137   /// ObjectGroup.
00138   /**
00139    * @note This method is used mainly by the
00140    *       GenericFactory::create_object() method.
00141    */
00142   PortableGroup::ObjectGroup_ptr create_object_group (
00143     CORBA::ULong group_id,
00144     const PortableServer::ObjectId &oid,
00145     const char * type_id,
00146     const PortableGroup::Criteria & the_criteria);
00147 
00148   /// Destroy the object group corresponding to the given ObjectId.
00149   /**
00150    * @note This method is used mainly by the
00151    *       GenericFactory::delete_object() method.
00152    */
00153   void destroy_object_group (const PortableServer::ObjectId & oid);
00154 
00155   /// Return the properties set when the object group was created, and
00156   /// the dynamic properties that may have overridden them.
00157   PortableGroup::Properties * get_properties (
00158       PortableGroup::ObjectGroup_ptr object_group);
00159 
00160   /// Return the type_id for the given object group.
00161   char * type_id (PortableGroup::ObjectGroup_ptr object_group);
00162 
00163   /// Return the object group associated with the given ObjectId.
00164   /**
00165    * @return Returns PortableGroup::ObjectGroup::_nil() if no object
00166    *         group corresponding to the given ObjectId exists.
00167    */
00168   PortableGroup::ObjectGroup_ptr object_group (
00169     const PortableServer::ObjectId & oid);
00170 
00171   /// Return the number of members in the given object group.
00172   CORBA::ULong member_count (PortableGroup::ObjectGroup_ptr group);
00173 
00174   /// Set the POA to use when converting object group references to
00175   /// ObjectIds.
00176   void poa (PortableServer::POA_ptr p);
00177 
00178   /// Set the pointer to the GenericFactory associated with this
00179   /// ObjectGroupManager.
00180   /**
00181    * The TAO_PG_GenericFactory will only be used when
00182    * ObjectGroupManager::remove_member() is explicitly called so that
00183    * the infrastructure may be given an opportunity to clean up any
00184    * object group members it may have created.
00185    */
00186   void generic_factory (TAO_PG_GenericFactory * generic_factory);
00187 
00188 protected:
00189 
00190   /// Underlying and non-locking implementation of the add_member()
00191   /// and _tao_add_member() methods in this class.
00192   PortableGroup::ObjectGroup_ptr add_member_i (
00193     PortableGroup::ObjectGroup_ptr object_group,
00194     const PortableGroup::Location & the_location,
00195     CORBA::Object_ptr member,
00196     const CORBA::Boolean check_type_id);
00197 
00198   /// Obtain the ObjectGroup hash map entry corresponding to the given
00199   /// ObjectGroup reference.
00200   TAO_PG_ObjectGroup_Map_Entry * get_group_entry (
00201       PortableGroup::ObjectGroup_ptr object_group);
00202 
00203 
00204   /// Check if a member resides at the location to which the group
00205   /// array belongs to.
00206   /**
00207    * A member is actually represented by the object group to which it
00208    * belongs.  In this implementation, a pointer to a object group
00209    * hash map entry is associated with a given a location.
00210    */
00211   CORBA::Boolean member_already_present (
00212     const TAO_PG_ObjectGroup_Array & groups,
00213     TAO_PG_ObjectGroup_Map_Entry * group_entry);
00214 
00215   /// get the position of the object_group_map_entry
00216   size_t get_object_group_position (
00217     const TAO_PG_ObjectGroup_Array & groups,
00218     TAO_PG_ObjectGroup_Map_Entry * group_entry);
00219 
00220   /// Verify that the member type_id matches the object group type_id.
00221   /**
00222    * @todo Strategize this -- e.g. strict type checking.
00223    */
00224   CORBA::Boolean valid_type_id (
00225     PortableGroup::ObjectGroup_ptr object_group,
00226     TAO_PG_ObjectGroup_Map_Entry * group_entry,
00227     CORBA::Object_ptr member);
00228 
00229 private:
00230 
00231   /// Reference to the POA that created the object group references.
00232   PortableServer::POA_var poa_;
00233 
00234   /// The underlying table that contains all object group
00235   /// information.
00236   TAO_PG_ObjectGroup_Map object_group_map_;
00237 
00238   /// Map that contains list of all members at a given location, in
00239   /// addition to the load monitor at that location.
00240   TAO_PG_Location_Map location_map_;
00241 
00242   /// Pointer to the TAO_PG_GenericFactory class responsible for
00243   /// object group creation/destruction.
00244   TAO_PG_GenericFactory * generic_factory_;
00245 
00246   /// Lock used to synchronize access to the underlying tables.
00247   TAO_SYNCH_MUTEX lock_;
00248 
00249 };
00250 
00251 TAO_END_VERSIONED_NAMESPACE_DECL
00252 
00253 #include /**/ "ace/post.h"
00254 
00255 #endif  /* TAO_PG_OBJECT_GROUP_MANAGER_H */

Generated on Sun Jan 27 16:22:30 2008 for TAO_PortableGroup by doxygen 1.3.6