ESA JPIP server  0.1
event.h
Go to the documentation of this file.
1 #ifndef _IPC_EVENT_H_
2 #define _IPC_EVENT_H_
3 
4 
5 #include <pthread.h>
6 #include "ipc_object.h"
7 
8 
9 namespace ipc
10 {
11 
20  class Event :public IPCObject
21  {
22  private:
23  bool state;
24  bool manual_reset;
25  pthread_cond_t condv;
26  pthread_mutex_t mutex;
27 
28  public:
32  typedef SHARED_PTR<Event> Ptr;
33 
38  virtual bool Init()
39  {
40  return Init(false);
41  }
42 
50  bool Init(bool manual_reset, bool initial_state = false);
51 
59  virtual WaitResult Wait(int time_out = -1);
60 
66  virtual bool Dispose();
67 
78  bool Set(bool new_state = true);
79 
83  bool Get() const
84  {
85  return state;
86  }
87 
94  bool Pulse();
95 
100  bool Reset()
101  {
102  return Set(false);
103  }
104  };
105 
106 }
107 
108 
109 #endif /* _IPC_EVENT_H_ */
bool Set(bool new_state=true)
Sets the state of the object.
Definition: event.cc:82
Class base of all the IPC classes that has the basic operations (Init, Wait and Dispose) to be overlo...
Definition: ipc_object.h:39
SHARED_PTR< Event > Ptr
Pointer to a Event object.
Definition: event.h:32
pthread_cond_t condv
Conditional variable information.
Definition: event.h:25
bool Get() const
Returns the current activation state of the object.
Definition: event.h:83
virtual bool Init()
Initializes the object desactivated and with automatic reset.
Definition: event.h:38
virtual bool Dispose()
Release the resources associated to the IPC object and sets the internal status to false...
Definition: event.cc:120
bool manual_reset
Indicates if the event reset is manual.
Definition: event.h:24
bool Pulse()
Generates the same result as if the event has automatic reset and the Set method is called with true...
Definition: event.cc:106
IPC object that offers the functionality of an event (Windows IPC object), implemented by means of a ...
Definition: event.h:20
pthread_mutex_t mutex
Mutex information.
Definition: event.h:26
virtual WaitResult Wait(int time_out=-1)
Performs a wait operation with the object to get it.
Definition: event.cc:41
bool Reset()
Desactivates the object.
Definition: event.h:100
WaitResult
Enumeration of the possible values returned when a wait operation is performed for an IPC object...
Definition: ipc_object.h:16
bool state
Current activation state of the event.
Definition: event.h:23