summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/Notify_Types.h
blob: 9e02aad2fbcf3a0a3e59599e626131fe2e7801af (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
// $Id$
// ==========================================================================
//
// = LIBRARY
//   Orbsvcs
//
// = FILENAME
//   Notify_Types.h
//
// = DESCRIPTION
//   Internal types used by Notify
//
// = AUTHOR
//    Pradeep Gore <pradeep@cs.wustl.edu>
//
// ==========================================================================

#ifndef TAO_NOTIFY_TYPES_H
#include "ace/pre.h"
#define TAO_NOTIFY_TYPES_H

#include "orbsvcs/CosNotifyFilterC.h"
#include "orbsvcs/CosNotifyCommC.h"
#include "ace/Containers_T.h"

class TAO_Notify_Event_Listener;
class TAO_Notify_Update_Listener;

class 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
};

class TAO_Notify_Event
{
  // = TITLE
  //   TAO_Notify_Event
  //
  // = DESCRIPTION
  //   Abstraction for an event
  //
public:
  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>
protected:
  CORBA::Boolean is_owner_;
  // Do we own the data.
};

class TAO_Notify_Any : public TAO_Notify_Event
{
public:
  TAO_Notify_Any (void);
  TAO_Notify_Any (const CORBA::Any & 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
};

class TAO_Notify_StructuredEvent : public TAO_Notify_Event
{
public:
  TAO_Notify_StructuredEvent (void);
  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:
  CosNotification::StructuredEvent* data_;
  // The data

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

class EVENTTYPE_LIST : public ACE_Unbounded_Set <TAO_Notify_EventType>
{
  // = TITLE
  //   EVENTTYPE_LIST
  //
  // = DESCRIPTION
  //   Allows operations using the CosNotification::EventTypeSeq type.
  //

  typedef ACE_Unbounded_Set <TAO_Notify_EventType> inherited;

public:
  void populate (CosNotification::EventTypeSeq& event_type_seq);
  // Populate <event_type_seq> with the contents of this object.

  void insert_seq (const CosNotification::EventTypeSeq& event_type_seq);
  // insert the contents of <event_type_seq> into this object.

  void remove_seq (const CosNotification::EventTypeSeq& event_type_seq);
  // remove the contents of <event_type_seq> from this object.
};

// = typedefs
typedef ACE_Unbounded_Set<TAO_Notify_Event_Listener*> EVENT_LISTENER_LIST;
// A list of event listeners that are looking for the same event type.

typedef ACE_Unbounded_Set<TAO_Notify_Update_Listener*> UPDATE_LISTENER_LIST;
// list of update listeners.

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