CCAFFEINE  0.8.8
BblConnectionEventListener.h
00001 #ifndef __BBLCONNECTIONEVENTLISTENER_H__
00002 #define __BBLCONNECTIONEVENTLISTENER_H__
00003 
00004 class BblConnectionEventListener
00005 : public virtual ccafeopq::connectionevents::ConnectionEventListener
00006 {
00007   
00008 private:
00009 
00010   gov::cca::ports::EventType type;
00011   gov::cca::ports::ConnectionEventListener l;
00012 
00013 public:
00014   BblConnectionEventListener(gov::cca::ports::EventType type_,
00015                                gov::cca::ports::ConnectionEventListener l_) {
00016     type = type_;
00017     l = l_;
00018 #ifdef CCAFE_AUDIT
00019   IO_dn2("BblConnectionEventListener::CTOR %d", (int)type_);
00020 #endif
00021   }
00022   virtual ~BblConnectionEventListener(){
00023 #ifdef CCAFE_AUDIT
00024   IO_dn2("BblConnectionEventListener::DTOR %d", (int)type);
00025 #endif
00026   }
00027 
00028   virtual void connectionActivity( ccafeopq::connectionevents::ConnectionEvent_shared evt) {
00029     ::gov::cca::ports::EventType typ = gov::cca::ports::EventType_Error;
00030     if(evt->connected()) {
00031       if (evt->preChange()) {
00032         typ = gov::cca::ports::EventType_ConnectPending;
00033       } else {
00034         typ = gov::cca::ports::EventType_Connected;
00035       }
00036     } else if(evt->disconnected()) {
00037       if (evt->preChange()) {
00038         typ = gov::cca::ports::EventType_DisconnectPending;
00039       } else {
00040         typ = gov::cca::ports::EventType_Disconnected;
00041       }
00042     }
00043     if (type != gov::cca::ports::EventType_ALL && typ != type) {
00044       return;
00045     }
00046     
00047     // yes, this is the only way to tunnel shared pointers through babel
00048     // but it is possible.
00049     void * vp = 0;
00050     vp = evt->getOpqTypeMapSharedPtrAddress(); // fixme
00051     ::ccaffeine::TypeMap ctm = ccaffeine::TypeMap::_create();
00052     ctm.initialize(vp);
00053 
00054 #ifdef CCAFE_AUDIT
00055     IO_dn2("BblConnectionEventListener::activity %d", (int)typ);
00056 #endif
00057     ccaffeine::ports::ConnectionEvent bblEvt = ccaffeine::ports::ConnectionEvent::_create();
00058     bblEvt.initialize(typ, ctm);
00059     l.connectionActivity(bblEvt);
00060   }
00061 
00062 };
00063 
00064 #endif // __BBLCONNECTIONEVENTLISTENER_H__