Trait.hpp

Directly measure a target quality about a type of object.

These objects are able to measure a specific trait on another object. They (will eventually) interface smoothly with DataNodes for data collection.

template<typename TARGET_T>
class BaseTrait
#include <Trait.hpp>

Subclassed by Trait< TARGET_T, VALUE_T >

Public Functions

inline virtual ~BaseTrait()
virtual std::string EvalString(TARGET_T &target) const = 0
virtual double EvalValue(TARGET_T &target) const = 0
virtual size_t EvalBin(TARGET_T &target, size_t num_bins) const = 0
virtual Ptr<BaseTrait<TARGET_T>> Clone() const = 0
template<typename VALUE_T>
inline bool IsType()
template<typename TARGET_T, typename VALUE_T = double>
class Trait : public BaseTrait<TARGET_T>
#include <Trait.hpp>

Public Types

using this_t = Trait<TARGET_T, VALUE_T>
using target_t = TARGET_T
using value_t = VALUE_T
using fun_t = std::function<value_t(target_t&)>
using range_t = Range<value_t>

Public Functions

inline Trait(const std::string &_n, const fun_t &_f)
inline Trait(const std::string &_n, const fun_t &_f, value_t min, value_t max)
inline Trait(const std::string &_n, const fun_t &_f, const range_t &_r)
Trait(const Trait&) = default
Trait(Trait&&) = default
Trait &operator=(const Trait&) = default
Trait &operator=(Trait&&) = default
inline const std::string &GetName() const
inline const std::string &GetDesc() const
inline const fun_t &GetFun() const
inline const range_t &GetRange() const
inline void SetName(const std::string &_in)
inline void SetDesc(const std::string &_in)
inline void SetFun(const fun_t &_in)
inline void SetRange(const range_t &_in)
inline void SetRange(value_t min, value_t max)
inline void SetMin(value_t min)
inline void SetMax(value_t max)
inline value_t Eval(target_t &target) const
inline value_t EvalLimit(target_t &target) const
inline virtual std::string EvalString(target_t &target) const
inline virtual double EvalValue(target_t &target) const
inline virtual size_t EvalBin(target_t &target, size_t num_bins) const
inline virtual Ptr<BaseTrait<TARGET_T>> Clone() const

Protected Attributes

std::string name

Unique name for this trait.

std::string desc

Full description explaining this trait.

fun_t fun

Function to retrieve trait value from target.

range_t range

Limits on legal values (defaults to extremes)

template<typename TARGET_T>
class TraitSet
#include <Trait.hpp>

A TraitSet houses a collection of traits and can trigger them to all be evaluated at once.

Public Types

using target_t = TARGET_T
using trait_t = BaseTrait<target_t>

Public Functions

inline TraitSet()
inline TraitSet(TraitSet &&in)
inline TraitSet(const TraitSet &in)
inline ~TraitSet()
inline TraitSet &operator=(TraitSet &&in)
inline TraitSet &operator=(const TraitSet &in)
inline trait_t &operator[](size_t id)
inline const trait_t &operator[](size_t id) const
inline size_t GetSize() const
inline void Clear()
inline size_t Find(const std::string &name) const
inline bool Has(const std::string &name) const
template<typename VALUE_T, typename ...EXTRA>
inline void AddTrait(const std::string &name, const std::function<VALUE_T(target_t&)> &fun, EXTRA&&... extra)
inline std::string EvalString(size_t id, target_t &target) const
inline double EvalValue(size_t id, target_t &target) const
inline vector<std::string> EvalStrings(target_t &target) const
inline vector<double> EvalValues(target_t &target) const
inline size_t EvalBin(target_t &target, vector<size_t> bin_counts) const
inline vector<double> CalcOffsets(target_t &target1, target_t &target2) const

Protected Attributes

vector<Ptr<trait_t>> traits