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
47using namespace std;
48#endif
49
50namespace OmniEvents {
51
52class SupplierAdmin_i;
53class ConsumerAdmin_i;
54class EventChannelStore;
55
112: public POA_omniEvents::EventChannel,
113 public Servant,
114 public omni_thread
115{
116public: // 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
123public:
125
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
185private:
187 void setInsName(const string v);
188
193 void createPoa(const char* channelName);
194
195private:
199 PortableServer::POAManager_var _poaManager;
203 omni_mutex _lock; //< Protects _refCount
205};
206
207
210{
211public:
214 void insert(EventChannel_i* channel);
215 void erase(EventChannel_i* channel);
216 void output(ostream &os);
217private:
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.
const PersistNode & properties() const
void activate(const char *channelName, const PersistNode *node=NULL)
Creates the channel's POA, and any child objects.
~EventChannel_i()
Cleans up the _poa, if this object is deleted before its thread starts.
void _remove_ref()
Shutdown the thread when refCount reaches zero.
void start()
Warn about interface change.
void mainLoop()
The main loop for a channel.
void * run_undetached(void *)
Entry point for the channel's thread.
EventChannelStore * _eventChannelStore
CORBA::ULong maxQueueLength() const
ConsumerAdmin_i & consumerAdmin() const
ConsumerAdmin_i * _consumerAdmin
CORBA::ULong pullRetryPeriod_ms() const
PortableServer::POAManager_var _poaManager
CORBA::Boolean is_alive()
'ping' method inherited from FT::PullMonitorable.
CORBA::ULong maxNumProxies() const
void createPoa(const char *channelName)
Constructs the main POA for this channel.
unsigned long cyclePeriod_ns() const
CosEventChannelAdmin::ConsumerAdmin_ptr for_consumers()
CosEventChannelAdmin::SupplierAdmin_ptr for_suppliers()
SupplierAdmin_i * _supplierAdmin
void setInsName(const string v)
Construct a new Mapper object, and registers it in the INSPOA.
Container for Event Channels.
void insert(EventChannel_i *channel)
set< EventChannel_i * > _channels
void erase(EventChannel_i *channel)
A dummy servant that installs itself into the INSPOA and redirects all calls to the real destination.
Definition Mapper.h:36
long attrLong(const string &key, long fallback=0) const
Base class for servants.
Definition Servant.h:114