Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

SupplierAdmin.cc

Go to the documentation of this file.
00001 //                            Package   : omniEvents
00002 // SupplierAdmin.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 #include "SupplierAdmin.h"
00025 
00026 #include "EventChannel.h"
00027 #include "ProxyPushConsumer.h"
00028 #include "ProxyPullConsumer.h"
00029 #include "oep_types.h"
00030 
00031 namespace OmniEvents {
00032 
00033 CosEventChannelAdmin::ProxyPushConsumer_ptr
00034 SupplierAdmin_i::obtain_push_consumer()
00035 {
00036   if(!_pushConsumer)
00037       _pushConsumer=new ProxyPushConsumer_i(_poa,_queue);
00038   return _pushConsumer->createObject();
00039 }
00040 
00041 
00042 CosEventChannelAdmin::ProxyPullConsumer_ptr
00043 SupplierAdmin_i::obtain_pull_consumer()
00044 {
00045   if(!_pullConsumer)
00046       _pullConsumer=new ProxyPullConsumerManager(_poa,_queue);
00047   return _pullConsumer->createObject();
00048 }
00049 
00050 
00051 SupplierAdmin_i::SupplierAdmin_i(
00052   const EventChannel_i&   channel,
00053   PortableServer::POA_ptr poa
00054 )
00055 : Servant(poa),
00056   _channel(channel),
00057   _pushConsumer(NULL),
00058   _pullConsumer(NULL),
00059   _queue()
00060 {
00061   activateObjectWithId("SupplierAdmin");
00062 }
00063 
00064 
00065 SupplierAdmin_i::SupplierAdmin_i(
00066   const EventChannel_i&   channel,
00067   PortableServer::POA_ptr poa,
00068   const OEP_saps&         saps
00069 )
00070 : Servant(poa),
00071   _channel(channel),
00072   _pushConsumer(NULL),
00073   _pullConsumer(NULL),
00074   _queue()
00075 {
00076   OepPrxyList pdat;
00077 
00078   // Build Push Consumer proxies
00079   pdat = saps.getProxyPushConsumers();
00080   if(!pdat.empty())
00081   {
00082     _pushConsumer=new ProxyPushConsumer_i(_poa,_queue);
00083     for(OepPrxyList::iterator iter=pdat.begin(); iter!=pdat.end(); iter++)
00084     {
00085       _pushConsumer->reincarnate((*iter)->getKey(),(*iter)->getIor());
00086     }
00087   }
00088 
00089   // Build Pull Consumer proxies
00090   pdat = saps.getProxyPullConsumers();
00091   if(!saps.getProxyPullConsumers().empty())
00092   {
00093     _pullConsumer=new ProxyPullConsumerManager(_poa,_queue);
00094     _pullConsumer->reincarnate(saps.getProxyPullConsumers());
00095   }
00096 
00097   // Reactivate this servant.
00098   activateObjectWithId(saps.getKey());
00099 }
00100 
00101 
00102 SupplierAdmin_i::~SupplierAdmin_i()
00103 {
00104   if(_pushConsumer)
00105   {
00106     delete _pushConsumer;
00107     _pushConsumer=NULL;
00108   }
00109   if(_pullConsumer)
00110   {
00111     delete _pullConsumer;
00112     _pullConsumer=NULL;
00113   }
00114   for(list<CORBA::Any*>::iterator i=_queue.begin(); i!=_queue.end(); ++i)
00115       delete *i;
00116 }
00117 
00118 
00119 void SupplierAdmin_i::collect(list<CORBA::Any*>& events)
00120 {
00121   if(_pullConsumer)
00122      _pullConsumer->trigger();
00123   events=_queue;
00124   _queue.clear();
00125 }
00126 
00127 
00128 void SupplierAdmin_i::output(ostream& os)
00129 {
00130   Output out =basicOutput(os,"supplierAdmin",2,this);
00131   if(_pushConsumer)
00132      _pushConsumer->output(os);
00133   if(_pullConsumer)
00134      _pullConsumer->output(os);
00135 }
00136 
00137 
00138 }; // end namespace OmniEvents

Generated on Fri Dec 12 10:53:03 2003 for OmniEvents by doxygen1.2.15