Tiny local class to load a PLUMED kernel. More...
#include <PlumedHandle.h>
Public Member Functions | |
PlumedHandle () | |
Default constructor. | |
PlumedHandle (PlumedHandle &&other) noexcept | |
Move constructor. | |
virtual | ~PlumedHandle () |
Destructor. | |
void | cmd (const char *key, const TypesafePtr &val=nullptr) |
Bring in the possibility to pass shape/nelem. | |
virtual void | cmd (const std::string &key, const TypesafePtr &val=nullptr) |
Bring in the possibility to pass shape/nelem. | |
void | cmd (std::string_view key, const TypesafePtr &ptr) override |
Execute cmd. | |
void | cmd (std::string_view key, const TypesafePtr &val, const std::size_t *shape) |
Bring in the possibility to pass shape/nelem. | |
template<typename I, typename std::enable_if< std::is_integral< I >::value, int >::type = 0> | |
void | cmd (std::string_view key, const TypesafePtr &val, I nelem, const std::size_t *shape=nullptr) |
Bring in the possibility to pass shape/nelem. | |
void | cmd (std::string_view key, const TypesafePtr &val, std::initializer_list< SizeLike > shape) |
Bring in the possibility to pass shape/nelem. | |
PlumedHandle & | operator= (PlumedHandle &&other) noexcept |
Move assignment. | |
Static Public Member Functions | |
static PlumedHandle | dlopen (const char *path) |
Construct a PlumedHandle given the path to a kernel. | |
Private Member Functions | |
PlumedHandle (const char *path) | |
Constructor using the path to a kernel. | |
Private Attributes | |
void * | loaded =nullptr |
Pointer to loaded Plumed object;. | |
std::unique_ptr< PlumedMain > | local |
Pointer to PlumedMain. | |
Tiny local class to load a PLUMED kernel.
Maps command to either a loaded PLUMED kernel or to the present one. It provides a wrapper around the official interface located at wrapper/Plumed.h, with some changes. Differences are:
PLUMED_KERNEL
env var. Indeed, it would not make sense to use it, since this class is meant to load different kernels.In its implementation, this class uses the PLMD::Plumed class in wrapper/Plumed.h and thus has the same capability to load PLUMED kernels of any version (starting with 2.0). It can also be created without passing any kernel path. In that case it refers to the current one (the one to which this class belongs).
The following syntax creates a handle referring to the current kernel
PlumedHandle p; // Alternatively: // auto p=PlumedHandle(); p.cmd("init");
The following syntax instead creates a handle referring to a loaded kernel
PlumedHandle p(PlumedHandle::dlopen("/path/to/libplumedkernel.so"); // Alternatively: // auto p=PlumedHandle::dlopen("/path/to/libplumedkernel.so"); p.cmd("init");
Notice that if there are problems loading the kernel an exception is thrown. Thus, once constructed the object is guaranteed to be functional.
|
explicitprivate |
Constructor using the path to a kernel.
I keep it private to avoid confusion wrt the similar constructor of PLMD::Plumed that accepts a string (conversion from FORTRAN).
PLMD::PlumedHandle::PlumedHandle | ( | ) |
Default constructor.
Maps following commands to the current kernel.
|
virtual |
Destructor.
In case a kernel was dlopened, it dlcloses it. I make it virtual for future extensibility, though this is not necessary now.
|
noexcept |
Move constructor.
|
inline |
Bring in the possibility to pass shape/nelem.
|
inlinevirtual |
Bring in the possibility to pass shape/nelem.
Reimplemented from PLMD::WithCmd.
|
overridevirtual |
Execute cmd.
Reimplemented from PLMD::WithCmd.
|
inline |
Bring in the possibility to pass shape/nelem.
|
inline |
Bring in the possibility to pass shape/nelem.
|
inline |
Bring in the possibility to pass shape/nelem.
|
static |
Construct a PlumedHandle given the path to a kernel.
It just uses the private constructor PlumedHandle(const char* path).
|
noexcept |
Move assignment.
|
private |
Pointer to loaded Plumed object;.
|
private |
Pointer to PlumedMain.
Used when using the current kernel in order to avoid unneeded indirections.
Hosted by GitHub
![]() |
![]() |