summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/Notify_Event.h
blob: cc6c9efe38c04b563e796f6901100da88553fea4 (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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/* -*- C++ -*- */
// $Id$
//
// ============================================================================
//
// = LIBRARY
//   ORBSVCS Notification
//
// = FILENAME
//   Notify_Event.h
//
// = DESCRIPTION
//   Abstraction for Notify's event types.
//
// = AUTHOR
//   Pradeep Gore <pradeep@cs.wustl.edu>
//
// ============================================================================

#ifndef TAO_NOTIFY_EVENT_H
#define TAO_NOTIFY_EVENT_H

#include "ace/pre.h"
#include "orbsvcs/CosNotificationC.h"
#include "notify_export.h"

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

#include "orbsvcs/CosNotifyFilterC.h"
#include "orbsvcs/CosEventCommC.h"

// @@ Pradeep: this is another case of multiple classes bunched in the
// same file, you should really think about separating it.

class TAO_Notify_Export TAO_Notify_EventType
{
  // = TITLE
  //   TAO_Notify_EventType
  //
  // = DESCRIPTION
  //   This type is used to compare different event types.
  //   It is used by the Event Manager as a key to find subscription lists.
  //
public:
  // = Initialization and termination
  TAO_Notify_EventType (void);
  TAO_Notify_EventType (const char* domain_name, const char* type_name);
  TAO_Notify_EventType (const CosNotification::EventType& event_type);
  // Constuctor

  ~TAO_Notify_EventType ();
  // Destructor

  u_long hash (void) const;
  // hash value

  void operator=(const CosNotification::EventType& event_type);
  // Assignment from CosNotification::EventType

  int operator==(const TAO_Notify_EventType& notify_event_type) const;
  // == operator

  static TAO_Notify_EventType& special_event_type (void);
  // Return the special event type.

  CORBA::Boolean is_special (void) const;
  // Is this the special event (accept everything).

  const CosNotification::EventType& get_native (void) const;
  // Get the type underneath us.

protected:
  void recompute_hash (void);
  // Recompute the hash value.

  // = Data Members
  CosNotification::EventType event_type_;
  // The event_type that we're decorating.

  u_long hash_value_;
  // The hash value computed.

  static TAO_Notify_EventType special_event_type_;
  // A special event type
};

// ****************************************************************
// @@ Pradeep: please remember to separate your classes with a line
// like the one above.  Or better yet, do not put multiple classes in
// the same file.

class TAO_Notify_Export TAO_Notify_Event
{
  // = TITLE
  //   TAO_Notify_Event
  //
  // = DESCRIPTION
  //   Abstraction for an event
  //   This class allows us to treat event types homogenously.
  //   Derived types for anys and structured events provide the implementation.
  //   This the the "prototype" creational pattern.
  //
public:
  TAO_Notify_Event (void);
  // The lock for its ref. count.
  // Owns the lock.

  virtual ~TAO_Notify_Event ();

  virtual CORBA::Boolean is_special_event_type (void) const = 0;
  // Is this the "special" event type.

  virtual const TAO_Notify_EventType& event_type (void) const = 0;
  // Get the event type.

  virtual TAO_Notify_Event* clone (void) = 0;
  // We may need to make a copy of the underlying data if it is not owned
  // by us.
  // Note this behaviour: If this object owns the data, then we *transfer*
  // ownership of the data to the new object otherwise we copy the data
  // for the new object.

  virtual CORBA::Boolean do_match (CosNotifyFilter::Filter_ptr filter, CORBA::Environment &ACE_TRY_ENV) const = 0;
  // Returns true if the filter matches.

  virtual void do_push (CosEventComm::PushConsumer_ptr consumer, CORBA::Environment &ACE_TRY_ENV) const = 0;
  virtual void do_push (CosNotifyComm::StructuredPushConsumer_ptr consumer, CORBA::Environment &ACE_TRY_ENV) const = 0;
  // Push self to <consumer>

  // = QoS Properties.
  //

  CORBA::Short event_reliability (void);
  void event_reliability (CORBA::Short event_reliability);
  // Not implemented.

  CORBA::Short priority (void);
  void priority (CORBA::Short priority);
  // Event priority

  TimeBase::UtcT start_time (void);
  void start_time (TimeBase::UtcT start_time);
  // Earliest delivery time.

  TimeBase::UtcT stop_time (void);
  void stop_time (TimeBase::UtcT stop_time);
  // Latest absolute expiry time for this event.

  TimeBase::TimeT timeout (void);
  void timeout (TimeBase::TimeT timeout);
  // Relative expiry time.

  // = Refcounted lifetime
  void _incr_refcnt (void);
  void _decr_refcnt (void);

 protected:
  ACE_Lock* lock_;
  // The locking strategy.

  CORBA::ULong refcount_;
  // The reference count.

  // = QoS properties
  CORBA::Short event_reliability_;
  CORBA::Short priority_;
  TimeBase::UtcT start_time_;
  TimeBase::UtcT stop_time_;
  TimeBase::TimeT timeout_;
};

// ****************************************************************

class TAO_Notify_Export TAO_Notify_Any : public TAO_Notify_Event
{
  // = TITLE
  //   TAO_Notify_Any
  //
  // = DESCRIPTION
  //   This class is the concrete prototype for the Any type.
  //

public:
  TAO_Notify_Any (CORBA::Any* data);
  // Refers to the data. Owns it!

  TAO_Notify_Any (const CORBA::Any* data);
  // Does not own data.

  virtual ~TAO_Notify_Any ();

  virtual TAO_Notify_Event* clone (void);

  void operator=(const TAO_Notify_Any& notify_any);

  virtual CORBA::Boolean is_special_event_type (void) const;
  virtual const TAO_Notify_EventType& event_type (void) const;
  virtual CORBA::Boolean do_match (CosNotifyFilter::Filter_ptr filter, CORBA::Environment &ACE_TRY_ENV) const;
  virtual void do_push (CosEventComm::PushConsumer_ptr consumer, CORBA::Environment &ACE_TRY_ENV) const;
  virtual void do_push (CosNotifyComm::StructuredPushConsumer_ptr consumer, CORBA::Environment &ACE_TRY_ENV) const;

protected:
  CORBA::Any* data_;
  // The data

  CORBA::Boolean is_owner_;
  // Do we own the data.
};

// ****************************************************************

class TAO_Notify_Export TAO_Notify_StructuredEvent : public TAO_Notify_Event
{
  // = TITLE
  //   TAO_Notify_StructuredEvent
  //
  // = DESCRIPTION
  //   This class is the concrete prototype for the Structured Event Type.
  //
public:
  TAO_Notify_StructuredEvent (CosNotification::StructuredEvent * notification);
  TAO_Notify_StructuredEvent (const CosNotification::StructuredEvent * notification);
  virtual ~TAO_Notify_StructuredEvent ();

  virtual TAO_Notify_Event* clone (void);
  void operator=(const TAO_Notify_StructuredEvent &structured_event);

  virtual CORBA::Boolean is_special_event_type (void) const;
  virtual const TAO_Notify_EventType& event_type (void) const;
  virtual CORBA::Boolean do_match (CosNotifyFilter::Filter_ptr filter, CORBA::Environment &ACE_TRY_ENV) const;
  virtual void do_push (CosEventComm::PushConsumer_ptr consumer, CORBA::Environment &ACE_TRY_ENV) const;
  virtual void do_push (CosNotifyComm::StructuredPushConsumer_ptr consumer, CORBA::Environment &ACE_TRY_ENV) const;

protected:

  void init_QoS (void);
  // Load the QoS properties specified for this event from <data_>.

  // = Data Members
  CosNotification::StructuredEvent* data_;
  // The data

  TAO_Notify_EventType event_type_;
  // The event type of <data_>

  CORBA::Boolean is_owner_;
  // Do we own the data.
};


#if defined (__ACE_INLINE__)
#include "Notify_Event.i"
#endif /* __ACE_INLINE__ */

#include "ace/post.h"

#endif /* TAO_NOTIFY_EVENT_H */