link.h

Go to the documentation of this file.
00001 #ifndef __LINK_H__
00002 #define __LINK_H__
00003 
00004 #include "simulator.h"
00005 #include <list>
00006 #include <iostream>
00007 #include <stdint.h>
00008 
00009 using namespace std;
00010 
00011 class OutputBase
00012 {
00013  public:
00014   OutputBase(int ID, double l) : componentId(ID), latency(l){}
00015     virtual void CallHandler(uint64_t, int) = 0;
00016     int componentId;
00017     double latency;
00018 };
00019 
00020 template<typename OBJ>
00021   class Output0 : public OutputBase
00022 {
00023  public:
00024   Output0(int componentId, double l, void (OBJ::*f)(uint64_t, int), OBJ* obj0)
00025     : OutputBase(componentId, l), handler(f), obj(obj0){}
00026     void (OBJ::*handler)(uint64_t, int);
00027     OBJ* obj;
00028     void CallHandler(uint64_t data, int src)
00029     {
00030       //cout<<"In Output0 handler"<<endl;
00031       (obj->*handler)(data, src);
00032     }
00033 };
00034 
00035 class Link
00036 {
00037  public:
00038 
00039   int src;
00040   int width;
00041 
00042   list<OutputBase*> outputs;
00043   Link(int srcComponentId, int linkWidth);
00044 
00045   void Send(uint64_t data, int srcComponentId);  
00046 };
00047 
00048  template<typename OBJ>
00049  void addOutput(Link* l, int outComponent, double latency, 
00050                    void (OBJ::*f)(uint64_t, int), OBJ* obj0)
00051   {
00052     OutputBase* temp = new Output0<OBJ>(outComponent, latency, f, obj0);
00053     l->outputs.push_back(temp);
00054   }
00055 #endif

Generated on Tue Oct 19 17:22:00 2010 for IRIS by  doxygen 1.5.8