32#ifndef RACK_DATASELECTOR
33#define RACK_DATASELECTOR
35#include <data/QuantitySelector.h>
38#include <drain/util/BeanLike.h>
39#include <drain/util/Range.h>
40#include <drain/util/ReferenceMap.h>
44#include "ODIMPathTools.h"
45#include "ODIMPathMatcher.h"
53 enum Crit {DATA, ELANGLE, TIME};
56 const char separator =
':';
59 CritFlagger criterion;
62 OperFlagger operation;
64 template<
typename ... TT>
65 void set(Crit crit,
const TT &... args) {
70 template<
typename ... TT>
71 void set(Oper oper,
const TT &... args) {
78 void set(
const std::string s) {
87 str = criterion.str() + separator + operation.str();
96std::ostream & operator<<(std::ostream & ostr,
const DataOrder & order){
111 enum Prf {SINGLE=1, DOUBLE=2, ANY=3};
121 DataSelector(
const std::string & parameters =
"");
126 template<
typename ... T>
130 pathMatcher.set(elem, args...);
135 template<
typename ... T>
139 pathMatcher.set(e, args...);
144 DataSelector(
const DataSelector & selector);
146 virtual ~DataSelector();
179 template<
typename ... TT>
181 void setPathMatcher(TT... args){
182 pathMatcher.set(args...);
186 const ODIMPathMatcher & getPathMatcher()
const {
215 bool quantityIsSet()
const {
216 return quantitySelector.isSet();
231 return quantitySelector;
236 void setMaxCount(
unsigned int i){
241 unsigned int getMaxCount()
const {
247 void setPrf(
const std::string & s){
249 this->prfSelector.set(s);
254 this->prfSelector.set(
prf);
255 this->prf = this->prfSelector.
str();
259 template<
typename ... TT>
261 void setOrder(
const TT &... args) {
262 this->order.set(args...);
266 const DataOrder & getOrder()
const {
318 void getPaths(
const Hi5Tree & src, std::list<ODIMPath> & pathContainer)
const;
446 void prunePaths(
const Hi5Tree & src, std::list<ODIMPath> & pathContainer)
const;
450std::ostream & operator<<(std::ostream & ostr,
const DataSelector &selector);
461 parameters.
delink(
"path");
462 mout.experimental<LOG_NOTICE>(
"not resetting DATASET" );
495DRAIN_ENUM_DICT(rack::DataOrder::Crit);
496DRAIN_ENUM_DICT(rack::DataOrder::Oper);
Something which has a name, a description and possibly some parameters of varying type.
Definition BeanLike.h:58
void setParameters(std::initializer_list< Variable::init_pair_t > args)
Grants access to (if above hidden)
Definition BeanLike.h:142
Flagger accepting values of enum type E.
Definition EnumFlagger.h:56
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:313
void trimHead(bool COMPLETE=false)
Removes leading empty elements. The resulting string presentation will not start with the separator.
Definition Path.h:373
Definition ReferenceMap.h:215
void delink(const std::string &key)
Removes an entry from the map.
Definition ReferenceMap.h:358
virtual const key_t & str() const override
String corresponding the current value. Returns empty, if not found.
Definition Flags.h:151
Tool for selecting datasets based on paths, quantities and min/max elevations.
Definition DataSelector.h:112
void init()
Sets the default values and sets references.
Definition DataSelector.cpp:135
Prf
Pulse repetition frequency mode.
Definition DataSelector.h:118
unsigned int count
The maximum length of the list of matching keys.
Definition DataSelector.h:396
virtual void updateBean() const
Updates member objects with their corresponding variable values .
Definition DataSelector.cpp:184
DataSelector(const ODIMPathElem &elem, const T &... args)
Inits pathmatcher.
Definition DataSelector.h:127
static void swapData(Hi5Tree &src, const ODIMPathElem &srcElem, Hi5Tree &dst)
Swap branches such that dst gets a /dataset or /data with a new index.
void setQuantities(const std::string &s)
Sets basic quantities and quality quantities. These sets are separated by '/'.
std::string prf
Reject or accept VRAD(VH)
Definition DataSelector.h:405
std::string path
Regular expression of accepted paths, for example ".*/data$". Deprecated.
Definition DataSelector.h:379
static void swapData(Hi5Tree &srcGroup, Hi5Tree &dst, ODIMPathElem::group_t groupType)
Like swapData(Hi5Tree & src,const ODIMPathElem &srcElem, Hi5Tree & dst), but src already at the level...
void updateQuantities() const
Continue path matching started with getMainPaths()
void getPaths(const Hi5Tree &src, std::list< ODIMPath > &pathContainer) const
Sets given parameters and implicitly determines missing parameters.
bool getNextPath(const Hi5Tree &src, ODIMPath &path, ODIMPathElem::group_t group=ODIMPathElem::DATA) const
Returns the a path with index one greater than the retrieved last path.
bool consumeParameters(std::string &args)
Sets parameters in predefined order or sets specified parameters. (Python style calling alternatives....
Definition DataSelector.h:168
void trimPathMatcher()
"Drop leading slashes", ie. remove leading empty elements.
Definition DataSelector.h:192
virtual void updateBean() const override
Traverses the parameters and updates the corresponding member objects.
void ensureDataGroup()
In path, ensure trailing DATA or QUANTITY element.
drain::Range< int > timespan
Time in seconds, compared to nominal time.
Definition DataSelector.h:411
bool getPath(const Hi5Tree &src, ODIMPath &path) const
Returns the first path encountered with selector attributes and given groupFilter .
bool getLastPath(const Hi5Tree &src, ODIMPath &path, ODIMPathElem::group_t group=ODIMPathElem::DATA) const
Returns the last path encountered with selector attributes and given groupFilter .
void reset()
Collect paths with all the criteria: path, elevation(range), PRF, quantity...
const std::string & getQuantity() const
Retrieve quantity list and regular expression, if defined.
Definition DataSelector.h:225
void prunePaths(const Hi5Tree &src, std::list< ODIMPath > &pathContainer) const
Use DataOrder::criterion DATA , TIME or ELANGLE and #DataOrder::order MIN or MAX to sort paths.
drain::Range< double > elangle
The minimum and maximum elevation angle (applicable with volume scan data only).
Definition DataSelector.h:400
bool collectPaths(const Hi5Tree &src, std::list< ODIMPath > &pathContainer, const ODIMPath &basepath=ODIMPath(), const std::string &parentQuantity="") const
Collect paths (only) with criteria: path, elevation(range), PRF, quantity.
Definition DataSelector.cpp:375
std::string quantities
Comma-separated list of conventional quantities, optionally followed by '/', and quality quantities.
Definition DataSelector.h:386
Definition DataSelector.h:452
unsigned int group_t
In H5, "groups" correspond to directories or folders in file system.
Definition ODIMPath.h:91
static const group_t ALL_GROUPS
User defined group, name stored as a separate string. Index allowed, but only catenated in the string...
Definition ODIMPath.h:139
static const group_t DATA
Second level group, /data + digit .
Definition ODIMPath.h:108
Structure for testing if a path matches a given sequence of path elements.
Definition ODIMPathMatcher.h:186
Definition DataSelector.cpp:1277
Definition DataSelector.cpp:44
std::map< std::string, ODIMPathElem > ODIMPathElemMap
Definition ODIMPath.h:464
Definition DataSelector.h:58
void set(const std::string s)
Expects <crit>[:<oper>].
Definition DataSelector.h:78