00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef TAO_ACTIVE_OBJECT_MAP_H
00015 #define TAO_ACTIVE_OBJECT_MAP_H
00016
00017 #include "ace/pre.h"
00018
00019 #include "tao/PortableServer/Key_Adapters.h"
00020
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif
00024
00025 #include "tao/PortableServer/Servant_Base.h"
00026 #include "tao/Server_Strategy_Factory.h"
00027 #include "ace/Map_T.h"
00028
00029 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00030
00031
00032 class TAO_Id_Uniqueness_Strategy;
00033 class TAO_Lifespan_Strategy;
00034 class TAO_Id_Assignment_Strategy;
00035 class TAO_Id_Hint_Strategy;
00036 struct TAO_Active_Object_Map_Entry;
00037
00038
00039
00040
00041
00042
00043
00044
00045 class TAO_Active_Object_Map
00046 {
00047 public:
00048
00049
00050 TAO_Active_Object_Map (int user_id_policy,
00051 int unique_id_policy,
00052 int persistent_id_policy,
00053 const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters);
00054
00055
00056 ~TAO_Active_Object_Map (void);
00057
00058
00059 int is_servant_in_map (PortableServer::Servant servant,
00060 bool &deactivated);
00061
00062
00063
00064 bool is_user_id_in_map (const PortableServer::ObjectId &user_id,
00065 CORBA::Short priority,
00066 bool &priorities_match,
00067 bool &deactivated);
00068
00069
00070 int bind_using_system_id_returning_system_id (PortableServer::Servant servant,
00071 CORBA::Short priority,
00072 PortableServer::ObjectId_out system_id);
00073
00074
00075 int bind_using_system_id_returning_user_id (PortableServer::Servant servant,
00076 CORBA::Short priority,
00077 PortableServer::ObjectId_out user_id);
00078
00079
00080
00081 int bind_using_user_id (PortableServer::Servant servant,
00082 const PortableServer::ObjectId &user_id,
00083 CORBA::Short priority);
00084
00085
00086
00087 int find_system_id_using_user_id (const PortableServer::ObjectId &user_id,
00088 CORBA::Short priority,
00089 PortableServer::ObjectId_out system_id);
00090
00091
00092 int rebind_using_user_id_and_system_id (PortableServer::Servant servant,
00093 const PortableServer::ObjectId &user_id,
00094 const PortableServer::ObjectId &system_id,
00095 TAO_Active_Object_Map_Entry *&entry);
00096
00097
00098
00099 int unbind_using_user_id (const PortableServer::ObjectId &user_id);
00100
00101
00102
00103 int find_user_id_using_servant (PortableServer::Servant servant,
00104 PortableServer::ObjectId_out user_id);
00105
00106
00107
00108 int find_system_id_using_servant (PortableServer::Servant servant,
00109 PortableServer::ObjectId_out system_id,
00110 CORBA::Short &priority);
00111
00112
00113
00114 int find_servant_using_user_id (const PortableServer::ObjectId &user_id,
00115 PortableServer::Servant &servant);
00116
00117
00118
00119 int find_servant_using_system_id_and_user_id (const PortableServer::ObjectId &system_id,
00120 const PortableServer::ObjectId &user_id,
00121 PortableServer::Servant &servant,
00122 TAO_Active_Object_Map_Entry *&entry);
00123
00124
00125
00126 int find_servant_and_system_id_using_user_id (const PortableServer::ObjectId &user_id,
00127 PortableServer::Servant &servant,
00128 PortableServer::ObjectId_out system_id,
00129 CORBA::Short &priority);
00130
00131
00132
00133
00134
00135
00136
00137 int find_entry_using_user_id (const PortableServer::ObjectId &user_id,
00138 TAO_Active_Object_Map_Entry *&entry);
00139
00140
00141
00142 int find_user_id_using_system_id (const PortableServer::ObjectId &system_id,
00143 PortableServer::ObjectId_out user_id);
00144
00145
00146
00147 int find_user_id_using_system_id (const PortableServer::ObjectId &system_id,
00148 PortableServer::ObjectId &user_id);
00149
00150
00151
00152 CORBA::Boolean remaining_activations (PortableServer::Servant servant);
00153
00154
00155 size_t current_size (void);
00156
00157
00158 static size_t system_id_size (void);
00159
00160
00161 static void set_system_id_size (const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters);
00162
00163
00164 typedef ACE_Map<
00165 PortableServer::ObjectId,
00166 TAO_Active_Object_Map_Entry *> user_id_map;
00167
00168
00169 typedef ACE_Hash_Map_Manager_Ex_Adapter<
00170 PortableServer::ObjectId,
00171 TAO_Active_Object_Map_Entry *,
00172 TAO_ObjectId_Hash,
00173 ACE_Equal_To<PortableServer::ObjectId>,
00174 TAO_Incremental_Key_Generator> user_id_hash_map;
00175
00176
00177 typedef ACE_Map_Manager_Adapter<
00178 PortableServer::ObjectId,
00179 TAO_Active_Object_Map_Entry *,
00180 TAO_Incremental_Key_Generator> user_id_linear_map;
00181
00182
00183 typedef ACE_Active_Map_Manager_Adapter<
00184 PortableServer::ObjectId,
00185 TAO_Active_Object_Map_Entry *,
00186 TAO_Ignore_Original_Key_Adapter> user_id_active_map;
00187
00188
00189 typedef ACE_Map<
00190 PortableServer::Servant,
00191 TAO_Active_Object_Map_Entry *> servant_map;
00192
00193
00194 typedef ACE_Hash_Map_Manager_Ex_Adapter<
00195 PortableServer::Servant,
00196 TAO_Active_Object_Map_Entry *,
00197 TAO_Servant_Hash,
00198 ACE_Equal_To<PortableServer::Servant>,
00199 ACE_Noop_Key_Generator<PortableServer::Servant> > servant_hash_map;
00200
00201 #if (TAO_HAS_MINIMUM_POA_MAPS == 0)
00202
00203 typedef ACE_Map_Manager_Adapter<
00204 PortableServer::Servant,
00205 TAO_Active_Object_Map_Entry *,
00206 ACE_Noop_Key_Generator<PortableServer::Servant> > servant_linear_map;
00207 #endif
00208
00209
00210 user_id_map *user_id_map_;
00211
00212
00213 servant_map *servant_map_;
00214
00215
00216 TAO_Id_Uniqueness_Strategy *id_uniqueness_strategy_;
00217
00218
00219 TAO_Lifespan_Strategy *lifespan_strategy_;
00220
00221
00222 TAO_Id_Assignment_Strategy *id_assignment_strategy_;
00223
00224
00225 TAO_Id_Hint_Strategy *id_hint_strategy_;
00226
00227
00228
00229 bool using_active_maps_;
00230
00231
00232 static size_t system_id_size_;
00233 };
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243 class TAO_Id_Uniqueness_Strategy
00244 {
00245 public:
00246
00247 virtual ~TAO_Id_Uniqueness_Strategy (void);
00248
00249
00250 virtual int is_servant_in_map (PortableServer::Servant servant,
00251 bool &deactivated) = 0;
00252
00253
00254
00255 virtual int unbind_using_user_id (const PortableServer::ObjectId &user_id) = 0;
00256
00257
00258
00259 virtual int find_user_id_using_servant (PortableServer::Servant servant,
00260 PortableServer::ObjectId_out user_id) = 0;
00261
00262
00263
00264 virtual int find_system_id_using_servant (PortableServer::Servant servant,
00265 PortableServer::ObjectId_out system_id,
00266 CORBA::Short &priority) = 0;
00267
00268
00269
00270 virtual int bind_using_user_id (PortableServer::Servant servant,
00271 const PortableServer::ObjectId &user_id,
00272 CORBA::Short priority,
00273 TAO_Active_Object_Map_Entry *&entry) = 0;
00274
00275
00276
00277 virtual CORBA::Boolean remaining_activations (PortableServer::Servant servant) = 0;
00278
00279
00280 void set_active_object_map (TAO_Active_Object_Map *active_object_map);
00281
00282 protected:
00283
00284
00285 TAO_Active_Object_Map *active_object_map_;
00286 };
00287
00288
00289
00290
00291
00292
00293
00294
00295 class TAO_Unique_Id_Strategy : public TAO_Id_Uniqueness_Strategy
00296 {
00297 public:
00298
00299
00300 virtual int is_servant_in_map (PortableServer::Servant servant,
00301 bool &deactivated);
00302
00303
00304
00305 virtual int unbind_using_user_id (const PortableServer::ObjectId &user_id);
00306
00307
00308
00309 virtual int find_user_id_using_servant (PortableServer::Servant servant,
00310 PortableServer::ObjectId_out user_id);
00311
00312
00313
00314 virtual int find_system_id_using_servant (PortableServer::Servant servant,
00315 PortableServer::ObjectId_out system_id,
00316 CORBA::Short &priority);
00317
00318
00319
00320 virtual int bind_using_user_id (PortableServer::Servant servant,
00321 const PortableServer::ObjectId &user_id,
00322 CORBA::Short priority,
00323 TAO_Active_Object_Map_Entry *&entry);
00324
00325
00326
00327 virtual CORBA::Boolean remaining_activations (PortableServer::Servant servant);
00328 };
00329
00330 #if !defined (CORBA_E_MICRO)
00331
00332
00333
00334
00335
00336
00337
00338 class TAO_Multiple_Id_Strategy : public TAO_Id_Uniqueness_Strategy
00339 {
00340 public:
00341
00342
00343 virtual int is_servant_in_map (PortableServer::Servant servant,
00344 bool &deactivated);
00345
00346
00347
00348 virtual int unbind_using_user_id (const PortableServer::ObjectId &user_id);
00349
00350
00351
00352 virtual int find_user_id_using_servant (PortableServer::Servant servant,
00353 PortableServer::ObjectId_out user_id);
00354
00355
00356
00357 virtual int find_system_id_using_servant (PortableServer::Servant servant,
00358 PortableServer::ObjectId_out system_id,
00359 CORBA::Short &priority);
00360
00361
00362
00363 virtual int bind_using_user_id (PortableServer::Servant servant,
00364 const PortableServer::ObjectId &user_id,
00365 CORBA::Short priority,
00366 TAO_Active_Object_Map_Entry *&entry);
00367
00368
00369
00370 virtual CORBA::Boolean remaining_activations (PortableServer::Servant servant);
00371 };
00372 #endif
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382 class TAO_Lifespan_Strategy
00383 {
00384 public:
00385
00386
00387 virtual ~TAO_Lifespan_Strategy (void);
00388
00389
00390 virtual int find_servant_using_system_id_and_user_id (const PortableServer::ObjectId &system_id,
00391 const PortableServer::ObjectId &user_id,
00392 PortableServer::Servant &servant,
00393 TAO_Active_Object_Map_Entry *&entry) = 0;
00394
00395
00396 void set_active_object_map (TAO_Active_Object_Map *active_object_map);
00397
00398 protected:
00399
00400
00401 TAO_Active_Object_Map *active_object_map_;
00402 };
00403
00404
00405
00406
00407
00408
00409
00410
00411 class TAO_Transient_Strategy : public TAO_Lifespan_Strategy
00412 {
00413 public:
00414
00415 virtual int find_servant_using_system_id_and_user_id (const PortableServer::ObjectId &system_id,
00416 const PortableServer::ObjectId &user_id,
00417 PortableServer::Servant &servant,
00418 TAO_Active_Object_Map_Entry *&entry);
00419 };
00420
00421 #if !defined (CORBA_E_MICRO)
00422
00423
00424
00425
00426
00427
00428
00429 class TAO_Persistent_Strategy : public TAO_Lifespan_Strategy
00430 {
00431 public:
00432
00433 virtual int find_servant_using_system_id_and_user_id (const PortableServer::ObjectId &system_id,
00434 const PortableServer::ObjectId &user_id,
00435 PortableServer::Servant &servant,
00436 TAO_Active_Object_Map_Entry *&entry);
00437
00438 };
00439 #endif
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449 class TAO_Id_Assignment_Strategy
00450 {
00451 public:
00452
00453 virtual ~TAO_Id_Assignment_Strategy (void);
00454
00455
00456 virtual int bind_using_system_id (PortableServer::Servant servant,
00457 CORBA::Short priority,
00458 TAO_Active_Object_Map_Entry *&entry) = 0;
00459
00460
00461 void set_active_object_map (TAO_Active_Object_Map *active_object_map);
00462
00463 protected:
00464
00465
00466 TAO_Active_Object_Map *active_object_map_;
00467 };
00468
00469 #if !defined (CORBA_E_MICRO)
00470
00471
00472
00473
00474
00475
00476
00477 class TAO_User_Id_Strategy : public TAO_Id_Assignment_Strategy
00478 {
00479 public:
00480
00481 virtual int bind_using_system_id (PortableServer::Servant servant,
00482 CORBA::Short priority,
00483 TAO_Active_Object_Map_Entry *&entry);
00484 };
00485 #endif
00486
00487
00488
00489
00490
00491
00492
00493
00494 class TAO_System_Id_With_Unique_Id_Strategy : public TAO_Id_Assignment_Strategy
00495 {
00496 public:
00497
00498 virtual int bind_using_system_id (PortableServer::Servant servant,
00499 CORBA::Short priority,
00500 TAO_Active_Object_Map_Entry *&entry);
00501 };
00502
00503 #if !defined (CORBA_E_MICRO)
00504
00505
00506
00507
00508
00509
00510
00511 class TAO_System_Id_With_Multiple_Id_Strategy : public TAO_Id_Assignment_Strategy
00512 {
00513 public:
00514
00515 virtual int bind_using_system_id (PortableServer::Servant servant,
00516 CORBA::Short priority,
00517 TAO_Active_Object_Map_Entry *&entry);
00518 };
00519 #endif
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529 class TAO_Id_Hint_Strategy
00530 {
00531 public:
00532
00533 virtual ~TAO_Id_Hint_Strategy (void);
00534
00535
00536 virtual int recover_key (const PortableServer::ObjectId &system_id,
00537 PortableServer::ObjectId &user_id) = 0;
00538
00539
00540 virtual int bind (TAO_Active_Object_Map_Entry &entry) = 0;
00541
00542
00543 virtual int unbind (TAO_Active_Object_Map_Entry &entry) = 0;
00544
00545
00546 virtual int find (const PortableServer::ObjectId &system_id,
00547 TAO_Active_Object_Map_Entry *&entry) = 0;
00548
00549
00550 virtual size_t hint_size (void) = 0;
00551
00552
00553 virtual int system_id (PortableServer::ObjectId_out system_id,
00554 TAO_Active_Object_Map_Entry &entry) = 0;
00555 };
00556
00557
00558
00559
00560
00561
00562
00563
00564 class TAO_Active_Hint_Strategy : public TAO_Id_Hint_Strategy
00565 {
00566 public:
00567 TAO_Active_Hint_Strategy (CORBA::ULong map_size);
00568
00569
00570 virtual ~TAO_Active_Hint_Strategy (void);
00571
00572 virtual int recover_key (const PortableServer::ObjectId &system_id,
00573 PortableServer::ObjectId &user_id);
00574
00575 virtual int bind (TAO_Active_Object_Map_Entry &entry);
00576
00577 virtual int unbind (TAO_Active_Object_Map_Entry &entry);
00578
00579 virtual int find (const PortableServer::ObjectId &system_id,
00580 TAO_Active_Object_Map_Entry *&entry);
00581
00582 virtual size_t hint_size (void);
00583
00584 virtual int system_id (PortableServer::ObjectId_out system_id,
00585 TAO_Active_Object_Map_Entry &entry);
00586
00587 typedef ACE_Active_Map_Manager_Adapter<
00588 PortableServer::ObjectId,
00589 TAO_Active_Object_Map_Entry *,
00590 TAO_Preserve_Original_Key_Adapter> system_id_map;
00591
00592 system_id_map system_id_map_;
00593 };
00594
00595
00596
00597
00598
00599
00600
00601
00602 class TAO_No_Hint_Strategy : public TAO_Id_Hint_Strategy
00603 {
00604 public:
00605
00606 virtual ~TAO_No_Hint_Strategy (void);
00607
00608 virtual int recover_key (const PortableServer::ObjectId &system_id,
00609 PortableServer::ObjectId &user_id);
00610
00611 virtual int bind (TAO_Active_Object_Map_Entry &entry);
00612
00613 virtual int unbind (TAO_Active_Object_Map_Entry &entry);
00614
00615 virtual int find (const PortableServer::ObjectId &system_id,
00616 TAO_Active_Object_Map_Entry *&entry);
00617
00618 virtual size_t hint_size (void);
00619
00620 virtual int system_id (PortableServer::ObjectId_out system_id,
00621 TAO_Active_Object_Map_Entry &entry);
00622 };
00623
00624 TAO_END_VERSIONED_NAMESPACE_DECL
00625
00626 #if defined (__ACE_INLINE__)
00627 # include "tao/PortableServer/Active_Object_Map.inl"
00628 #endif
00629
00630 #include "ace/post.h"
00631
00632 #endif