LAMA
|
Singleton class for an object that provides distributions of a certain type. More...
#include <DistributionFactory.hpp>
Public Types | |
typedef std::map< std::string, boost::shared_ptr < DistributionManager > > | DistributionToManagerMap |
Public Member Functions | |
boost::shared_ptr < DistributionManager > | getDistributionManager (const std::string &type) |
Get a communicator of a certain type from the factory. | |
void | addDistributionManager (const std::string &type, boost::shared_ptr< DistributionManager > manager) |
This method adds a new distribution manager to the factory. | |
const std::string & | getDefaultDistributionType () const |
Query routine for the default distribution type. | |
void | setDefaultDistributionType (const std::string &type) const |
Set the default distribution type. | |
virtual | ~DistributionFactory () |
Destructor, also frees all registered communicator managers. | |
Static Public Member Functions | |
static DistributionPtr | get (const IndexType size) |
Get a distribution of a certain type with using additional arguments. | |
static DistributionPtr | get (const IndexType size, const std::string &type) |
static DistributionPtr | get (const IndexType size, const std::string &type, int arg1) |
static DistributionPtr | get (const IndexType size, const std::string &type, int arg1, int arg2) |
static DistributionPtr | get (const IndexType size, const std::string &type, const std::vector< int > &arguments) |
static DistributionFactory & | getFactory () |
Get a default distribution from the factory. | |
static void | setDefaultDistribution (const std::string &type) |
Method that sets the default distribution of the factory. | |
static void | setDefaultDistribution (const std::string &type, int arg1) |
static void | setDefaultDistribution (const std::string &type, int arg1, int arg2) |
static void | release () |
Releases all distribution managers registered in the communicator factory instance. | |
Private Member Functions | |
void | setDefaultDistributionType () const |
Routine to find a default communicator. | |
DistributionFactory () | |
Constructor of a communicator factory. | |
LAMA_LOG_DECL_STATIC_LOGGER (logger) | |
Private Attributes | |
DistributionToManagerMap | mDistributionToManagerMap |
Map with manager for each registered communicator type. | |
std::string | mDefaultDistributionType |
std::vector< int > | mDefaultArgs |
Singleton class for an object that provides distributions of a certain type.
The factory uses managers that must have been registered before. This gives extensibility for new distribution classes as the factory itself has no need to create any distribution by itself.
Distribution managers are stored via shared pointers so ownership of managers is flexible. The release function of the factory gives up ownership of all managers so they will be freed if there are no other references.
Note: The type of the disrtribution is given by a string.
typedef std::map<std::string, boost::shared_ptr<DistributionManager> > lama::DistributionFactory::DistributionToManagerMap |
lama::DistributionFactory::~DistributionFactory | ( | ) | [virtual] |
Destructor, also frees all registered communicator managers.
lama::DistributionFactory::DistributionFactory | ( | ) | [private] |
Constructor of a communicator factory.
The constructor is private to guarantee that only one singleton instance is created.
void lama::DistributionFactory::addDistributionManager | ( | const std::string & | type, |
boost::shared_ptr< DistributionManager > | manager | ||
) |
This method adds a new distribution manager to the factory.
type | is the type of distribution that is managed by the manager. |
manager | is the distribution manager that provides Distribution of the given type. |
The factory takes ownership of the manager, i.e. the manager will be deleted if it is replaced or if the factory is destroyed or released.
DistributionPtr lama::DistributionFactory::get | ( | const IndexType | size | ) | [static] |
Get a distribution of a certain type with using additional arguments.
size | is the global number of elements to be distributed |
type | is the communicator type needed |
The additional arguments will be passed to the manager that uses them for creation
References getDefaultDistributionType(), and mDefaultArgs.
DistributionPtr lama::DistributionFactory::get | ( | const IndexType | size, |
const std::string & | type | ||
) | [static] |
DistributionPtr lama::DistributionFactory::get | ( | const IndexType | size, |
const std::string & | type, | ||
int | arg1 | ||
) | [static] |
DistributionPtr lama::DistributionFactory::get | ( | const IndexType | size, |
const std::string & | type, | ||
int | arg1, | ||
int | arg2 | ||
) | [static] |
DistributionPtr lama::DistributionFactory::get | ( | const IndexType | size, |
const std::string & | type, | ||
const std::vector< int > & | arguments | ||
) | [static] |
References getDefaultDistributionType(), LAMA_THROWEXCEPTION, and mDistributionToManagerMap.
const std::string & lama::DistributionFactory::getDefaultDistributionType | ( | ) | const |
Query routine for the default distribution type.
References LAMA_ENV_FOR_DISTRIBUTION.
Referenced by get().
boost::shared_ptr< DistributionManager > lama::DistributionFactory::getDistributionManager | ( | const std::string & | type | ) |
Get a communicator of a certain type from the factory.
type | is the name of the needed communicator. |
References LAMA_ASSERT.
DistributionFactory & lama::DistributionFactory::getFactory | ( | ) | [static] |
Get a default distribution from the factory.
lama::DistributionFactory::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [private] |
void lama::DistributionFactory::release | ( | ) | [static] |
Releases all distribution managers registered in the communicator factory instance.
Might be called at the end of a program to finalize all distribution before program exit.
References mDistributionToManagerMap.
void lama::DistributionFactory::setDefaultDistribution | ( | const std::string & | type | ) | [static] |
Method that sets the default distribution of the factory.
References mDefaultArgs, and setDefaultDistributionType().
void lama::DistributionFactory::setDefaultDistribution | ( | const std::string & | type, |
int | arg1 | ||
) | [static] |
References mDefaultArgs, and setDefaultDistributionType().
void lama::DistributionFactory::setDefaultDistribution | ( | const std::string & | type, |
int | arg1, | ||
int | arg2 | ||
) | [static] |
References mDefaultArgs, and setDefaultDistributionType().
void lama::DistributionFactory::setDefaultDistributionType | ( | const std::string & | type | ) | const |
Set the default distribution type.
Referenced by setDefaultDistribution().
void lama::DistributionFactory::setDefaultDistributionType | ( | ) | const [private] |
Routine to find a default communicator.
std::vector<int> lama::DistributionFactory::mDefaultArgs [mutable, private] |
Referenced by get(), and setDefaultDistribution().
std::string lama::DistributionFactory::mDefaultDistributionType [mutable, private] |