LAMA
lama::DistributionFactory Class Reference

Singleton class for an object that provides distributions of a certain type. More...

#include <DistributionFactory.hpp>

Inheritance diagram for lama::DistributionFactory:

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 DistributionFactorygetFactory ()
 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

Detailed Description

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.


Member Typedef Documentation

typedef std::map<std::string, boost::shared_ptr<DistributionManager> > lama::DistributionFactory::DistributionToManagerMap

Constructor & Destructor Documentation

Destructor, also frees all registered communicator managers.

Constructor of a communicator factory.

The constructor is private to guarantee that only one singleton instance is created.


Member Function Documentation

void lama::DistributionFactory::addDistributionManager ( const std::string &  type,
boost::shared_ptr< DistributionManager manager 
)

This method adds a new distribution manager to the factory.

Parameters:
typeis the type of distribution that is managed by the manager.
manageris 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.

Get a distribution of a certain type with using additional arguments.

Parameters:
sizeis the global number of elements to be distributed
typeis 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]

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.

Parameters:
typeis the name of the needed communicator.
Returns:
pointer to the desired communicator, the default one if not found

References LAMA_ASSERT.

Get a default distribution from the factory.

Returns:
pointer to the default distribution. Method that returns a reference to the communicator factory singleton.

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]
void lama::DistributionFactory::setDefaultDistribution ( const std::string &  type,
int  arg1,
int  arg2 
) [static]
void lama::DistributionFactory::setDefaultDistributionType ( const std::string &  type) const

Set the default distribution type.

Referenced by setDefaultDistribution().

Routine to find a default communicator.


Field Documentation

std::vector<int> lama::DistributionFactory::mDefaultArgs [mutable, private]

Referenced by get(), and setDefaultDistribution().

Map with manager for each registered communicator type.

Referenced by get(), and release().


The documentation for this class was generated from the following files: