7 #if BOOST_VERSION_MACRO >= 104100
8 #include <boost/property_tree/ptree.hpp>
9 #include <boost/property_tree/json_parser.hpp>
12 #include <boost/foreach.hpp>
34 : _pt (iConfigHolderStruct._pt) {
52 std::ostringstream oStr;
53 oStr <<
"Configuration Display:" << std::endl;
57 const bool hasStartDateBeenRetrieved =
58 exportValue<Date_T> (lStartDate,
"date.start");
59 if (hasStartDateBeenRetrieved ==
true) {
60 oStr <<
" Start date: " << lStartDate << std::endl;
63 const bool hasEndDateBeenRetrieved =
64 exportValue<Date_T> (lEndDate,
"date.end");
65 if (hasEndDateBeenRetrieved ==
true) {
66 oStr <<
" End date: " << lEndDate << std::endl;
71 const bool hasSeedBeenRetrieved =
72 exportValue<RandomSeed_T> (lRandomSeed,
"random.seed");
73 if (hasSeedBeenRetrieved ==
true) {
74 oStr <<
" Random Seed: " << lRandomSeed << std::endl;
79 const bool hasDemandGenMethodBeenRetrieved =
80 exportValue<char> (lChar,
"demand generation.method");
81 if (hasDemandGenMethodBeenRetrieved ==
true) {
82 oStr <<
" Demand Generation method: " << lChar << std::endl;
87 const bool hasNumberOfRunsBeenRetrieved =
88 exportValue<Count_T> (lTotalNumberOfRuns,
"runs.number");
89 if (hasNumberOfRunsBeenRetrieved ==
true) {
90 oStr <<
" Number Of Runs: " << lTotalNumberOfRuns << std::endl;
95 const bool hasScheduleFileBeenRetrieved =
96 exportValue<stdair::Filename_T> (lFilename,
"input.schedule");
97 if (hasScheduleFileBeenRetrieved ==
true) {
98 oStr <<
" Schedule input file: " << lFilename << std::endl;
100 const bool hasODFileBeenRetrieved =
101 exportValue<stdair::Filename_T> (lFilename,
"input.ond");
102 if (hasODFileBeenRetrieved ==
true) {
103 oStr <<
" OnD input file: " << lFilename << std::endl;
105 const bool hasFrat5FileBeenRetrieved =
106 exportValue<stdair::Filename_T> (lFilename,
"input.frat5");
107 if (hasFrat5FileBeenRetrieved ==
true) {
108 oStr <<
" Frat5 input file: " << lFilename << std::endl;
110 const bool hasFFdisutilityFileBeenRetrieved =
111 exportValue<stdair::Filename_T> (lFilename,
"input.ffdisutility");
112 if (hasFFdisutilityFileBeenRetrieved ==
true) {
113 oStr <<
" FFdisutility input file: " << lFilename << std::endl;
115 const bool hasYieldFileBeenRetrieved =
116 exportValue<stdair::Filename_T> (lFilename,
"input.yield");
117 if (hasYieldFileBeenRetrieved ==
true) {
118 oStr <<
" Yield input file: " << lFilename << std::endl;
120 const bool hasFareFileBeenRetrieved =
121 exportValue<stdair::Filename_T> (lFilename,
"input.fare");
122 if (hasFareFileBeenRetrieved ==
true) {
123 oStr <<
" Fare input file: " << lFilename << std::endl;
125 const bool hasDemandFileBeenRetrieved =
126 exportValue<stdair::Filename_T> (lFilename,
"input.demand");
127 if (hasDemandFileBeenRetrieved ==
true) {
128 oStr <<
" Demand input file: " << lFilename << std::endl;
136 std::ostringstream oStr;
137 #if BOOST_VERSION_MACRO >= 104100
139 write_json (oStr, _pt);
148 std::string lEmptyPath (
"");
149 add (iConfigPropertyTree, lEmptyPath);
154 const std::string& iPath) {
157 bool isThereAnyChild =
false;
159 #if BOOST_VERSION_MACRO >= 104100
162 BOOST_FOREACH(boost::property_tree::ptree::value_type itChild, iConfigPropertyTree) {
164 isThereAnyChild =
true;
167 std::ostringstream lCurrentPathStr;
168 const bool isPathEmptyForNow = iPath.empty();
169 if (isPathEmptyForNow ==
false) {
170 lCurrentPathStr << iPath <<
".";
173 lCurrentPathStr << itChild.first.data();
174 const std::string lCurrentPath (lCurrentPathStr.str());
177 const bpt::ptree& lChildTree = itChild.second;
178 add(lChildTree, lCurrentPath);
183 if (isThereAnyChild ==
false) {
184 std::string lValue (iConfigPropertyTree.data());
185 const bool hasInsertionBeenSuccessful =
addValue (lValue, iPath);
186 assert (hasInsertionBeenSuccessful ==
true);
193 const std::string& iPath) {
194 bool hasInsertionBeenSuccessful =
true;
197 #if BOOST_VERSION_MACRO >= 104100
201 const std::string lPrefix (
"config");
202 std::string lFinalPath;
203 found = iPath.find(lPrefix);
204 if (found == std::string::npos) {
205 lFinalPath += lPrefix;
209 if (lFinalPath != lPrefix) {
210 _pt.put (lFinalPath, iValue);
212 }
catch (bpt::ptree_bad_data& bptException) {
213 hasInsertionBeenSuccessful =
false;
217 return hasInsertionBeenSuccessful;
223 #if BOOST_VERSION_MACRO >= 104100
227 BOOST_FOREACH(boost::property_tree::ptree::value_type itChild, _pt) {
228 std::ostringstream lPathStr;
229 lPathStr << itChild.first.data() <<
".airline_code";
230 const bool hasAirlineCodeBeenRetrieved =
231 exportValue<AirlineCode_T> (lAirlineCode , lPathStr.str());
232 if (hasAirlineCodeBeenRetrieved ==
true) {
235 if (lAirlineFeature_ptr != NULL) {
239 std::ostringstream lPathStr;
243 lPathStr << itChild.first.data() <<
".forecasting_method";
244 const bool hasForecastingMethodBeenRetrieved =
245 exportValue<char> (lChar, lPathStr.str());
246 if (hasForecastingMethodBeenRetrieved ==
true) {
253 lPathStr << itChild.first.data() <<
".unconstraining_method";
254 const bool hasUnconstrainingMethodBeenRetrieved =
255 exportValue<char> (lChar, lPathStr.str());
256 if (hasUnconstrainingMethodBeenRetrieved ==
true) {
263 lPathStr << itChild.first.data() <<
".partnership_technique";
264 const bool hasPartnershipTechniqueBeenRetrieved =
265 exportValue<char> (lChar, lPathStr.str());
266 if (hasPartnershipTechniqueBeenRetrieved ==
true) {
273 lPathStr << itChild.first.data() <<
".pre_optimisation_method";
274 const bool hasPreOptMethodBeenRetrieved =
275 exportValue<char> (lChar, lPathStr.str());
276 if (hasPreOptMethodBeenRetrieved ==
true) {
283 lPathStr << itChild.first.data() <<
".optimisation_method";
284 const bool hasOptMethodBeenRetrieved =
285 exportValue<char> (lChar, lPathStr.str());
286 if (hasOptMethodBeenRetrieved ==
true) {
292 std::ostringstream oMessage;
293 oMessage <<
"Wrong input features for the airline '"
294 << lAirlineCode <<
"' in the input configuration file: "
295 << lCodeConversionException.
what();
#define STDAIR_LOG_ERROR(iToBeLogged)
Handle on the StdAir library context.
boost::gregorian::date Date_T
unsigned long int RandomSeed_T
std::string AirlineCode_T
Enumeration of partnership techniques.
Class representing various configuration parameters (e.g., revenue management methods such EMSRb or M...
void setForecastingMethod(const ForecastingMethod &iForecastingMethod)
void setOptimisationMethod(const OptimisationMethod &iOptimisationMethod)
void setPartnershipTechnique(const PartnershipTechnique &iPartnershipTechnique)
void setPreOptimisationMethod(const PreOptimisationMethod &iPreOptimisationMethod)
void setUnconstrainingMethod(const UnconstrainingMethod &iUnconstrainingMethod)
static AirlineFeature * retrieveAirlineFeatureFromKey(const BomRoot &, const AirlineCode_T &)
Class representing the actual attributes for the Bom root.
const std::string describe() const
void add(const bpt::ptree &)
bool addValue(const std::string &iValue, const std::string &iPath)
const std::string jsonExport() const
void updateAirlineFeatures(BomRoot &)
void toStream(std::ostream &ioOut) const
void fromStream(std::istream &ioIn)
const char * what() const