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 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 
00107 class EventChannel_i
00108 : public POA_omniEvents::EventChannel,
00109   public Servant,
00110   public omni_thread
00111 {
00112 public: // CORBA interface methods
00113   CosEventChannelAdmin::ConsumerAdmin_ptr for_consumers();
00114   CosEventChannelAdmin::SupplierAdmin_ptr for_suppliers();
00115   void destroy();
00117   CORBA::Boolean is_alive() { return 1; }
00118 
00119 public:
00120   EventChannel_i(EventChannelStore* store=NULL);
00121 
00123   ~EventChannel_i();
00124 
00128   void activate(const char* channelName, const PersistNode* node =NULL);
00129 
00134   void run(void* arg);
00135 
00152   void mainLoop();
00153   
00154   void output(ostream& os);
00155 
00156   //
00157   // Accessors
00158   ConsumerAdmin_i& consumerAdmin() const
00159     {assert(_consumerAdmin!=NULL);return *_consumerAdmin;}
00160   const PersistNode& properties() const
00161     {return _properties;}
00162 
00163   //
00164   // Values stored in _properties member.
00165   CORBA::ULong  pullRetryPeriod_ms() const
00166     {return _properties.attrLong("PullRetryPeriod_ms",PULL_RETRY_PERIOD_MS);}
00167   CORBA::ULong  maxQueueLength() const
00168     {return _properties.attrLong("MaxQueueLength",MAX_QUEUE_LENGTH);}
00169   CORBA::ULong  maxNumProxies() const
00170     {return _properties.attrLong("MaxNumProxies",MAX_NUM_PROXIES);}
00171   unsigned long cyclePeriod_ns() const
00172     {return _properties.attrLong("CyclePeriod_ns",CYCLE_PERIOD_NS);}
00173   
00174 
00175 private:
00177   void setInsName(const string v);
00178 
00183   void createPoa(const char* channelName);
00184   
00185 private:
00186   EventChannelStore*             _eventChannelStore;
00187   SupplierAdmin_i*               _supplierAdmin;
00188   ConsumerAdmin_i*               _consumerAdmin;
00189   PortableServer::POAManager_var _poaManager;
00190   bool                           _shutdownRequested;
00191   PersistNode                    _properties;
00192   Mapper*                        _mapper;
00193 };
00194 
00195 
00197 class EventChannelStore
00198 {
00199 public:
00200   EventChannelStore();
00201   ~EventChannelStore();
00202   void insert(EventChannel_i* channel);
00203   void erase(EventChannel_i* channel);
00204   void output(ostream &os);
00205 private:
00206   set<EventChannel_i*> _channels;
00207   omni_mutex           _lock;
00208 };
00209 
00210 }; // end namespace OmniEvents
00211 
00212 #endif // OMNIEVENTS__EVENTCHANNEL_H

Generated on Mon Jan 9 03:52:13 2006 for OmniEvents by  doxygen 1.4.6