Collective Variables Module - Developer Documentation
colvarparams.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 
3 // This file is part of the Collective Variables module (Colvars).
4 // The original version of Colvars and its updates are located at:
5 // https://github.com/Colvars/colvars
6 // Please update all Colvars source files before making any changes.
7 // If you wish to distribute your changes, please submit them to the
8 // Colvars repository at GitHub.
9 
10 #ifndef COLVARPARAMS_H
11 #define COLVARPARAMS_H
12 
13 #include <map>
14 
16 
17 class colvarmodule;
18 
19 class colvarparams {
20 
21  public:
22 
24  int param_exists(std::string const &param_name);
25 
27  virtual std::vector<std::string> get_param_names();
28 
30  virtual std::vector<std::string> get_param_grad_names();
31 
33  virtual void const *get_param_ptr(std::string const &param_name);
34 
36  virtual void const *get_param_grad_ptr(std::string const &param_name);
37 
39  virtual cvm::real get_param(std::string const &param_name);
40 
42  virtual int set_param(std::string const &param_name, void const *new_value);
43 
44 protected:
45 
46  colvarmodule *cvmodule = nullptr;
47 
49  colvarparams(colvarmodule *cvmodule_in);
50 
52  virtual ~colvarparams();
53 
55  std::map<std::string, void const *> param_map;
56 
58  std::map<std::string, colvarvalue const *> param_grad_map;
59 
61  void register_param(std::string const &param_name, void *param_ptr);
62 
64  void register_param_grad(std::string const &param_name,
65  colvarvalue *param_grad_ptr);
66 
67 };
68 
69 #endif
Collective variables module (main class)
Definition: colvarmodule.h:87
double real
Defining an abstract real number allows to switch precision.
Definition: colvarmodule.h:114
Definition: colvarparams.h:19
void register_param(std::string const &param_name, void *param_ptr)
Register the given parameter.
Definition: colvarparams.cpp:28
virtual cvm::real get_param(std::string const &param_name)
Value of the parameter param_name (must be a scalar)
Definition: colvarparams.cpp:94
virtual std::vector< std::string > get_param_names()
Get a copy of the names of registered parameters.
Definition: colvarparams.cpp:51
std::map< std::string, void const * > param_map
Pointers to relevant parameters that may be accessed by other objects.
Definition: colvarparams.h:55
virtual void const * get_param_ptr(std::string const &param_name)
Pointer to the parameter param_name.
Definition: colvarparams.cpp:73
virtual ~colvarparams()
Default destructor.
Definition: colvarparams.cpp:24
std::map< std::string, colvarvalue const * > param_grad_map
Derivatives of the object with respect to internal parameters.
Definition: colvarparams.h:58
virtual std::vector< std::string > get_param_grad_names()
Get a copy of the names of registered parameter gradients.
Definition: colvarparams.cpp:62
void register_param_grad(std::string const &param_name, colvarvalue *param_grad_ptr)
Register the gradient of the given parameter.
Definition: colvarparams.cpp:35
virtual void const * get_param_grad_ptr(std::string const &param_name)
Pointer to the gradient of parameter param_name.
Definition: colvarparams.cpp:83
virtual int set_param(std::string const &param_name, void const *new_value)
Set the named parameter to the given value.
Definition: colvarparams.cpp:102
colvarparams(colvarmodule *cvmodule_in)
Default constructor.
Definition: colvarparams.cpp:20
int param_exists(std::string const &param_name)
Whether the parameter param_name exists.
Definition: colvarparams.cpp:42
Value of a collective variable: this is a metatype which can be set at runtime. By default it is set ...
Definition: colvarvalue.h:43