Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / LF_CH_Event.h
blob8be0f5ef7bff9fc51d025a8334409521ce830bb5
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file LF_CH_Event.h
7 * @author Balachandran Natarajan <bala@cs.wustl.edu>
8 */
9 //=============================================================================
11 #ifndef TAO_LF_CH_EVENT_H
12 #define TAO_LF_CH_EVENT_H
14 #include /**/ "ace/pre.h"
16 #include "tao/LF_Event.h"
17 #include "tao/orbconf.h"
18 #include "ace/Hash_Map_Manager_T.h"
19 #include "ace/Null_Mutex.h"
20 #include "ace/Thread_Mutex.h"
22 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 # pragma once
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
28 class TAO_LF_Multi_Event;
30 /**
31 * @class TAO_LF_CH_Event
33 * @brief Use the Leader/Follower loop to wait for one specific event
34 * in the invocation path.
36 * Concrete event types and manipulation class which is used for
37 * connection handling purposes.
39 class TAO_Export TAO_LF_CH_Event: public TAO_LF_Event
41 public:
42 /**
43 * The TAO_LF_Multi_Event class is another specialization of
44 * TAO_LF_Event, used for aggregating many connection handlers into
45 * a single event object. It requires friendship so that it can
46 * check the is_state_final() flag on each of its contained
47 * connection handlers.
49 friend class TAO_LF_Multi_Event;
51 /// Constructor
52 TAO_LF_CH_Event ();
54 /// Destructor
55 virtual ~TAO_LF_CH_Event ();
57 //@{
58 protected:
59 /// Check whether we have reached the final state..
60 virtual bool is_state_final () const;
62 //@}
63 private:
64 /// Validate and change the state
66 * This concrete class uses the following states declared in the
67 * class TAO_LF_Event to transition states
69 * LFS_IDLE - The event is created, and is in
70 * initial state.
72 * LFS_CONNECTION_WAIT - The event is waiting for connection
73 * completion and it can transition to
74 * any of the following states, all the
75 * states are final.
77 * LFS_SUCCESS - The event, connection establishment, has
78 * completed successfully.
80 * LFS_TIMEOUT - The event has timed out.
82 * LFS_CONNECTION_CLOSED - The connection was closed since
83 * an error occurred while trying to
84 * establish connection
86 * Event State Diagram
87 * -------------------
88 * |----> CLOSED
89 * | ^
90 * | |
91 * IDLE ---> CONNECTION_WAIT--| |
92 * | |
93 * | |
94 * |----> SUCESS
96 * Timeouts can occur while waiting for connections.
99 virtual void state_changed_i (LFS_STATE new_state);
101 /// Return true if the condition was satisfied successfully, false if it
102 /// has not
103 virtual bool successful_i () const;
105 /// Return true if an error was detected while waiting for the
106 /// event
107 virtual bool error_detected_i () const;
109 /// Set the state irrespective of anything.
110 virtual void set_state (LFS_STATE new_state);
112 virtual int bind (TAO_LF_Follower *follower);
113 virtual int unbind (TAO_LF_Follower *follower);
115 private:
116 /// The previous state that the LF_CH_Event was in
117 LFS_STATE prev_state_;
119 void validate_state_change (LFS_STATE new_state);
121 typedef ACE_Hash_Map_Manager_Ex <TAO_LF_Follower *, int,
122 ACE_Hash<void *>,
123 ACE_Equal_To<TAO_LF_Follower *>,
124 TAO_SYNCH_MUTEX> HASH_MAP;
125 HASH_MAP followers_;
128 TAO_END_VERSIONED_NAMESPACE_DECL
130 #include /**/ "ace/post.h"
132 #endif /* TAO_LF_CH_EVENT_H */