summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/examples/CosEC/RtEC_Based/lib/CosEvent_Utilities.h
blob: 4438de78581daa7bc159ed3136bb457538b6000c (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
/* -*- C++ -*- */

//=============================================================================
/**
 *  @file     CosEvent_Utilities.h
 *
 *  A few utility classes to make it easier to write EC applications.
 *
 *  @author Pradeep Gore <pradeep@cs.wustl.edu>
 */
//=============================================================================


#ifndef TAO_COSEVENT_UTILITIES_H
#define TAO_COSEVENT_UTILITIES_H
#include /**/ "ace/pre.h"

#include "orbsvcs/RtecBaseC.h"
#include "orbsvcs/RtecEventChannelAdminS.h"
#include "orbsvcs/CosEventChannelAdminS.h"
#include "orbsvcs/Event_Utilities.h"
#include "rtec_cosec_export.h"

class TAO_CosEC_EventChannel_i;

class TAO_RTEC_COSEC_Export CosEC_ServantBase :
  public virtual POA_CosEventChannelAdmin::EventChannel
{
  // = TITLE
  //   A generic servant base class.
  // = DESCRIPTION
  //   This class contains all the member data and methods required to
  //   create and manage a CosEC servant.
  //   Clients can derive from this class and create servants.
 public:
  /// Constructor.
  CosEC_ServantBase (void);

  /// Destructor.
  virtual ~CosEC_ServantBase (void);

  /**
   * This method creates a local scheduler, rtec and cosec.
   * The POA <poa> specified here is used when <activate> is called to
   * activate the contained servants.
   * The POA <thispoa> is used to activate this.
   */
  virtual void init (PortableServer::POA_ptr thispoa,
                     PortableServer::POA_ptr poa,
                     ACE_TCHAR *eventTypeIds,
                     ACE_TCHAR *eventSourceIds,
                     ACE_TCHAR *source_type_pairs);

  /// Activates the CosEC with <thispoa_> and friends with the <poa_>
  int activate (void);

  /// If the servant_id is not nil then it is used to supply the object id
  /// for <this> servant.
  int activate (const char* servant_id);

  /// Deactivates the CosEC and friends with the POA.
  void deactivate (void);

  // =  POA_CosEventChannelAdmin::EventChannel methods.
  virtual CosEventChannelAdmin::ConsumerAdmin_ptr for_consumers (void);

  virtual CosEventChannelAdmin::SupplierAdmin_ptr for_suppliers (void);

  /// Destroys this Event Channel object.
  virtual void destroy (void);

 protected:
  // = RtEC creation, activation and deactivation methods.
  /// Create a local rtec.
  virtual POA_RtecEventChannelAdmin::EventChannel_ptr
  create_rtec (void);

  /// Activates the rtec.
  virtual void activate_rtec (void);

  /// Deactivates the rtec.
  virtual void deactivate_rtec (void);

  // = CosEC creation, activation and deactivation methods.
  /// Create a local cosec.
  TAO_CosEC_EventChannel_i*
  create_cosec (void);

  /// Activates the cosec.
  int activate_cosec (void);

  /// Deactivates the cosec.
  void deactivate_cosec (void);

  /// Initialize the SupplierQOS Factory.
  void init_SupplierQOS (RtecBase::handle_t supp_handle,
                         ACE_SupplierQOS_Factory &supplier_qos,
                         ACE_TCHAR *source_type_pairs);


  /// Initialize the ConsumerQOS Factory.
  void init_ConsumerQOS (RtecBase::handle_t cons_handle,
                         ACE_ConsumerQOS_Factory &consumer_qos,
                         ACE_TCHAR *eventTypeIds,
                         ACE_TCHAR *eventSourceIds);

  // = Protected Data members.

  /// The poa that we use to activate ourselves.
  PortableServer::POA_var thispoa_;

  /// The poa that we use to activate others
  PortableServer::POA_var poa_;

  /// The Event Channel servant.
  POA_RtecEventChannelAdmin::EventChannel_ptr rtec_servant_;

  /// The servant object of the COS Event Channel.
  TAO_CosEC_EventChannel_i *cosec_servant_;

  /// Ref to the Rtec.
  RtecEventChannelAdmin::EventChannel_var rtec_;

  /// Ref to the cosec.
  CosEventChannelAdmin::EventChannel_var cosec_;

  /// The Consumer QOS.
  ACE_ConsumerQOS_Factory consumer_qos_;

  /// The Supplier QOS.
  ACE_SupplierQOS_Factory supplier_qos_;

  /// The list of EventTypeIDs (for ConsumerQOS) separated by spaces.
  /// e.g. "1 2 3 4"
  ACE_TCHAR *eventTypeIds_;

  /// The list of EventSourceIDs (for ConsumerQOS) separated by spaces.
  /// e.g. "1 2 3 4"
  ACE_TCHAR *eventSourceIds_;

  /**
   * The pairs of Source and EventType Ids (for the SupplierQOS).
   * e.g "1 4 2 5 3 6" where (1,4) (2,5) and (3,6) from source id,
   * event id pairs.
   */
  ACE_TCHAR *source_type_pairs_;
};

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