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