ppap4lmp
0.7.2
|
FilComparison applies a filter defined by comparison operators. More...
#include <fil_comparison.h>
Public Member Functions | |
FilComparison (const std::tuple< Str, Str, Json > &compare_expr_) | |
Constructor of FilComparison class with one criterion. More... | |
FilComparison (const Vec< std::tuple< Str, Str, Json >> &compare_expr_list_) | |
Constructor of FilComparison class with multiple criteria. More... | |
![]() | |
Updater ()=default | |
Constructor of Updater class. More... | |
![]() | |
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. | |
![]() | |
virtual void | compute_body (const ElPtr &elem, Json &data) override |
Filter elements from array Element::data given as a mutable reference. More... | |
![]() | |
virtual void | compute_common (const ElPtr &elem, Json &data) |
Common part of compute_body. More... | |
Private Member Functions | |
const JsonToBoolFunc | make_compare_func (const Str &oper, const Json &rval) |
Make a JsonToBoolFunc object from a comparison operator and a right side value. More... | |
const CompareFuncs | make_compare_func_list () |
Convert tuples in compare_expr_list to pairs of a string key and JsonToBoolFunc. More... | |
const bool | check_if_pass_data_elem (const Json &elem_in_data, const CompareFuncs &compare_func_list) |
Check if an element in data array can pass this filter. More... | |
Private Attributes | |
Vec< std::tuple< Str, Str, Json > > | compare_expr_list |
Additional Inherited Members | |
![]() | |
ShPtr< Generator > | ext_generator |
FilComparison applies a filter defined by comparison operators.
An object of this class has a filter defined by compare_expr_list, which is a list consisting of tuples where the first element is a string key, the second element is a comparison operator and the third element is a right hand value of an inequality (or equation). Currently supported operators are <
, >
, <=
, >=
, ==
, and !=
. An element of array Element::data can pass this filter only if satisfying all the inequalities. The element can pass a inequality when its value for the string key satisfies the condition defined by the comparison operator and right hand value.
About usage in Python, please see pybind::py_fil_comparison.
Definition at line 35 of file fil_comparison.h.
Constructor of FilComparison class with one criterion.
compare_expr_ | A three-elements tuple consisting of a string key, comparison operator and right side value of an inequality (or equation). Note that an Element object, where the constructed object is appended to, must has a property corresponding to the first element of this parameter (string key). A single-element Vec object consisting of this parameter is assigned to compare_expr_list. |
Definition at line 16 of file fil_comparison.cpp.
Constructor of FilComparison class with multiple criteria.
compare_expr_list_ | List of three-elements tuples consisting of a string key, comparison operator and right side value of an inequality (or equation). Note that an Element object, where the constructed object is appended to, must has properties corresponding to the first elements of this parameter (string key). This parameter is assigned to compare_expr_list. |
Definition at line 24 of file fil_comparison.cpp.
|
private |
Check if an element in data array can pass this filter.
elem_in_data | An element in data array. |
compare_func_list | Comparison functions made by make_compare_func_list. |
elem_in_data
can pass this filter. Definition at line 101 of file fil_comparison.cpp.
|
private |
Make a JsonToBoolFunc object from a comparison operator and a right side value.
oper | A string representing a comparison operator. One of < , > , <= , >= , == , and != . |
rval | A right side value. Since it is Json, it can be either an integer or a float. |
Definition at line 32 of file fil_comparison.cpp.
|
private |
Convert tuples in compare_expr_list to pairs of a string key and JsonToBoolFunc.
Returned value of this method is used for evaluating inequalities consisting of the second and third elements of tuples contained in compare_expr_list. Note that this conversion from tuples to pairs should not be conducted in constructor because of possibility of throwing (and raising) a runtime error.
Definition at line 82 of file fil_comparison.cpp.
Criteria of this filter stored in a Vec (list) object. Elements of the list are three-elements tuples. The first element of each tuple is a key; and the key must be contained in an Element object where this object is appended to. Note that the reason not using Map is to allow duplicate keys.
Definition at line 44 of file fil_comparison.h.