32#ifndef RACK_DATASELECTOR
33#define RACK_DATASELECTOR
35#include <data/QuantitySelector.h>
41#include <drain/RegExp.h>
42#include <drain/Sprinter.h>
43#include <drain/Type.h>
44#include <drain/util/BeanLike.h>
45#include <drain/util/Range.h>
46#include <drain/util/ReferenceMap.h>
47#include <drain/util/StringMatcherList.h>
51#include "ODIMPathTools.h"
52#include "ODIMPathMatcher.h"
61 enum Crit {DATA, ELANGLE, TIME};
64 const char separator =
':';
67 CritFlagger criterion;
70 OperFlagger operation;
72 template<
typename ... TT>
73 void set(Crit crit,
const TT &... args) {
78 template<
typename ... TT>
79 void set(Oper oper,
const TT &... args) {
86 void set(
const std::string s) {
95 str = criterion.str() + separator + operation.str();
104std::ostream & operator<<(std::ostream & ostr,
const DataOrder & order){
119 enum Prf {SINGLE=1, DOUBLE=2, ANY=3};
129 DataSelector(
const std::string & parameters =
"");
134 template<
typename ... T>
138 pathMatcher.set(elem, args...);
143 template<
typename ... T>
147 pathMatcher.set(e, args...);
152 DataSelector(
const DataSelector & selector);
154 virtual ~DataSelector();
187 template<
typename ... TT>
189 void setPathMatcher(TT... args){
190 pathMatcher.set(args...);
194 const ODIMPathMatcher & getPathMatcher()
const {
210 bool quantityIsSet()
const {
211 return quantitySelector.isSet();
226 return quantitySelector;
237 void setMaxCount(
unsigned int i){
242 unsigned int getMaxCount()
const {
248 void setPrf(
const std::string & s){
250 this->prfSelector.set(s);
255 this->prfSelector.set(
prf);
256 this->prf = this->prfSelector.
str();
260 template<
typename ... TT>
262 void setOrder(
const TT &... args) {
263 this->order.set(args...);
267 const DataOrder & getOrder()
const {
319 void getPaths(
const Hi5Tree & src, std::list<ODIMPath> & pathContainer)
const;
447 void prunePaths(
const Hi5Tree & src, std::list<ODIMPath> & pathContainer)
const;
451std::ostream & operator<<(std::ostream & ostr,
const DataSelector &selector);
462 parameters.
delink(
"path");
463 mout.experimental<LOG_NOTICE>(
"not resetting DATASET" );
Something which has a name, a description and possibly some parameters of varying type.
Definition BeanLike.h:60
void setParameters(std::initializer_list< Variable::init_pair_t > args)
Grants access to (if above hidden)
Definition BeanLike.h:144
Flagger accepting values of enum type E.
Definition EnumFlags.h:190
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:312
void trimHead(bool COMPLETE=false)
Removes leading empty elements. The resulting string presentation will not start with the separator.
Definition Path.h:329
Definition ReferenceMap.h:207
void delink(const std::string &key)
Removes an entry from the map.
Definition ReferenceMap.h:342
virtual const key_t & str() const override
String corresponding the current value. Returns empty, if not found.
Definition Flags.h:159
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:135
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:176
void trimPathMatcher()
"Drop leading slashes", ie. remove leading empty elements.
Definition DataSelector.h:200
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:220
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: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:186
Definition DataSelector.cpp:1277
DRAIN_TYPENAME(void)
Add a specialization for each type of those you want to support.
Definition DataSelector.cpp:44
std::map< std::string, ODIMPathElem > ODIMPathElemMap
Definition ODIMPath.h:465
Definition DataSelector.h:58
void set(const std::string s)
Expects <crit>[:<oper>].
Definition DataSelector.h:86