00001 #ifndef SingleThreadAnalogMsgDispatcher_H_
00002 #define SingleThreadAnalogMsgDispatcher_H_
00003
00004 #include "SimObject.h"
00005 #include "AnalogMessageDispatcher.h"
00006
00007 #include <vector>
00008 #include <utility>
00009 #include "pcsim_hash.h"
00010
00011 #include "hash_ext.h"
00012
00013 using std::vector;
00014 using std::pair;
00015
00017
00020 class SingleThreadAnalogMsgDispatcher : public AnalogMessageDispatcher
00021 {
00022 public:
00023
00024 SingleThreadAnalogMsgDispatcher();
00025 virtual ~SingleThreadAnalogMsgDispatcher();
00026
00028
00037 void addAnalogMessage(SimObject *src, analog_port_id_t src_port, SimObject *dest, analog_port_id_t dest_port);
00038
00040
00041
00042
00043
00044
00045
00046
00047 void addAnalogMessage(SimObject *src, string srcfield, SimObject *dest, string destfield);
00048
00049
00051 void addAnalogMessage(SimObject *src, analog_port_id_t src_port, SimObject *dest, string destfield);
00052
00054 void addAnalogMessage(SimObject *src, string srcfield, SimObject *dest, analog_port_id_t dest_port);
00055
00057
00059 virtual void dispatchAnalogMsgs();
00060
00061
00062 virtual void initialize();
00063
00064 virtual void reset(double dt) {};
00065
00066 protected:
00067
00068 typedef vector< vector<pair<SimObject*,analog_port_id_t> > > port_msg_destinations_type;
00069
00070 typedef vector< vector< pair<void *, Field::ValueType> > > field_msg_destinations_type;
00071
00072 port_msg_destinations_type port2port_msg_destinations;
00073
00074 field_msg_destinations_type port2field_msg_destinations;
00075
00076 port_msg_destinations_type field2port_msg_destinations;
00077
00078 field_msg_destinations_type field2field_msg_destinations;
00079
00080
00081 typedef vector< pair< SimObject *,analog_port_id_t> > port_msg_sources_type;
00082 typedef vector< pair< void *, Field::ValueType> > field_msg_sources_type;
00083
00084 port_msg_sources_type port2port_msg_sources;
00085 port_msg_sources_type port2field_msg_sources;
00086
00087 field_msg_sources_type field2port_msg_sources;
00088 field_msg_sources_type field2field_msg_sources;
00089
00090
00091
00092 typedef hash_map< pair<SimObject *, analog_port_id_t>, int,
00093 PCSIM::hash< pair<SimObject *,analog_port_id_t> > > port_msg_sources_positions_type;
00094
00095 typedef hash_map< void *, int,
00096 PCSIM::hash<void *> > field_msg_sources_positions_type;
00097
00098 port_msg_sources_positions_type *port2port_msg_sources_positions;
00099 port_msg_sources_positions_type *port2field_msg_sources_positions;
00100
00101 field_msg_sources_positions_type *field2port_msg_sources_positions;
00102 field_msg_sources_positions_type *field2field_msg_sources_positions;
00103
00104 bool initialized;
00105
00106 };
00107
00108 #endif