# TTTT Analysis: /home/caleb/Sources/TTTT/filval/filter.hpp Source File

filter.hpp
Go to the documentation of this file.
#ifndef filter_h
#define filter_h
#include <iostream>
#include <functional>
#include "value.hpp"
namespace fv {
class Filter : public DerivedValue<bool>{
private:
Function<bool()>& filter_function;
void update_value(){
value = filter_function();
}
void verify_integrity(){ };
public:
Filter(const std::string& name, std::function<bool()> filter_function, const std::string& impl="")
:DerivedValue<bool>(name),
filter_function(GenFunction::register_function<bool()>("filter::"+name, filter_function, impl)){ }
Filter* operator*(Filter *f){
auto new_name = this->get_name() + "&&" + f->get_name();
return new Filter(new_name, [this, f](){return this->get_value() && f->get_value();});
}
Filter* operator+(Filter *f){
auto new_name = this->get_name() + "||" + f->get_name();
return new Filter(new_name, [this, f](){return this->get_value() || f->get_value();});
}
Filter* operator!(){
auto new_name = std::string("!(") + this->get_name() + std::string(")");
return new Filter(new_name, [this](){return !this->get_value();});
}
};
template <typename T>
class RangeFilter : public Filter{
private:
public:
RangeFilter(const std::string name, Value<T>* test_value, T range_low, T range_high):
Filter(name, [test_value, range_low, range_high]{
T val = test_value->get_value();
return (val >= range_low) && (val < range_high);
}) { }
};
}
#endif // filter_h
fv::Filter::verify_integrity
void verify_integrity()
This function serves to check that this Value has been created with real, i.e.
Definition: filter.hpp:52
fv::DerivedValue< bool >::get_value
bool & get_value()
Definition: value.hpp:389
fv::GenValue::name
std::string name
The name of the value.
Definition: value.hpp:190
fv::Filter
Definition: filter.hpp:44
fv
The namespace containing all filval classes and functions.
fv::Filter::operator+
Filter * operator+(Filter *f)
Return a new filter that is the disjunction of the two source filters.
Definition: filter.hpp:70
fv::Value
A generic value.
Definition: value.hpp:310
fv::RangeFilter
Definition: filter.hpp:84
fv::DerivedValue
A generic, derived, value.
Definition: value.hpp:366
fv::Filter::operator*
Filter * operator*(Filter *f)
Return a new filter that is the conjuction of the two source filters.
Definition: filter.hpp:62
fv::Filter::update_value
void update_value()
Updates the internal value.
Definition: filter.hpp:48
fv::Filter::operator!
Filter * operator!()
Return a new filter that is the negation of the source filter.
Definition: filter.hpp:77
fv::Function< bool()>
fv::Value::get_value
virtual T & get_value()=0
Calculate, if necessary, and return the value held by this object.