PG_ObjectGroupManager.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  * @file PG_ObjectGroupManager.h
00006  *
00007  * PG_ObjectGroupManager.h,v 1.15 2006/03/14 06:14:34 jtc Exp
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       ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00073     ACE_THROW_SPEC ((CORBA::SystemException,
00074                      PortableGroup::ObjectGroupNotFound,
00075                      PortableGroup::MemberAlreadyPresent,
00076                      PortableGroup::NoFactory,
00077                      PortableGroup::ObjectNotCreated,
00078                      PortableGroup::InvalidCriteria,
00079                      PortableGroup::CannotMeetCriteria));
00080 
00081   /// Add an existing object to the ObjectGroup.
00082   virtual PortableGroup::ObjectGroup_ptr add_member (
00083       PortableGroup::ObjectGroup_ptr object_group,
00084       const PortableGroup::Location & the_location,
00085       CORBA::Object_ptr member
00086       ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00087     ACE_THROW_SPEC ((CORBA::SystemException,
00088                      PortableGroup::ObjectGroupNotFound,
00089                      PortableGroup::MemberAlreadyPresent,
00090                      PortableGroup::ObjectNotAdded));
00091 
00092   /**
00093    * Remove an object at a specific location from the given
00094    * ObjectGroup.  Deletion of application created objects must be
00095    * deleted by the application.  Objects created by the
00096    * infrastructure (load balancer) will be deleted by the
00097    * infrastructure.
00098    */
00099   virtual PortableGroup::ObjectGroup_ptr remove_member (
00100       PortableGroup::ObjectGroup_ptr object_group,
00101       const PortableGroup::Location & the_location
00102       ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00103     ACE_THROW_SPEC ((CORBA::SystemException,
00104                      PortableGroup::ObjectGroupNotFound,
00105                      PortableGroup::MemberNotFound));
00106 
00107   /// Return the locations of the members in the given ObjectGroup.
00108   virtual PortableGroup::Locations * locations_of_members (
00109       PortableGroup::ObjectGroup_ptr object_group
00110       ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00111     ACE_THROW_SPEC ((CORBA::SystemException,
00112                      PortableGroup::ObjectGroupNotFound));
00113 
00114   /// Return the locations of the members in the given ObjectGroup.
00115   virtual PortableGroup::ObjectGroups * groups_at_location (
00116       const PortableGroup::Location & the_location
00117       ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00118     ACE_THROW_SPEC ((CORBA::SystemException));
00119 
00120   /// Return the ObjectGroupId for the given ObjectGroup.
00121   /// @note Does this method make sense for load balanced objects?
00122   virtual PortableGroup::ObjectGroupId get_object_group_id (
00123       PortableGroup::ObjectGroup_ptr object_group
00124       ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00125     ACE_THROW_SPEC ((CORBA::SystemException,
00126                      PortableGroup::ObjectGroupNotFound));
00127 
00128   /// @note Does this method make sense for load balanced objects?
00129   virtual PortableGroup::ObjectGroup_ptr get_object_group_ref (
00130       PortableGroup::ObjectGroup_ptr object_group
00131       ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00132     ACE_THROW_SPEC ((CORBA::SystemException,
00133                      PortableGroup::ObjectGroupNotFound));
00134 
00135   /// Return the reference corresponding to the member of a given
00136   /// ObjectGroup at the given location.
00137   virtual CORBA::Object_ptr get_member_ref (
00138       PortableGroup::ObjectGroup_ptr object_group,
00139       const PortableGroup::Location & loc
00140       ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00141     ACE_THROW_SPEC ((CORBA::SystemException,
00142                      PortableGroup::ObjectGroupNotFound,
00143                      PortableGroup::MemberNotFound));
00144   /**
00145    * TAO-specific extension.
00146    * Return the ObjectGroup reference for the given ObjectGroupId.
00147    */
00148    virtual PortableGroup::ObjectGroup_ptr get_object_group_ref_from_id (
00149         PortableGroup::ObjectGroupId group_id
00150         ACE_ENV_ARG_DECL_WITH_DEFAULTS
00151       )
00152       ACE_THROW_SPEC ((
00153         CORBA::SystemException
00154         , PortableGroup::ObjectGroupNotFound
00155       ));
00156 
00157   //@}
00158 
00159   /// TAO-specific member addition method.
00160   /**
00161    * This method is meant to be invoked by TAO's GenericFactory
00162    * implementation.  It is designed to allow only certain exceptions
00163    * to be propagated to the caller, and to prevent redundant remote
00164    * RepositoryId checking.
00165    */
00166   PortableGroup::ObjectGroup_ptr _tao_add_member (
00167       PortableGroup::ObjectGroup_ptr object_group,
00168       const PortableGroup::Location & the_location,
00169       CORBA::Object_ptr member,
00170       const char * type_id,
00171       const CORBA::Boolean propagate_member_already_present
00172       ACE_ENV_ARG_DECL)
00173     ACE_THROW_SPEC ((CORBA::SystemException,
00174                      PortableGroup::MemberAlreadyPresent,
00175                      PortableGroup::NoFactory));
00176 
00177   /// Create object group hash map entry that represents an actual
00178   /// ObjectGroup.
00179   /**
00180    * @note This method is used mainly by the
00181    *       GenericFactory::create_object() method.
00182    */
00183   PortableGroup::ObjectGroup_ptr create_object_group (
00184     CORBA::ULong group_id,
00185     const PortableServer::ObjectId &oid,
00186     const char * type_id,
00187     const PortableGroup::Criteria & the_criteria
00188     ACE_ENV_ARG_DECL);
00189 
00190   /// Destroy the object group corresponding to the given ObjectId.
00191   /**
00192    * @note This method is used mainly by the
00193    *       GenericFactory::delete_object() method.
00194    */
00195   void destroy_object_group (const PortableServer::ObjectId & oid
00196                              ACE_ENV_ARG_DECL);
00197 
00198   /// Return the properties set when the object group was created, and
00199   /// the dynamic properties that may have overridden them.
00200   PortableGroup::Properties * get_properties (
00201       PortableGroup::ObjectGroup_ptr object_group
00202       ACE_ENV_ARG_DECL)
00203     ACE_THROW_SPEC ((CORBA::SystemException,
00204                      PortableGroup::ObjectGroupNotFound));
00205 
00206   /// Return the type_id for the given object group.
00207   char * type_id (PortableGroup::ObjectGroup_ptr object_group
00208                   ACE_ENV_ARG_DECL);
00209 
00210   /// Return the object group associated with the given ObjectId.
00211   /**
00212    * @return Returns PortableGroup::ObjectGroup::_nil() if no object
00213    *         group corresponding to the given ObjectId exists.
00214    */
00215   PortableGroup::ObjectGroup_ptr object_group (
00216     const PortableServer::ObjectId & oid);
00217 
00218   /// Return the number of members in the given object group.
00219   CORBA::ULong member_count (PortableGroup::ObjectGroup_ptr group
00220                              ACE_ENV_ARG_DECL)
00221     ACE_THROW_SPEC ((CORBA::SystemException,
00222                      PortableGroup::ObjectGroupNotFound));
00223 
00224   /// Set the POA to use when converting object group references to
00225   /// ObjectIds.
00226   void poa (PortableServer::POA_ptr p);
00227 
00228   /// Set the pointer to the GenericFactory associated with this
00229   /// ObjectGroupManager.
00230   /**
00231    * The TAO_PG_GenericFactory will only be used when
00232    * ObjectGroupManager::remove_member() is explicitly called so that
00233    * the infrastructure may be given an opportunity to clean up any
00234    * object group members it may have created.
00235    */
00236   void generic_factory (TAO_PG_GenericFactory * generic_factory);
00237 
00238 protected:
00239 
00240   /// Underlying and non-locking implementation of the add_member()
00241   /// and _tao_add_member() methods in this class.
00242   PortableGroup::ObjectGroup_ptr add_member_i (
00243     PortableGroup::ObjectGroup_ptr object_group,
00244     const PortableGroup::Location & the_location,
00245     CORBA::Object_ptr member,
00246     const CORBA::Boolean check_type_id
00247     ACE_ENV_ARG_DECL)
00248   ACE_THROW_SPEC ((CORBA::SystemException,
00249                    PortableGroup::ObjectGroupNotFound,
00250                    PortableGroup::MemberAlreadyPresent,
00251                    PortableGroup::ObjectNotAdded));
00252 
00253   /// Obtain the ObjectGroup hash map entry corresponding to the given
00254   /// ObjectGroup reference.
00255   TAO_PG_ObjectGroup_Map_Entry * get_group_entry (
00256       PortableGroup::ObjectGroup_ptr object_group
00257       ACE_ENV_ARG_DECL)
00258     ACE_THROW_SPEC ((CORBA::SystemException,
00259                      PortableGroup::ObjectGroupNotFound));
00260 
00261 
00262   /// Check if a member resides at the location to which the group
00263   /// array belongs to.
00264   /**
00265    * A member is actually represented by the object group to which it
00266    * belongs.  In this implementation, a pointer to a object group
00267    * hash map entry is associated with a given a location.
00268    */
00269   CORBA::Boolean member_already_present (
00270     const TAO_PG_ObjectGroup_Array & groups,
00271     TAO_PG_ObjectGroup_Map_Entry * group_entry);
00272 
00273   /// get the position of the object_group_map_entry
00274   size_t get_object_group_position (
00275     const TAO_PG_ObjectGroup_Array & groups,
00276     TAO_PG_ObjectGroup_Map_Entry * group_entry);
00277 
00278   /// Verify that the member type_id matches the object group type_id.
00279   /**
00280    * @todo Strategize this -- e.g. strict type checking.
00281    */
00282   CORBA::Boolean valid_type_id (
00283     PortableGroup::ObjectGroup_ptr object_group,
00284     TAO_PG_ObjectGroup_Map_Entry * group_entry,
00285     CORBA::Object_ptr member
00286     ACE_ENV_ARG_DECL);
00287 
00288 private:
00289 
00290   /// Reference to the POA that created the object group references.
00291   PortableServer::POA_var poa_;
00292 
00293   /// The underlying table that contains all object group
00294   /// information.
00295   TAO_PG_ObjectGroup_Map object_group_map_;
00296 
00297   /// Map that contains list of all members at a given location, in
00298   /// addition to the load monitor at that location.
00299   TAO_PG_Location_Map location_map_;
00300 
00301   /// Pointer to the TAO_PG_GenericFactory class responsible for
00302   /// object group creation/destruction.
00303   TAO_PG_GenericFactory * generic_factory_;
00304 
00305   /// Lock used to synchronize access to the underlying tables.
00306   TAO_SYNCH_MUTEX lock_;
00307 
00308 };
00309 
00310 TAO_END_VERSIONED_NAMESPACE_DECL
00311 
00312 #include /**/ "ace/post.h"
00313 
00314 #endif  /* TAO_PG_OBJECT_GROUP_MANAGER_H */

Generated on Thu Nov 9 14:03:34 2006 for TAO_PortableGroup by doxygen 1.3.6