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/OS.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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 class ACE_Export ACE_Registry
00043 {
00044 public:
00045
00046
00047 struct ACE_Export Name_Component
00048 {
00049 ACE_TString id_;
00050 ACE_TString kind_;
00051
00052 int operator== (const Name_Component &rhs) const;
00053 int operator!= (const Name_Component &rhs) const;
00054
00055 };
00056
00057
00058
00059
00060 typedef ACE_Unbounded_Set<Name_Component> Name;
00061
00062
00063 static const ACE_TCHAR *STRING_SEPARATOR;
00064
00065
00066 static ACE_TString make_string (const Name &name);
00067
00068
00069 static Name make_name (const ACE_TString &string);
00070
00071
00072 enum Binding_Type {INVALID, OBJECT, CONTEXT};
00073
00074 struct ACE_Export Binding
00075 {
00076
00077 Binding (void);
00078
00079
00080
00081 Binding (const Name &binding_name,
00082 Binding_Type binding_type);
00083
00084
00085
00086 Binding (const ACE_TString &binding_name,
00087 Binding_Type binding_type);
00088
00089 int operator== (const Binding &rhs) const;
00090 int operator!= (const Binding &rhs) const;
00091
00092
00093
00094
00095 void name (Name &name);
00096
00097
00098 void name (ACE_TString &name);
00099
00100
00101 ACE_TString name (void);
00102
00103
00104 Binding_Type type (void);
00105
00106 private:
00107
00108 ACE_TString name_;
00109
00110
00111 Binding_Type type_;
00112 };
00113
00114
00115 typedef ACE_Unbounded_Set<Binding> Binding_List;
00116
00117
00118 class Binding_Iterator;
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 class ACE_Export Object
00132 {
00133 public:
00134
00135 Object (void *data = 0,
00136 u_long size = 0,
00137 u_long type = REG_NONE);
00138
00139
00140 void data (void *data);
00141
00142
00143 void *data (void) const;
00144
00145
00146 void size (u_long size);
00147
00148
00149 u_long size (void) const;
00150
00151
00152 void type (u_long type);
00153
00154
00155 u_long type (void) const;
00156
00157 private:
00158
00159 void *data_;
00160
00161
00162 u_long size_;
00163
00164
00165 u_long type_;
00166 };
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 class ACE_Export Naming_Context
00177 {
00178 public:
00179
00180 friend class ACE_Predefined_Naming_Contexts;
00181
00182 enum {
00183
00184
00185 MAX_OBJECT_NAME_SIZE = BUFSIZ,
00186
00187
00188 MAX_CONTEXT_NAME_SIZE = MAXPATHLEN + 1
00189 };
00190
00191
00192 Naming_Context (void);
00193
00194
00195 Naming_Context (const HKEY &key);
00196
00197
00198 ~Naming_Context (void);
00199
00200
00201
00202
00203
00204
00205
00206
00207 int bind_new (const Name &name,
00208 const Object &object);
00209
00210
00211
00212
00213
00214
00215 int bind_new (const ACE_TString &name,
00216 const Object &object);
00217
00218
00219
00220
00221
00222
00223 int bind (const Name &name,
00224 const Object &object);
00225
00226
00227
00228
00229
00230
00231 int bind (const ACE_TString &name,
00232 const Object &object);
00233
00234
00235
00236 int rebind (const Name &name,
00237 const Object &object);
00238
00239
00240 int rebind (const ACE_TString &name,
00241 const Object &object);
00242
00243
00244
00245 int resolve (const Name &name,
00246 Object &object);
00247
00248
00249 int resolve (const ACE_TString &name,
00250 Object &object);
00251
00252
00253
00254 int unbind (const Name &name);
00255
00256
00257 int unbind (const ACE_TString &name);
00258
00259
00260
00261
00262
00263 int new_context (Naming_Context &naming_context);
00264
00265
00266
00267
00268
00269
00270 int bind_new_context (const Name &name,
00271 Naming_Context &naming_context,
00272 u_long persistence = REG_OPTION_NON_VOLATILE,
00273 u_long security_access = KEY_ALL_ACCESS,
00274 LPSECURITY_ATTRIBUTES security_attributes = 0);
00275
00276
00277
00278 int bind_new_context (const ACE_TString &name,
00279 Naming_Context &naming_context,
00280 u_long persistence = REG_OPTION_NON_VOLATILE,
00281 u_long security_access = KEY_ALL_ACCESS,
00282 LPSECURITY_ATTRIBUTES security_attributes = 0);
00283
00284
00285
00286
00287
00288
00289 int bind_context (const Name &name,
00290 Naming_Context &naming_context,
00291 u_long persistence = REG_OPTION_NON_VOLATILE,
00292 u_long security_access = KEY_ALL_ACCESS,
00293 LPSECURITY_ATTRIBUTES security_attributes = 0);
00294
00295
00296
00297 int bind_context (const ACE_TString &name,
00298 Naming_Context &naming_context,
00299 u_long persistence = REG_OPTION_NON_VOLATILE,
00300 u_long security_access = KEY_ALL_ACCESS,
00301 LPSECURITY_ATTRIBUTES security_attributes = 0);
00302
00303
00304
00305 int rebind_context (const Name &name,
00306 Naming_Context &naming_context);
00307
00308
00309 int rebind_context (const ACE_TString &name,
00310 Naming_Context &naming_context);
00311
00312
00313
00314 int resolve_context (const Name &name,
00315 Naming_Context &naming_context,
00316 u_long security_access = KEY_ALL_ACCESS);
00317
00318
00319 int resolve_context (const ACE_TString &name,
00320 Naming_Context &naming_context,
00321 u_long security_access = KEY_ALL_ACCESS);
00322
00323
00324
00325 int unbind_context (const Name &name);
00326
00327
00328 int unbind_context (const ACE_TString &name);
00329
00330
00331 int destroy (void);
00332
00333
00334
00335
00336
00337
00338
00339 int list (u_long how_many,
00340 Binding_List &list,
00341 Binding_Iterator &iterator);
00342
00343
00344
00345 int list (Binding_List &list);
00346
00347
00348
00349
00350
00351
00352 int flush (void);
00353
00354
00355
00356 int close (void);
00357
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
00560
00561 #if defined (ACE_HAS_BROKEN_NESTED_TEMPLATES)
00562 typedef ACE_Registry::Name_Component Name_Component;
00563 typedef ACE_Registry::Binding Binding;
00564 #endif
00565
00566 #endif
00567 #include "ace/post.h"
00568 #endif