3 //=============================================================================
5 * @file Active_Object_Map.h
7 * @author Irfan Pyarali
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)
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"
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
;
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
52 TAO_Active_Object_Map (
55 int persistent_id_policy
,
56 const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters
&creation_parameters
);
59 ~TAO_Active_Object_Map ();
61 /// Must be used with UNIQUE_ID policy.
63 is_servant_in_map (PortableServer::Servant servant
,
66 /// Can be used with any policy. With the SYSTEM_ID policy,
67 /// user_id is actually system_id.
69 is_user_id_in_map (const PortableServer::ObjectId
&user_id
,
70 CORBA::Short priority
,
71 bool &priorities_match
,
74 /// Must be used with SYSTEM_ID policy.
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.
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.
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.
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.
177 remaining_activations (PortableServer::Servant servant
);
183 /// Can be used with any policy.
187 /// Set the system id size.
190 const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters
&creation_parameters
);
192 /// Base class of the id map.
194 PortableServer::ObjectId
,
195 TAO_Active_Object_Map_Entry
*> user_id_map
;
198 typedef ACE_Hash_Map_Manager_Ex_Adapter
<
199 PortableServer::ObjectId
,
200 TAO_Active_Object_Map_Entry
*,
202 ACE_Equal_To
<PortableServer::ObjectId
>,
203 TAO_Incremental_Key_Generator
> user_id_hash_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
;
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.
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
*,
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 */
239 std::unique_ptr
<user_id_map
> user_id_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
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
279 /// Virtual destructor.
280 virtual ~TAO_Id_Uniqueness_Strategy () = default;
282 /// Must be used with UNIQUE_ID policy.
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.
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.
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.
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.
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.
320 set_active_object_map (TAO_Active_Object_Map
*active_object_map
);
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
337 /// Must be used with UNIQUE_ID policy.
339 is_servant_in_map (PortableServer::Servant servant
,
342 /// Can be used with any policy. With the SYSTEM_ID policy,
343 /// @a user_id is actually @c system_id.
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.
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.
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.
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
385 /// Must be used with UNIQUE_ID policy.
387 is_servant_in_map (PortableServer::Servant servant
,
390 /// Can be used with any policy. With the SYSTEM_ID policy,
391 /// @a user_id is actually @c system_id.
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.
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.
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.
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
);
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
434 /// Virtual destructor.
435 virtual ~TAO_Lifespan_Strategy () = default;
437 /// Can be used with any policy.
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.
447 set_active_object_map (TAO_Active_Object_Map
*active_object_map
);
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
464 /// Can be used with any policy.
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
484 /// Can be used with any policy.
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
);
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
505 /// Virtual destructor.
506 virtual ~TAO_Id_Assignment_Strategy () = default;
508 /// Must be used with SYSTEM_ID policy.
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.
516 set_active_object_map (TAO_Active_Object_Map
*active_object_map
);
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
534 /// Must be used with SYSTEM_ID policy.
536 bind_using_system_id (PortableServer::Servant servant
,
537 CORBA::Short priority
,
538 TAO_Active_Object_Map_Entry
*&entry
);
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
553 /// Must be used with SYSTEM_ID policy.
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
572 /// Must be used with SYSTEM_ID policy.
574 bind_using_system_id (PortableServer::Servant servant
,
575 CORBA::Short priority
,
576 TAO_Active_Object_Map_Entry
*&entry
);
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
591 /// Virtual destructor.
592 virtual ~TAO_Id_Hint_Strategy () = default;
594 /// Find the user id from the system id.
596 recover_key (const PortableServer::ObjectId
&system_id
,
597 PortableServer::ObjectId
&user_id
) = 0;
601 bind (TAO_Active_Object_Map_Entry
&entry
) = 0;
605 unbind (TAO_Active_Object_Map_Entry
&entry
) = 0;
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?
616 /// Get the system id associated with this entry.
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
632 TAO_Active_Hint_Strategy (CORBA::ULong map_size
);
634 /// Virtual destructor.
635 virtual ~TAO_Active_Hint_Strategy () = default;
638 recover_key (const PortableServer::ObjectId
&system_id
,
639 PortableServer::ObjectId
&user_id
);
642 bind (TAO_Active_Object_Map_Entry
&entry
);
645 unbind (TAO_Active_Object_Map_Entry
&entry
);
648 find (const PortableServer::ObjectId
&system_id
,
649 TAO_Active_Object_Map_Entry
*&entry
);
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
676 /// Virtual destructor.
677 virtual ~TAO_No_Hint_Strategy () = default;
680 recover_key (const PortableServer::ObjectId
&system_id
,
681 PortableServer::ObjectId
&user_id
);
684 bind (TAO_Active_Object_Map_Entry
&entry
);
687 unbind (TAO_Active_Object_Map_Entry
&entry
);
690 find (const PortableServer::ObjectId
&system_id
,
691 TAO_Active_Object_Map_Entry
*&entry
);
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 */