DistIncomingAnalogSources2BufPosMap.h

Go to the documentation of this file.
00001 #ifndef DistIncomingAnalogSources2BufPosMap_H_
00002 #define DistIncomingAnalogSources2BufPosMap_H_
00003 
00004 #include <vector>
00005 #include <string>
00006 #include "pcsim_hash.h"
00007 #include <boost/functional/hash.hpp>
00008 
00009 #include "SimObject.h"
00010 #include "hash_ext.h"
00011 #include "AnalogDelayObject.h"
00012 
00013 using std::vector;
00014 using std::string;
00015 
00016 using std::pair;
00017 using std::make_pair;
00018 
00019 class DistIncomingAnalogSources2BufPosMap
00020 {
00021 public:
00022         template<typename T>
00023         struct type
00024         {
00025                 typedef typename hash_map< pair<SimObject::ID, T>, pair<unsigned, IncomingAnalogDelayObject *>,
00026                         PCSIM::hash< pair<SimObject::ID, T> > >::iterator iterator;
00027         };
00028 
00029         DistIncomingAnalogSources2BufPosMap();
00030         virtual ~DistIncomingAnalogSources2BufPosMap();
00031 
00033         inline type<analog_port_id_t>::iterator
00034                 find(const SimObject::ID &id, analog_port_id_t port);
00035 
00037         inline type<string>::iterator
00038                 find(const SimObject::ID &id, const string &fieldname);
00039 
00041         inline int insert(const SimObject::ID &id, analog_port_id_t port, size_t position, IncomingAnalogDelayObject *delayObject = NULL);
00042 
00044         inline int insert(const SimObject::ID &id, const string & fieldname, size_t position, IncomingAnalogDelayObject *delayObject = NULL);
00045 
00046         type<string>::iterator end(string const&);
00047         //type<string>::iterator begin(string const&);
00048 
00049         type<analog_port_id_t>::iterator end(analog_port_id_t const&);
00050         //type<analog_port_id_t>::iterator begin(analog_port_id_t const&);
00051 
00052 
00053 protected:
00054         // [simobject][port/field] -> position in the incoming buffer or null
00055         typedef hash_map< pair<SimObject::ID, analog_port_id_t>,
00056                 pair<unsigned, IncomingAnalogDelayObject *>,
00057                 PCSIM::hash< pair<SimObject::ID, analog_port_id_t> > >
00058                 port_incoming_sources_map_type;
00059 
00060         port_incoming_sources_map_type port_incoming_sources_map;
00061 
00062         typedef hash_map< pair<SimObject::ID, string>,
00063                 pair<unsigned, IncomingAnalogDelayObject *>,
00064                 PCSIM::hash< pair<SimObject::ID, string > > >
00065                 field_incoming_sources_map_type;
00066 
00067         field_incoming_sources_map_type field_incoming_sources_map;
00068 
00069 };
00070 
00071 inline DistIncomingAnalogSources2BufPosMap::type<analog_port_id_t>::iterator
00072 DistIncomingAnalogSources2BufPosMap::find(const SimObject::ID &id, analog_port_id_t port)
00073 {
00074         return port_incoming_sources_map.find(make_pair(id, port));
00075 }
00076 
00077 inline DistIncomingAnalogSources2BufPosMap::type<string>::iterator
00078 DistIncomingAnalogSources2BufPosMap::find(const SimObject::ID &id, const string &fieldname)
00079 {
00080         return field_incoming_sources_map.find(make_pair(id, fieldname));
00081 }
00082 
00083 inline int DistIncomingAnalogSources2BufPosMap::insert(const SimObject::ID &id, analog_port_id_t port, size_t position, IncomingAnalogDelayObject *delayObj)
00084 {
00085         return port_incoming_sources_map.insert(make_pair(make_pair(id, port), make_pair(position, delayObj))).first->second.first;
00086 }
00087 
00088 inline int DistIncomingAnalogSources2BufPosMap::insert(const SimObject::ID &id, const string &fieldname, size_t position, IncomingAnalogDelayObject *delayObj)
00089 {
00090         return field_incoming_sources_map.insert(make_pair(make_pair(id, fieldname), make_pair(position, delayObj))).first->second.first;
00091 }
00092 
00093 /*template <typename analogSrcType>
00094 inline typename DistIncomingAnalogSources2BufPosMap::type<analogSrcType>::iterator
00095 DistIncomingAnalogSources2BufPosMap::end()
00096 {
00097 return port_incoming_sources_map.end();
00098 }
00099 
00100 template <typename analogSrcType>
00101 inline typename DistIncomingAnalogSources2BufPosMap::type<analogSrcType>::iterator
00102 DistIncomingAnalogSources2BufPosMap::begin()
00103 {
00104 return port_incoming_sources_map.begin();
00105 }*/
00106 
00107 
00108 
00109 inline DistIncomingAnalogSources2BufPosMap::type<string>::iterator
00110 DistIncomingAnalogSources2BufPosMap::end(string const&)
00111 {
00112         return field_incoming_sources_map.end();
00113 }
00114 
00115 inline DistIncomingAnalogSources2BufPosMap::type<analog_port_id_t>::iterator
00116 DistIncomingAnalogSources2BufPosMap::end(analog_port_id_t const&)
00117 {
00118         return port_incoming_sources_map.end();
00119 }
00120 
00121 /*inline DistIncomingAnalogSources2BufPosMap::type<string>::iterator
00122 DistIncomingAnalogSources2BufPosMap::begin(string const&)
00123 {
00124         return field_incoming_sources_map.begin();
00125 }
00126 
00127 inline DistIncomingAnalogSources2BufPosMap::type<analog_port_id_t>::iterator
00128 DistIncomingAnalogSources2BufPosMap::begin(analog_port_id_t const&)
00129 {
00130         return port_incoming_sources_map.begin();
00131 }*/
00132 
00133 
00134 
00135 #endif /*DistIncomingAnalogSources2BufPosMap_H_*/

Generated on Wed Jul 9 16:34:37 2008 for PCSIM by  doxygen 1.5.5