OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
DatFile.hpp
Go to the documentation of this file.
1 
2 #ifndef FOCS_DATFILE
3 #define FOCS_DATFILE
4 
5 #include <functional>
6 #include <iterator>
7 #include <string>
8 #include <tuple>
9 #include <unordered_map>
10 #include <vector>
11 
12 namespace focs {
29  class DatFile {
30  using Callback = std::function<bool(const std::tuple<std::string, int, double>&)>;
31  public:
33  DatFile() = default;
39  explicit DatFile(const std::string& file);
46  DatFile(const std::string& file, Callback callback);
47 
55  bool load(const std::string& file);
63  bool load(std::istream& in);
71  bool load_line(const std::string& line);
72 
73  bool empty() { return kv_.empty(); };
74 
80  std::unordered_map<std::string, std::vector<double>>::const_iterator begin() const;
86  std::unordered_map<std::string, std::vector<double>>::const_iterator end() const;
87 
97  std::vector<double>& operator[] (const std::string& k);
107  std::vector<double>& operator[] (std::string&& k);
108 
117  friend std::ostream& operator<<(std::ostream& os, const DatFile& kv);
118 
124  void callback(Callback callback){callback_ = callback;}
130  Callback callback(){return callback_;}
131 
132  private:
133  std::unordered_map<std::string, std::vector<double>> kv_{};
134 
135  Callback callback_{};
136  };
137 } // namespace focs
138 
139 #endif // FOCS_DATFILE
140 
Callback callback()
Return the user function to call for each line.
Definition: DatFile.hpp:130
friend std::ostream & operator<<(std::ostream &os, const DatFile &kv)
Output dat file to stream.
void callback(Callback callback)
Set the user function to call for each line.
Definition: DatFile.hpp:124
DatFile()=default
Default constructor, creates an empty object.
@ string
std::unordered_map< std::string, std::vector< double > >::const_iterator end() const
End variable iterator.
bool empty()
Definition: DatFile.hpp:73
bool load_line(const std::string &line)
Load a single line.
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed file
Definition: HISTORY.txt:413
bool load(const std::string &file)
Load dat file from path.
subroutine os(tamoy, trmoy, pizmoy, tamoyp, trmoyp, palt, phirad, nt, mu, np, rm, gb, rp, xl)
Definition: 6sm1.f:5484
.dat file reader
Definition: DatFile.hpp:29
std::vector< double > & operator[](const std::string &k)
Access a variable.
#define bool
Definition: usrmac.h:88
std::unordered_map< std::string, std::vector< double > >::const_iterator begin() const
Iterator returning each variable read.
int k
Definition: decode_rs.h:73