Collective Variables Module - Developer Documentation
|
Parent class for a member object of a bias, cv or cvc etc. containing features and their dependencies, and handling dependency resolution. More...
#include <colvardeps.h>
Classes | |
class | feature |
struct | feature_state |
This contains the current state of each feature for each object. More... | |
Public Member Functions | |
int | get_time_step_factor () const |
returns time_step_factor | |
void | init_feature (int feature_id, const char *description, feature_type type) |
Pair a numerical feature ID with a description and type. | |
bool | is_not_set (int id) |
bool | is_dynamic (int id) |
bool | is_static (int id) |
bool | is_user (int id) |
virtual const std::vector< feature * > & | features () const =0 |
virtual std::vector< feature * > & | modify_features ()=0 |
void | add_child (colvardeps *child) |
void | remove_child (colvardeps *child) |
void | remove_all_children () |
bool | is_enabled (int f=f_cv_active) const |
bool | is_available (int f=f_cv_active) const |
void | provide (int feature_id, bool truefalse=true) |
void | set_enabled (int feature_id, bool truefalse=true) |
Enable or disable, depending on flag value. | |
int | enable (int f, bool dry_run=false, bool toplevel=true, bool error=false) |
int | disable (int f) |
void | free_children_deps () |
void | restore_children_deps () |
re-enable children features (to be used when object becomes active) | |
int | decr_ref_count (int f) |
virtual void | do_feature_side_effects (int) |
virtual int | init_dependencies ()=0 |
Initialize dependency tree for object of a derived class. More... | |
void | require_feature_self (int f, int g) |
Make feature f require feature g within the same object. | |
void | exclude_feature_self (int f, int g) |
Make features f and g mutually exclusive within the same object. | |
void | require_feature_children (int f, int g) |
Make feature f require feature g within children. | |
void | require_feature_alt (int f, int g, int h) |
Make feature f require either g or h within the same object. | |
void | require_feature_alt (int f, int g, int h, int i) |
Make feature f require any of g, h, or i within the same object. | |
void | require_feature_alt (int f, int g, int h, int i, int j) |
Make feature f require any of g, h, i, or j within the same object. | |
void | print_state () |
print all enabled features and those of children, for debugging | |
void | check_enabled (int f, std::string const &reason) const |
Check that a feature is enabled, raising COLVARS_BUG_ERROR if not. | |
Public Attributes | |
std::string | description |
Protected Types | |
enum | feature_type { f_type_not_set , f_type_dynamic , f_type_user , f_type_static } |
Enum of possible feature types. | |
Protected Member Functions | |
bool | get_keyval_feature (colvarparse *cvp, std::string const &conf, char const *key, int feature_id, bool const &def_value, colvarparse::Parse_Mode const parse_mode=colvarparse::parse_normal) |
Parse a keyword and enable a feature accordingly. | |
Protected Attributes | |
int | time_step_factor |
std::vector< feature_state > | feature_states |
List of the states of all features. | |
Private Attributes | |
std::vector< colvardeps * > | children |
std::vector< colvardeps * > | parents |
Parent class for a member object of a bias, cv or cvc etc. containing features and their dependencies, and handling dependency resolution.
There are 3 kinds of features:
The following diagram summarizes the dependency tree at the bias, colvar, and colvarcomp levels. Isolated and atom group features are not shown to save space.
In all classes, feature 0 is active
. When an object is inactivated all its children dependencies are dereferenced (free_children_deps) While the object is inactive, no dependency solving is done on children it is done when the object is activated back (restore_children_deps)
int colvardeps::decr_ref_count | ( | int | f | ) |
Decrement the reference count of a feature disabling it if it's dynamic and count reaches zero
int colvardeps::disable | ( | int | f | ) |
Disable a feature, decrease the reference count of its dependencies and recursively disable them as applicable
|
inlinevirtual |
Implements possible actions to be carried out when a given feature is enabled Base function does nothing, can be overloaded
Reimplemented in colvar, and colvarmodule::atom_group.
int colvardeps::enable | ( | int | f, |
bool | dry_run = false , |
||
bool | toplevel = true , |
||
bool | error = false |
||
) |
Enable a feature and recursively solve its dependencies. For accurate reference counting, do not add spurious calls to enable()
dry_run | Recursively test whether a feature is available, without enabling it |
toplevel | False if this is called as part of a chain of dependency resolution. This is used to diagnose failed dependencies by displaying the full stack: only the toplevel dependency will throw a fatal error. |
error | Recursively enable, printing error messages along the way Necessary when propagating errors across alternate dependencies |
|
pure virtual |
Implemented in colvar, colvarbias, colvar::cvc, and colvarmodule::atom_group.
void colvardeps::free_children_deps | ( | ) |
disable all enabled features to free their dependencies to be done when deleting the object Cannot be in the base class destructor because it needs the derived class features()
|
pure virtual |
Initialize dependency tree for object of a derived class.
Implemented in colvar, colvarbias, colvar::cvc, and colvarmodule::atom_group.
void colvardeps::provide | ( | int | feature_id, |
bool | truefalse = true |
||
) |
Set the feature's available flag, without checking To be used for dynamic properties dependencies will be checked by enable()
void colvardeps::remove_all_children | ( | ) |
Used before deleting an object, if not handled by that object's destructor (useful for cvcs because their children are member objects)
|
private |
pointers to objects this object depends on list should be maintained by any code that modifies the object this could be secured by making lists of colvars / cvcs / atom groups private and modified through accessor functions
|
private |
pointers to objects that depend on this object the size of this array is in effect a reference counter
|
protected |
Time step multiplier (for coarse-timestep biases & colvars) Biases and colvars will only be calculated at those times (f_cvb_awake and f_cv_awake); a Biases use this to apply "impulse" biasing forces at the outer timestep Unused by lower-level objects (cvcs and atom groups)