• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/core/link.h

00001 // Copyright 2009-2010 Sandia Corporation. Under the terms
00002 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
00003 // Government retains certain rights in this software.
00004 // 
00005 // Copyright (c) 2009-2010, Sandia Corporation
00006 // All rights reserved.
00007 // 
00008 // This file is part of the SST software package. For license
00009 // information, see the LICENSE file in the top level directory of the
00010 // distribution.
00011 
00012 
00013 #ifndef SST_CORE_LINK_H
00014 #define SST_CORE_LINK_H
00015 
00016 #include <sst/core/sst_types.h>
00017 // #include <sst/core/eventFunctor.h>
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   /** Link between two components. Carries events */
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     /** set minimum link latency */
00042     void setLatency(Cycle_t lat);
00043 
00044 //     void setFunctor(EventHandler_t* functor) {
00045     void setFunctor(Event::HandlerBase* functor) {
00046         rFunctor = functor;
00047     }
00048 
00049     void setPolling();
00050     
00051     /** Send an event over the link with additional delay. Sends an event
00052         over a link with an additional delay specified with a
00053         TimeConverter. I.e. the total delay is the link's delay + the
00054         additional specified delay.
00055         @param delay The additional delay
00056         @param tc The time converter to specify units for the additional delay
00057         @param the Event to send
00058     */
00059     void Send( SimTime_t delay, TimeConverter* tc, Event* event );
00060     
00061     /** Send an event with additional delay. Sends an event over a link
00062         with additional delay specified by the Link's default
00063         timebase.
00064         @param delay The additional delay, in units of the default Link timebase
00065         @param event The event to send
00066     */
00067     inline void Send( SimTime_t delay, Event* event ) {
00068         Send(delay,defaultTimeBase,event);
00069     }
00070     
00071     /** Send an event with the Link's default delay
00072         @param event The event to send */
00073     inline void Send( Event* event ) {
00074         Send( 0, event );
00075     }
00076     
00077     
00078     /** Retrieve a pending event from the Link. For links which do not
00079         have a set event handler, they can be polled with this function.
00080         Returns NULL if there is no pending event.
00081     */
00082     Event* Recv();
00083     
00084     
00085     /** Manually set the default detaulTimeBase 
00086         @param tc TimeConverter object for the timebase */ 
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 //     EventQueue_t*      recvQueue;
00098     ActivityQueue* recvQueue;
00099     
00100     /** Recieve functor. This functor is set when the link is connected.
00101         Determines what the receiver wants to be called */ 
00102 //     EventHandler_t*  rFunctor; 
00103     Event::HandlerBase*  rFunctor;
00104     
00105     /** Timebase used if no other timebase is specified. Used to specify
00106         the untits for added delays when sending, such as in
00107         Link::Send(). Often set by the Component::registerClock()
00108         function if the regAll argument is true. */
00109     TimeConverter*     defaultTimeBase;
00110     
00111     /** Latency of the link. It is used by the partitioner as the
00112         weight. This latency is added to the delay put on the event by
00113         the component. */
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     //  ActivityQueue* send_queue;
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 } // namespace SST
00146 
00147 BOOST_CLASS_EXPORT_KEY(SST::Link)
00148 BOOST_CLASS_EXPORT_KEY(SST::SelfLink)
00149 
00150 #endif

Generated on Fri Oct 22 2010 11:02:13 for SST by  doxygen 1.7.1