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"
54 enum Crit {DATA, ELANGLE, TIME};
57 const char separator =
':';
65 template<
typename ...
TT>
66 void set(Crit
crit,
const TT &... args) {
71 template<
typename ...
TT>
72 void set(Oper oper,
const TT &... args) {
79 void set(
const std::string s) {
88 str = criterion.
str() + separator + operation.
str();
97std::ostream &
operator<<(std::ostream & ostr,
const DataOrder & order){
112 enum Prf {SINGLE=1, DOUBLE=2, ANY=3};
124 DataSelector(
const std::string &
parameters =
"");
130 template<
typename ... T>
134 pathMatcher.set(elem, args...);
140 template<
typename ... T>
144 pathMatcher.set(e, args...);
184 template<
typename ...
TT>
186 void setPathMatcher(
TT... args){
187 pathMatcher.set(args...);
191 const ODIMPathMatcher & getPathMatcher()
const {
220 bool quantityIsSet()
const {
221 return quantitySelector.isSet();
236 return quantitySelector;
241 void setMaxCount(
unsigned int i){
246 unsigned int getMaxCount()
const {
252 void setPrf(
const std::string & s){
254 this->prfSelector.set(s);
259 this->prfSelector.set(
prf);
260 this->prf = this->prfSelector.
str();
264 template<
typename ... TT>
266 void setOrder(
const TT &... args) {
267 this->order.set(args...);
271 const DataOrder & getOrder()
const {
317 void getPaths(
const Hi5Tree & src, std::list<ODIMPath> & pathContainer)
const;
326 bool getPath(
const Hi5Tree & src, ODIMPath &
path)
const;
352 void swapData(Hi5Tree & src,
const ODIMPathElem &srcElem, Hi5Tree & dst);
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
map_t parameters
Parameters (name -> linked variable), typically linked to member variables of the derived class.
Definition BeanLike.h:313
void setParameters(std::initializer_list< Variable::init_pair_t > args)
Grants access to (if above hidden)
Definition BeanLike.h:157
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:326
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:355
virtual const key_t & str() const override
String corresponding the current value. Returns empty, if not found.
Definition Flags.h:155
Tool for selecting datasets based on paths, quantities and min/max elevations.
Definition DataSelector.h:106
void init()
Sets the default values and sets references.
Definition DataSelector.cpp:140
Prf
Pulse repetition frequency mode.
Definition DataSelector.h:112
unsigned int count
The maximum length of the list of matching keys.
Definition DataSelector.h:402
DataSelector(const ODIMPathElem &elem, const T &... args)
Inits pathmatcher.
Definition DataSelector.h:131
void setQuantities(const std::string &s)
Sets basic quantities and quality quantities. These sets are separated by '/'.
Definition DataSelector.cpp:299
std::string prf
Reject or accept VRAD(VH)
Definition DataSelector.h:411
std::string path
Regular expression of accepted paths, for example ".*/data$". Deprecated.
Definition DataSelector.h:385
DataSelector(ODIMPathElem::group_t e, const T &... args)
Constructor initializing path matcher from group type(s).
Definition DataSelector.h:141
void updateQuantities() const
Continue path matching started with getMainPaths()
Definition DataSelector.cpp:307
void getPaths(const Hi5Tree &src, std::list< ODIMPath > &pathContainer) const
Sets given parameters and implicitly determines missing parameters.
Definition DataSelector.cpp:725
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.
Definition DataSelector.cpp:836
bool collectPaths(const Hi5Tree &src, std::list< ODIMPath > &pathContainer, const ODIMPath &basepath=ODIMPath(), const std::string &parentQuantity="", ODIMPathElem::group_t filter=ODIMPathElem::ALL_GROUPS) const
Collect paths (only) with criteria: path, elevation(range), PRF, quantity.
Definition DataSelector.cpp:339
virtual void updateBean() const override
Traverses the parameters and updates the corresponding member objects.
Definition DataSelector.cpp:199
bool consumeParameters(std::string &args)
Sets parameters in predefined order or sets specified parameters. (Python style calling alternatives....
Definition DataSelector.h:173
static void swapData(Hi5Tree &src, const ODIMPathElem &srcElem, Hi5Tree &dst)
Swap branches such that dst gets a /dataset or /data with a new index.
Definition DataSelector.cpp:862
void trimPathMatcher()
"Drop leading slashes", ie. remove leading empty elements.
Definition DataSelector.h:197
void ensureDataGroup()
In path, ensure trailing DATA or QUANTITY element.
Definition DataSelector.cpp:245
bool getPath(const Hi5Tree &src, ODIMPath &path) const
Returns the first path encountered with selector attributes and given groupFilter .
Definition DataSelector.cpp:738
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 .
Definition DataSelector.cpp:795
void reset()
Collect paths with all the criteria: path, elevation(range), PRF, quantity...
Definition DataSelector.cpp:166
const std::string & getQuantity() const
Retrieve quantity list and regular expression, if defined.
Definition DataSelector.h:230
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.
Definition DataSelector.cpp:562
drain::Range< int > timespan
Time in seconds, compared to nominal time.
Definition DataSelector.h:417
drain::Range< double > elangle
The minimum and maximum elevation angle (applicable with volume scan data only).
Definition DataSelector.h:406
std::string quantities
Comma-separated list of conventional quantities, optionally followed by '/', and quality quantities.
Definition DataSelector.h:392
A map of radar data, indexed by quantity code (DBZH, VRAD, etc).
Definition Data.h:1293
DOC: Add class description.
Definition DataSelector.h:455
DOC: Add class description.
Definition ODIMPath.h:82
static const group_t DATASET
First level group, /dataset + digit .
Definition ODIMPath.h:106
unsigned int group_t
In H5, "groups" correspond to directories or folders in file system.
Definition ODIMPath.h:92
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:140
static const group_t DATA
Second level group, /data + digit .
Definition ODIMPath.h:109
Structure for testing if a path matches a given sequence of path elements.
Definition ODIMPathMatcher.h:190
Definition AltitudeOp.cpp:42
std::map< std::string, ODIMPathElem > ODIMPathElemMap
Definition ODIMPath.h:474
std::ostream & operator<<(std::ostream &ostr, const PlainData< DT > &d)
Definition Data.h:631
DOC: Add class description.
Definition DataSelector.h:52
void set(const std::string s)
Expects crit[:oper].
Definition DataSelector.h:79