resources-base.h
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 /*
27 Part of Rack development has been done in the BALTRAD projects part-financed
28 by the European Union (European Regional Development Fund and European
29 Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30 */
31 
32 // # pragma once
33 
34 #ifndef RACK_RESOURCES_BASE
35 #define RACK_RESOURCES_BASE
36 
37 #include <string>
38 
39 #include <drain/util/Static.h>
40 
41 #include "data/DataSelector.h"
42 #include "data/PolarODIM.h"
43 #include "hi5/Hi5.h"
44 
45 // #include "graphics.h" // SVG
46 
47 #include "resources-image.h"
48 
49 
50 namespace rack {
51 
52 
53 
54 class AndreContext {
55 public:
56 
57  AndreContext() : andreSelect("path=dataset1:3,elangle=0:2.0"), defaultQuality(0.9) {
58  // defaultQuality initialized in respective cmd CmdQuality
59  }
60 
61  AndreContext(const AndreContext & ctx) : andreSelect(ctx.andreSelect), defaultQuality(ctx.defaultQuality) {
62  // defaultQuality initialized in respective cmd CmdQuality
63  }
64 
65  std::string andreSelect;
66 
67  float defaultQuality;
68 };
69 
70 
71 
72 
73 
74 class Hdf5Context {
75 
76 public:
77 
78  Hdf5Context();
79 
80  Hdf5Context(const Hdf5Context &ctx);
81 
82  std::string select;
83  std::string inputSelect;
84 
86  Hi5Tree polarInputHi5;
87 
89  Hi5Tree polarProductHi5;
90 
92  Hi5Tree cartesianHi5;
93 
95  Hi5Tree *currentHi5; // = &inputHi5;
96 
97 
99 
102  Hi5Tree *currentPolarHi5; // = &inputHi5;
103 
104 
105  enum Hi5Role {
106  CURRENT=1, // Latest HDF5 processed
107  INPUT=2, // Latest input file
108  POLAR=4, // Current Polar volume or product
109  CARTESIAN=8, // Accept Cartesian
110  EMPTY=16, // Also accept empty
111  PRIVATE=32, // File owned my this thread only
112  SHARED=64, // File shared by all the threads
113  };
114 
115  typedef drain::EnumFlagger<drain::MultiFlagger<Hi5Role> > Hi5RoleFlagger;
116 
117 
119 
123  Hi5Tree & getMyHi5(Hi5RoleFlagger::ivalue_t filter=(CARTESIAN|POLAR|INPUT|CURRENT));
124 
125 
127 
133  Hi5Tree & getHi5Defunct(Hi5RoleFlagger::ivalue_t filter);
134 
136 
142  /*
143  inline
144  Hi5Tree & getCartesianHi5(h5_role::value_t filter=(PRIVATE|SHARED)){
145  return getHi5(filter | CARTESIAN);
146  }
147 
148  inline
149  Hi5Tree & getCurrentInputHi5(h5_role::value_t filter=(PRIVATE|SHARED)){
150  return getHi5(filter | CURRENT|INPUT);
151  }
152 
153  static inline
154  Hdf5Context & getStaticContext(){
155  return drain::Static::get<Hdf5Context>();
156  }
157  */
158 
159 protected:
160 
161  void updateHdf5Status(drain::VariableMap & statusMap) const; // Not static, because checks
162 
163  static Hi5Tree empty;
164 
165 };
166 
167 template <>
169 
170 } /* namespace rack */
171 
172 #endif /* RACKLET_H_ */
173 
174 // Rack
Two-way mapping between strings and objects of template class T.
Definition: Dictionary.h:63
Flagger accepting values of enum type E.
Definition: EnumFlags.h:190
A map of Variables.
Definition: VariableMap.h:61
Definition: resources-base.h:54
Definition: resources-base.h:74
Hi5Tree polarInputHi5
The last input file read, typically a volume. May be concatenated ie. read in incrementally.
Definition: resources-base.h:86
Hi5Tree & getHi5Defunct(Hi5RoleFlagger::ivalue_t filter)
Derives the most relevant polar data (input or product) and returns it.
Definition: resources-base.cpp:382
Hi5Tree & getMyHi5(Hi5RoleFlagger::ivalue_t filter=(CARTESIAN|POLAR|INPUT|CURRENT))
Pointer to the last HDF5 structure in Cartesian coordinates: input or Cartesian product.
Definition: resources-base.cpp:303
Hi5Tree * currentPolarHi5
Pointer to the last HDF5 structure in polar coordinates: input volume or polar product.
Definition: resources-base.h:102
void updateHdf5Status(drain::VariableMap &statusMap) const
Derives the most relevant polar input data and returns it.
Definition: resources-base.cpp:416
Hi5Tree cartesianHi5
A single-radar Cartesian product or a multi-radar composite (mosaic).
Definition: resources-base.h:92
Hi5Tree polarProductHi5
The polar product that has been generated from the volume.
Definition: resources-base.h:89
Hi5Tree * currentHi5
Pointer to the last HDF5 structure read or generated.
Definition: resources-base.h:95
Definition: DataSelector.cpp:44
Wrapper for unique (static) dictionary of enum values.
Definition: EnumFlags.h:66