Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Types | Static Private Member Functions | Private Attributes | Related Functions | List of all members
PLMD::CLToolRegister Class Referenceabstract

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

#include <CLToolRegister.h>

Inheritance diagram for PLMD::CLToolRegister:
Inheritance graph
[legend]

Public Member Functions

ID add (std::string key, const CLToolRegisterPointers &content)
 Register a new class. More...
 
ID add (std::string key, creator_pointer cp, keywords_pointer kp)
 Register a new class. More...
 
bool check (const std::string &key) const
 Verify if a key is present in the register, only considering the default image. More...
 
bool check (const std::vector< void * > &images, const std::string &key) const
 Verify if a key is present in the register, accessing to registered images. More...
 
void clearStaged () noexcept override
 Clear staged objects. More...
 
void completeRegistration (void *handle) override
 complete registration all staged keys will be enabled Should be called after dlopen has been completed correctly. More...
 
std::unique_ptr< CLToolcreate (const CLToolOptions &ao)
 Create an CLTool of the type indicated in the options. More...
 
std::unique_ptr< CLToolcreate (const std::vector< void * > &images, const CLToolOptions &ao)
 
const CLToolRegisterPointersget (const std::string &key) const
 Return the content associated to a key in the register, only considering the default image. More...
 
const CLToolRegisterPointersget (const std::vector< void * > &images, const std::string &key) const
 Return the content associated to a key in the register, accessing to registerd images. More...
 
const std::string & getFullPath (const std::vector< void * > &images, const std::string &key) const
 Return the full path associated to a key in the register, accessing to registerd images. More...
 
std::vector< std::string > getKeys () const override
 Get a list of keys Notice that these are the keys in the map, not the plumed keywords! Also notice that this list includes keys from all images, including the textual version of the image void*. More...
 
std::vector< std::string > getKeys (const std::string &cltool) const
 Return all the keys of this cltool. More...
 
std::vector< std::string > getKeysWithDLHandle (void *handle) const
 Get only keys registered specifically by a given image. 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 (ID id)
 Remove a registered keyword. More...
 

Static Public Member Functions

static void completeAllRegistrations (void *image)
 Save all staged objects in all registers. More...
 
static RegistrationLock registrationLock (const std::string &fullpath)
 return a registration lock More...
 

Protected Member Functions

virtual std::vector< std::string > getKeys () const =0
 Get all registered keys. More...
 

Static Protected Member Functions

static const std::string getRegisteringFullPath () noexcept
 Return the path of the currently-loading library. More...
 
static std::string imageToString (void *image)
 Internal tool to format image addresses. More...
 
static bool isDLRegistering () noexcept
 Check if we are in a dlopen section. More...
 

Protected Attributes

std::shared_mutex mutex
 Mutex protecting access to map. More...
 

Private Types

typedef CLToolRegisterPointers::creator_pointer creator_pointer
 
typedef CLToolRegisterPointers::keywords_pointer keywords_pointer
 
typedef CLToolRegisterPointers Pointers
 

Static Private Member Functions

static void popDLRegistration () noexcept
 Finalize registration - only used by registrationLock() More...
 
static void pushDLRegistration (const std::string &fullpath)
 Initialize registration - only used by registrationLock() More...
 

Private Attributes

std::map< std::string, std::unique_ptr< ContentAndFullPath > > m
 Main register map. More...
 
std::map< std::string, std::unique_ptr< ContentAndFullPath > > staged_m
 Map of staged keys. 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 CLToolRegisterPointers::creator_pointer PLMD::CLToolRegister::creator_pointer
private

◆ keywords_pointer

typedef CLToolRegisterPointers::keywords_pointer PLMD::CLToolRegister::keywords_pointer
private

◆ Pointers

Member Function Documentation

◆ add() [1/2]

RegisterBase< CLToolRegisterPointers >::ID PLMD::RegisterBase< CLToolRegisterPointers >::add ( std::string  key,
const CLToolRegisterPointers content 
)
inherited

Register a new class.

Parameters
keyThe name of the directive to be used in the input file
contentThe registered content
IDA returned ID that can be used to remove the directive later

◆ add() [2/2]

CLToolRegister::ID 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() [1/2]

bool PLMD::RegisterBase< CLToolRegisterPointers >::check ( const std::string &  key) const
inherited

Verify if a key is present in the register, only considering the default image.

◆ check() [2/2]

bool PLMD::RegisterBase< CLToolRegisterPointers >::check ( const std::vector< void * > &  images,
const std::string &  key 
) const
inherited

Verify if a key is present in the register, accessing to registered images.

◆ clearStaged()

void PLMD::RegisterBase< CLToolRegisterPointers >::clearStaged
overridevirtualnoexceptinherited

Clear staged objects.

Should be used when leaving the dlopen section to remove any dangling object.

Implements PLMD::Register.

◆ completeAllRegistrations()

void PLMD::Register::completeAllRegistrations ( void *  image)
staticinherited

Save all staged objects in all registers.

◆ completeRegistration()

void PLMD::RegisterBase< CLToolRegisterPointers >::completeRegistration ( void *  handle)
overridevirtualinherited

