00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef ACE_REGISTRY_H
00015 #define ACE_REGISTRY_H
00016 #include "ace/pre.h"
00017
00018 #include "ace/config-all.h"
00019
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif
00023
00024 #if defined (ACE_WIN32)
00025
00026
00027 #include "ace/Containers.h"
00028 #include "ace/SString.h"
00029
00030 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 class ACE_Export ACE_Registry
00045 {
00046 public:
00047
00048
00049 struct ACE_Export Name_Component
00050 {
00051 ACE_TString id_;
00052 ACE_TString kind_;
00053
00054 bool operator== (const Name_Component &rhs) const;
00055 bool operator!= (const Name_Component &rhs) const;
00056
00057 };
00058
00059
00060
00061
00062 typedef ACE_Unbounded_Set<Name_Component> Name;
00063
00064
00065 static const ACE_TCHAR STRING_SEPARATOR[];
00066
00067
00068 static ACE_TString make_string (const Name &name);
00069
00070
00071 static Name make_name (const ACE_TString &string);
00072
00073
00074 enum Binding_Type {INVALID, OBJECT, CONTEXT};
00075
00076 struct ACE_Export Binding
00077 {
00078
00079 Binding (void);
00080
00081
00082
00083 Binding (const Name &binding_name,
00084 Binding_Type binding_type);
00085
00086
00087
00088 Binding (const ACE_TString &binding_name,
00089 Binding_Type binding_type);
00090
00091 bool operator== (const Binding &rhs) const;
00092 bool operator!= (const Binding &rhs) const;
00093
00094
00095
00096
00097 void name (Name &name);
00098
00099
00100 void name (ACE_TString &name);
00101
00102
00103 ACE_TString name (void);
00104
00105
00106 Binding_Type type (void);
00107
00108 private:
00109
00110 ACE_TString name_;
00111
00112
00113 Binding_Type type_;
00114 };
00115
00116
00117 typedef ACE_Unbounded_Set<Binding> Binding_List;
00118
00119
00120 class Binding_Iterator;
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 class ACE_Export Object
00134 {
00135 public:
00136
00137 Object (void *data = 0,
00138 u_long size = 0,
00139 u_long type = REG_NONE);
00140
00141
00142 void data (void *data);
00143
00144
00145 void *data (void) const;
00146
00147
00148 void size (u_long size);
00149
00150
00151 u_long size (void) const;
00152
00153
00154 void type (u_long type);
00155
00156
00157 u_long type (void) const;
00158
00159 private:
00160
00161 void *data_;
00162
00163
00164 u_long size_;
00165
00166
00167 u_long type_;
00168 };
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 class ACE_Export Naming_Context
00179 {
00180 public:
00181
00182 friend class ACE_Predefined_Naming_Contexts;
00183
00184 enum {
00185
00186
00187 MAX_OBJECT_NAME_SIZE = BUFSIZ,
00188
00189
00190 MAX_CONTEXT_NAME_SIZE = MAXPATHLEN + 1
00191 };
00192
00193
00194 Naming_Context (void);
00195
00196
00197 Naming_Context (const HKEY &key);
00198
00199
00200 ~Naming_Context (void);
00201
00202
00203
00204
00205
00206
00207
00208
00209 int bind_new (const Name &name,
00210 const Object &object);
00211
00212
00213
00214
00215
00216
00217 int bind_new (const ACE_TString &name,
00218 const Object &object);
00219
00220
00221
00222
00223
00224
00225 int bind (const Name &name,
00226 const Object &object);
00227
00228
00229
00230
00231
00232
00233 int bind (const ACE_TString &name,
00234 const Object &object);
00235
00236
00237
00238 int rebind (const Name &name,
00239 const Object &object);
00240
00241
00242 int rebind (const ACE_TString &name,
00243 const Object &object);
00244
00245
00246
00247 int resolve (const Name &name,
00248 Object &object);
00249
00250
00251 int resolve (const ACE_TString &name,
00252 Object &object);
00253
00254
00255
00256 int unbind (const Name &name);
00257
00258
00259 int unbind (const ACE_TString &name);
00260
00261
00262
00263
00264
00265 int new_context (Naming_Context &naming_context);
00266
00267
00268
00269
00270
00271
00272 int bind_new_context (const Name &name,
00273 Naming_Context &naming_context,
00274 u_long persistence = REG_OPTION_NON_VOLATILE,
00275 u_long security_access = KEY_ALL_ACCESS,
00276 LPSECURITY_ATTRIBUTES security_attributes = 0);
00277
00278
00279
00280 int bind_new_context (const ACE_TString &name,
00281 Naming_Context &naming_context,
00282 u_long persistence = REG_OPTION_NON_VOLATILE,
00283 u_long security_access = KEY_ALL_ACCESS,
00284 LPSECURITY_ATTRIBUTES security_attributes = 0);
00285
00286
00287
00288
00289
00290
00291 int bind_context (const Name &name,
00292 Naming_Context &naming_context,
00293 u_long persistence = REG_OPTION_NON_VOLATILE,
00294 u_long security_access = KEY_ALL_ACCESS,
00295 LPSECURITY_ATTRIBUTES security_attributes = 0);
00296
00297
00298
00299 int bind_context (const ACE_TString &name,
00300 Naming_Context &naming_context,
00301 u_long persistence = REG_OPTION_NON_VOLATILE,
00302 u_long security_access = KEY_ALL_ACCESS,
00303 LPSECURITY_ATTRIBUTES security_attributes = 0);
00304
00305
00306
00307 int rebind_context (const Name &name,
00308 Naming_Context &naming_context);
00309
00310
00311 int rebind_context (const ACE_TString &name,
00312 Naming_Context &naming_context);
00313
00314
00315
00316 int resolve_context (const Name &name,
00317 Naming_Context &naming_context,
00318 u_long security_access = KEY_ALL_ACCESS);
00319
00320
00321 int resolve_context (const ACE_TString &name,
00322 Naming_Context &naming_context,
00323 u_long security_access = KEY_ALL_ACCESS);
00324
00325
00326
00327 int unbind_context (const Name &name);
00328
00329
00330 int unbind_context (const ACE_TString &name);
00331
00332
00333 int destroy (void);
00334
00335
00336
00337
00338
00339
00340
00341 int list (u_long how_many,
00342 Binding_List &list,
00343 Binding_Iterator &iterator);
00344
00345
00346
00347 int list (Binding_List &list);
00348
00349
00350
00351
00352
00353 int flush (void);
00354
00355
00356
00357 int close (void);
00358
00359
00360
00361
00362 HKEY key (void);
00363
00364
00365
00366 HKEY parent (void);
00367
00368
00369
00370 void name (Name &name);
00371
00372
00373 void name (ACE_TString &name);
00374
00375
00376 ACE_TString name (void);
00377
00378 protected:
00379
00380 void key (HKEY key);
00381
00382
00383 void parent (HKEY parent);
00384
00385
00386
00387 void name (const Name &name);
00388
00389
00390
00391 void name (const ACE_TString &name);
00392
00393 private:
00394
00395 Naming_Context (const Naming_Context &rhs);
00396
00397
00398 const Naming_Context &operator= (const Naming_Context &rhs);
00399
00400
00401 HKEY key_;
00402
00403
00404 HKEY parent_key_;
00405
00406
00407 ACE_TString name_;
00408 };
00409
00410
00411
00412
00413
00414
00415
00416
00417 class ACE_Export Binding_Iterator
00418 {
00419 public:
00420
00421 friend class Naming_Context;
00422
00423
00424 Binding_Iterator (void);
00425
00426
00427 int next_one (Binding &binding);
00428
00429
00430 int next_n (u_long how_many,
00431 Binding_List &list);
00432
00433
00434 int destroy (void);
00435
00436
00437 void reset (void);
00438
00439
00440 Naming_Context &naming_context (void);
00441
00442 private:
00443
00444
00445 void naming_context (Naming_Context& naming_context);
00446
00447
00448 Naming_Context *naming_context_;
00449
00450 public:
00451
00452
00453
00454
00455
00456
00457
00458
00459 class ACE_Export Iteration_State
00460 {
00461 public:
00462
00463 Iteration_State (Binding_Iterator &iterator);
00464
00465
00466 virtual int next_n (u_long how_many,
00467 Binding_List &list) = 0;
00468
00469
00470 void reset (void);
00471
00472 protected:
00473
00474 Binding_Iterator *parent_;
00475
00476 u_long index_;
00477 };
00478
00479 private:
00480 class ACE_Export Object_Iteration : public Iteration_State
00481 {
00482 public:
00483 Object_Iteration (Binding_Iterator &iterator);
00484
00485
00486 int next_n (u_long how_many,
00487 Binding_List &list);
00488 };
00489
00490 class ACE_Export Context_Iteration : public Iteration_State
00491 {
00492 public:
00493 Context_Iteration (Binding_Iterator &iterator);
00494
00495
00496 int next_n (u_long how_many,
00497 Binding_List &list);
00498 };
00499
00500 class ACE_Export Iteration_Complete : public Iteration_State
00501 {
00502 public:
00503 Iteration_Complete (Binding_Iterator &iterator);
00504
00505
00506 int next_n (u_long how_many,
00507 Binding_List &list);
00508 };
00509
00510
00511 friend class Iteration_State;
00512 friend class Object_Iteration;
00513 friend class Context_Iteration;
00514 friend class Iteration_Complete;
00515
00516
00517 Object_Iteration object_iteration_;
00518 Context_Iteration context_iteration_;
00519 Iteration_Complete iteration_complete_;
00520
00521
00522 Iteration_State *current_enumeration_;
00523
00524
00525 void current_enumeration (Iteration_State& current_enumeration);
00526
00527
00528 Iteration_State ¤t_enumeration (void);
00529 };
00530 };
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541 class ACE_Export ACE_Predefined_Naming_Contexts
00542 {
00543 public:
00544
00545
00546
00547
00548
00549
00550 static int connect (ACE_Registry::Naming_Context &naming_context,
00551 HKEY predefined = HKEY_LOCAL_MACHINE,
00552 const ACE_TCHAR *machine_name = 0);
00553
00554 private:
00555
00556 static int is_local_host (const ACE_TCHAR *machine_name);
00557 };
00558
00559 ACE_END_VERSIONED_NAMESPACE_DECL
00560
00561 #endif
00562 #include "ace/post.h"
00563 #endif