Add a builder attribute to the topology and construct method

This commit is contained in:
lasnier 2012-11-20 16:53:28 +01:00
commit 631d693bef
8 changed files with 86 additions and 18 deletions

View file

@ -38,7 +38,7 @@ namespace smp
class AbstractTopology
{
public :
virtual std::vector<unsigned> getIdNeighbours(unsigned idIsland) const =0;
virtual std::vector<unsigned> getIdNeighbors(unsigned idIsland) const =0;
};
}

View file

@ -38,4 +38,4 @@ void paradiseo::smp::Complete::operator()(unsigned nbIsland, std::vector<std::ve
matrix.assign(nbIsland, line);
for(int i=0;i<nbIsland;i++)
matrix[i][i]=false;
}
}

View file

@ -28,7 +28,6 @@ Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <vector>
#include <topology/topologyBuilder.h>
#include <topology/ring.h>
void paradiseo::smp::Ring::operator()(unsigned nbIsland, std::vector<std::vector<bool>>& matrix) const

View file

@ -28,7 +28,6 @@ Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <vector>
#include <topology/topologyBuilder.h>
#include <topology/star.h>
void paradiseo::smp::Star::operator()(unsigned nbIsland, std::vector<std::vector<bool>>& matrix) const

View file

@ -30,18 +30,18 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <vector>
template <class TopologyType>
paradiseo::smp::Topology<TopologyType>::Topology(unsigned nbIsland)
{
TopologyType builder;
builder(nbIsland, _matrix);
}
template <class TopologyType>
std::vector<unsigned> paradiseo::smp::Topology<TopologyType>::getIdNeighbours(unsigned idIsland) const
std::vector<unsigned> paradiseo::smp::Topology<TopologyType>::getIdNeighbors(unsigned idIsland) const
{
std::vector<unsigned> neighbours;
std::vector<unsigned> neighbors;
for(unsigned j=0; j<_matrix.size();j++)
if(_matrix[idIsland][j]) neighbours.push_back(j);
if(_matrix[idIsland][j]) neighbors.push_back(j);
return neighbours;
return neighbors;
}
template <class TopologyType>
void paradiseo::smp::Topology<TopologyType>::construct(unsigned nbIsland)
{
_builder(nbIsland, _matrix);
}

View file

@ -40,9 +40,9 @@ class Topology : public AbstractTopology
{
public :
Topology(unsigned nbIsland);
std::vector<unsigned> getIdNeighbours(unsigned idIsland) const;
Topology() = default;
std::vector<unsigned> getIdNeighbors(unsigned idIsland) const;
void construct(unsigned nbIsland);
private :
TopologyType _builder;