complete registration all staged keys will be enabled Should be called after dlopen has been completed correctly.

Implements PLMD::Register.

◆ create() [1/2]

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

◆ create() [2/2]

std::unique_ptr< CLTool > PLMD::CLToolRegister::create ( const std::vector< void * > &  images,
const CLToolOptions ao 
)

◆ get() [1/2]

const CLToolRegisterPointers & PLMD::RegisterBase< CLToolRegisterPointers >::get ( const std::string &  key) const
inherited

Return the content associated to a key in the register, only considering the default image.

◆ get() [2/2]

const CLToolRegisterPointers & PLMD::RegisterBase< CLToolRegisterPointers >::get ( const std::vector< void * > &  images,
const std::string &  key 
) const
inherited

Return the content associated to a key in the register, accessing to registerd images.

◆ getFullPath()

const std::string & PLMD::RegisterBase< CLToolRegisterPointers >::getFullPath ( const std::vector< void * > &  images,
const std::string &  key 
) const
inherited

Return the full path associated to a key in the register, accessing to registerd images.

◆ getKeys() [1/3]

virtual std::vector<std::string> PLMD::Register::getKeys ( ) const
protectedpure virtualinherited

Get all registered keys.

These are the keys in the map, not the plumed keywords!

Implemented in PLMD::RegisterBase< Content >.

◆ getKeys() [2/3]

std::vector< std::string > PLMD::RegisterBase< CLToolRegisterPointers >::getKeys
overrideinherited

Get a list of keys Notice that these are the keys in the map, not the plumed keywords! Also notice that this list includes keys from all images, including the textual version of the image void*.

◆ getKeys() [3/3]

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

Return all the keys of this cltool.

◆ getKeysWithDLHandle()

std::vector< std::string > PLMD::Register::getKeysWithDLHandle ( void *  handle) const
inherited

Get only keys registered specifically by a given image.

◆ getRegisteringFullPath()

const std::string PLMD::Register::getRegisteringFullPath ( )
staticprotectednoexceptinherited

Return the path of the currently-loading library.

◆ imageToString()

std::string PLMD::Register::imageToString ( void *  image)
staticprotectedinherited

Internal tool to format image addresses.

◆ isDLRegistering()

bool PLMD::Register::isDLRegistering ( )
staticprotectednoexceptinherited

Check if we are in a dlopen section.

◆ list()

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

Returns a list of the allowed CLTools.

◆ popDLRegistration()

void PLMD::Register::popDLRegistration ( )
staticprivatenoexceptinherited

Finalize registration - only used by registrationLock()

◆ 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.

◆ pushDLRegistration()

void PLMD::Register::pushDLRegistration ( const std::string &  fullpath)
staticprivateinherited

Initialize registration - only used by registrationLock()

◆ registrationLock()

Register::RegistrationLock PLMD::Register::registrationLock ( const std::string &  fullpath)
staticinherited

return a registration lock

◆ remove()

void PLMD::RegisterBase< CLToolRegisterPointers >::remove ( ID  id)
inherited

Remove a registered keyword.

Use the ID returned by add().

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

◆ PLUMED_REGISTER_CLTOOL

#define PLUMED_REGISTER_CLTOOL (   classname,
  directive 
)
related
Value:
namespace { class classname##RegisterMe{ \
CLToolRegister::ID id; \
static std::unique_ptr<CLTool> create(const CLToolOptions&ao) { \
return std::make_unique<classname>(ao); \
} \
public: \
classname##RegisterMe() : \
id(PLMD::cltoolRegister().add(directive,create,classname::registerKeywords)) \
{} \
~classname##RegisterMe(){PLMD::cltoolRegister().remove(id);} \
} 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

◆ m

std::map<std::string,std::unique_ptr<ContentAndFullPath> > PLMD::RegisterBase< CLToolRegisterPointers >::m
privateinherited

Main register map.

◆ mutex

std::shared_mutex PLMD::Register::mutex
mutableprotectedinherited

Mutex protecting access to map.

◆ staged_m

std::map<std::string,std::unique_ptr<ContentAndFullPath> > PLMD::RegisterBase< CLToolRegisterPointers >::staged_m
privateinherited

Map of staged keys.


The documentation for this class was generated from the following files:
PLMD::RegisterBase::remove
void remove(ID id)
Remove a registered keyword.
Definition: RegisterBase.h:271
PLMD::CLToolRegister::add
ID add(std::string key, creator_pointer cp, keywords_pointer kp)
Register a new class.
Definition: CLToolRegister.cpp:51
PLMD::CLToolRegister::cltoolRegister
CLToolRegister & cltoolRegister()
Function returning a reference to the CLToolRegister.
Definition: CLToolRegister.cpp:31
PLMD::cltoolRegister
CLToolRegister & cltoolRegister()
Definition: CLToolRegister.cpp:31
PLMD
Definition: AdjacencyMatrixBase.cpp:27
PLMD::CLToolRegister::create
std::unique_ptr< CLTool > create(const CLToolOptions &ao)
Create an CLTool of the type indicated in the options.
Definition: CLToolRegister.cpp:36