| 
									
										
										
										
											2017-04-22 12:07:11 +00:00
										 |  |  | #include "Conf.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 19:14:45 +00:00
										 |  |  | class CONF_PLANPATH_INVALID: public std::runtime_error | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     CONF_PLANPATH_INVALID(): std::runtime_error("conf: The supplied path for the plan definition file is invalid.") {} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class CONF_UNITSPATH_INVALID: public std::runtime_error | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     CONF_UNITSPATH_INVALID(): std::runtime_error("conf: The supplied path for the unit definition file is invalid.") {} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-09 04:41:06 +00:00
										 |  |  | Conf::Conf( std::string filename ): JSON_Loader() | 
					
						
							| 
									
										
										
										
											2017-04-22 12:07:11 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-06-11 19:14:45 +00:00
										 |  |  |     // load the conf file.
 | 
					
						
							| 
									
										
										
										
											2017-06-09 04:41:06 +00:00
										 |  |  |     this->load_json_file( filename, true ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 19:14:45 +00:00
										 |  |  |     // find the path to the plan file
 | 
					
						
							| 
									
										
										
										
											2017-06-18 14:39:46 +00:00
										 |  |  |     if (this->get_serialized(this->plan_path, "plan_path", true) != 0 ) { throw CONF_PLANPATH_INVALID(); } | 
					
						
							| 
									
										
										
										
											2017-06-09 04:46:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 19:14:45 +00:00
										 |  |  |     // find the path to the unit definitions file
 | 
					
						
							| 
									
										
										
										
											2017-06-18 14:39:46 +00:00
										 |  |  |     if (this->get_serialized(this->units_path, "units_path", true) != 0 ) { throw CONF_UNITSPATH_INVALID(); } | 
					
						
							| 
									
										
										
										
											2017-04-22 12:07:11 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | std::string Conf::get_plan_path() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-06-09 04:46:05 +00:00
										 |  |  |     return this->plan_path.asString(); | 
					
						
							| 
									
										
										
										
											2017-04-22 12:07:11 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | std::string Conf::get_units_path() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-06-09 04:46:05 +00:00
										 |  |  |     return this->units_path.asString(); | 
					
						
							| 
									
										
										
										
											2017-04-22 12:07:11 +00:00
										 |  |  | } |