00001 00011 #ifndef CONNECTIONITERATOR_H 00012 #define CONNECTIONITERATOR_H 00013 00014 #include "RandomDistribution.h" 00015 #include "ThreadSpecificRandomEngine.h" 00016 #include "SimObjectIDSortedVector.h" 00017 #include "SimObjectPopulation.h" 00018 00019 #include <utility> 00020 using std::pair; 00021 00022 #include <cmath> 00023 00025 00030 class ConnectionIterator { 00031 00032 public: 00033 00035 ConnectionIterator(); 00036 00038 virtual ~ConnectionIterator(); 00039 00041 00042 00044 virtual void init( const SimObjectPopulation &src, const SimObjectPopulation &dst ) = 0; 00045 00047 virtual void reset(SimObject::ID::SortedVector::const_iterator src_begin, 00048 SimObject::ID::SortedVector::const_iterator src_end, 00049 SimObject::ID::SortedVector::const_iterator dst_begin, 00050 SimObject::ID::SortedVector::const_iterator dst_end ) = 0; 00051 00053 virtual bool next( pair<SimObject::ID, SimObject::ID> &connection ) = 0; 00054 00056 virtual bool getIdx(size_t &src_idx, size_t &dst_idx); 00057 00059 virtual size_t estimate() { return 0; } 00060 00062 00064 00065 00067 void setRNDEngine(RandomEngine *engine) { 00068 m_rnd_eng = engine; 00069 }; 00070 00072 void unsetRNDEngine(void) { 00073 theThreadSpecificRandomEngine.init(); 00074 m_rnd_eng =theThreadSpecificRandomEngine.get(); 00075 }; 00076 00078 00079 protected: 00080 00082 RandomEngine *m_rnd_eng; 00083 00084 pair<size_t, size_t> last_conn_idx; 00085 bool last_conn_valid; 00086 }; 00087 00088 #endif