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 ACE_ENV_ARG_DECL);
00055
00056
00057 ~TAO_Active_Object_Map (void);
00058
00059
00060 int is_servant_in_map (PortableServer::Servant servant,
00061 int &deactivated);
00062
00063
00064
00065 int is_user_id_in_map (const PortableServer::ObjectId &user_id,
00066 CORBA::Short priority,
00067 int &priorities_match,
00068 int &deactivated);
00069
00070
00071 int bind_using_system_id_returning_system_id (PortableServer::Servant servant,
00072 CORBA::Short priority,
00073 PortableServer::ObjectId_out system_id);
00074
00075
00076 int bind_using_system_id_returning_user_id (PortableServer::Servant servant,
00077 CORBA::Short priority,
00078 PortableServer::ObjectId_out user_id);
00079
00080
00081
00082 int bind_using_user_id (PortableServer::Servant servant,
00083 const PortableServer::ObjectId &user_id,
00084 CORBA::Short priority);
00085
00086
00087
00088 int find_system_id_using_user_id (const PortableServer::ObjectId &user_id,
00089 CORBA::Short priority,
00090 PortableServer::ObjectId_out system_id);
00091
00092
00093 int rebind_using_user_id_and_system_id (PortableServer::Servant servant,
00094 const PortableServer::ObjectId &user_id,
00095 const PortableServer::ObjectId &system_id,
00096 TAO_Active_Object_Map_Entry *&entry);
00097
00098
00099
00100 int unbind_using_user_id (const PortableServer::ObjectId &user_id);
00101
00102
00103
00104 int find_user_id_using_servant (PortableServer::Servant servant,
00105 PortableServer::ObjectId_out user_id);
00106
00107
00108
00109 int find_system_id_using_servant (PortableServer::Servant servant,
00110 PortableServer::ObjectId_out system_id,
00111 CORBA::Short &priority);
00112
00113
00114
00115 int find_servant_using_user_id (const PortableServer::ObjectId &user_id,
00116 PortableServer::Servant &servant);
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 #if (TAO_HAS_MINIMUM_POA_MAPS == 0)
00177
00178 typedef ACE_Map_Manager_Adapter<
00179 PortableServer::ObjectId,
00180 TAO_Active_Object_Map_Entry *,
00181 TAO_Incremental_Key_Generator> user_id_linear_map;
00182 #endif
00183
00184
00185 typedef ACE_Active_Map_Manager_Adapter<
00186 PortableServer::ObjectId,
00187 TAO_Active_Object_Map_Entry *,
00188 TAO_Ignore_Original_Key_Adapter> user_id_active_map;
00189
00190
00191 typedef ACE_Map<
00192 PortableServer::Servant,
00193 TAO_Active_Object_Map_Entry *> servant_map;
00194
00195
00196 typedef ACE_Hash_Map_Manager_Ex_Adapter<
00197 PortableServer::Servant,
00198 TAO_Active_Object_Map_Entry *,
00199 TAO_Servant_Hash,
00200 ACE_Equal_To<PortableServer::Servant>,
00201 ACE_Noop_Key_Generator<PortableServer::Servant> > servant_hash_map;
00202
00203 #if (TAO_HAS_MINIMUM_POA_MAPS == 0)
00204
00205 typedef ACE_Map_Manager_Adapter<
00206 PortableServer::Servant,
00207 TAO_Active_Object_Map_Entry *,
00208 ACE_Noop_Key_Generator<PortableServer::Servant> > servant_linear_map;
00209 #endif
00210
00211
00212 user_id_map *user_id_map_;
00213
00214
00215 servant_map *servant_map_;
00216
00217
00218 TAO_Id_Uniqueness_Strategy *id_uniqueness_strategy_;
00219
00220
00221 TAO_Lifespan_Strategy *lifespan_strategy_;
00222
00223
00224 TAO_Id_Assignment_Strategy *id_assignment_strategy_;
00225
00226
00227 TAO_Id_Hint_Strategy *id_hint_strategy_;
00228
00229
00230
00231 int using_active_maps_;
00232
00233
00234 static size_t system_id_size_;
00235 };
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245 class TAO_Id_Uniqueness_Strategy
00246 {
00247 public:
00248
00249 virtual ~TAO_Id_Uniqueness_Strategy (void);
00250
00251
00252 virtual int is_servant_in_map (PortableServer::Servant servant,
00253 int &deactivated) = 0;
00254
00255
00256
00257 virtual int unbind_using_user_id (const PortableServer::ObjectId &user_id) = 0;
00258
00259
00260
00261 virtual int find_user_id_using_servant (PortableServer::Servant servant,
00262 PortableServer::ObjectId_out user_id) = 0;
00263
00264
00265
00266 virtual int find_system_id_using_servant (PortableServer::Servant servant,
00267 PortableServer::ObjectId_out system_id,
00268 CORBA::Short &priority) = 0;
00269
00270
00271
00272 virtual int bind_using_user_id (PortableServer::Servant servant,
00273 const PortableServer::ObjectId &user_id,
00274 CORBA::Short priority,
00275 TAO_Active_Object_Map_Entry *&entry) = 0;
00276
00277
00278
00279 virtual CORBA::Boolean remaining_activations (PortableServer::Servant servant) = 0;
00280
00281
00282 void set_active_object_map (TAO_Active_Object_Map *active_object_map);
00283
00284 protected:
00285
00286
00287 TAO_Active_Object_Map *active_object_map_;
00288 };
00289
00290
00291
00292
00293
00294
00295
00296
00297 class TAO_Unique_Id_Strategy : public TAO_Id_Uniqueness_Strategy
00298 {
00299 public:
00300
00301
00302 virtual int is_servant_in_map (PortableServer::Servant servant,
00303 int &deactivated);
00304
00305
00306
00307 virtual int unbind_using_user_id (const PortableServer::ObjectId &user_id);
00308
00309
00310
00311 virtual int find_user_id_using_servant (PortableServer::Servant servant,
00312 PortableServer::ObjectId_out user_id);
00313
00314
00315
00316 virtual int find_system_id_using_servant (PortableServer::Servant servant,
00317 PortableServer::ObjectId_out system_id,
00318 CORBA::Short &priority);
00319
00320
00321
00322 virtual int bind_using_user_id (PortableServer::Servant servant,
00323 const PortableServer::ObjectId &user_id,
00324 CORBA::Short priority,
00325 TAO_Active_Object_Map_Entry *&entry);
00326
00327
00328
00329 virtual CORBA::Boolean remaining_activations (PortableServer::Servant servant);
00330 };
00331
00332
00333
00334
00335
00336
00337
00338
00339 class TAO_Multiple_Id_Strategy : public TAO_Id_Uniqueness_Strategy
00340 {
00341 public:
00342
00343
00344 virtual int is_servant_in_map (PortableServer::Servant servant,
00345 int &deactivated);
00346
00347
00348
00349 virtual int unbind_using_user_id (const PortableServer::ObjectId &user_id);
00350
00351
00352
00353 virtual int find_user_id_using_servant (PortableServer::Servant servant,
00354 PortableServer::ObjectId_out user_id);
00355
00356
00357
00358 virtual int find_system_id_using_servant (PortableServer::Servant servant,
00359 PortableServer::ObjectId_out system_id,
00360 CORBA::Short &priority);
00361
00362
00363
00364 virtual int bind_using_user_id (PortableServer::Servant servant,
00365 const PortableServer::ObjectId &user_id,
00366 CORBA::Short priority,
00367 TAO_Active_Object_Map_Entry *&entry);
00368
00369
00370
00371 virtual CORBA::Boolean remaining_activations (PortableServer::Servant servant);
00372 };
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
00422
00423
00424
00425
00426
00427
00428 class TAO_Persistent_Strategy : public TAO_Lifespan_Strategy
00429 {
00430 public:
00431
00432 virtual int find_servant_using_system_id_and_user_id (const PortableServer::ObjectId &system_id,
00433 const PortableServer::ObjectId &user_id,
00434 PortableServer::Servant &servant,
00435 TAO_Active_Object_Map_Entry *&entry);
00436
00437 };
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447 class TAO_Id_Assignment_Strategy
00448 {
00449 public:
00450
00451 virtual ~TAO_Id_Assignment_Strategy (void);
00452
00453
00454 virtual int bind_using_system_id (PortableServer::Servant servant,
00455 CORBA::Short priority,
00456 TAO_Active_Object_Map_Entry *&entry) = 0;
00457
00458
00459 void set_active_object_map (TAO_Active_Object_Map *active_object_map);
00460
00461 protected:
00462
00463
00464 TAO_Active_Object_Map *active_object_map_;
00465 };
00466
00467
00468
00469
00470
00471
00472
00473
00474 class TAO_User_Id_Strategy : public TAO_Id_Assignment_Strategy
00475 {
00476 public:
00477
00478 virtual int bind_using_system_id (PortableServer::Servant servant,
00479 CORBA::Short priority,
00480 TAO_Active_Object_Map_Entry *&entry);
00481 };
00482
00483
00484
00485
00486
00487
00488
00489
00490 class TAO_System_Id_With_Unique_Id_Strategy : public TAO_Id_Assignment_Strategy
00491 {
00492 public:
00493
00494 virtual int bind_using_system_id (PortableServer::Servant servant,
00495 CORBA::Short priority,
00496 TAO_Active_Object_Map_Entry *&entry);
00497 };
00498
00499
00500
00501
00502
00503
00504
00505
00506 class TAO_System_Id_With_Multiple_Id_Strategy : public TAO_Id_Assignment_Strategy
00507 {
00508 public:
00509
00510 virtual int bind_using_system_id (PortableServer::Servant servant,
00511 CORBA::Short priority,
00512 TAO_Active_Object_Map_Entry *&entry);
00513 };
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523 class TAO_Id_Hint_Strategy
00524 {
00525 public:
00526
00527 virtual ~TAO_Id_Hint_Strategy (void);
00528
00529
00530 virtual int recover_key (const PortableServer::ObjectId &system_id,
00531 PortableServer::ObjectId &user_id) = 0;
00532
00533
00534 virtual int bind (TAO_Active_Object_Map_Entry &entry) = 0;
00535
00536
00537 virtual int unbind (TAO_Active_Object_Map_Entry &entry) = 0;
00538
00539
00540 virtual int find (const PortableServer::ObjectId &system_id,
00541 TAO_Active_Object_Map_Entry *&entry) = 0;
00542
00543
00544 virtual size_t hint_size (void) = 0;
00545
00546
00547 virtual int system_id (PortableServer::ObjectId_out system_id,
00548 TAO_Active_Object_Map_Entry &entry) = 0;
00549 };
00550
00551
00552
00553
00554
00555
00556
00557
00558 class TAO_Active_Hint_Strategy : public TAO_Id_Hint_Strategy
00559 {
00560 public:
00561 TAO_Active_Hint_Strategy (CORBA::ULong map_size);
00562
00563
00564 virtual ~TAO_Active_Hint_Strategy (void);
00565
00566 virtual int recover_key (const PortableServer::ObjectId &system_id,
00567 PortableServer::ObjectId &user_id);
00568
00569 virtual int bind (TAO_Active_Object_Map_Entry &entry);
00570
00571 virtual int unbind (TAO_Active_Object_Map_Entry &entry);
00572
00573 virtual int find (const PortableServer::ObjectId &system_id,
00574 TAO_Active_Object_Map_Entry *&entry);
00575
00576 virtual size_t hint_size (void);
00577
00578 virtual int system_id (PortableServer::ObjectId_out system_id,
00579 TAO_Active_Object_Map_Entry &entry);
00580
00581 typedef ACE_Active_Map_Manager_Adapter<
00582 PortableServer::ObjectId,
00583 TAO_Active_Object_Map_Entry *,
00584 TAO_Preserve_Original_Key_Adapter> system_id_map;
00585
00586 system_id_map system_id_map_;
00587 };
00588
00589
00590
00591
00592
00593
00594
00595
00596 class TAO_No_Hint_Strategy : public TAO_Id_Hint_Strategy
00597 {
00598 public:
00599
00600 virtual ~TAO_No_Hint_Strategy (void);
00601
00602 virtual int recover_key (const PortableServer::ObjectId &system_id,
00603 PortableServer::ObjectId &user_id);
00604
00605 virtual int bind (TAO_Active_Object_Map_Entry &entry);
00606
00607 virtual int unbind (TAO_Active_Object_Map_Entry &entry);
00608
00609 virtual int find (const PortableServer::ObjectId &system_id,
00610 TAO_Active_Object_Map_Entry *&entry);
00611
00612 virtual size_t hint_size (void);
00613
00614 virtual int system_id (PortableServer::ObjectId_out system_id,
00615 TAO_Active_Object_Map_Entry &entry);
00616 };
00617
00618 TAO_END_VERSIONED_NAMESPACE_DECL
00619
00620 #if defined (__ACE_INLINE__)
00621 # include "tao/PortableServer/Active_Object_Map.i"
00622 #endif
00623
00624 #include "ace/post.h"
00625
00626 #endif