1 #include <boost/lambda/lambda.hpp>
2 #include <boost/lexical_cast.hpp>
3 #include <cdet/CModelsXMLManager.h>
4 #include <utl/ErrorLogger.h>
5 #include <utl/TabulatedFunction.h>
6 #include <cdet/CDetector.h>
7 #include <cdet/CManagerRegister.h>
13 using namespace xercesc;
14 using namespace boost::lambda;
31 const string& componentProperty,
32 const string& componentName,
39 FindBranch(componentProperty, componentName, componentIndex);
52 const string& componentProperty,
53 const string& componentName,
60 FindBranch(componentProperty, componentName, componentIndex);
86 for_each(y.begin(), y.end(), _1 *= scaleY);
89 const unsigned int n = x.size();
90 for (
unsigned int i = 0; i < n; ++i)
107 const string& modelType,
114 const int nIndices = componentIndex.size();
129 const IndexMap::const_iterator stIt = componentIndex.begin();
130 if (stIt->first ==
"stationId") {
131 stationId = stIt->second;
134 if (IsReportingErrors())
135 INFO(
string(
"If data request is made using 1 index, "
136 "that index must specify 'stationId'; ") +
137 QueryInfoMessage(componentProperty, modelType, componentIndex));
143 const IndexMap::const_iterator stIt = componentIndex.find(
"stationId");
144 if (stIt == componentIndex.end()) {
145 if (IsReportingErrors())
146 INFO(
string(
"Request with two indices, "
147 "neither of which specifies 'stationId'; ") +
148 QueryInfoMessage(componentProperty, modelType, componentIndex));
151 stationId = stIt->second;
153 const IndexMap::const_iterator rpcIt = componentIndex.find(
"RPCId");
154 if (rpcIt != componentIndex.end())
155 componentAtts[
"RPCId"] = rpcIt->second;
161 if (IsReportingErrors())
162 INFO(
string(
"Three indices in query: not yet supported; ") +
163 QueryInfoMessage(componentProperty, modelType, componentIndex));
167 if (IsReportingErrors()) {
168 INFO(
string(
"Invalid number of parameters; ") +
169 QueryInfoMessage(componentProperty, modelType, componentIndex));
175 const map<string, IndexMap>::const_iterator sModel =
176 fStationModelMap.find(stationId);
177 if (sModel != fStationModelMap.end())
178 modelMap = sModel->second;
179 else if (!fAllStationsModelMap.empty())
180 modelMap = fAllStationsModelMap;
183 err <<
"Cannot map station " << stationId <<
" to the list of known models "
184 "since model for 'all' does not exist.";
191 const IndexMap::const_iterator mIt = modelMap.find(modelType);
192 if (mIt != modelMap.end())
193 modelId = mIt->second;
199 atts[
"id"] = modelId;
203 return stationModelsB;
218 dataB = modelTypeB.
GetChild(componentProperty);
224 dataB = modelTypeB.
GetChild(componentProperty, componentAtts);
247 const IndexMap atts(modelB.GetAttributes());
248 modelMap[modelB.GetName()] = atts.find(
"id")->second;
253 optAtts[
"id"] =
"all";
257 fAllStationsModelMap = modelMap;
268 const IndexMap atts(stationB.GetAttributes());
269 const string stationIdString(atts.find(
"id")->second);
272 fStationModelMap[stationIdString] = modelMap;
283 const std::string& component,
284 const std::string& property,
288 if (!returnData.
Is<
unsigned int>())
295 FindBranch(property, component, index);
300 returnData.
Get<
unsigned int>() = dataBranch.
Get<
unsigned int>();
Status InternalGetData(T &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const
utl::Branch FindBranch(const std::string &property, const std::string &modelType, const IndexMap &componentIndex) const
Class to hold collection (x,y) points and provide interpolation between them.
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
void PushBack(const double x, const double y)
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Branch GetNextSibling() const
Get next sibling of this branch.
Class representing a document branch.
REGISTER_C_MANAGER("CStationListXMLManager", CStationListXMLManager)
Status GetData(utl::TabulatedFunction &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const
Manager for MARTA station description in XML "model" files.
void GetData(bool &b) const
Overloads of the GetData member template function.
std::map< std::string, std::string > IndexMap
Branch GetFirstChild() const
Get first child of this Branch.
boost::add_reference< typename boost::remove_const< T >::type >::type Get()
virtual Status GenericGetData(Handle &returnData, const std::string &component, const std::string &property, const IndexMap &index) const
#define ERROR(message)
Macro for logging error messages.
Status
Specifies success or (eventually) various possible failure modes.