summaryrefslogtreecommitdiff
path: root/TAO/tao/LF_CH_Event.h
blob: 2a92f9007ab13a415e2c659d2c0f160b0925c69f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// -*- C++ -*-

//=============================================================================
/**
 *  @file LF_CH_Event.h
 *
 *  $Id$
 *
 *  @author Balachandran Natarajan <bala@cs.wustl.edu>
 */
//=============================================================================

#ifndef TAO_LF_CH_EVENT_H
#define TAO_LF_CH_EVENT_H

#include /**/ "ace/pre.h"

#include "tao/LF_Event.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

/**
 * @class TAO_LF_CH_Event
 *
 * @brief Use the Leader/Follower loop to wait for one specific event
 * in the invocation path.
 *
 * Concrete event types and manipulation class which is used for
 * connection handling purposes.
 */
class TAO_Export TAO_LF_CH_Event: public TAO_LF_Event
{
public:
  /// Constructor
  TAO_LF_CH_Event (void);

  /// Destructor
  virtual ~TAO_LF_CH_Event (void);

  //@{
  /// Return 1 if the condition was satisfied successfully, 0 if it
  /// has not
  int successful (void) const;

  /// Return 1 if an error was detected while waiting for the
  /// event
  int error_detected (void) const;


  /// Reset the state, irrespective of the previous states
  void reset_state (int new_state);

protected:

  /// Check whether we have reached the final state..
  virtual int is_state_final (void);

  //@}
private:
  /// Validate and change the state
  /*
   * This concrete class uses the following states declared in the
   * class TAO_LF_Event to transition states
   *
   * LFS_IDLE                  - The event is created, and is in
   *                             initial  state.
   *
   * LFS_CONNECTION_WAIT       - The event is waiting for connection
   *                             completion and it can transition to
   *                             any of the following states, all the
   *                             states are final.
   *
   * LFS_SUCCESS               - The event, connection establishment, has
   *                             completed successfully.
   *
   * LFS_TIMEOUT               - The event has timed out.
   *
   * LFS_CONNECTION_CLOSED     - The connection was closed since
   *                             an error occured while trying to
   *                             establish connection
   *
   *  Event State Diagram
   *  -------------------
   *                              |----> CLOSED
   *                              |        ^
   *                              |        |
   *   IDLE ---> CONNECTION_WAIT--|        |
   *                              |        |
   *                              |        |
   *                              |----> SUCESS
   *
   * Timeouts can occur while waiting for connections.
   *
   */
  virtual void state_changed_i (int new_state);

  /// Set the state irrespective of anything.
  virtual void set_state (int new_state);

private:

  /// The previous state that the LF_CH_Event was in
  int prev_state_;
};

TAO_END_VERSIONED_NAMESPACE_DECL

#include /**/ "ace/post.h"

#endif  /* TAO_LF_CH_EVENT_H */