ppap4lmp  0.7.2
AddMap Class Reference

AddMap adds a new property by mapping from an existing property. More...

#include <add_map.h>

Inheritance diagram for AddMap:
Collaboration diagram for AddMap:

Public Member Functions

 AddMap (const Str &key_ref_, const Str &key_new_, const Map< Json, Json > &mapping_)
 Constructor of AddMap class. More...
 
ShPtr< AddMapoverwrite (bool do_overwrite_=true)
 Allow overwriting an existing property by a new property with the same name. More...
 
- Public Member Functions inherited from Adder
 Updater ()=default
 Constructor of Updater class. More...
 
- Public Member Functions inherited from Updater
 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_impl (Json &data, JsonToVoidFunc check_required_keys, JsonToBoolFunc check_optional_keys) override
 This method overrides Updater::compute_impl. More...
 
- Protected Member Functions inherited from Adder
virtual void compute_body (const ElPtr &elem, Json &data) override
 Compute properties and add them to Element::data given as a mutable reference. More...
 
- Protected Member Functions inherited from Updater
virtual void compute_common (const ElPtr &elem, Json &data)
 Common part of compute_body. More...
 

Private Attributes

bool do_overwrite = false
 
Str key_ref
 
Str key_new
 
Map< Json, Jsonmapping
 

Additional Inherited Members

- Protected Attributes inherited from Updater
ShPtr< Generatorext_generator
 

Detailed Description

AddMap adds a new property by mapping from an existing property.

An object of this class owns a mapping. Domain of the mapping consists of values for an existing property of an Element object where the object of this class is appended to. Codomain of the mapping consists of values for a new property. Note that the domain must cover all values for the existing property.

About usage in Python, please see pybind::py_add_map.

Definition at line 27 of file add_map.h.

Constructor & Destructor Documentation

◆ AddMap()

AddMap::AddMap ( const Str key_ref_,
const Str key_new_,
const Map< Json, Json > &  mapping_ 
)

Constructor of AddMap class.

Parameters
key_ref_

A string key for a reference property: an existing property to be used as domain of mapping. This parameter is assigned to key_ref.

key_new_A string key for a new property to be added. Values for the new property are determined by mapping. This parameter is assigned to key_new.
mapping_Dictionary defining a mapping from values for the reference property to values for the new property. Keys of the dictionary corresponds to domain of the mapping, and values of the dictionary corresponds to codomain of the mapping. Note that the keys must cover all values of the reference property in an Element object where the constructed object is appended to. This parameter is assigned to mapping.

Definition at line 16 of file add_map.cpp.

Member Function Documentation

◆ compute_impl()

void AddMap::compute_impl ( Json data,
JsonToVoidFunc  check_required_keys,
JsonToBoolFunc  check_optional_keys 
)
overrideprotectedvirtual

This method overrides Updater::compute_impl.

Property to be added
  • [key_new] : any type
Required property
  • [key_ref] : any type (but, in most cases, integer or strings)

Implements Updater.

Definition at line 28 of file add_map.cpp.

Here is the call graph for this function:

◆ overwrite()

ShPtr< AddMap > AddMap::overwrite ( bool  do_overwrite_ = true)

Allow overwriting an existing property by a new property with the same name.

Parameters
do_overwrite_A boolean, whether an existing property can be overwritten by a new property (default is true). This parameter is assigned to do_overwrite.
Returns
Shared pointer to this object.

Please be careful not to call this method in a multithreading context because it is thread-unsafe.

Definition at line 59 of file add_map.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ do_overwrite

bool AddMap::do_overwrite = false
private

Whether overwriting an existing property whose name is the same as a new property to be added (default is false).

Definition at line 32 of file add_map.h.

◆ key_new

Str AddMap::key_new
private

Key for a new property to be added (codomain of the mapping)

Definition at line 40 of file add_map.h.

◆ key_ref

Str AddMap::key_ref
private

Key for an existing property (domain of the mapping).

Definition at line 36 of file add_map.h.

◆ mapping

Map<Json,Json> AddMap::mapping
private

Mapping from values for an existing property specified by key_ref to values for a new property specified by key_new. Domain of the mapping consists of values for the existing property in Element::data of an Element object where this object is appended to. Codomain of the mapping consists of user-defined values for the new property to be added to the Element::data.

Definition at line 49 of file add_map.h.


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