IODA Bundle
BufrCollectors.cpp
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 #include <iostream>
9 
10 #include <memory>
11 
12 #include "BufrCollectors.h"
13 #include "BufrIntCollector.h"
14 #include "BufrRepCollector.h"
15 #include "DataContainer.h"
16 
17 
18 namespace Ingester
19 {
20  BufrCollectors::BufrCollectors(unsigned int fortranFileId) :
21  fortranFileId_(fortranFileId)
22  {
23  }
24 
25  void BufrCollectors::addMnemonicSets(const std::vector <BufrMnemonicSet> &mnemonicSets)
26  {
27  for (const auto &set : mnemonicSets)
28  {
29  addMnemonicSet(set);
30  }
31  }
32 
34  {
35  if (mnemonicSet.getMaxColumn() == 1)
36  {
37  collectors_.push_back(std::make_shared<BufrIntCollector>(fortranFileId_, mnemonicSet));
38  }
39  else
40  {
41  collectors_.push_back(std::make_shared<BufrRepCollector>(fortranFileId_, mnemonicSet));
42  }
43  }
44 
46  {
47  for (const auto &collector : collectors_)
48  {
49  collector->collect();
50  }
51  }
52 
54  {
55  auto dataMap = BufrDataMap();
56 
57  for (const auto &collector : collectors_)
58  {
59  IngesterArrayMap collectorDataMap = collector->finalize();
60  dataMap.insert(collectorDataMap.begin(), collectorDataMap.end());
61  }
62 
63  return dataMap;
64  }
65 } // namespace Ingester
BufrDataMap finalize()
Finalize all the collectors and assemble the resulting data into a map.
std::vector< std::shared_ptr< BufrCollector > > collectors_
Collection of all the collectors being managed.
BufrCollectors(unsigned int fortranFileId)
void collect()
Cause all the collectors to grab the next peaces of data from the BUFR file.
unsigned int fortranFileId_
Fortran file ID for the open BUFR file.
void addMnemonicSets(const std::vector< BufrMnemonicSet > &mnemonicSets)
Add collectors for mnemonic sets.
void addMnemonicSet(const BufrMnemonicSet &mnemonicSet)
Add collector for a mnemonic set.
Defenition of BUFR mnemonics and associated channels of interest.
IngesterArrayMap BufrDataMap
Definition: BufrTypes.h:21
std::map< std::string, IngesterArray > IngesterArrayMap
Definition: IngesterTypes.h:20