00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00033
00034
00049 #ifndef _PUSHSUPP_H
00050 #define _PUSHSUPP_H
00051
00052 #include <OpenTracker/OpenTracker.h>
00053 #include <OpenTracker/tool/OT_ACE_Log.h>
00054 #include <OpenTracker/skeletons/OT_CORBA.hh>
00055 #include <OpenTracker/network/CORBAUtils.h>
00056 #include <omniEvents/CosEventComm.hh>
00057 #include <omniEvents/CosEventChannelAdmin.hh>
00058
00067 namespace ot {
00068
00069 class CORBAModule;
00070
00071 class Supplier_i : virtual public POA_CosEventComm::PushSupplier {
00072 public:
00073 Supplier_i () {};
00074 void disconnect_push_supplier () {
00075 logPrintI("Push Supplier: disconnected.\n");
00076 };
00077 };
00078
00079 class OPENTRACKER_API PushSupp : public Node
00080 {
00081
00082 public:
00084 CosEventChannelAdmin::EventChannel_var channel;
00085 CosEventChannelAdmin::SupplierAdmin_var supplier_admin;
00086 CosEventChannelAdmin::ProxyPushConsumer_var proxy_consumer;
00087 CosEventComm::PushSupplier_var sptr;
00088 Supplier_i* supplier;
00089 int cycle;
00090
00091
00092
00093 protected:
00097 PushSupp( CosEventChannelAdmin::EventChannel_var channel_) :
00098 Node(),
00099 channel( channel_ ),
00100 cycle ( 0 )
00101 {
00102 supplier = new Supplier_i();
00103 try {
00104 supplier_admin = CORBAUtils::getSupplierAdmin(channel);
00105 } catch (CORBA::INV_OBJREF) {
00106 LOG_ACE_ERROR("Object reference of event channel is internally malformed. Exiting....\n");
00107 exit(-1);
00108 }
00109 proxy_consumer = CORBAUtils::getProxyPushConsumer(supplier_admin);
00110 CosEventComm::PushSupplier_var sptr = supplier->_this();
00111 CORBAUtils::connectPushSupplier(proxy_consumer, sptr);
00112 }
00113 virtual ~PushSupp() {
00114 CORBAUtils::disconnectPushSupplier(proxy_consumer);
00115 delete supplier;
00116 logPrintI("PushSupp destructor");
00117 }
00118
00119 public:
00123 virtual int isEventGenerator()
00124 {
00125 return 1;
00126
00127 }
00128
00138 virtual void onEventGenerated( Event& event, Node& generator)
00139 {
00140 cycle++;
00141
00142
00143 OT_CORBA::Event corba_event = event.getCORBAEvent();
00144 try {
00145 CORBA::Any any;
00146 any <<= corba_event;
00147 proxy_consumer->push(any);
00148 }
00149 catch (CORBA::COMM_FAILURE) {
00150 logPrintE("Caught CORBA::COMM_FAILURE\n");
00151 }
00152 catch (CORBA::TRANSIENT) {
00153 logPrintE("Caught CORBA::TRANSIENT\n");
00154 }
00155 updateObservers( event );
00156 }
00157
00158 friend class CORBAModule;
00159 };
00160
00161 }
00162
00163 #endif