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
00048
00049 type<analog_port_id_t>::iterator end(analog_port_id_t const&);
00050
00051
00052
00053 protected:
00054
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
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
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
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 #endif