Loading...
Searching...
No Matches
PLMD::CLToolRegister Class Reference

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

#include <CLToolRegister.h>

Inheritance diagram for PLMD::CLToolRegister:

Public Member Functions

ID add (std::string key, creator_pointer cp, keywords_pointer kp)
 Register a new class.
 
ID add (std::string key, const CLToolRegisterPointers &content)
 Register a new class.
 
bool check (const std::string &key) const
 Verify if a key is present in the register, only considering the default image.
 
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.
 
void clearStaged () noexcept override
 Clear staged objects.
 
void completeRegistration (void *handle) override
 complete registration all staged keys will be enabled Should be called after dlopen has been completed correctly.
 
std::unique_ptr< CLToolcreate (const CLToolOptions &ao)
 Create an CLTool of the type indicated in the options.
 
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.
 
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.
 
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.
 
std::vector< std::string > getKeys (const std::string &cltool) const
 Return all the keys of this cltool.
 
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!
 
std::vector< std::string > getKeysWithDLHandle (void *handle) const
 Get only keys registered specifically by a given image.
 
std::vector< std::string > list () const
 Returns a list of the allowed CLTools.
 
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.
 
void remove (ID id)
 Remove a registered keyword.
 

Static Public Member Functions

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

Static Protected Member Functions

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

Protected Attributes

std::shared_mutex mutex
 Mutex protecting access to map.
 

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()
 
static void pushDLRegistration (const std::string &fullpath)
 Initialize registration - only used by registrationLock()
 

Private Attributes

std::map< std::string, std::unique_ptr< ContentAndFullPath > > m
 Main register map.
 
std::map< std::string, std::unique_ptr< ContentAndFullPath > > staged_m
 Map of staged keys.
 

Related Symbols

(Note that these are not member symbols.)

CLToolRegistercltoolRegister ()
 Function returning a reference to the CLToolRegister.
 
#define PLUMED_REGISTER_CLTOOL(classname, directive)
 Shortcut for CLTool registrationFor easier registration, this file also provides a macro PLUMED_REGISTER_CLTOOL.
 

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]

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

◆ add() [2/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

◆ 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/2]

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

Return all the keys of this cltool.

◆ getKeys() [2/2]

std::vector< std::string > PLMD::RegisterBase< CLToolRegisterPointers >::getKeys ( ) const
overridevirtualinherited

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*

Implements PLMD::Register.

◆ 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 Symbol 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; }
Definition CLTool.h:35
std::unique_ptr< CLTool > create(const CLToolOptions &ao)
Create an CLTool of the type indicated in the options.
Definition CLToolRegister.cpp:36
CLToolRegister & cltoolRegister()
Function returning a reference to the CLToolRegister.
Definition CLToolRegister.cpp:31
ID add(std::string key, creator_pointer cp, keywords_pointer kp)
Register a new class.
Definition CLToolRegister.cpp:53
void remove(ID id)
Remove a registered keyword.
Definition RegisterBase.h:281
Definition AdjacencyMatrixBase.h:31
CLToolRegister & cltoolRegister()
Definition CLToolRegister.cpp:31

Shortcut for CLTool registrationFor 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: