32 #ifndef RACK_DATASELECTOR
33 #define RACK_DATASELECTOR
40 #include <drain/RegExp.h>
41 #include <drain/Sprinter.h>
42 #include <drain/Type.h>
43 #include <drain/util/BeanLike.h>
44 #include <drain/util/KeySelector.h>
45 #include <drain/util/Range.h>
46 #include <drain/util/ReferenceMap.h>
50 #include "ODIMPathTools.h"
51 #include "ODIMPathMatcher.h"
52 #include "PolarODIM.h"
60 enum Crit {DATA, ELANGLE, TIME};
63 const char separator =
':';
71 template<
typename ... TT>
72 void set(Crit crit,
const TT &... args) {
77 template<
typename ... TT>
78 void set(Oper oper,
const TT &... args) {
85 void set(
const std::string s) {
94 str = criterion.
str() + separator + operation.
str();
103 std::ostream & operator<<(std::ostream & ostr,
const DataOrder & order){
118 enum Prf {SINGLE=1, DOUBLE=2, ANY=3};
126 DataSelector(
const std::string & parameters =
"");
131 template<
typename ... T>
135 pathMatcher.set(elem, args...);
140 template<
typename ... T>
144 pathMatcher.set(e, args...);
149 DataSelector(
const DataSelector & selector);
151 virtual ~DataSelector();
184 template<
typename ... TT>
186 void setPathMatcher(TT... args){
187 pathMatcher.set(args...);
191 const ODIMPathMatcher & getPathMatcher()
const {
204 void setQuantityRegExp(
const std::string & s);
207 bool quantityIsSet()
const {
208 return quantitySelector.isSet() || qualitySelector.isSet();
223 return quantitySelector;
228 return qualitySelector;
232 void setMaxCount(
unsigned int i){
237 unsigned int getMaxCount()
const {
243 void setPrf(
const std::string & s){
245 this->prfSelector.set(s);
250 this->prfSelector.set(
prf);
251 this->prf = this->prfSelector.
str();
255 template<
typename ... TT>
257 void setOrder(
const TT &... args) {
258 this->order.set(args...);
262 const DataOrder & getOrder()
const {
271 void selectPaths(
const Hi5Tree & src, std::list<ODIMPath> & pathContainer)
const;
329 void getPaths(
const Hi5Tree & src, std::list<ODIMPath> & pathContainer)
const;
338 bool getPath(
const Hi5Tree & src, ODIMPath &
path)
const;
364 void swapData(Hi5Tree & src,
const ODIMPathElem &srcElem, Hi5Tree & dst);
435 bool collectPaths(
const Hi5Tree & src, std::list<ODIMPath> & pathContainer,
const ODIMPath & basepath =
ODIMPath(),
const std::string & parentQuantity=
"")
const;
437 bool collectPathsOLD(
const Hi5Tree & src, std::list<ODIMPath> & pathContainer,
const ODIMPath & basepath =
ODIMPath())
const;
441 void prunePaths(
const Hi5Tree & src, std::list<ODIMPath> & pathContainer)
const;
447 std::ostream & operator<<(std::ostream & ostr,
const DataSelector &selector);
458 parameters.
delink(
"path");
459 mout.info(
"experimental: not re-setting 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:131
Flagger accepting values of enum type E.
Definition: Flags.h:763
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition: Log.h:308
void trimHead(bool COMPLETE=false)
Removes leading empty elements. The resulting string presentation will not start with the separator.
Definition: Path.h:321
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
String corresponding the current value. Returns empty, if not found.
Definition: Flags.h:555
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:132
void setQuantities(const std::string &s)
Sets basic quantities and quality quantities. These sets are separated by '/'.
Definition: DataSelector.cpp:282
std::string prf
Reject or accept VRAD(VH)
Definition: DataSelector.h:405
const std::string & getQuantity() const
Retrieve quantity list and regular expression, if defined.
Definition: DataSelector.h:217
std::string path
Regular expression of accepted paths, for example ".*/data$". Deprecated.
Definition: DataSelector.h:379
void updateQuantities() const
Continue path matching started with getMainPaths()
Definition: DataSelector.cpp:290
void getPaths(const Hi5Tree &src, std::list< ODIMPath > &pathContainer) const
Sets given parameters and implicitly determines missing parameters.
Definition: DataSelector.cpp:1126
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:1214
bool consumeParameters(std::string &args)
Sets parameters in predefined order or sets specified parameters. (Python style calling alternatives....
Definition: DataSelector.h:173
void selectPaths(const Hi5Tree &src, std::list< ODIMPath > &pathContainer) const
Collect paths with all the criteria: path, elevation(range), PRF, quantity...
Definition: DataSelector.cpp:359
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:1240
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:230
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 .
Definition: DataSelector.cpp:1135
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:1173
void reset()
Restore default values.
Definition: DataSelector.cpp:156
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:930
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
Definition: ODIMPath.h:82
static const group_t DATASET
First level group, /dataset + digit .
Definition: ODIMPath.h:103
drain::Flagger::ivalue_t group_t
In H5, "groups" correspond to "directories" or "folders" in Unix and Windows.
Definition: ODIMPath.h:91
static const group_t DATA
Second level group, /data + digit .
Definition: ODIMPath.h:106
Structure for testing if a path matches a given sequence of path elements.
Definition: ODIMPathMatcher.h:182
Definition: DataSelector.cpp:1277
Definition: DataSelector.cpp:44
std::map< std::string, ODIMPathElem > ODIMPathElemMap
Definition: ODIMPath.h:462
Definition: DataSelector.h:58
void set(const std::string s)
Expects <crit>[:<oper>].
Definition: DataSelector.h:85