PG_Object_Group.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    PG_Object_Group.h
00006  *
00007  *  PG_Object_Group.h,v 1.12 2006/04/19 10:16:09 jwillemsen Exp
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         ACE_ENV_ARG_DECL)
00181       ACE_THROW_SPEC ((CORBA::SystemException,
00182                        PortableGroup::InvalidProperty,
00183                        PortableGroup::UnsupportedProperty));
00184 
00185     /**
00186      * @@TODO DOC
00187      */
00188     void get_properties (PortableGroup::Properties_var & result) const
00189       ACE_THROW_SPEC ((CORBA::SystemException));
00190 
00191     /**
00192      * @@TODO DOC
00193      */
00194     PortableGroup::ObjectGroupId  get_object_group_id () const;
00195 
00196     /**
00197      * Add a new member to the group.
00198      * @param the_location the location for the new member
00199      * @param member the member to be added
00200      */
00201     void add_member (
00202         const PortableGroup::Location & the_location,
00203         CORBA::Object_ptr member
00204         ACE_ENV_ARG_DECL)
00205       ACE_THROW_SPEC ( (CORBA::SystemException,
00206                        PortableGroup::ObjectNotAdded));
00207 
00208     /**
00209      * set the replica at the given location to be primary.
00210      * Note: This should return void and throw FT::PrimaryNotSet
00211      * but to avoid dependancies between PortableGroup and FaultTolerance
00212      * it returns a boolean result.  A false return means caller should
00213      * throw FT::PrimaryNot_Set.
00214      */
00215     int set_primary_member (
00216       TAO_IOP::TAO_IOR_Property * prop,
00217       const PortableGroup::Location & the_location
00218       ACE_ENV_ARG_DECL)
00219       ACE_THROW_SPEC ((
00220         CORBA::SystemException
00221         , PortableGroup::MemberNotFound
00222       ));
00223 
00224     /**
00225      * @@TODO DOC
00226      */
00227     void remove_member (
00228         const PortableGroup::Location & the_location
00229         ACE_ENV_ARG_DECL)
00230       ACE_THROW_SPEC ( (CORBA::SystemException,
00231                        PortableGroup::MemberNotFound));
00232 
00233 
00234     /**
00235      * @@TODO DOC
00236      */
00237     void create_member (
00238         const PortableGroup::Location & the_location,
00239         const char * type_id,
00240         const PortableGroup::Criteria & the_criteria
00241         ACE_ENV_ARG_DECL)
00242       ACE_THROW_SPEC ( (CORBA::SystemException,
00243         PortableGroup::MemberAlreadyPresent,
00244         PortableGroup::NoFactory,
00245         PortableGroup::ObjectNotCreated,
00246         PortableGroup::InvalidCriteria,
00247         PortableGroup::CannotMeetCriteria));
00248 
00249     /**
00250      * @@TODO DOC
00251      */
00252     PortableGroup::Locations * locations_of_members (ACE_ENV_SINGLE_ARG_DECL)
00253       ACE_THROW_SPEC ((CORBA::SystemException));
00254 
00255     /**
00256      * @@TODO DOC
00257      */
00258     CORBA::Object_ptr get_member_reference (
00259         const PortableGroup::Location & the_location
00260         ACE_ENV_ARG_DECL)
00261       ACE_THROW_SPEC ((
00262         CORBA::SystemException,
00263         PortableGroup::MemberNotFound));
00264 
00265 
00266     /**
00267      * @@TODO DOC
00268      */
00269     void initial_populate (ACE_ENV_SINGLE_ARG_DECL);
00270 
00271     /**
00272      * @@TODO DOC
00273      */
00274     void minimum_populate (ACE_ENV_SINGLE_ARG_DECL);
00275 
00276 
00277     /**
00278      * @@TODO DOC
00279      */
00280     int has_member_at (const PortableGroup::Location & location );
00281 
00282     /////////////////////////
00283     // Implementation methods
00284   private:
00285 
00286     int increment_version ();
00287 
00288     void distribute_iogr (ACE_ENV_SINGLE_ARG_DECL);
00289 
00290     PortableGroup::ObjectGroup_ptr add_member_to_iogr(CORBA::Object_ptr member ACE_ENV_ARG_DECL);
00291 
00292 
00293     void create_members (size_t count ACE_ENV_ARG_DECL)
00294       ACE_THROW_SPEC ((
00295         CORBA::SystemException,
00296         PortableGroup::NoFactory
00297         ));
00298 
00299 
00300     /////////////////////////
00301     // Forbidden methods
00302   private:
00303     PG_Object_Group ();
00304     PG_Object_Group (const PG_Object_Group & rhs);
00305     PG_Object_Group & operator = (const PG_Object_Group & rhs);
00306 
00307 
00308     /////////////////
00309     // Static Methods
00310   public:
00311 
00312     ///////////////
00313     // Static Data
00314   private:
00315 
00316     ///////////////
00317     // Data Members
00318   private:
00319 
00320     /**
00321      * Protect internal state.
00322      */
00323     mutable TAO_SYNCH_MUTEX internals_;
00324 
00325     CORBA::ORB_var orb_;
00326 
00327     /// Where to find the factories for replicas.
00328     PortableGroup::FactoryRegistry_var factory_registry_;
00329 
00330 
00331     // The object group manipulator
00332     TAO::PG_Object_Group_Manipulator & manipulator_;
00333 
00334     /// boolean true if empty group
00335     int empty_;
00336 
00337     ACE_CString role_;
00338     PortableGroup::TypeId_var type_id_;
00339 
00340     /**
00341      * the GroupTaggedComponent that defines this group
00342      * contains:
00343      *   GIOP::Version component_version;
00344      *   TAO::String_Manager group_domain_id;
00345      *   PortableGroup::ObjectGroupId object_group_id;
00346      *   PortableGroup::ObjectGroupRefVersion object_group_ref_version;
00347      */
00348     PortableGroup::TagGroupTaggedComponent tagged_component_;
00349 
00350     /**
00351      * the reference (IOGR) to this group
00352      */
00353     PortableGroup::ObjectGroup_var reference_;
00354 
00355     /**
00356      * The CORBA object id assigned to this object group
00357      */
00358     PortableServer::ObjectId_var object_id_;
00359 
00360     // group members
00361     MemberMap members_;
00362 
00363     PortableGroup::Location primary_location_;
00364 
00365     // Miscellaneous properties passed to create_object when this group
00366     // was initially created.  To be used to create new members.
00367     TAO::PG_Property_Set properties_;
00368 
00369     // Cached property information
00370 
00371     PortableGroup::InitialNumberMembersValue initial_number_members_;
00372     PortableGroup::MinimumNumberMembersValue minimum_number_members_;
00373     PortableGroup::FactoryInfos group_specific_factories_;
00374 
00375   };
00376 } // namespace TAO
00377 
00378 TAO_END_VERSIONED_NAMESPACE_DECL
00379 
00380 #include /**/ "ace/post.h"
00381 
00382 #endif // TAO_PG_OBJECT_GROUP_H_

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