MolecularZone.cc
Go to the documentation of this file.
1 
10 #include <iostream>
11 #include <boost/lexical_cast.hpp>
12 
13 #include <atm/MolecularZone.h>
14 #include <atm/MolecularLayer.h>
15 #include <atm/Atmosphere.h>
16 #include <utl/ErrorLogger.h>
17 
18 using namespace det;
19 using namespace std;
20 using namespace atm;
21 using namespace utl;
22 
23 
24 MolecularZone::MolecularZone(const string& zoneId, const string& molecularId,
25  const string& zoneName,
26  const double northing, const double easting) :
27  VZone(zoneId, zoneName, northing, easting),
28  fLayerVector(0),
29  fMolecularIdString(molecularId)
30 {
31  // Find the id for this MolecularZone object.
32  // This is just the primary key in the molecular_zone table for the
33  // given molecular_id and zone_id
34  //
35  VManager::IndexMap indexMap;
36  indexMap["molecular_id"] = fMolecularIdString;
37  indexMap["zone_id"] = fZoneIdString;
38 
39  const VManager& manager = Detector::GetInstance().GetAManagerRegister();
40  const VManager::Status stat =
41  manager.GetData(fMolecularZoneIdString, "molecular_zone", "molecular_zone_id", indexMap);
42  if (stat == VManager::eNotFound)
43  throw DataNotFoundInDBException("molecular_zone", "molecular_zone_id", indexMap,
44  boost::lexical_cast<string>(Detector::GetInstance().GetTime()));
45 }
46 
47 
50  const
51 {
52  if (!fLayerVector)
54  return LayerIterator(fLayerVector->begin());
55 }
56 
57 
60  const
61 {
62  if (!fLayerVector)
64  return LayerIterator(fLayerVector->end());
65 }
66 
67 
69 {
70  if (fLayerVector) {
71  for (InternalLayerIterator sIt = fLayerVector->begin();
72  sIt != fLayerVector->end(); ++sIt)
73  delete *sIt;
74  delete fLayerVector;
75  }
76 }
77 
78 
79 void
80 MolecularZone::CacheLayers(vector<const MolecularLayer*>*& layerVector,
81  const string& zoneIdString)
82  const
83 {
84  if (layerVector)
85  return;
86 
87  const VManager& manager = Detector::GetInstance().GetAManagerRegister();
88 
89  layerVector = new vector<const MolecularLayer*>;
90 
91  VManager::IndexMap indexMap;
92  indexMap["molecular_zone_id"] = zoneIdString;
93 
94  vector<string> layerIdStrings;
95  const VManager::Status stat =
96  manager.GetData(layerIdStrings, "molecular_layer", "molecular_layer_id", indexMap);
97 
98  if (stat == VManager::eNotFound) {
99  ostringstream msg;
100  msg << "Did not find requested data, header table: molecular_layer, "
101  " zoneId: " << zoneIdString;
102  ERROR(msg);
103  throw DataNotFoundInDBException("molecularLayer", "zone_id", indexMap,
104  boost::lexical_cast<string>(Detector::GetInstance().GetTime()));
105  }
106 
107  for (vector<string>::iterator it = layerIdStrings.begin();
108  it != layerIdStrings.end(); ++it) {
109  MolecularLayer* layer = new MolecularLayer(*it);
110  layerVector->push_back(layer);
111  }
112 }
113 
114 
115 // Configure (x)emacs for this file ...
116 // Local Variables:
117 // mode:c++
118 // compile-command: "make -C .. -k"
119 // End:
InternalLayerVector::const_iterator InternalLayerIterator
Definition: MolecularZone.h:37
void CacheLayers(InternalLayerVector *&layerVector, const std::string &zoneIdString) const
std::string fMolecularIdString
Definition: MolecularZone.h:65
InternalLayerVector * fLayerVector
Definition: MolecularZone.h:39
Interface for detector managers.
Definition: VManager.h:115
virtual Status GetData(double &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const =0
Exception to use in case requested data not found in the database with detailed printout.
Base class for Aerosol, Molecula, Overall Quality and Lidar atmosphere zones.
Definition: VZone.h:28
std::string fMolecularZoneIdString
Definition: MolecularZone.h:66
boost::indirect_iterator< InternalLayerIterator, const MolecularLayer & > LayerIterator
Layer iterator returns a pointer to the molecular data slice for this zone.
Definition: MolecularZone.h:43
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
LayerIterator LayersBegin() const
Beginning of the collection of molecular data slices.
LayerIterator LayersEnd() const
End of the collection of molecular data slices.
Molecular data for a zone slice.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
virtual ~MolecularZone()
std::string fZoneIdString
Definition: VZone.h:51
Status
Specifies success or (eventually) various possible failure modes.
Definition: VManager.h:127

, generated on Tue Sep 26 2023.