OutgoingAnalogMPIBufferSourcesSet.h

Go to the documentation of this file.
00001 #ifndef OUTGOINGANALOGMPIBUFFERSOURCESSET_H_
00002 #define OUTGOINGANALOGMPIBUFFERSOURCESSET_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 
00012 using std::vector;
00013 using std::string;
00014 
00015 class OutgoingAnalogMPIBufferSourcesSet
00016 {
00017 public:
00018         OutgoingAnalogMPIBufferSourcesSet();
00019         virtual ~OutgoingAnalogMPIBufferSourcesSet();
00020 
00021         bool exists(SimObject *obj, string fieldname);
00022 
00023         bool exists(SimObject *obj, unsigned int port);
00024 
00025         bool insert(SimObject *obj, unsigned int port);
00026 
00027         bool insert(SimObject *obj, string fieldname);
00028 
00029 protected:
00030   typedef hash_set< SimObject *, PCSIM::hash<const SimObject *> > port_outgoing_msgs_inner_set_type;
00031   typedef vector< port_outgoing_msgs_inner_set_type > port_outgoing_msgs_set_type;
00032   port_outgoing_msgs_set_type port_outgoing_msgs_set;
00033 
00034   typedef hash_set< SimObject *, PCSIM::hash<const SimObject *> > field_outgoing_msgs_inner_set_type;
00035   typedef hash_map< string, field_outgoing_msgs_inner_set_type , PCSIM::hash<string> > field_outgoing_msgs_set_type;
00036   field_outgoing_msgs_set_type field_outgoing_msgs_set;
00037 
00038 };
00039 
00040 inline bool OutgoingAnalogMPIBufferSourcesSet::exists(SimObject *obj, unsigned int port)
00041 {
00042         if (port_outgoing_msgs_set.size() > port) {
00043                 if (port_outgoing_msgs_set[port].find(obj) != port_outgoing_msgs_set[port].end())
00044                         return true;
00045         }
00046         return false;
00047 }
00048 
00049 inline bool OutgoingAnalogMPIBufferSourcesSet::exists(SimObject *obj, string fieldname)
00050 {
00051         field_outgoing_msgs_set_type::iterator find_iter_field;
00052         if ((find_iter_field = field_outgoing_msgs_set.find(fieldname)) != field_outgoing_msgs_set.end()) {
00053                 if ((*find_iter_field).second.find(obj) != (*find_iter_field).second.end())
00054                         return true;
00055         }
00056         return false;
00057 }
00058 
00059 inline bool OutgoingAnalogMPIBufferSourcesSet::insert(SimObject *obj, unsigned int port)
00060 {
00061         if (port >= port_outgoing_msgs_set.size())
00062                 port_outgoing_msgs_set.resize(port + 1);
00063         return port_outgoing_msgs_set[port].insert(obj).second;
00064 }
00065 
00066 inline bool OutgoingAnalogMPIBufferSourcesSet::insert(SimObject *obj, string fieldname)
00067 {
00068   return field_outgoing_msgs_set[fieldname].insert(obj).second;
00069 }
00070 
00071 
00072 #endif /*OUTGOINGANALOGMPIBUFFERSOURCESSET_H_*/

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