ConnectionsProjection.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00015 #ifndef CONNECTIONSPROJECTION_H_
00016 #define CONNECTIONSPROJECTION_H_
00017 
00018 #include "SimNetwork.h"
00019 #include "SimObject.h"
00020 #include "SimObjectPopulation.h"
00021 #include "WiringMethodSelector.h"
00022 #include "ConnectionIterator.h"
00023 
00024 #include <utility>
00025 
00026 #include <boost/shared_ptr.hpp>
00027 using boost::shared_ptr;
00028 
00029 using std::pair;
00030 using std::make_pair;
00031 
00033 
00037 class ConnectionsProjection {
00038     public:
00039 
00041 
00051         ConnectionsProjection(
00052             shared_ptr<SimObjectPopulation> source,
00053             shared_ptr<SimObjectPopulation> destination,
00054             SimObjectFactory &connector,
00055             ConnectionIterator &iterator,
00056             WiringMethod *wiring = NULL,
00057             bool collectIDs = false,
00058             bool collectPairs = false);
00059 
00060 
00062 
00072         ConnectionsProjection(
00073             shared_ptr<SimObjectPopulation> source,
00074             shared_ptr<SimObjectPopulation> destination,
00075             ConnObjectFactory &connector,
00076             ConnectionIterator &iterator,
00077             WiringMethod *wiring = NULL,
00078             bool collectIDs = false,
00079             bool collectPairs = false);
00080 
00082 
00090         ConnectionsProjection(
00091             const SimObjectPopulation &source,
00092             const SimObjectPopulation &destination,
00093             ConnectionIterator &iterator,
00094             WiringMethod *wiring = NULL,
00095             bool collectPairs = false);
00096 
00098 
00105         ConnectionsProjection(
00106             const SimObjectPopulation &source,
00107             const SimObjectPopulation &destination,
00108             Time &delay,
00109             bool collectPairs = false);
00110 
00112         virtual ~ConnectionsProjection() { /*NOOP*/ };
00113 
00115 
00118         SimObject::ID::Packed operator [] (int idx) const {
00119             if (collectIDs)
00120                 return (*connector_ids)[idx];
00121             else {
00122                 return SimObject::ID().packed(); // invalid sim object id
00123             }
00124         };
00125 
00127 
00130         SimObject::ID operator() (int idx) const {
00131             if (collectIDs)
00132                 return SimObject::ID((*connector_ids)[idx]);
00133             else {
00134                 return SimObject::ID::Invalid; // invalid sim object id
00135             }
00136         };
00137 
00139 
00142         pair<SimObject::ID, SimObject::ID> prePostPair(int idx) const {
00143             if (collectPairs)
00144                 return (*connectPairs)[idx];
00145             else
00146                 return make_pair(SimObject::ID(), SimObject::ID()); // invalid id pair
00147         }
00148         ;
00149 
00151 
00154         SimObject * object(int idx) const {
00155             if (collectIDs)
00156                 return net->object((*connector_ids)[idx]);
00157             else
00158                 return NULL;
00159         };
00160 
00162         const vector<SimObject::ID::Packed> & idVector() const {
00163             return *connector_ids;
00164         };
00165 
00167         size_t size() const {
00168             if (collectIDs)
00169                 return connector_ids->size();
00170             else
00171                 return (*connector_ids)[0];
00172         };
00173 
00174     protected:
00176         SimNetwork *net;
00177 
00179         bool collectIDs;
00180 
00182         bool collectPairs;
00183 
00185         SimObject::ID::Vector connector_ids;
00186 
00188         WiringMethod::ConnectPairsVector connectPairs;
00189 
00190 };
00191 
00192 #endif /*CONNECTIONSPROJECTION_H_*/

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