OmniEvents
EventChannel.h
Go to the documentation of this file.
1 // Package : omniEvents
2 // EventsChannel.h Created : 2003/12/04
3 // Author : Alex Tingle
4 //
5 // Copyright (C) 2003-2005 Alex Tingle.
6 //
7 // This file is part of the omniEvents application.
8 //
9 // omniEvents is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // omniEvents is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 //
23 
24 #ifndef OMNIEVENTS__EVENTCHANNEL_H
25 #define OMNIEVENTS__EVENTCHANNEL_H
26 
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30 
31 #ifdef HAVE_IOSTREAM
32 # include <iostream>
33 #else
34 # include <iostream.h>
35 #endif
36 
37 #include "Servant.h"
38 #include "PersistNode.h"
39 #include "omniEvents.hh"
40 #include "Mapper.h"
41 #include "defaults.h"
42 
43 #include <set>
44 #include <assert.h>
45 
46 #ifdef HAVE_STD_IOSTREAM
47 using namespace std;
48 #endif
49 
50 namespace OmniEvents {
51 
52 class SupplierAdmin_i;
53 class ConsumerAdmin_i;
54 class EventChannelStore;
55 
112 : public POA_omniEvents::EventChannel,
113  public Servant,
114  public omni_thread
115 {
116 public: // CORBA interface methods
117  CosEventChannelAdmin::ConsumerAdmin_ptr for_consumers();
118  CosEventChannelAdmin::SupplierAdmin_ptr for_suppliers();
119  void destroy();
121  CORBA::Boolean is_alive() { return 1; }
122 
123 public:
124  EventChannel_i(EventChannelStore* store=NULL);
125 
127  ~EventChannel_i();
128 
132  void activate(const char* channelName, const PersistNode* node =NULL);
133 
135  void start(){DB(0,"It is no longer necessary to call EventChannel::start().")}
136 
141  void* run_undetached(void*);
142 
159  void mainLoop();
160 
161  void _add_ref();
162  void _remove_ref();
163 
164  void output(ostream& os);
165 
166  //
167  // Accessors
169  {assert(_consumerAdmin!=NULL);return *_consumerAdmin;}
170  const PersistNode& properties() const
171  {return _properties;}
172 
173  //
174  // Values stored in _properties member.
175  CORBA::ULong pullRetryPeriod_ms() const
176  {return _properties.attrLong("PullRetryPeriod_ms",PULL_RETRY_PERIOD_MS);}
177  CORBA::ULong maxQueueLength() const
178  {return _properties.attrLong("MaxQueueLength",MAX_QUEUE_LENGTH);}
179  CORBA::ULong maxNumProxies() const
180  {return _properties.attrLong("MaxNumProxies",MAX_NUM_PROXIES);}
181  unsigned long cyclePeriod_ns() const
182  {return _properties.attrLong("CyclePeriod_ns",CYCLE_PERIOD_NS);}
183 
184 
185 private:
187  void setInsName(const string v);
188 
193  void createPoa(const char* channelName);
194 
195 private:
199  PortableServer::POAManager_var _poaManager;
203  omni_mutex _lock; //< Protects _refCount
205 };
206 
207 
210 {
211 public:
214  void insert(EventChannel_i* channel);
215  void erase(EventChannel_i* channel);
216  void output(ostream &os);
217 private:
218  set<EventChannel_i*> _channels;
219  omni_mutex _lock;
220 };
221 
222 }; // end namespace OmniEvents
223 
224 #endif // OMNIEVENTS__EVENTCHANNEL_H
#define PULL_RETRY_PERIOD_MS
1 second
Definition: defaults.h:76
#define CYCLE_PERIOD_NS
Delay between cycles. (0.1 second)
Definition: defaults.h:79
#define MAX_QUEUE_LENGTH
Definition: defaults.h:77
#define MAX_NUM_PROXIES
Only limits number of ProxyPullSuppliers.
Definition: defaults.h:78
#define DB(l, x)
Definition: Orb.h:49
Servant for CosEventChannelAdmin::EventChannel objects, also inherits from omni_thread.
Definition: EventChannel.h:115
void start()
Warn about interface change.
Definition: EventChannel.h:135
ConsumerAdmin_i & consumerAdmin() const
Definition: EventChannel.h:168
EventChannelStore * _eventChannelStore
Definition: EventChannel.h:196
CORBA::ULong maxQueueLength() const
Definition: EventChannel.h:177
ConsumerAdmin_i * _consumerAdmin
Definition: EventChannel.h:198
const PersistNode & properties() const
Definition: EventChannel.h:170
CORBA::ULong pullRetryPeriod_ms() const
Definition: EventChannel.h:175
PortableServer::POAManager_var _poaManager
Definition: EventChannel.h:199
CORBA::Boolean is_alive()
'ping' method inherited from FT::PullMonitorable.
Definition: EventChannel.h:121
CORBA::ULong maxNumProxies() const
Definition: EventChannel.h:179
unsigned long cyclePeriod_ns() const
Definition: EventChannel.h:181
SupplierAdmin_i * _supplierAdmin
Definition: EventChannel.h:197
Container for Event Channels.
Definition: EventChannel.h:210
set< EventChannel_i * > _channels
Definition: EventChannel.h:218
A dummy servant that installs itself into the INSPOA and redirects all calls to the real destination.
Definition: Mapper.h:36
Base class for servants.
Definition: Servant.h:114