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::ActionRegister Class Referenceabstract

Register holding all the allowed keywords. More...

#include <ActionRegister.h>

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

Public Member Functions

ID add (std::string key, const ActionRegisterPointers &content)
 Register a new class. More...
 
ID add (std::string key, creator_pointer cp, keywords_pointer kp)
 
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< Actioncreate (const ActionOptions &ao)
 Create an Action of the type indicated in the options. More...
 
std::unique_ptr< Actioncreate (const std::vector< void * > &images, const ActionOptions &ao)
 
const ActionRegisterPointersget (const std::string &key) const
 Return the content associated to a key in the register, only considering the default image. More...
 
const ActionRegisterPointersget (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...
 
std::vector< std::string > getActionNames () const
 
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 > getKeysWithDLHandle (void *handle) const
 Get only keys registered specifically by a given image. More...
 
bool getKeywords (const std::string &action, Keywords &keys)
 Retrieve a keywords object for a particular action. More...
 
void getKeywords (const std::vector< void * > &images, const std::string &action, Keywords &keys)
 
bool printManual (const std::string &action, const bool &vimout, const bool &spellout)
 Print out the keywords for an action in html/vim ready for input into the manual. More...
 
bool printTemplate (const std::string &action, bool include_optional)
 Print out a template command for an action. 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 ActionRegisterPointers::creator_pointer creator_pointer
 
typedef ActionRegisterPointers::keywords_pointer keywords_pointer
 
typedef ActionRegisterPointers 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.)

ActionRegisteractionRegister ()
 Function returning a reference to the ActionRegister. More...
 
#define PLUMED_REGISTER_ACTION(classname, directive)
 Shortcut for Action registration. More...
 

Detailed Description

Register holding all the allowed keywords.

This is a register which holds a map between strings (directives) and function pointers. The function pointers are pointing to functions which create an object of the corresponding class given the corresponding options (ActionOptions). There should be only one of there objects allocated. Actions should be registered here at the beginning of execution

Member Typedef Documentation

◆ creator_pointer

typedef ActionRegisterPointers::creator_pointer PLMD::ActionRegister::creator_pointer
private

◆ keywords_pointer

typedef ActionRegisterPointers::keywords_pointer PLMD::ActionRegister::keywords_pointer
private

◆ Pointers

Member Function Documentation

◆ add() [1/2]

RegisterBase< ActionRegisterPointers >::ID PLMD::RegisterBase< ActionRegisterPointers >::add ( std::string  key,
const ActionRegisterPointers 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]

ActionRegister::ID PLMD::ActionRegister::add ( std::string  key,
creator_pointer  cp,
keywords_pointer  kp 
)

◆ check() [1/2]

bool PLMD::RegisterBase< ActionRegisterPointers >::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< ActionRegisterPointers >::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< ActionRegisterPointers >::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< ActionRegisterPointers >::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< Action > PLMD::ActionRegister::create ( const ActionOptions ao)

Create an Action 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< Action > PLMD::ActionRegister::create ( const std::vector< void * > &  images,
const ActionOptions ao 
)

◆ get() [1/2]

const ActionRegisterPointers & PLMD::RegisterBase< ActionRegisterPointers >::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 ActionRegisterPointers & PLMD::RegisterBase< ActionRegisterPointers >::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.

◆ getActionNames()

std::vector< std::string > PLMD::ActionRegister::getActionNames ( ) const

◆ getFullPath()

const std::string & PLMD::RegisterBase< ActionRegisterPointers >::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]

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

std::vector< std::string > PLMD::RegisterBase< ActionRegisterPointers >::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*.

◆ getKeysWithDLHandle()

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

Get only keys registered specifically by a given image.

◆ getKeywords() [1/2]

bool PLMD::ActionRegister::getKeywords ( const std::string &  action,
Keywords keys 
)

Retrieve a keywords object for a particular action.

◆ getKeywords() [2/2]

void PLMD::ActionRegister::getKeywords ( const std::vector< void * > &  images,
const std::string &  action,
Keywords keys 
)

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

◆ popDLRegistration()

void PLMD::Register::popDLRegistration ( )
staticprivatenoexceptinherited

Finalize registration - only used by registrationLock()

◆ printManual()

bool PLMD::ActionRegister::printManual ( const std::string &  action,
const bool &  vimout,
const bool &  spellout 
)

Print out the keywords for an action in html/vim ready for input into the manual.

◆ printTemplate()

bool PLMD::ActionRegister::printTemplate ( const std::string &  action,
bool  include_optional 
)

Print out a template command for an action.

◆ 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< ActionRegisterPointers >::remove ( ID  id)
inherited

Remove a registered keyword.

Use the ID returned by add().

Friends And Related Function Documentation

◆ actionRegister()

ActionRegister & actionRegister ( )
related

Function returning a reference to the ActionRegister.

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

◆ PLUMED_REGISTER_ACTION

#define PLUMED_REGISTER_ACTION (   classname,
  directive 
)
related
Value:
PLUMED_CONCATENATE(classname##Registerer,__LINE__)(directive);}

Shortcut for Action registration.

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

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< ActionRegisterPointers >::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< ActionRegisterPointers >::staged_m
privateinherited

Map of staged keys.


The documentation for this class was generated from the following files:
PLMD::ActionRegistration
Each instance of this specialized class represents an action that can be called with the specified di...
Definition: ActionRegister.h:92