DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::oks::OksRange Class Reference

OKS range class. More...

#include <attribute.hpp>

Public Member Functions

 OksRange (const std::string &range, OksAttribute *a)
void reset (const std::string &range, OksAttribute *a)
bool validate (const OksData &) const
bool is_empty ()

Private Member Functions

void clear ()

Private Attributes

std::string m_range
std::list< OksDatam_less
std::list< OksDatam_equal
std::list< std::pair< OksData, OksData > > m_interval
std::list< OksDatam_great
std::list< boost::regex > m_like

Detailed Description

OKS range class.

The OksRange class implements OKS range that can be defined for an OKS attribute. The range is a set of list of conditions using UML syntax. For string types the range is a regular expression.

Definition at line 46 of file attribute.hpp.

Constructor & Destructor Documentation

◆ OksRange()

dunedaq::oks::OksRange::OksRange ( const std::string & range,
OksAttribute * a )
inline

Definition at line 50 of file attribute.hpp.

51 {
52 reset(range, a);
53 }
void reset(const std::string &range, OksAttribute *a)
DAC value out of range
Message.
Definition DACNode.hpp:32

Member Function Documentation

◆ clear()

void dunedaq::oks::OksRange::clear ( )
inlineprivate

Definition at line 80 of file attribute.hpp.

81 {
82 m_range.clear();
83
84 m_less.clear();
85 m_equal.clear();
86 m_interval.clear();
87 m_great.clear();
88 m_like.clear();
89 }
std::list< std::pair< OksData, OksData > > m_interval
Definition attribute.hpp:73
std::list< OksData > m_less
Definition attribute.hpp:71
std::list< OksData > m_great
Definition attribute.hpp:74
std::list< boost::regex > m_like
Definition attribute.hpp:75
std::list< OksData > m_equal
Definition attribute.hpp:72

◆ is_empty()

bool dunedaq::oks::OksRange::is_empty ( )
inline

Definition at line 62 of file attribute.hpp.

63 {
64 return (m_less.empty() && m_equal.empty() && m_interval.empty() && m_great.empty() && m_like.empty());
65 }

◆ reset()

void dunedaq::oks::OksRange::reset ( const std::string & range,
OksAttribute * a )

Definition at line 844 of file attribute.cpp.

845{
846 clear();
847
848 if (a->get_data_type() != OksData::string_type)
849 {
850 if (!range.empty())
851 {
852 Oks::Tokenizer t(range, ",");
853 std::string token, token1, token2;
854
855 while (t.next(token))
856 {
857 if (is_star(token))
858 {
859 TLOG_DEBUG(2) << "token \'" << token << "\' of \'" << range << "\' allows any value";
860 clear();
861 return;
862 }
863
864 static const char __dot_dot_str[] = "..";
865 std::string::size_type p = token.find(__dot_dot_str, 0, (sizeof(__dot_dot_str) - 1));
866
867 bool pi; // if true, then it is plus infinity, i.e. x..*
868
869 if (p != std::string::npos)
870 {
871 token1.assign(token, 0, p);
872 token2.assign(token, p + 2, std::string::npos);
873 pi = (is_star(token2));
874 }
875 else
876 {
877 token1.assign(token);
878 token2.clear();
879 pi = false;
880 }
881
882 bool mi = (is_star(token1)); // if true, then it is minus infinity, i.e. *..x
883
884 if (mi && pi)
885 {
886 TLOG_DEBUG(2) << "token \'" << token << "\' of \'" << range << "\' allows any value";
887 clear();
888 return;
889 }
890
891 OksData d1, d2;
892
893 if (!mi)
894 {
895 d1.type = a->get_data_type();
896 d1.ReadFrom(token1, a);
897 }
898
899 if (token2.empty())
900 {
901 TLOG_DEBUG(2) << "token \'" << token << "\' of \'" << range << "\' defines equality condition";
902 m_equal.emplace_back(d1);
903 }
904 else
905 {
906 if (!pi)
907 {
908 d2.type = a->get_data_type();
909 d2.ReadFrom(token2, a);
910 }
911
912 if (mi)
913 {
914 TLOG_DEBUG(2) << "token \'" << token << "\' of \'" << range << "\' defines smaller condition";
915 m_less.emplace_back(d2);
916 }
917 else if (pi)
918 {
919 TLOG_DEBUG(2) << "token \'" << token << "\' of \'" << range << "\' defines greater condition";
920 m_great.emplace_back(d1);
921 }
922 else
923 {
924 TLOG_DEBUG(2) << "token \'" << token << "\' of \'" << range << "\' defines interval condition";
925 m_interval.emplace_back(d1, d2);
926 }
927 }
928 }
929 }
930 }
931 else
932 {
933 try
934 {
935 m_like.emplace_back(range);
936 }
937 catch (std::exception& ex)
938 {
939 throw BadReqExp(range, ex.what());
940 }
941 }
942}
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
bool is_star(const std::string &s)

◆ validate()

bool dunedaq::oks::OksRange::validate ( const OksData & d) const

Definition at line 945 of file attribute.cpp.

946{
947 for (const auto& x : m_less)
948 {
949 if (d <= x)
950 return true;
951 }
952
953 for (const auto& x : m_great)
954 {
955 if (d >= x)
956 return true;
957 }
958
959 for (const auto& x : m_equal)
960 {
961 if (d == x)
962 return true;
963 }
964
965 for (const auto& x : m_interval)
966 {
967 if (d >= x.first && d <= x.second)
968 return true;
969 }
970
971 for (const auto& x : m_like)
972 {
974 return true;
975
976 if (boost::regex_match(d.str(),x))
977 return true;
978 }
979
980 return false;
981}
static bool get_skip_string_range()
Get status of string range validator.
Definition kernel.hpp:804

Member Data Documentation

◆ m_equal

std::list<OksData> dunedaq::oks::OksRange::m_equal
private

Definition at line 72 of file attribute.hpp.

◆ m_great

std::list<OksData> dunedaq::oks::OksRange::m_great
private

Definition at line 74 of file attribute.hpp.

◆ m_interval

std::list<std::pair<OksData,OksData> > dunedaq::oks::OksRange::m_interval
private

Definition at line 73 of file attribute.hpp.

◆ m_less

std::list<OksData> dunedaq::oks::OksRange::m_less
private

Definition at line 71 of file attribute.hpp.

◆ m_like

std::list<boost::regex> dunedaq::oks::OksRange::m_like
private

Definition at line 75 of file attribute.hpp.

◆ m_range

std::string dunedaq::oks::OksRange::m_range
private

Definition at line 69 of file attribute.hpp.


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