• Main Page
  • Classes
  • Files
  • File List

RoutingDelayMap.h

00001 #ifndef ROUTINGDELAYMAP_H_
00002 #define ROUTINGDELAYMAP_H_
00003 
00004 #include <vector>
00005 #include <map>
00006 #include "globals.h"
00007 #include "EvSimObject.h"
00008 
00009 using std::map;
00010 using std::vector;
00011 
00012 typedef double delay_t;
00013 
00015 
00026 class RoutingDelayMap
00027 {
00028 
00029 
00030 public:
00031     typedef map<delay_t, event_target_group_id_t> delaymaptype;
00032 
00033     // Iterator type for iterating through (delay, etg) pairs
00034     typedef delaymaptype::const_iterator const_iterator;
00035 
00036     RoutingDelayMap() : totalNumOutPorts(0) {};
00037 
00038     virtual ~RoutingDelayMap() {};
00039 
00041     inline void insert(global_out_port_id_t port_id, delay_t delay, event_target_group_id_t group)
00042     {
00043         resize( port_id );
00044         _map[port_id].insert( delaymaptype::value_type(delay, group) );
00045     }
00046 
00048 
00051     event_target_group_id_t find(global_out_port_id_t port_id, delay_t delay);
00052 
00054     inline const_iterator begin(global_out_port_id_t out_port_id)
00055     {
00056         resize( out_port_id );
00057         return _map[out_port_id].begin();
00058     };
00059 
00061     inline const_iterator end(global_out_port_id_t out_port_id)
00062     {
00063         resize( out_port_id );
00064         return _map[out_port_id].end();
00065     };
00066 
00067     inline void increaseTotalNumOutPorts(unsigned num_ports)
00068     {
00069         totalNumOutPorts += num_ports;
00070     }
00071 
00072     inline unsigned getTotalNumOutPorts()
00073     {
00074         return totalNumOutPorts;
00075     }
00076 
00077     void registerOutPorts(EvSimObject *obj);
00078 
00079 protected :
00080 
00081     inline void resize( global_out_port_id_t out_port_id )
00082     {
00083         if (out_port_id >= _map.size()) {
00084             _map.resize(out_port_id+1);
00085         }
00086     };
00087 
00088     // data structure used for holding the mapping: [senderid]->(delay, etg)
00089     vector< delaymaptype > _map;
00090 
00091     unsigned totalNumOutPorts;
00092 };
00093 
00094 #endif /*ROUTINGDELAYMAP_H_*/

Generated on Wed Sep 18 2013 11:25:40 for NEVESIM by  doxygen 1.7.1