00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef _SST_LINK_H
00015 #define _SST_LINK_H
00016
00017 #include <sst/core/sst.h>
00018
00019 #include <sst/core/eventQueue.h>
00020 #include <sst/core/eventFunctor.h>
00021
00022 namespace SST {
00023
00024 #define _LINK_DBG( fmt, args...) __DBG( DBG_LINK, Link, fmt, ## args )
00025
00026 class TimeConverter;
00027 class LinkPair;
00028 class Event;
00029
00030
00031 class Link {
00032 typedef enum { POLL, HANDLER, QUEUE } Type_t;
00033 public:
00034
00035 friend class LinkPair;
00036
00037 Link();
00038
00039 ~Link();
00040
00041
00042 void setLatency(Cycle_t lat);
00043
00044 void setFunctor(EventHandler_t* functor) {
00045 rFunctor = functor;
00046 }
00047
00048 void setPolling();
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 void Send( SimTime_t delay, TimeConverter* tc, Event* event );
00059
00060
00061
00062
00063
00064
00065
00066 inline void Send( SimTime_t delay, Event* event ) {
00067 Send(delay,defaultTimeBase,event);
00068 }
00069
00070
00071
00072 inline void Send( Event* event ) {
00073 Send( 0, event );
00074 }
00075
00076
00077
00078
00079
00080
00081 Event* Recv();
00082
00083
00084
00085
00086 void setDefaultTimeBase(TimeConverter* tc);
00087
00088 inline void deliverEvent(Event* event) {
00089 (*rFunctor)(event);
00090 }
00091
00092 protected:
00093 EventQueue_t* recvQueue;
00094
00095
00096
00097 EventHandler_t* rFunctor;
00098
00099
00100
00101
00102
00103 TimeConverter* defaultTimeBase;
00104
00105
00106
00107
00108 SimTime_t latency;
00109
00110 protected:
00111 Link* pair_link;
00112
00113 private:
00114 Link( const Link& l );
00115
00116 Type_t type;
00117
00118 LinkId_t id;
00119
00120
00121 friend class boost::serialization::access;
00122 template<class Archive>
00123 void serialize(Archive & ar, const unsigned int version )
00124 {
00125 ar & BOOST_SERIALIZATION_NVP( defaultTimeBase );
00126 ar & BOOST_SERIALIZATION_NVP( latency );
00127 ar & BOOST_SERIALIZATION_NVP( type );
00128 }
00129 };
00130
00131 class SelfLink : public Link {
00132
00133 public:
00134 SelfLink() :
00135 Link()
00136 {
00137 pair_link = this;
00138 }
00139
00140 };
00141
00142
00143 }
00144
00145 #endif