LAMA
lama::CommunicatorFactory Class Reference

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

#include <CommunicatorFactory.hpp>

Inheritance diagram for lama::CommunicatorFactory:

Public Types

typedef std::map< std::string,
boost::shared_ptr
< CommunicatorManager > > 
CommunicatorToManagerMap

Public Member Functions

boost::shared_ptr
< CommunicatorManager
getCommunicatorManager (const std::string &type)
 Get a communicator of a certain type from the factory.
void addCommunicatorManager (const std::string &type, boost::shared_ptr< CommunicatorManager > manager)
 This method adds a new communicator manager to the factory.
const std::string & getDefaultCommunicatorType () const
 Query routine for the default communicator type.
void setDefaultCommunicatorType (const std::string &type) const
 Set the default communicator type.
virtual ~CommunicatorFactory ()
 Destructor, also frees all registered communicator managers.

Static Public Member Functions

static CommunicatorPtr get (const std::string &type, int &argc, char **&argv)
 Get a communicator of a certain type with using inline arguments.
static CommunicatorPtr get (const std::string &type)
 Get a communicator of a certain type from the factory.
static CommunicatorPtr get ()
 Get a default communicator from the factory.
static CommunicatorFactorygetFactory ()
 Method that returns a reference to the communicator factory singleton.
static void release ()
 Releases all communication managers registered in the communicator factory instance.

Private Member Functions

void setDefaultCommunicatorType () const
 Routine to find a default communicator.
 CommunicatorFactory ()
 Constructor of a communicator factory.
 LAMA_LOG_DECL_STATIC_LOGGER (logger)

Private Attributes

CommunicatorToManagerMap mCommunicatorToManagerMap
 Map with manager for each registered communicator type.
std::string mDefaultCommunicatorType

Detailed Description

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

The factory uses managers that must have been registered before. This gives extensibility for new communicator classes as the factory itself has no need to create any communicator by itself.

Communicator 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 communicator is given by a string.


Member Typedef Documentation

typedef std::map<std::string, boost::shared_ptr<CommunicatorManager> > lama::CommunicatorFactory::CommunicatorToManagerMap

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::CommunicatorFactory::addCommunicatorManager ( const std::string &  type,
boost::shared_ptr< CommunicatorManager manager 
)

This method adds a new communicator manager to the factory.

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

Referenced by lama::PGASCommunicatorManager::init().

CommunicatorPtr lama::CommunicatorFactory::get ( const std::string &  type,
int &  argc,
char **&  argv 
) [static]

Get a communicator of a certain type with using inline arguments.

Parameters:
typeis the communicator type needed
argcpointer to the number of command line arguments
argvreference to the array of command line arguments

Note: the command line arguments might be modified.

References getDefaultCommunicatorType(), LAMA_THROWEXCEPTION, and mCommunicatorToManagerMap.

CommunicatorPtr lama::CommunicatorFactory::get ( const std::string &  type) [static]

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
boost::shared_ptr< CommunicatorManager > lama::CommunicatorFactory::getCommunicatorManager ( 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.

Referenced by lama::MatrixConfigGrammar::MatrixConfigGrammar().

Query routine for the default communicator type.

References LAMA_ENV_FOR_COMMUNICATOR.

Referenced by get().

Method that returns a reference to the communicator factory singleton.

Referenced by lama::PGASCommunicatorManager::init(), and lama::MatrixConfigGrammar::MatrixConfigGrammar().

Releases all communication managers registered in the communicator factory instance.

Might be called at the end of a program to finalize all communication before program exit. NOTE: was mandatory for VAMPIR trace of MPI communication.

References mCommunicatorToManagerMap.

void lama::CommunicatorFactory::setDefaultCommunicatorType ( const std::string &  type) const

Set the default communicator type.

Routine to find a default communicator.

References LAMA_THROWEXCEPTION.


Field Documentation

Map with manager for each registered communicator type.

Referenced by get(), and release().


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