PG_Object_Group.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    PG_Object_Group.h
00006  *
00007  *  $Id: PG_Object_Group.h 77001 2007-02-12 07:54:49Z johnnyw $
00008  *
00009  *  Manage all information related to an object group.
00010  *  @@ Note: the above description is optimistic.  The hope is to eventually
00011  *  @@ consolidate all information related to an object group into this object.
00012  *  @@ however at the moment GenericFactory, ObjectGroupManager, and
00013  *  FT_ReplicationManager have parallel collections of object group
00014  *  information.
00015  *
00016  *  @author Dale Wilson <wilson_d@ociweb.com>
00017  */
00018 //=============================================================================
00019 
00020 #ifndef TAO_PG_OBJECT_GROUP_H_
00021 #define TAO_PG_OBJECT_GROUP_H_
00022 #include /**/ "ace/pre.h"
00023 
00024 #include "orbsvcs/PortableGroup/portablegroup_export.h"
00025 
00026 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00027 #pragma once
00028 #endif /* ACE_LACKS_PRAGMA_ONCE */
00029 
00030 
00031 /////////////////////////////////
00032 // Includes needed by this header
00033 #include "orbsvcs/PortableGroup/PG_Property_Set.h"
00034 #include "orbsvcs/PortableGroup/PG_Location_Hash.h"
00035 #include "orbsvcs/PortableGroup/PG_Location_Equal_To.h"
00036 #include "orbsvcs/PortableGroup/PG_Object_Group_Manipulator.h"
00037 #include "orbsvcs/PortableGroupC.h"
00038 #include "tao/PortableServer/PortableServer.h"
00039 #include "ace/Hash_Map_Manager_T.h"
00040 #include "ace/ACE.h"
00041 
00042 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00043 
00044 /////////////////////
00045 // Forward references
00046 
00047 namespace TAO_IOP
00048 {
00049   class TAO_IOR_Property;
00050 }
00051 
00052 ////////////////
00053 // Class declarations
00054 namespace TAO
00055 {
00056   /**
00057    */
00058   class TAO_PortableGroup_Export PG_Object_Group
00059   {
00060     // Information about an object group member
00061     struct MemberInfo
00062     {
00063       /// Reference to the member.
00064       CORBA::Object_var member_;
00065 
00066       /// The factory that was used to create this object
00067       /// nil if application created.
00068       PortableGroup::GenericFactory_var factory_;
00069 
00070       /// FactoryCreationId assigned to the member. Empty if application created
00071       PortableGroup::GenericFactory::FactoryCreationId factory_id_;
00072 
00073       /// Location where this member exists
00074       PortableGroup::Location location_;
00075 
00076 
00077       /// TRUE if this is primary member
00078       CORBA::Boolean is_primary_;
00079 
00080 
00081       ///////////////
00082       // Methods
00083 
00084       /// Construct an application-supplied member.
00085       MemberInfo (CORBA::Object_ptr member, const PortableGroup::Location & location);
00086 
00087       /// Construct a infrastructure-created member.
00088       MemberInfo (
00089         CORBA::Object_ptr member,
00090         const PortableGroup::Location & location,
00091         PortableGroup::GenericFactory_ptr factory,
00092         PortableGroup::GenericFactory::FactoryCreationId factory_id);
00093 
00094       /// Destructor
00095       ~MemberInfo();
00096     };
00097 
00098     typedef TAO_SYNCH_MUTEX MemberMapMutex;
00099     typedef ACE_Hash_Map_Manager_Ex <
00100       PortableGroup::Location,
00101       MemberInfo *,
00102       TAO_PG_Location_Hash,
00103       TAO_PG_Location_Equal_To,
00104       MemberMapMutex>  MemberMap;
00105     typedef ACE_Hash_Map_Entry <PortableGroup::Location, MemberInfo *> MemberMap_Entry;
00106     typedef ACE_Hash_Map_Iterator_Ex <
00107       PortableGroup::Location,
00108       MemberInfo *,
00109       TAO_PG_Location_Hash,
00110       TAO_PG_Location_Equal_To,
00111       MemberMapMutex> MemberMap_Iterator;
00112 
00113     /////////////////////
00114     // Construct/Destruct
00115   public:
00116     /**
00117      * @@TODO DOC
00118      */
00119     PG_Object_Group (
00120       CORBA::ORB_ptr orb,
00121       PortableGroup::FactoryRegistry_ptr factory_registry,
00122       TAO::PG_Object_Group_Manipulator & manipulator,
00123       CORBA::Object_ptr empty_group,
00124       const PortableGroup::TagGroupTaggedComponent & tagged_component,
00125       const char * type_id,
00126       const PortableGroup::Criteria & the_criteria,
00127       TAO::PG_Property_Set * type_properties);
00128 
00129 
00130     /// Destructor
00131     ~PG_Object_Group ();
00132 
00133     /////////////////
00134     // public methods
00135 
00136   public:
00137     /// return a duplicated reference to this group (IOGR)
00138     PortableGroup::ObjectGroup_ptr reference()const;
00139 
00140     /**
00141      * Note the caller receives a copy of the factoryinfos in the result argument.
00142      * inefficient, but thread safe.
00143      */
00144     void get_group_specific_factories (PortableGroup::FactoryInfos & result) const;
00145 
00146     /**
00147      * get location of primary member
00148      */
00149     const PortableGroup::Location & get_primary_location() const;
00150 
00151     /**
00152      * returns a duplicate
00153      * caller must release
00154      */
00155     PortableGroup::TypeId get_type_id ()const;
00156 
00157 
00158     /**
00159      * @@TODO DOC
00160      */
00161     PortableGroup::MembershipStyleValue get_membership_style() const;
00162 
00163     /**
00164      * @@TODO DOC
00165      */
00166     PortableGroup::MinimumNumberMembersValue get_minimum_number_members () const;
00167 
00168     /**
00169      * @@TODO DOC
00170      */
00171     PortableGroup::InitialNumberMembersValue get_initial_number_members () const;
00172 
00173 
00174 
00175     /**
00176      * @@TODO DOC
00177      */
00178     void set_properties_dynamically (
00179         const PortableGroup::Properties & overrides);
00180 
00181     /**
00182      * @@TODO DOC
00183      */
00184     void get_properties (PortableGroup::Properties_var & result) const;
00185 
00186     /**
00187      * @@TODO DOC
00188      */
00189     PortableGroup::ObjectGroupId  get_object_group_id () const;
00190 
00191     /**
00192      * Add a new member to the group.
00193      * @param the_location the location for the new member
00194      * @param member the member to be added
00195      */
00196     void add_member (
00197         const PortableGroup::Location & the_location,
00198         CORBA::Object_ptr member);
00199 
00200     /**
00201      * set the replica at the given location to be primary.
00202      * Note: This should return void and throw FT::PrimaryNotSet
00203      * but to avoid dependancies between PortableGroup and FaultTolerance
00204      * it returns a boolean result.  A false return means caller should
00205      * throw FT::PrimaryNot_Set.
00206      */
00207     int set_primary_member (
00208       TAO_IOP::TAO_IOR_Property * prop,
00209       const PortableGroup::Location & the_location);
00210 
00211     /**
00212      * @@TODO DOC
00213      */
00214     void remove_member (
00215         const PortableGroup::Location & the_location);
00216 
00217 
00218     /**
00219      * @@TODO DOC
00220      */
00221     void create_member (
00222         const PortableGroup::Location & the_location,
00223         const char * type_id,
00224         const PortableGroup::Criteria & the_criteria);
00225 
00226     /**
00227      * @@TODO DOC
00228      */
00229     PortableGroup::Locations * locations_of_members (void);
00230 
00231     /**
00232      * @@TODO DOC
00233      */
00234     CORBA::Object_ptr get_member_reference (
00235         const PortableGroup::Location & the_location);
00236 
00237 
00238     /**
00239      * @@TODO DOC
00240      */
00241     void initial_populate (void);
00242 
00243     /**
00244      * @@TODO DOC
00245      */
00246     void minimum_populate (void);
00247 
00248 
00249     /**
00250      * @@TODO DOC
00251      */
00252     int has_member_at (const PortableGroup::Location & location );
00253 
00254     /////////////////////////
00255     // Implementation methods
00256   private:
00257 
00258     int increment_version ();
00259 
00260     void distribute_iogr (void);
00261 
00262     PortableGroup::ObjectGroup_ptr add_member_to_iogr(CORBA::Object_ptr member);
00263 
00264 
00265     void create_members (size_t count);
00266 
00267 
00268     /////////////////////////
00269     // Forbidden methods
00270   private:
00271     PG_Object_Group ();
00272     PG_Object_Group (const PG_Object_Group & rhs);
00273     PG_Object_Group & operator = (const PG_Object_Group & rhs);
00274 
00275 
00276     /////////////////
00277     // Static Methods
00278   public:
00279 
00280     ///////////////
00281     // Static Data
00282   private:
00283 
00284     ///////////////
00285     // Data Members
00286   private:
00287 
00288     /**
00289      * Protect internal state.
00290      */
00291     mutable TAO_SYNCH_MUTEX internals_;
00292 
00293     CORBA::ORB_var orb_;
00294 
00295     /// Where to find the factories for replicas.
00296     PortableGroup::FactoryRegistry_var factory_registry_;
00297 
00298 
00299     // The object group manipulator
00300     TAO::PG_Object_Group_Manipulator & manipulator_;
00301 
00302     /// boolean true if empty group
00303     int empty_;
00304 
00305     ACE_CString role_;
00306     PortableGroup::TypeId_var type_id_;
00307 
00308     /**
00309      * the GroupTaggedComponent that defines this group
00310      * contains:
00311      *   GIOP::Version component_version;
00312      *   TAO::String_Manager group_domain_id;
00313      *   PortableGroup::ObjectGroupId object_group_id;
00314      *   PortableGroup::ObjectGroupRefVersion object_group_ref_version;
00315      */
00316     PortableGroup::TagGroupTaggedComponent tagged_component_;
00317 
00318     /**
00319      * the reference (IOGR) to this group
00320      */
00321     PortableGroup::ObjectGroup_var reference_;
00322 
00323     /**
00324      * The CORBA object id assigned to this object group
00325      */
00326     PortableServer::ObjectId_var object_id_;
00327 
00328     // group members
00329     MemberMap members_;
00330 
00331     PortableGroup::Location primary_location_;
00332 
00333     // Miscellaneous properties passed to create_object when this group
00334     // was initially created.  To be used to create new members.
00335     TAO::PG_Property_Set properties_;
00336 
00337     // Cached property information
00338 
00339     PortableGroup::InitialNumberMembersValue initial_number_members_;
00340     PortableGroup::MinimumNumberMembersValue minimum_number_members_;
00341     PortableGroup::FactoryInfos group_specific_factories_;
00342 
00343   };
00344 } // namespace TAO
00345 
00346 TAO_END_VERSIONED_NAMESPACE_DECL
00347 
00348 #include /**/ "ace/post.h"
00349 
00350 #endif // TAO_PG_OBJECT_GROUP_H_

Generated on Tue Feb 2 17:49:50 2010 for TAO_PortableGroup by  doxygen 1.4.7