00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef TAO_PG_FACTORYREGISTRY_H_
00017 #define TAO_PG_FACTORYREGISTRY_H_
00018 #include "ace/pre.h"
00019 #include "ace/ACE.h"
00020
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 #pragma once
00023 #endif
00024
00025 #include "tao/Versioned_Namespace.h"
00026
00027
00028
00029 #include "orbsvcs/PortableGroup/portablegroup_export.h"
00030 #include "orbsvcs/PortableGroupS.h"
00031 #include "ace/Hash_Map_Manager.h"
00032 #include "ace/SString.h"
00033 #include "ace/Null_Mutex.h"
00034
00035 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00036
00037
00038
00039 namespace TAO
00040 {
00041 class PG_FactoryRegistry;
00042 }
00043
00044
00045
00046
00047 namespace TAO
00048 {
00049
00050
00051
00052
00053
00054 class TAO_PortableGroup_Export PG_FactoryRegistry
00055 : public virtual POA_PortableGroup::FactoryRegistry
00056 {
00057 struct RoleInfo
00058 {
00059 ACE_CString type_id_;
00060 PortableGroup::FactoryInfos infos_;
00061
00062 RoleInfo(size_t estimated_number_entries = 5);
00063 };
00064 typedef ACE_Null_Mutex MapMutex;
00065 typedef ACE_Hash_Map_Manager <ACE_CString, RoleInfo *, MapMutex> RegistryType;
00066 typedef ACE_Hash_Map_Entry <ACE_CString, RoleInfo *> RegistryType_Entry;
00067 typedef ACE_Hash_Map_Iterator <ACE_CString, RoleInfo *, MapMutex> RegistryType_Iterator;
00068
00069
00070
00071 public:
00072
00073 PG_FactoryRegistry (const char * name = "FactoryRegistry");
00074
00075
00076 virtual ~PG_FactoryRegistry (void);
00077
00078
00079
00080
00081
00082
00083
00084 int parse_args (int argc, char * argv[]);
00085
00086
00087
00088
00089
00090
00091 int init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL);
00092
00093
00094
00095
00096 void init (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa ACE_ENV_ARG_DECL);
00097
00098
00099
00100
00101
00102 int fini (ACE_ENV_SINGLE_ARG_DECL);
00103
00104
00105
00106
00107
00108
00109 int idle(int & result ACE_ENV_ARG_DECL);
00110
00111
00112
00113
00114
00115 const char * identity () const;
00116
00117
00118
00119
00120
00121 ::PortableGroup::FactoryRegistry_ptr reference();
00122
00123
00124
00125 virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL);
00126
00127
00128
00129
00130
00131 virtual void register_factory (
00132 const char * role,
00133 const char * type_id,
00134 const PortableGroup::FactoryInfo & factory_info
00135 ACE_ENV_ARG_DECL
00136 )
00137 ACE_THROW_SPEC ((
00138 CORBA::SystemException
00139 , PortableGroup::MemberAlreadyPresent
00140 , PortableGroup::TypeConflict));
00141
00142 virtual void unregister_factory (
00143 const char * role,
00144 const PortableGroup::Location & location
00145 ACE_ENV_ARG_DECL
00146 )
00147 ACE_THROW_SPEC ((CORBA::SystemException, PortableGroup::MemberNotFound));
00148
00149 virtual void unregister_factory_by_role (
00150 const char * role
00151 ACE_ENV_ARG_DECL
00152 )
00153 ACE_THROW_SPEC ((CORBA::SystemException));
00154
00155
00156 virtual void unregister_factory_by_location (
00157 const PortableGroup::Location & location
00158 ACE_ENV_ARG_DECL
00159 )
00160 ACE_THROW_SPEC ((CORBA::SystemException));
00161
00162 virtual ::PortableGroup::FactoryInfos * list_factories_by_role (
00163 const char * role,
00164 CORBA::String_out type_id
00165 ACE_ENV_ARG_DECL
00166 )
00167 ACE_THROW_SPEC ((CORBA::SystemException));
00168
00169 virtual ::PortableGroup::FactoryInfos * list_factories_by_location (
00170 const PortableGroup::Location & location
00171 ACE_ENV_ARG_DECL
00172 )
00173 ACE_THROW_SPEC ((CORBA::SystemException));
00174
00175
00176
00177 private:
00178
00179
00180
00181 int write_ior_file (const char * outputFile, const char * ior);
00182
00183
00184
00185 private:
00186
00187
00188
00189
00190 ACE_CString identity_;
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200 TAO_SYNCH_MUTEX internals_;
00201 typedef ACE_Guard<TAO_SYNCH_MUTEX> InternalGuard;
00202
00203
00204
00205
00206 CORBA::ORB_var orb_;
00207
00208
00209
00210
00211 PortableServer::POA_var poa_;
00212
00213
00214
00215
00216 PortableServer::ObjectId_var object_id_;
00217
00218
00219
00220
00221 CORBA::Object_var this_obj_;
00222
00223
00224
00225
00226 CORBA::String_var ior_;
00227
00228
00229
00230
00231 const char * ior_output_file_;
00232
00233
00234
00235
00236 const char * ns_name_;
00237
00238 CosNaming::NamingContext_var naming_context_;
00239
00240 CosNaming::Name this_name_;
00241
00242
00243
00244
00245 int quit_on_idle_;
00246
00247
00248
00249
00250 enum {LIVE, DEACTIVATED, GONE} quit_state_;
00251
00252 int linger_;
00253
00254 RegistryType registry_;
00255
00256 };
00257 }
00258
00259 TAO_END_VERSIONED_NAMESPACE_DECL
00260
00261 #include "ace/post.h"
00262
00263 #endif // TAO_PG_FACTORYREGISTRY_H_