Classes | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | Static Private Member Functions | Private Attributes | List of all members
PLMD::RegisterBase< Content > Class Template Reference

General register. More...

#include <RegisterBase.h>

Inheritance diagram for PLMD::RegisterBase< Content >:
Inheritance graph
[legend]

Classes

struct  ContentAndFullPath
 auxiliary class More...
 
struct  ID
 

Public Member Functions

 ~RegisterBase () noexcept override
 
ID add (std::string key, const Content &content)
 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...
 
const Content & get (const std::string &key) const
 Return the content associated to a key in the register, only considering the default image. More...
 
const Content & get (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 > getKeysWithDLHandle (void *handle) const
 Get only keys registered specifically by a given image. 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...
 

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

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

Detailed Description

template<class Content>
class PLMD::RegisterBase< Content >

General register.

This class provide a generic implementation based on the content of the Register

Constructor & Destructor Documentation

◆ ~RegisterBase()

template<class Content >
PLMD::RegisterBase< Content >::~RegisterBase
overridenoexcept

Member Function Documentation

◆ add()

template<class Content >
RegisterBase< Content >::ID PLMD::RegisterBase< Content >::add ( std::string  key,
const Content &  content 
)

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]

template<class Content >
bool PLMD::RegisterBase< Content >::check ( const std::string &  key) const

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

◆ check() [2/2]

template<class Content >
bool PLMD::RegisterBase< Content >::check ( const std::vector< void * > &  images,
const std::string &  key 
) const

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

◆ clearStaged()

template<class Content >
void PLMD::RegisterBase< Content >::clearStaged ( )
overridevirtualnoexcept

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()

template<class Content >
void PLMD::RegisterBase< Content >::completeRegistration ( void *  handle)
overridevirtual

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

Implements PLMD::Register.

◆ get() [1/2]

template<class Content >
const Content & PLMD::RegisterBase< Content >::get ( const std::string &  key) const

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

◆ get() [2/2]

template<class Content >
const Content & PLMD::RegisterBase< Content >::get ( const std::vector< void * > &  images,
const std::string &  key 
) const

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

◆ getFullPath()

template<class Content >
const std::string & PLMD::RegisterBase< Content >::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.

◆ getKeys()

template<class Content >
std::vector< std::string > PLMD::RegisterBase< Content >::getKeys
overridevirtual

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.

◆ popDLRegistration()

void PLMD::Register::popDLRegistration ( )
staticprivatenoexceptinherited

Finalize registration - only used by registrationLock()

◆ 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()

template<class Content >
void PLMD::RegisterBase< Content >::remove ( ID  id)

Remove a registered keyword.

Use the ID returned by add().

Member Data Documentation

◆ m

template<class Content >
std::map<std::string,std::unique_ptr<ContentAndFullPath> > PLMD::RegisterBase< Content >::m
private

Main register map.

◆ mutex

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

Mutex protecting access to map.

◆ staged_m

template<class Content >
std::map<std::string,std::unique_ptr<ContentAndFullPath> > PLMD::RegisterBase< Content >::staged_m
private

Map of staged keys.


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