IODA Bundle
DataContainer.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020 NOAA/NWS/NCEP/EMC
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  */
7 
8 #pragma once
9 
10 
11 #include <map>
12 #include <string>
13 #include <vector>
14 #include <memory>
15 #include "Eigen/Dense"
16 
17 #include "DataObject/DataObject.h"
18 #include "IngesterTypes.h"
19 
20 
21 namespace Ingester
22 {
23  /// List of possible category strings (for splitting data)
24  typedef std::vector<std::string> SubCategory;
25 
26  /// Map of data set id's to vector of possible value strings
27  typedef std::map<std::string, SubCategory> CategoryMap;
28 
29  /// Map string paths (ex: variable/radiance) to DataObject
30  typedef std::map<std::string, std::shared_ptr<DataObject>> DataSetMap;
31 
32  /// Map category combo (ex: SatId/sat_1, GeoBox/lat_25_30__lon_23_26) to the relevant DataSetMap
33  typedef std::map<std::vector<std::string>, DataSetMap> DataSets;
34 
35 
36  /// \brief Collection of DataObjects that a Parser collected identified by their exported name
38  {
39  public:
40  /// \brief Simple constructor
41  DataContainer();
42 
43  /// \brief Construct to create container with subcategories.
44  /// \details constructor that creates a underlying data structure to store data in separate
45  /// sub categories defined by combining all possible combinations of categories
46  /// defined in the category map.
47  /// \param categoryMap map of major category types ex: "SatId" to the possible sub types
48  /// for the category type ex: {"GOES-15", "GOES-16", "GOES-17"}.
49  explicit DataContainer(const CategoryMap& categoryMap);
50 
51  /// \brief Add a DataObject to the collection
52  /// \param fieldName The unique (export) string that identifies this data
53  /// \param data The DataObject to store
54  /// \param categoryId The vector<string> for the subcategory
55  void add(const std::string& fieldName,
56  std::shared_ptr<DataObject> data,
57  const SubCategory& categoryId = {});
58 
59  /// \brief Get a DataObject from the collection
60  /// \param fieldName The name of the data object ot get
61  /// \param categoryId The vector<string> for the subcategory
62  std::shared_ptr<DataObject> get(const std::string& fieldName,
63  const SubCategory& categoryId = {}) const;
64 
65  /// \brief Check if DataObject with name is available
66  /// \param fieldName The name of the object
67  /// \param categoryId The vector<string> for the subcategory
68  bool hasKey(const std::string& fieldName,
69  const SubCategory& categoryId = {}) const;
70 
71  /// \brief Get the number of rows of the specified sub category
72  /// \param categoryId The vector<string> for the subcategory
73  size_t size(const SubCategory& categoryId = {}) const;
74 
75  /// \brief Get the number of rows of the specified sub category
76  std::vector<SubCategory> allSubCategories() const;
77 
78  /// \brief Get the map of categories
79  inline CategoryMap getCategoryMap() const { return categoryMap_; }
80 
81  private:
82  /// Category map given (see constructor).
84 
85  /// Map of data for each possible subcategory
87 
88  /// \brief Uses category map to generate listings of all possible subcategories.
89  void makeDataSets();
90 
91  /// \brief Convenience function used to make a string out of a subcategory listing.
92  /// \param categoryId Subcategory (ie: vector<string>) listing.
93  static std::string makeSubCategoryStr(const SubCategory& categoryId);
94  };
95 } // namespace Ingester
Collection of DataObjects that a Parser collected identified by their exported name.
Definition: DataContainer.h:38
DataSets dataSets_
Map of data for each possible subcategory.
Definition: DataContainer.h:86
std::shared_ptr< DataObject > get(const std::string &fieldName, const SubCategory &categoryId={}) const
Get a DataObject from the collection.
bool hasKey(const std::string &fieldName, const SubCategory &categoryId={}) const
Check if DataObject with name is available.
CategoryMap getCategoryMap() const
Get the map of categories.
Definition: DataContainer.h:79
void makeDataSets()
Uses category map to generate listings of all possible subcategories.
size_t size(const SubCategory &categoryId={}) const
Get the number of rows of the specified sub category.
DataContainer()
Simple constructor.
void add(const std::string &fieldName, std::shared_ptr< DataObject > data, const SubCategory &categoryId={})
Add a DataObject to the collection.
std::vector< SubCategory > allSubCategories() const
Get the number of rows of the specified sub category.
static std::string makeSubCategoryStr(const SubCategory &categoryId)
Convenience function used to make a string out of a subcategory listing.
const CategoryMap categoryMap_
Category map given (see constructor).
Definition: DataContainer.h:83
std::map< std::string, std::shared_ptr< DataObject > > DataSetMap
Map string paths (ex: variable/radiance) to DataObject.
Definition: DataContainer.h:30
std::map< std::string, SubCategory > CategoryMap
Map of data set id's to vector of possible value strings.
Definition: DataContainer.h:27
std::vector< std::string > SubCategory
List of possible category strings (for splitting data)
Definition: DataContainer.h:24
std::map< std::vector< std::string >, DataSetMap > DataSets
Map category combo (ex: SatId/sat_1, GeoBox/lat_25_30__lon_23_26) to the relevant DataSetMap.
Definition: DataContainer.h:33