=default for generated implementation copy ctor
[ACE_TAO.git] / TAO / tao / PortableServer / Active_Object_Map.h
blob7c9bdca71da8696123ebde4aa23f6b806d20cbaa
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Active_Object_Map.h
7 * @author Irfan Pyarali
8 */
9 //=============================================================================
12 #ifndef TAO_ACTIVE_OBJECT_MAP_H
13 #define TAO_ACTIVE_OBJECT_MAP_H
15 #include /**/ "ace/pre.h"
17 #include "tao/PortableServer/Key_Adapters.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 # pragma once
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "tao/PortableServer/Servant_Base.h"
24 #include "tao/Server_Strategy_Factory.h"
25 #include "ace/Map_T.h"
26 #include <memory>
28 #if defined (TAO_HAS_MONITOR_POINTS) && (TAO_HAS_MONITOR_POINTS == 1)
29 #include "ace/Monitor_Size.h"
30 #endif /* TAO_HAS_MONITOR_POINTS==1 */
32 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
34 // Forward declarations.
35 class TAO_Id_Uniqueness_Strategy;
36 class TAO_Lifespan_Strategy;
37 class TAO_Id_Assignment_Strategy;
38 class TAO_Id_Hint_Strategy;
39 struct TAO_Active_Object_Map_Entry;
41 /**
42 * @class TAO_Active_Object_Map
44 * @brief Map of object ids to servants.
46 * Implementation to be used by the POA.
48 class TAO_Active_Object_Map
50 public:
51 /// Constructor.
52 TAO_Active_Object_Map (
53 int user_id_policy,
54 int unique_id_policy,
55 int persistent_id_policy,
56 const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters);
58 /// Destructor.
59 ~TAO_Active_Object_Map ();
61 /// Must be used with UNIQUE_ID policy.
62 int
63 is_servant_in_map (PortableServer::Servant servant,
64 bool &deactivated);
66 /// Can be used with any policy. With the SYSTEM_ID policy,
67 /// user_id is actually system_id.
68 bool
69 is_user_id_in_map (const PortableServer::ObjectId &user_id,
70 CORBA::Short priority,
71 bool &priorities_match,
72 bool &deactivated);
74 /// Must be used with SYSTEM_ID policy.
75 int
76 bind_using_system_id_returning_system_id (
77 PortableServer::Servant servant,
78 CORBA::Short priority,
79 PortableServer::ObjectId_out system_id);
81 /// Must be used with SYSTEM_ID policy.
82 int
83 bind_using_system_id_returning_user_id (
84 PortableServer::Servant servant,
85 CORBA::Short priority,
86 PortableServer::ObjectId_out user_id);
88 /// Can be used with any policy. With the SYSTEM_ID policy,
89 /// user_id is actually system_id.
90 int
91 bind_using_user_id (PortableServer::Servant servant,
92 const PortableServer::ObjectId &user_id,
93 CORBA::Short priority);
95 /// Can be used with any policy. With the SYSTEM_ID policy,
96 /// user_id is actually system_id.
97 int
98 find_system_id_using_user_id (const PortableServer::ObjectId &user_id,
99 CORBA::Short priority,
100 PortableServer::ObjectId_out system_id);
102 /// Can be used with any policy.
104 rebind_using_user_id_and_system_id (
105 PortableServer::Servant servant,
106 const PortableServer::ObjectId &user_id,
107 const PortableServer::ObjectId &system_id,
108 TAO_Active_Object_Map_Entry *&entry);
110 /// Can be used with any policy. With the SYSTEM_ID policy,
111 /// user_id is actually system_id.
113 unbind_using_user_id (const PortableServer::ObjectId &user_id);
115 /// Must be used with UNIQUE_ID policy. With the SYSTEM_ID policy,
116 /// user_id is actually system_id.
118 find_user_id_using_servant (PortableServer::Servant servant,
119 PortableServer::ObjectId_out user_id);
121 /// Must be used with UNIQUE_ID policy. With the SYSTEM_ID policy,
122 /// user_id is actually system_id.
124 find_system_id_using_servant (PortableServer::Servant servant,
125 PortableServer::ObjectId_out system_id,
126 CORBA::Short &priority);
128 /// Can be used with any policy. With the SYSTEM_ID policy,
129 /// user_id is actually system_id.
131 find_servant_using_user_id (const PortableServer::ObjectId &user_id,
132 PortableServer::Servant &servant);
135 /// Can be used with any policy.
137 find_servant_using_system_id_and_user_id (
138 const PortableServer::ObjectId &system_id,
139 const PortableServer::ObjectId &user_id,
140 PortableServer::Servant &servant,
141 TAO_Active_Object_Map_Entry *&entry);
143 /// Can be used with any policy. With the SYSTEM_ID policy,
144 /// @a user_id is identical to @a system_id.
146 find_servant_and_system_id_using_user_id (
147 const PortableServer::ObjectId &user_id,
148 PortableServer::Servant &servant,
149 PortableServer::ObjectId_out system_id,
150 CORBA::Short &priority);
152 /// Can be used with any policy. With the SYSTEM_ID policy,
153 /// @a user_id is identical to @c system_id.
155 * @retval -1 Entry is not found or is deactivated.
156 * @retval 0 Entry is found.
159 find_entry_using_user_id (const PortableServer::ObjectId &user_id,
160 TAO_Active_Object_Map_Entry *&entry);
162 /// Can be used with any policy. When the SYSTEM_ID policy is used,
163 /// the @a system_id is identical to @a user_id.
165 find_user_id_using_system_id (const PortableServer::ObjectId &system_id,
166 PortableServer::ObjectId_out user_id);
168 /// Can be used with any policy. When the SYSTEM_ID policy is used,
169 /// the @a system_id is identical to @a user_id.
171 find_user_id_using_system_id (const PortableServer::ObjectId &system_id,
172 PortableServer::ObjectId &user_id);
174 /// Are there any remaining activations of @a servant in the active
175 /// object map? Can be used with any policy.
176 CORBA::Boolean
177 remaining_activations (PortableServer::Servant servant);
179 /// Size of the map.
180 size_t
181 current_size ();
183 /// Can be used with any policy.
184 static size_t
185 system_id_size ();
187 /// Set the system id size.
188 static void
189 set_system_id_size (
190 const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters);
192 /// Base class of the id map.
193 typedef ACE_Map<
194 PortableServer::ObjectId,
195 TAO_Active_Object_Map_Entry *> user_id_map;
197 /// Id hash map.
198 typedef ACE_Hash_Map_Manager_Ex_Adapter<
199 PortableServer::ObjectId,
200 TAO_Active_Object_Map_Entry *,
201 TAO_ObjectId_Hash,
202 ACE_Equal_To<PortableServer::ObjectId>,
203 TAO_Incremental_Key_Generator> user_id_hash_map;
205 /// Id linear map.
206 typedef ACE_Map_Manager_Adapter<
207 PortableServer::ObjectId,
208 TAO_Active_Object_Map_Entry *,
209 TAO_Incremental_Key_Generator> user_id_linear_map;
211 /// Id active map.
212 typedef ACE_Active_Map_Manager_Adapter<
213 PortableServer::ObjectId,
214 TAO_Active_Object_Map_Entry *,
215 TAO_Ignore_Original_Key_Adapter> user_id_active_map;
217 /// Base class of the servant map.
218 typedef ACE_Map<
219 PortableServer::Servant,
220 TAO_Active_Object_Map_Entry *> servant_map;
222 /// Servant hash map.
223 typedef ACE_Hash_Map_Manager_Ex_Adapter<
224 PortableServer::Servant,
225 TAO_Active_Object_Map_Entry *,
226 TAO_Servant_Hash,
227 ACE_Equal_To<PortableServer::Servant>,
228 ACE_Noop_Key_Generator<PortableServer::Servant> > servant_hash_map;
230 #if (TAO_HAS_MINIMUM_POA_MAPS == 0)
231 /// Servant linear map.
232 typedef ACE_Map_Manager_Adapter<
233 PortableServer::Servant,
234 TAO_Active_Object_Map_Entry *,
235 ACE_Noop_Key_Generator<PortableServer::Servant> > servant_linear_map;
236 #endif /* TAO_HAS_MINIMUM_POA_MAPS == 0 */
238 /// Id map.
239 std::unique_ptr<user_id_map> user_id_map_;
241 /// Servant map.
242 std::unique_ptr<servant_map> servant_map_;
244 /// Id uniqueness strategy.
245 std::unique_ptr<TAO_Id_Uniqueness_Strategy> id_uniqueness_strategy_;
247 /// Lifespan strategy.
248 std::unique_ptr<TAO_Lifespan_Strategy> lifespan_strategy_;
250 /// Id assignment strategy.
251 std::unique_ptr<TAO_Id_Assignment_Strategy> id_assignment_strategy_;
253 /// Id hint strategy.
254 std::unique_ptr<TAO_Id_Hint_Strategy> id_hint_strategy_;
256 /// Flag to see if we are using active maps in this active object
257 /// map.
258 bool using_active_maps_;
260 /// Size of the system id produced by the map.
261 static size_t system_id_size_;
263 #if defined (TAO_HAS_MONITOR_POINTS) && (TAO_HAS_MONITOR_POINTS == 1)
264 ACE::Monitor_Control::Size_Monitor *monitor_;
265 #endif /* TAO_HAS_MONITOR_POINTS==1 */
269 * @class TAO_Id_Uniqueness_Strategy
271 * @brief Id uniqueness strategy.
273 * Strategy for implementing points of variation between the
274 * UNIQUE_ID and the MULTIPLE_ID policies.
276 class TAO_Id_Uniqueness_Strategy
278 public:
279 /// Virtual destructor.
280 virtual ~TAO_Id_Uniqueness_Strategy () = default;
282 /// Must be used with UNIQUE_ID policy.
283 virtual int
284 is_servant_in_map (PortableServer::Servant servant,
285 bool &deactivated) = 0;
287 /// Can be used with any policy. With the SYSTEM_ID policy,
288 /// @a user_id is actually @c system_id.
289 virtual int
290 unbind_using_user_id (const PortableServer::ObjectId &user_id) = 0;
292 /// Must be used with UNIQUE_ID policy. With the SYSTEM_ID policy,
293 /// @a user_id is actually @c system_id.
294 virtual int
295 find_user_id_using_servant (PortableServer::Servant servant,
296 PortableServer::ObjectId_out user_id) = 0;
298 /// Must be used with UNIQUE_ID policy. With the SYSTEM_ID policy,
299 /// <user_id> is actually @a system_id.
300 virtual int
301 find_system_id_using_servant (PortableServer::Servant servant,
302 PortableServer::ObjectId_out system_id,
303 CORBA::Short &priority) = 0;
305 /// Can be used with any policy. With the SYSTEM_ID policy,
306 /// @a user_id is actually @c system_id.
307 virtual int
308 bind_using_user_id (PortableServer::Servant servant,
309 const PortableServer::ObjectId &user_id,
310 CORBA::Short priority,
311 TAO_Active_Object_Map_Entry *&entry) = 0;
313 /// Are there any remaining activations of @a servant in the active
314 /// object map? Can be used with any policy.
315 virtual CORBA::Boolean
316 remaining_activations (PortableServer::Servant servant) = 0;
318 /// Set the active map.
319 void
320 set_active_object_map (TAO_Active_Object_Map *active_object_map);
322 protected:
323 /// Pointer to the active map.
324 TAO_Active_Object_Map *active_object_map_;
328 * @class TAO_Unique_Id_Strategy
330 * @brief Unique id strategy.
332 * Strategy for the UNIQUE_ID policy.
334 class TAO_Unique_Id_Strategy : public TAO_Id_Uniqueness_Strategy
336 public:
337 /// Must be used with UNIQUE_ID policy.
338 virtual int
339 is_servant_in_map (PortableServer::Servant servant,
340 bool &deactivated);
342 /// Can be used with any policy. With the SYSTEM_ID policy,
343 /// @a user_id is actually @c system_id.
344 virtual int
345 unbind_using_user_id (const PortableServer::ObjectId &user_id);
347 /// Must be used with UNIQUE_ID policy. With the SYSTEM_ID policy,
348 /// @a user_id is actually @c system_id.
349 virtual int
350 find_user_id_using_servant (PortableServer::Servant servant,
351 PortableServer::ObjectId_out user_id);
353 /// Must be used with UNIQUE_ID policy. With the SYSTEM_ID policy,
354 /// <user_id> is actually @a system_id.
355 virtual int
356 find_system_id_using_servant (PortableServer::Servant servant,
357 PortableServer::ObjectId_out system_id,
358 CORBA::Short &priority);
360 /// Can be used with any policy. With the SYSTEM_ID policy,
361 /// @a user_id is actually @c system_id.
362 virtual int
363 bind_using_user_id (PortableServer::Servant servant,
364 const PortableServer::ObjectId &user_id,
365 CORBA::Short priority,
366 TAO_Active_Object_Map_Entry *&entry);
368 /// Are there any remaining activations of @a servant in the active
369 /// object map? Can be used with any policy.
370 virtual CORBA::Boolean
371 remaining_activations (PortableServer::Servant servant);
374 #if !defined (CORBA_E_MICRO)
376 * @class TAO_Multiple_Id_Strategy
378 * @brief Multiple id strategy.
380 * Strategy for the MULTIPLE_ID policy.
382 class TAO_Multiple_Id_Strategy : public TAO_Id_Uniqueness_Strategy
384 public:
385 /// Must be used with UNIQUE_ID policy.
386 virtual int
387 is_servant_in_map (PortableServer::Servant servant,
388 bool &deactivated);
390 /// Can be used with any policy. With the SYSTEM_ID policy,
391 /// @a user_id is actually @c system_id.
392 virtual int
393 unbind_using_user_id (const PortableServer::ObjectId &user_id);
395 /// Must be used with UNIQUE_ID policy. With the SYSTEM_ID policy,
396 /// @a user_id is actually @c system_id.
397 virtual int
398 find_user_id_using_servant (PortableServer::Servant servant,
399 PortableServer::ObjectId_out user_id);
401 /// Must be used with UNIQUE_ID policy. With the SYSTEM_ID policy,
402 /// <user_id> is actually @a system_id.
403 virtual int
404 find_system_id_using_servant (PortableServer::Servant servant,
405 PortableServer::ObjectId_out system_id,
406 CORBA::Short &priority);
408 /// Can be used with any policy. With the SYSTEM_ID policy,
409 /// @a user_id is actually @c system_id.
410 virtual int
411 bind_using_user_id (PortableServer::Servant servant,
412 const PortableServer::ObjectId &user_id,
413 CORBA::Short priority,
414 TAO_Active_Object_Map_Entry *&entry);
416 /// Are there any remaining activations of @a servant in the active
417 /// object map? Can be used with any policy.
418 virtual CORBA::Boolean
419 remaining_activations (PortableServer::Servant servant);
421 #endif
424 * @class TAO_Lifespan_Strategy
426 * @brief Lifespan strategy.
428 * Strategy for implementing points of variation between the
429 * TRANSIENT and the PERSISTENT policies.
431 class TAO_Lifespan_Strategy
433 public:
434 /// Virtual destructor.
435 virtual ~TAO_Lifespan_Strategy () = default;
437 /// Can be used with any policy.
438 virtual int
439 find_servant_using_system_id_and_user_id (
440 const PortableServer::ObjectId &system_id,
441 const PortableServer::ObjectId &user_id,
442 PortableServer::Servant &servant,
443 TAO_Active_Object_Map_Entry *&entry) = 0;
445 /// Set the active map.
446 void
447 set_active_object_map (TAO_Active_Object_Map *active_object_map);
449 protected:
450 /// Pointer to the active map.
451 TAO_Active_Object_Map *active_object_map_;
455 * @class TAO_Transient_Strategy
457 * @brief Transient strategy.
459 * Strategy for the TRANSIENT policy.
461 class TAO_Transient_Strategy : public TAO_Lifespan_Strategy
463 public:
464 /// Can be used with any policy.
465 virtual int
466 find_servant_using_system_id_and_user_id (
467 const PortableServer::ObjectId &system_id,
468 const PortableServer::ObjectId &user_id,
469 PortableServer::Servant &servant,
470 TAO_Active_Object_Map_Entry *&entry);
473 #if !defined (CORBA_E_MICRO)
475 * @class TAO_Persistent_Strategy
477 * @brief Persistent strategy.
479 * Strategy for the PERSISTENT policy.
481 class TAO_Persistent_Strategy : public TAO_Lifespan_Strategy
483 public:
484 /// Can be used with any policy.
485 virtual int
486 find_servant_using_system_id_and_user_id (
487 const PortableServer::ObjectId &system_id,
488 const PortableServer::ObjectId &user_id,
489 PortableServer::Servant &servant,
490 TAO_Active_Object_Map_Entry *&entry);
492 #endif
495 * @class TAO_Id_Assignment_Strategy
497 * @brief Id uniqueness strategy.
499 * Strategy for implementing points of variation between the
500 * USER_ID and the SYSTEM_ID policies.
502 class TAO_Id_Assignment_Strategy
504 public:
505 /// Virtual destructor.
506 virtual ~TAO_Id_Assignment_Strategy () = default;
508 /// Must be used with SYSTEM_ID policy.
509 virtual int
510 bind_using_system_id (PortableServer::Servant servant,
511 CORBA::Short priority,
512 TAO_Active_Object_Map_Entry *&entry) = 0;
514 /// Set the active map.
515 void
516 set_active_object_map (TAO_Active_Object_Map *active_object_map);
518 protected:
519 /// Pointer to the active map.
520 TAO_Active_Object_Map *active_object_map_;
523 #if !defined (CORBA_E_MICRO)
525 * @class TAO_User_Id_Strategy
527 * @brief User id strategy.
529 * Strategy for the USER_ID policy.
531 class TAO_User_Id_Strategy : public TAO_Id_Assignment_Strategy
533 public:
534 /// Must be used with SYSTEM_ID policy.
535 virtual int
536 bind_using_system_id (PortableServer::Servant servant,
537 CORBA::Short priority,
538 TAO_Active_Object_Map_Entry *&entry);
540 #endif
543 * @class TAO_System_Id_With_Unique_Id_Strategy
545 * @brief System id strategy.
547 * Strategy for the SYSTEM_ID policy (with UNIQUE_ID policy).
549 class TAO_System_Id_With_Unique_Id_Strategy
550 : public TAO_Id_Assignment_Strategy
552 public:
553 /// Must be used with SYSTEM_ID policy.
554 virtual int
555 bind_using_system_id (PortableServer::Servant servant,
556 CORBA::Short priority,
557 TAO_Active_Object_Map_Entry *&entry);
560 #if !defined (CORBA_E_MICRO)
562 * @class TAO_System_Id_With_Multiple_Id_Strategy
564 * @brief System id strategy.
566 * Strategy for the SYSTEM_ID policy (with MULTIPLE_ID policy).
568 class TAO_System_Id_With_Multiple_Id_Strategy
569 : public TAO_Id_Assignment_Strategy
571 public:
572 /// Must be used with SYSTEM_ID policy.
573 virtual int
574 bind_using_system_id (PortableServer::Servant servant,
575 CORBA::Short priority,
576 TAO_Active_Object_Map_Entry *&entry);
578 #endif
581 * @class TAO_Id_Hint_Strategy
583 * @brief Id uniqueness strategy.
585 * Strategy for implementing points of variation between the
586 * active hint and the no hint policies.
588 class TAO_Id_Hint_Strategy
590 public:
591 /// Virtual destructor.
592 virtual ~TAO_Id_Hint_Strategy () = default;
594 /// Find the user id from the system id.
595 virtual int
596 recover_key (const PortableServer::ObjectId &system_id,
597 PortableServer::ObjectId &user_id) = 0;
599 /// Add to map.
600 virtual int
601 bind (TAO_Active_Object_Map_Entry &entry) = 0;
603 /// Remove from map.
604 virtual int
605 unbind (TAO_Active_Object_Map_Entry &entry) = 0;
607 /// Find system id.
608 virtual int
609 find (const PortableServer::ObjectId &system_id,
610 TAO_Active_Object_Map_Entry *&entry) = 0;
612 /// How big is the hint generated by this strategy?
613 virtual size_t
614 hint_size () = 0;
616 /// Get the system id associated with this entry.
617 virtual int
618 system_id (PortableServer::ObjectId_out system_id,
619 TAO_Active_Object_Map_Entry &entry) = 0;
623 * @class TAO_Active_Hint_Strategy
625 * @brief Active hint strategy.
627 * Strategy for adding active hints to ids.
629 class TAO_Active_Hint_Strategy : public TAO_Id_Hint_Strategy
631 public:
632 TAO_Active_Hint_Strategy (CORBA::ULong map_size);
634 /// Virtual destructor.
635 virtual ~TAO_Active_Hint_Strategy () = default;
637 virtual int
638 recover_key (const PortableServer::ObjectId &system_id,
639 PortableServer::ObjectId &user_id);
641 virtual int
642 bind (TAO_Active_Object_Map_Entry &entry);
644 virtual int
645 unbind (TAO_Active_Object_Map_Entry &entry);
647 virtual int
648 find (const PortableServer::ObjectId &system_id,
649 TAO_Active_Object_Map_Entry *&entry);
651 virtual size_t
652 hint_size ();
654 virtual int
655 system_id (PortableServer::ObjectId_out system_id,
656 TAO_Active_Object_Map_Entry &entry);
658 typedef ACE_Active_Map_Manager_Adapter<
659 PortableServer::ObjectId,
660 TAO_Active_Object_Map_Entry *,
661 TAO_Preserve_Original_Key_Adapter> system_id_map;
663 system_id_map system_id_map_;
667 * @class TAO_No_Hint_Strategy
669 * @brief No hint strategy.
671 * Strategy for not adding active hints to ids.
673 class TAO_No_Hint_Strategy : public TAO_Id_Hint_Strategy
675 public:
676 /// Virtual destructor.
677 virtual ~TAO_No_Hint_Strategy () = default;
679 virtual int
680 recover_key (const PortableServer::ObjectId &system_id,
681 PortableServer::ObjectId &user_id);
683 virtual int
684 bind (TAO_Active_Object_Map_Entry &entry);
686 virtual int
687 unbind (TAO_Active_Object_Map_Entry &entry);
689 virtual int
690 find (const PortableServer::ObjectId &system_id,
691 TAO_Active_Object_Map_Entry *&entry);
693 virtual size_t
694 hint_size ();
696 virtual int
697 system_id (PortableServer::ObjectId_out system_id,
698 TAO_Active_Object_Map_Entry &entry);
701 TAO_END_VERSIONED_NAMESPACE_DECL
703 #if defined (__ACE_INLINE__)
704 # include "tao/PortableServer/Active_Object_Map.inl"
705 #endif /* __ACE_INLINE__ */
707 #include /**/ "ace/post.h"
709 #endif /* TAO_ACTIVE_OBJECT_MAP_H */