Public Member Functions | Private Types | Private Attributes | Friends | Related Functions | List of all members
PLMD::CLToolRegister Class Reference

Same as ActionRegister, but for CLTools. More...

#include <CLToolRegister.h>

Public Member Functions

 ~CLToolRegister ()
 
void add (std::string key, creator_pointer cp, keywords_pointer kp)
 Register a new class. More...
 
bool check (std::string cltool) const
 Verify if a directive is present in the register. More...
 
std::unique_ptr< CLToolcreate (const CLToolOptions &ao)
 Create an CLTool of the type indicated in the options. More...
 
std::vector< std::string > getKeys (const std::string &cltool) const
 Return all the keys of this cltool. More...
 
std::vector< std::string > list () const
 Returns a list of the allowed CLTools. More...
 
bool printManual (const std::string &cltool, const bool &spelling)
 Print out the instructions for using the tool in html ready for input into the manual. More...
 
void remove (creator_pointer)
 

Private Types

typedef std::unique_ptr< CLTool >(* creator_pointer) (const CLToolOptions &)
 Pointer to a function which, given the options, create an CLTool. More...
 
typedef void(* keywords_pointer) (Keywords &)
 Pointer to a function which, returns the keywords allowed. More...
 

Private Attributes

std::set< std::string > disabled
 Set of disabled cltools (which were registered more than once) More...
 
std::map< std::string, creator_pointerm
 Map cltool to a function which creates the related object. More...
 
std::map< std::string, Keywordsmk
 Map cltool name to the keywords for this function. More...
 

Friends

std::ostream & operator<< (std::ostream &, const CLToolRegister &)
 Write on a stream the list of registered directives. More...
 

Related Functions

(Note that these are not member functions.)

CLToolRegistercltoolRegister ()
 Function returning a reference to the CLToolRegister. More...
 
#define PLUMED_REGISTER_CLTOOL(classname, directive)
 Shortcut for CLTool registration. More...
 

Detailed Description

Same as ActionRegister, but for CLTools.

Member Typedef Documentation

◆ creator_pointer

typedef std::unique_ptr<CLTool>(* PLMD::CLToolRegister::creator_pointer) (const CLToolOptions &)
private

Pointer to a function which, given the options, create an CLTool.

◆ keywords_pointer

typedef void(* PLMD::CLToolRegister::keywords_pointer) (Keywords &)
private

Pointer to a function which, returns the keywords allowed.

Constructor & Destructor Documentation

◆ ~CLToolRegister()

PLMD::CLToolRegister::~CLToolRegister ( )

Member Function Documentation

◆ add()

void PLMD::CLToolRegister::add ( std::string  key,
creator_pointer  cp,
keywords_pointer  kp 
)

Register a new class.

Parameters
keyThe name of the directive to be used in the input file
cpA pointer to a function which creates an object of that class
kpA pointer to a function which returns the allowed keywords

◆ check()

bool PLMD::CLToolRegister::check ( std::string  cltool) const

Verify if a directive is present in the register.

◆ create()

std::unique_ptr< CLTool > PLMD::CLToolRegister::create ( const CLToolOptions ao)

Create an CLTool of the type indicated in the options.

Parameters
aoobject containing information for initialization, such as the full input line, a pointer to PlumedMain, etc

◆ getKeys()

std::vector< std::string > PLMD::CLToolRegister::getKeys ( const std::string &  cltool) const

Return all the keys of this cltool.

◆ list()

std::vector< std::string > PLMD::CLToolRegister::list ( ) const

Returns a list of the allowed CLTools.

◆ printManual()

bool PLMD::CLToolRegister::printManual ( const std::string &  cltool,
const bool &  spelling 
)

Print out the instructions for using the tool in html ready for input into the manual.

◆ remove()

void PLMD::CLToolRegister::remove ( creator_pointer  f)

Friends And Related Function Documentation

◆ cltoolRegister()

CLToolRegister & cltoolRegister ( )
related

Function returning a reference to the CLToolRegister.

To avoid problems with order of initialization, this function contains a static CLToolRegister which is built the first time the function is called. In this manner, it is always initialized before it's used

◆ operator<<

std::ostream& operator<< ( std::ostream &  ,
const CLToolRegister  
)
friend

Write on a stream the list of registered directives.

◆ PLUMED_REGISTER_CLTOOL

#define PLUMED_REGISTER_CLTOOL (   classname,
  directive 
)
related
Value:
namespace { class classname##RegisterMe{ \
static std::unique_ptr<PLMD::CLTool> create(const PLMD::CLToolOptions&ao){return PLMD::Tools::make_unique<classname>(ao);} \
public: \
classname##RegisterMe(){PLMD::cltoolRegister().add(directive,create,classname::registerKeywords);} \
~classname##RegisterMe(){PLMD::cltoolRegister().remove(create);} \
} classname##RegisterMeObject; }

Shortcut for CLTool registration.

For easier registration, this file also provides a macro PLUMED_REGISTER_CLTOOL.

Parameters
classnamethe name of the class to be registered
directivea string containing the corresponding directive This macro should be used in the .cpp file of the corresponding class

Member Data Documentation

◆ disabled

std::set<std::string> PLMD::CLToolRegister::disabled
private

Set of disabled cltools (which were registered more than once)

◆ m

std::map<std::string,creator_pointer> PLMD::CLToolRegister::m
private

Map cltool to a function which creates the related object.

◆ mk

std::map<std::string,Keywords> PLMD::CLToolRegister::mk
private

Map cltool name to the keywords for this function.


The documentation for this class was generated from the following files:
PLMD::CLToolOptions
Definition: CLTool.h:35
PLMD::CLToolRegister::remove
void remove(creator_pointer)
Definition: CLToolRegister.cpp:44
PLMD::CLToolRegister::add
void add(std::string key, creator_pointer cp, keywords_pointer kp)
Register a new class.
Definition: CLToolRegister.cpp:52
PLMD::cltoolRegister
CLToolRegister & cltoolRegister()
Definition: CLToolRegister.cpp:39
PLMD::CLToolRegister::create
std::unique_ptr< CLTool > create(const CLToolOptions &ao)
Create an CLTool of the type indicated in the options.
Definition: CLToolRegister.cpp:68