SingleThreadAnalogMsgDispatcher.h

Go to the documentation of this file.
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     /*  NOTE: both fields should be of type double.
00041      *
00042      * \param src pointer to the object containing the source field
00043      * \param srcfield name of the field which is the source of the analog message
00044      * \param dest pointer to the destination object containing the destination field
00045      * \param destfield name of the field which is the target of the analog message
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     // destinations list
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     // sources list
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     // sources -> destination_vector position mapping
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 /*SingleThreadAnalogMsgDispatcher_H_*/

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