summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Event/EC_Supplier_Filter.h
blob: c57640cb4095e742986193b68a9ca977f0b13b60 (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
/* -*- C++ -*- */
// $Id$
//
// ============================================================================
//
// = LIBRARY
//   ORBSVCS Real-time Event Channel
//
// = FILENAME
//   EC_Supplier_Filter
//
// = AUTHOR
//   Carlos O'Ryan (coryan@cs.wustl.edu)
//
// = DESCRIPTION
//   Define the TAO_EC_Supplier_Filter interface and some simple
//   implementations.
//
// = CREDITS
//   Based on previous work by Tim Harrison (harrison@cs.wustl.edu)
//   and other members of the DOC group.
//   More details can be found in:
//   http://www.cs.wustl.edu/~schmidt/oopsla.ps.gz
//   http://www.cs.wustl.edu/~schmidt/JSAC-98.ps.gz
//
//
// ============================================================================

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

#include "orbsvcs/RtecEventCommC.h"
#include "EC_Worker.h"
#include "event_export.h"

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

class TAO_EC_ProxyPushSupplier;
class TAO_EC_ProxyPushConsumer;
class TAO_EC_Event_Channel;
class TAO_EC_QOS_Info;

class TAO_RTEvent_Export TAO_EC_Supplier_Filter
{
  // = TITLE
  //   The strategy to filter close to the supplier.
  //
  // = DESCRIPTION
  //   After an event is received by the a ProxyPushConsumer it must
  //   be dispatched to the right set of ProxyPushSuppliers;
  //   determining this set is the task of this class.
  //   Notice that this is in fact a filter, and enforces (in part)
  //   the subscriptions and publications of the Event Service
  //   clients.
  //
  //   Several implementations are possible:
  //
  //   - Each ProxyPushConsumer keeps a list of ProxyPushSuppliers,
  //     using the subscriptions and publications to find potential
  //     matches.
  //   - Each ProxyPushConsumer keeps several such lists, indexed by
  //     event type and/or source, this has the advantage of further
  //     minimizing the set of ProxyPushSuppliers invoked.
  //   - A single list of consumers is kept (global for the event
  //     channel), such a list results is faster updates and requires
  //     an smaller memory footprint.
  //   - Multiple global lists are kept, indexed by type and/or
  //     source, this is a tradeoff between the solutions above.
  //   - No list is kept, the events are sent to the consumers which
  //     must filter out what they want, this is good when no
  //     filtering is wanted or when the amount of filtering is coarse
  //     i.e. each event goes to a large subset of the
  //     ProxyPushSuppliers.
  //
  //  Different applications will require to use different
  //  implementations of this class; as usual the EC_Factory will
  //  create the right instance.
  //
public:
  virtual ~TAO_EC_Supplier_Filter (void);
  // Destructor

  virtual void bind (TAO_EC_ProxyPushConsumer* consumer) = 0;
  // Whenever a ProxyPushConsumer is initialized it calls this method
  // to inform the Supplier_Filter of its identity.
  // Strategies that do not keep ProxyPushConsumer specific
  // information, or that are shared between multiple
  // ProxyPushConsumers can ignore this message.

  virtual void unbind (TAO_EC_ProxyPushConsumer* consumer) = 0;
  // Wheneve a ProxyPushConsumer is about to be destroyed it calls
  // this method to inform the Supplier_Filter that it should
  // release any resources related to it.
  // Supplier_Filter strategies that are bound to a particular
  // ProxyConsumer can use this opportunity to destroy themselves;
  // filter strategies that do not keep ProxyPushConsumer specific
  // information can simply ignore the message.

  virtual void connected (TAO_EC_ProxyPushSupplier *supplier,
                          CORBA::Environment &env) = 0;
  virtual void reconnected (TAO_EC_ProxyPushSupplier *supplier,
                          CORBA::Environment &env) = 0;
  virtual void disconnected (TAO_EC_ProxyPushSupplier *supplier,
                             CORBA::Environment &env) = 0;
  // Concrete implementations can use this methods to keep track of
  // the consumers interested in this events.

  virtual void shutdown (CORBA::Environment &env) = 0;
  // The event channel is shutting down.

  virtual void push (const RtecEventComm::EventSet &event,
                     CORBA::Environment &) = 0;
  // The ProxyPushConsumer delegates on this class to actually send
  // the event.

  virtual CORBA::ULong _incr_refcnt (void) = 0;
  virtual CORBA::ULong _decr_refcnt (void) = 0;
  // Increment and decrement the reference count, locking must be
  // provided by the user.
};

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

class TAO_EC_Filter_Worker : public TAO_EC_Worker<TAO_EC_ProxyPushSupplier>
{
public:
  TAO_EC_Filter_Worker (RtecEventComm::EventSet &event,
                        const TAO_EC_QOS_Info &event_info);

  virtual void work (TAO_EC_ProxyPushSupplier *supplier,
                     CORBA::Environment &ACE_TRY_ENV);

private:
  RtecEventComm::EventSet &event_;
  // The event we push on each case, use a reference to avoid copies.

  const TAO_EC_QOS_Info &event_info_;
  // The QoS info propagated on each event.
};

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

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