Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

EventChannel.h

Go to the documentation of this file.
00001 //                            Package   : omniEvents
00002 // EventsChannel.h            Created   : 2003/12/04
00003 //                            Author    : Alex Tingle
00004 //
00005 //    Copyright (C) 2003-2005 Alex Tingle.
00006 //
00007 //    This file is part of the omniEvents application.
00008 //
00009 //    omniEvents is free software; you can redistribute it and/or
00010 //    modify it under the terms of the GNU Lesser General Public
00011 //    License as published by the Free Software Foundation; either
00012 //    version 2.1 of the License, or (at your option) any later version.
00013 //
00014 //    omniEvents is distributed in the hope that it will be useful,
00015 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 //    Lesser General Public License for more details.
00018 //
00019 //    You should have received a copy of the GNU Lesser General Public
00020 //    License along with this library; if not, write to the Free Software
00021 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 
00024 #ifndef OMNIEVENTS__EVENTCHANNEL_H
00025 #define OMNIEVENTS__EVENTCHANNEL_H
00026 
00027 #ifdef HAVE_CONFIG_H
00028 #  include "config.h"
00029 #endif
00030 
00031 #ifdef HAVE_IOSTREAM
00032 #  include <iostream>
00033 #else
00034 #  include <iostream.h>
00035 #endif
00036 
00037 #include "Servant.h"
00038 #include "PersistNode.h"
00039 #include "omniEvents.hh"
00040 #include "Mapper.h"
00041 #include "defaults.h"
00042 
00043 #include <set>
00044 #include <assert.h>
00045 
00046 #ifdef HAVE_STD_IOSTREAM
00047 using namespace std;
00048 #endif
00049 
00050 namespace OmniEvents {
00051 
00052 class SupplierAdmin_i;
00053 class ConsumerAdmin_i;
00054 class EventChannelStore;
00055 
00111 class EventChannel_i
00112 : public POA_omniEvents::EventChannel,
00113   public Servant,
00114   public omni_thread
00115 {
00116 public: // CORBA interface methods
00117   CosEventChannelAdmin::ConsumerAdmin_ptr for_consumers();
00118   CosEventChannelAdmin::SupplierAdmin_ptr for_suppliers();
00119   void destroy();
00121   CORBA::Boolean is_alive() { return 1; }
00122 
00123 public:
00124   EventChannel_i(EventChannelStore* store=NULL);
00125 
00127   ~EventChannel_i();
00128 
00132   void activate(const char* channelName, const PersistNode* node =NULL);
00133 
00135   void start(){DB(0,"It is no longer necessary to call EventChannel::start().")}
00136 
00141   void* run_undetached(void*);
00142 
00159   void mainLoop();
00160 
00161   void _add_ref();
00162   void _remove_ref(); 
00163   
00164   void output(ostream& os);
00165 
00166   //
00167   // Accessors
00168   ConsumerAdmin_i& consumerAdmin() const
00169     {assert(_consumerAdmin!=NULL);return *_consumerAdmin;}
00170   const PersistNode& properties() const
00171     {return _properties;}
00172 
00173   //
00174   // Values stored in _properties member.
00175   CORBA::ULong  pullRetryPeriod_ms() const
00176     {return _properties.attrLong("PullRetryPeriod_ms",PULL_RETRY_PERIOD_MS);}
00177   CORBA::ULong  maxQueueLength() const
00178     {return _properties.attrLong("MaxQueueLength",MAX_QUEUE_LENGTH);}
00179   CORBA::ULong  maxNumProxies() const
00180     {return _properties.attrLong("MaxNumProxies",MAX_NUM_PROXIES);}
00181   unsigned long cyclePeriod_ns() const
00182     {return _properties.attrLong("CyclePeriod_ns",CYCLE_PERIOD_NS);}
00183   
00184 
00185 private:
00187   void setInsName(const string v);
00188 
00193   void createPoa(const char* channelName);
00194   
00195 private:
00196   EventChannelStore*             _eventChannelStore;
00197   SupplierAdmin_i*               _supplierAdmin;
00198   ConsumerAdmin_i*               _consumerAdmin;
00199   PortableServer::POAManager_var _poaManager;
00200   bool                           _shutdownRequested;
00201   PersistNode                    _properties;
00202   Mapper*                        _mapper;
00203   omni_mutex                     _lock; //< Protects _refCount
00204   int                            _refCount;
00205 };
00206 
00207 
00209 class EventChannelStore
00210 {
00211 public:
00212   EventChannelStore();
00213   ~EventChannelStore();
00214   void insert(EventChannel_i* channel);
00215   void erase(EventChannel_i* channel);
00216   void output(ostream &os);
00217 private:
00218   set<EventChannel_i*> _channels;
00219   omni_mutex           _lock;
00220 };
00221 
00222 }; // end namespace OmniEvents
00223 
00224 #endif // OMNIEVENTS__EVENTCHANNEL_H

Generated on Fri Aug 26 20:56:14 2005 for OmniEvents by  doxygen 1.4.3-20050530