ppap4lmp  0.7.2
Updater Class Referenceabstract

Updater is an abstract class to update data held by an Element object. More...

#include <updater.h>

Inheritance diagram for Updater:
Collaboration diagram for Updater:

Public Member Functions

 Updater ()=default
 Constructor of Updater class. More...
 
void compute (const ElPtr &elem, const int elementid, Json &data)
 Managing computation to update Element::data. More...
 
void remove_from_skippable_elementids (const int elementid)
 Remove Element::elementid from skippable_elementids. More...
 
const ShPtr< Generator > & get_ext_generator ()
 Get ext_generator of this object. More...
 

Protected Member Functions

virtual void compute_body (const ElPtr &elem, Json &data)=0
 Managing computation to update Element::data. More...
 
virtual void compute_common (const ElPtr &elem, Json &data)
 Common part of compute_body. More...
 
virtual void compute_impl (Json &data, JsonToVoidFunc check_required_keys, JsonToBoolFunc check_optional_keys)=0
 Implementation of computation updating Element::data. More...
 

Protected Attributes

ShPtr< Generatorext_generator
 

Private Member Functions

bool check_compute_request_for (const int elementid)
 

Private Attributes

Set< int > skippable_elementids
 

Detailed Description

Updater is an abstract class to update data held by an Element object.

This class is a superclass of the Starter, Adder and Filter class.

An object of this class is append to an Element object by Element::append_updater and stored as UpdatePair (where the first item is the Element object and the second item is the object of this class).

Definition at line 34 of file updater.h.

Constructor & Destructor Documentation

◆ Updater()

Updater::Updater ( )
default

Constructor of Updater class.

This constructor is thread-unsafe because it accesses its members thread-globally. Ensure this constructor is not called in a multithreading context. Please be careful that constructors of subclasses of this class are also thread-unsafe.

Member Function Documentation

◆ check_compute_request_for()

bool Updater::check_compute_request_for ( const int  elementid)
private

Look for Element::elementid in skippable_elementids.

Parameters
elementidAn Element::elementid to be checked.
Returns
A boolean. If elementid is found in skippable_elementids, this method returns false, that is, rejects the Element object of the elementid.

Definition at line 13 of file updater.cpp.

Here is the caller graph for this function:

◆ compute()

void Updater::compute ( const ElPtr elem,
const int  elementid,
Json data 
)

Managing computation to update Element::data.

Parameters
elemShared pointer to an Element object where computed properties are added to.
elementidA constant integer copied from Element::elementid.
dataMutable reference to Element::data where computed properties are added to.
Returns
None.

Definition at line 34 of file updater.cpp.

Here is the call graph for this function:

◆ compute_body()

virtual void Updater::compute_body ( const ElPtr elem,
Json data 
)
protectedpure virtual

Managing computation to update Element::data.

Parameters
elemShared pointer to an Element object where computed properties are added to.
dataMutable reference to Element::data where computed properties are added to.
Returns
None.

More specific than compute; implementation of this method is different in each subclass.

Implemented in Starter, Adder, and Filter.

Here is the caller graph for this function:

◆ compute_common()

void Updater::compute_common ( const ElPtr elem,
Json data 
)
protectedvirtual

Common part of compute_body.

Parameters
elemShared pointer to an Element object where computed properties are added to.
dataMutable reference to Element::data where computed properties are added to.
Returns
None.

Definition at line 47 of file updater.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_impl()

virtual void Updater::compute_impl ( Json data,
JsonToVoidFunc  check_required_keys,
JsonToBoolFunc  check_optional_keys 
)
protectedpure virtual

Implementation of computation updating Element::data.

Parameters
dataMutable reference to Element::data where computed properties are added to.
check_required_keysWrapper function for Element::check_required_keys of an Element object where this instance is appended to.
check_optional_keysWrapper function for Element::check_optional_keys of an Element object where this instance is appended to.
Returns
None.

Implemented in FilComparison, AddMap, StaBeads, AddChildPositions, AddGyrationRadius, AddInertiaMoment, AddChildIDs, AddCoMPosition, AddMolecularOrientation, AddSpecialBonds, AddDihedralAngle, AddBondAngle, AddBondLength, FilSet, AddWrappedPosition, StaDumpBox, AddRename, StaMolecules, StaDumpAtoms, StaCustom, and StaCopy.

Here is the caller graph for this function:

◆ get_ext_generator()

const ShPtr< Generator > & Updater::get_ext_generator ( )

Get ext_generator of this object.

Returns
Constance reference to ShPtr<Generator>.

This method is mainly used in Element::update_chain.

Definition at line 86 of file updater.cpp.

◆ remove_from_skippable_elementids()

void Updater::remove_from_skippable_elementids ( const int  elementid)

Remove Element::elementid from skippable_elementids.

Parameters
elementidAn Element::elementid to be removed.
Returns
None.

Removing elementid from skippable_elementids is necessary so that this object can update the Element object of the elementid again after its Element::data being cleared.

Definition at line 75 of file updater.cpp.

Member Data Documentation

◆ ext_generator

ShPtr<Generator> Updater::ext_generator
protected

Shared pointer to a Generator object used in updating process. To compute some properties for an Element object where this object is appended to, an external Generator object (can be Element/GenDict/GenList) might be required. For example, to compute the center of mass of molecules for a molecular Element object, an atomic Element object containing positions of the atoms is required.

Definition at line 64 of file updater.h.

◆ skippable_elementids

Set<int> Updater::skippable_elementids
private

If this Updater object is called from an Element object for the first time, this object stores Element::elementid in skippable_elementids and updates Element::data. From the second time on, this object skips the updating computation.

Definition at line 41 of file updater.h.


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