ppap4lmp  0.7.2
FilComparison Class Reference

FilComparison applies a filter defined by comparison operators. More...

#include <fil_comparison.h>

Inheritance diagram for FilComparison:
Collaboration diagram for FilComparison:

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...
 
- Public Member Functions inherited from Filter
 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.
 
- Protected Member Functions inherited from Filter
virtual void compute_body (const ElPtr &elem, Json &data) override
 Filter elements from array 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 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

- Protected Attributes inherited from Updater
ShPtr< Generatorext_generator
 

Detailed Description

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 & Destructor Documentation

◆ FilComparison() [1/2]

FilComparison::FilComparison ( const std::tuple< Str, Str, Json > &  compare_expr_)

Constructor of FilComparison class with one criterion.

Parameters
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.

◆ FilComparison() [2/2]

FilComparison::FilComparison ( const Vec< std::tuple< Str, Str, Json >> &  compare_expr_list_)

Constructor of FilComparison class with multiple criteria.

Parameters
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.

Member Function Documentation

◆ check_if_pass_data_elem()

const bool FilComparison::check_if_pass_data_elem ( const Json elem_in_data,
const CompareFuncs compare_func_list 
)
private

Check if an element in data array can pass this filter.

Parameters
elem_in_dataAn element in data array.
compare_func_listComparison functions made by make_compare_func_list.
Returns
If elem_in_data can pass this filter.

Definition at line 101 of file fil_comparison.cpp.

Here is the caller graph for this function:

◆ make_compare_func()

const JsonToBoolFunc FilComparison::make_compare_func ( const Str oper,
const Json rval 
)
private

Make a JsonToBoolFunc object from a comparison operator and a right side value.

Parameters
operA string representing a comparison operator. One of <, >, <=, >=, ==, and !=.
rvalA right side value. Since it is Json, it can be either an integer or a float.
Returns
A function evaluating an inequality (or equation).

Definition at line 32 of file fil_comparison.cpp.

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

◆ make_compare_func_list()

const CompareFuncs FilComparison::make_compare_func_list ( )
private

Convert tuples in compare_expr_list to pairs of a string key and JsonToBoolFunc.

Returns
A constant Vec<std::pair<Str,JsonToBoolFunc>> object, which describes criteria of this filter.

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.

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

Member Data Documentation

◆ compare_expr_list

Vec<std::tuple<Str,Str,Json> > FilComparison::compare_expr_list
private

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.


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