Commit 0011e562 authored by Aaron Bray's avatar Aaron Bray
Browse files

Dev/nested requestables bug fix

parent ac1881cc
......@@ -92,39 +92,45 @@ const SEScalar* SEEnvironment::GetScalar(const std::string& name)
return nullptr;
}
bool SEEnvironment::ProcessChange(const SEInitialEnvironmentConditions& change)
bool SEEnvironment::ProcessChange(SEInitialEnvironmentConditions& change)
{
// If we have data then we merge it, if a file was provided
// we reset and set the environment to the file, so we only have the file data
if (change.HasConditions())
GetConditions().Merge(*change.GetConditions());
GetConditions().Merge(change.GetConditions());
else if (change.HasConditionsFile())
{
if (!GetConditions().SerializeFromFile(change.GetConditionsFile(),JSON))// Does NOT merge file in data, Should we?
// Update the condition with the file contents
std::string cfg_file = change.GetConditionsFile();
if (!change.GetConditions().SerializeFromFile(cfg_file,JSON))
{
/// \error Unable to read Configuration Action file
Error("Could not read provided SEInitialEnvironment file", "SEEnvironment::ProcessChange");
return false;
}
GetConditions().Merge(change.GetConditions());
}
StateChange();
return true;
}
bool SEEnvironment::ProcessChange(const SEChangeEnvironmentConditions& change)
bool SEEnvironment::ProcessChange(SEChangeEnvironmentConditions& change)
{
// If we have data then we merge it, if a file was provided
// we reset and set the environment to the file, so we only have the file data
if (change.HasConditions())
GetConditions().Merge(*change.GetConditions());
GetConditions().Merge(change.GetConditions());
else if (change.HasConditionsFile())
{
if (!GetConditions().SerializeFromFile(change.GetConditionsFile(),JSON))// Does NOT merge file in data, Should we?
// Update the action with the file contents
std::string cfg_file = change.GetConditionsFile();
if (!change.GetConditions().SerializeFromFile(cfg_file,JSON))
{
/// \error Unable to read Configuration Action file
Error("Could not read provided SEEnvironmentChange file", "SEEnvironment::ProcessChange");
return false;
}
GetConditions().Merge(change.GetConditions());
}
StateChange();
return true;
......
......@@ -19,15 +19,16 @@ public:
virtual void Clear();
protected:
/** @name ProcessChange
* @brief - Will change this class as directed by the Action
*/
virtual bool ProcessChange(const SEChangeEnvironmentConditions& action);
virtual bool ProcessChange(SEChangeEnvironmentConditions& action);
/** @name ProcessChange
* @brief - Will change this class as directed by the Condition
*/
virtual bool ProcessChange(const SEInitialEnvironmentConditions& change);
virtual bool ProcessChange(SEInitialEnvironmentConditions& change);
/** @name StateChange
* @brief - This method is called when ever there is a state change
......
......@@ -111,13 +111,18 @@ bool SEAnesthesiaMachine::SerializeFromFile(const std::string& filename, Seriali
return PBAnesthesiaMachine::SerializeFromFile(filename, *this, m);
}
void SEAnesthesiaMachine::ProcessConfiguration(const SEAnesthesiaMachineConfiguration& config)
void SEAnesthesiaMachine::ProcessConfiguration(SEAnesthesiaMachineConfiguration& config)
{
if (config.HasConfiguration())
Merge(*config.GetConfiguration());
Merge(config.GetConfiguration());
else if (config.HasConfigurationFile())
if (!SerializeFromFile(config.GetConfigurationFile(),JSON)) // Does NOT merge file in data, Should we ?
{
// Update the action with the file contents
std::string cfg_file = config.GetConfigurationFile();
if (!config.GetConfiguration().SerializeFromFile(cfg_file, JSON))
Error("Unable to load configuration file", "SEAnesthesiaMachine::ProcessConfiguration");
Merge(config.GetConfiguration());
}
StateChange();
}
......
......@@ -53,7 +53,7 @@ protected:
*/
virtual void StateChange(){};
virtual void Merge(const SEAnesthesiaMachine& from);
virtual void ProcessConfiguration(const SEAnesthesiaMachineConfiguration& config);
virtual void ProcessConfiguration(SEAnesthesiaMachineConfiguration& config);
public:
......
......@@ -89,13 +89,18 @@ void SEInhaler::Merge(const SEInhaler& from)
}
}
void SEInhaler::ProcessConfiguration(const SEInhalerConfiguration& config)
void SEInhaler::ProcessConfiguration(SEInhalerConfiguration& config)
{
if (config.HasConfiguration())
Merge(*config.GetConfiguration());
Merge(config.GetConfiguration());
else if (config.HasConfigurationFile())
if (!SerializeFromFile(config.GetConfigurationFile(),JSON))// Does NOT merge file in data, Should we?
{
// Update the action with the file contents
std::string cfg_file = config.GetConfigurationFile();
if (!config.GetConfiguration().SerializeFromFile(cfg_file, JSON))
Error("Unable to load configuration file", "SEInhaler::ProcessConfiguration");
Merge(config.GetConfiguration());// Preserve our pointers!
}
StateChange();
}
......
......@@ -41,7 +41,7 @@ protected:
*/
virtual void StateChange(){};
virtual void Merge(const SEInhaler& from);
virtual void ProcessConfiguration(const SEInhalerConfiguration& config);
virtual void ProcessConfiguration(SEInhalerConfiguration& config);
public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment