RStationListXMLManager.cc
Go to the documentation of this file.
1 #include <iostream>
2 
4 
5 #include <rdet/RStationListXMLManager.h>
6 #include <utl/ErrorLogger.h>
7 #include <utl/Reader.h>
8 #include <rdet/RManagerRegister.h>
9 
10 using namespace std;
11 using namespace rdet;
12 using namespace utl;
13 using namespace det;
14 
15 
16 REGISTER_R_MANAGER("RStationListXMLManager", RStationListXMLManager);
17 
18 
19 void
20 RStationListXMLManager::Init(const std::string& configLink)
21 {
22  // first do the normal Init()
23  VManager::Init(configLink);
24 
25  for (Branch cB = fBranch.GetFirstChild(); cB; cB = cB.GetNextSibling())
26 
27  if (cB.GetName() == "station") {
28 
30 
31  station.fId = FindComponent<int>("id", cB.GetAttributes());
32  station.fSource = "XML"; // to identify that the describtion of this station should come from an XML manager
33 
34  cB.GetChild("northing").GetData(station.fNorthing);
35  cB.GetChild("easting").GetData(station.fEasting);
36  cB.GetChild("altitude").GetData(station.fAltitude);
37  station.fName = cB.GetChild("name").GetDataString();
38  cB.GetChild("commission").GetData(station.fCommissionTime);
39  cB.GetChild("decommission").GetData(station.fDecommissionTime);
40  cB.GetChild("inGrid").GetData(station.fInGrid);
41  cB.GetChild("ellipsoid").GetData(station.fEllipsoid);
42  cB.GetChild("zone").GetData(station.fZone);
43  cB.GetChild("band").GetData(station.fBand);
44  cB.GetChild("nChannels").GetData(station.fNChannels);
45  cB.GetChild("firstChannelId").GetData(station.fFirstChannelId);
46  cB.GetChild("lastChannelId").GetData(station.fLastChannelId);
47 
48  const bool ok =
49  fStationManager.ConditionalAddStationData(station);
50 
51  if (!ok) {
52  ostringstream err;
53  err << "multiple instances of station id " << station.fId
54  << "found in XML configuration";
55  ERROR(err);
56  throw utl::XMLParseException(err.str());
57  }
58  }
59 }
60 
61 
63 RStationListXMLManager::GetListOfChannelIds(std::vector<int>& resultData,
64  const string& /*componentProperty*/,
65  const det::VManager::IndexMap& componentIndex)
66  const
67 {
68  std::vector<int> result;
69  int firstChannelId = 0;
70  int lastChannelId = 0;
71  if ((fStationManager.GetData(firstChannelId, "firstChannelId", componentIndex) == eFound) &&
72  (fStationManager.GetData(lastChannelId, "lastChannelId", componentIndex) == eFound)) {
73  for (int i = firstChannelId; i <= lastChannelId; ++i) {
74  result.push_back(i);
75  }
76  resultData = result;
77  return eFound;
78  } else
79  return eNotFound;
80 }
void Init()
Initialise the registry.
bool ok(bool okay)
Definition: testlib.cc:89
Exception for errors encountered when parsing XML.
Branch GetNextSibling() const
Get next sibling of this branch.
Definition: Branch.cc:284
#define REGISTER_R_MANAGER(_name_, _Type_)
Class representing a document branch.
Definition: Branch.h:107
const Data result[]
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
Branch GetFirstChild() const
Get first child of this Branch.
Definition: Branch.cc:98
Manager for Radio description in XML station lists.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
Status
Specifies success or (eventually) various possible failure modes.
Definition: VManager.h:127

, generated on Tue Sep 26 2023.