Browse Source

renamed action to command

yaml_config_changes
Thomas Knoll 12 months ago
parent
commit
91dcfb400e
  1. 22
      util/ConfigYaml.cpp
  2. 12
      util/ConfigYaml.h

22
util/ConfigYaml.cpp

@ -11,8 +11,8 @@ std::ostream& operator << (std::ostream &os, const Formula& formula) {
return os;
}
std::ostream& operator << (std::ostream& os, const Action& action) {
os << action.action_;
std::ostream& operator << (std::ostream& os, const Command& command) {
os << command.action_;
return os;
}
@ -23,8 +23,8 @@ std::ostream& operator << (std::ostream& os, const Constant& constant) {
std::ostream& operator << (std::ostream& os, const Module& module) {
os << "Module: " << module.module_ << std::endl;
for (auto& action : module.actions_) {
os << action << std::endl;
for (auto& command : module.commands_) {
os << command << std::endl;
}
return os;
}
@ -45,7 +45,7 @@ std::string Formula::createExpression() const {
return "formula " + formula_ + " = " + content_ + Configuration::configuration_identifier_;
}
std::string Action::createExpression() const {
std::string Command::createExpression() const {
if (overwrite_) {
return action_ + "\t" + guard_ + "-> " + update_ + Configuration::overwrite_identifier_;
}
@ -65,7 +65,7 @@ YAML::Node YAML::convert<Module>::encode(const Module& rhs) {
YAML::Node node;
node.push_back(rhs.module_);
node.push_back(rhs.actions_);
node.push_back(rhs.commands_);
return node;
}
@ -74,12 +74,12 @@ bool YAML::convert<Module>::decode(const YAML::Node& node, Module& rhs) {
if (!node.Type() == NodeType::Map) {
return false;
}
rhs.actions_ = node["actions"].as<std::vector<Action>>();
rhs.commands_ = node["commands"].as<std::vector<Command>>();
rhs.module_ = node["module"].as<std::string>();
return true;
}
YAML::Node YAML::convert<Action>::encode(const Action& rhs) {
YAML::Node YAML::convert<Command>::encode(const Command& rhs) {
YAML::Node node;
node.push_back(rhs.action_);
@ -90,7 +90,7 @@ YAML::Node YAML::convert<Action>::encode(const Action& rhs) {
return node;
}
bool YAML::convert<Action>::decode(const YAML::Node& node, Action& rhs) {
bool YAML::convert<Command>::decode(const YAML::Node& node, Command& rhs) {
if (!node.Type() == NodeType::Map) {
return false;
}
@ -244,8 +244,8 @@ YamlConfigParseResult YamlConfigParser::parseConfiguration() {
configuration.push_back({formula.createExpression(), formula.formula_ ,ConfigType::Formula, formula.overwrite_});
}
for (auto& module : modules) {
for (auto& action : module.actions_) {
configuration.push_back({action.createExpression(), action.action_, ConfigType::Module, action.overwrite_, module.module_, action.index_});
for (auto& command : module.commands_) {
configuration.push_back({command.createExpression(), command.action_, ConfigType::Module, command.overwrite_, module.module_, command.index_});
}
}
for (auto& constant : constants) {

12
util/ConfigYaml.h

@ -95,7 +95,7 @@ struct Formula {
friend std::ostream& operator << (std::ostream &os, const Formula& formula);
};
struct Action {
struct Command {
public:
std::string action_;
std::string guard_;
@ -105,13 +105,13 @@ struct Action {
std::string createExpression() const;
friend std::ostream& operator << (std::ostream& os, const Action& action);
friend std::ostream& operator << (std::ostream& os, const Command& command);
};
struct Module {
public:
std::vector<Action> actions_;
std::vector<Command> commands_;
std::string module_;
friend std::ostream& operator << (std::ostream& os, const Module& module);
@ -125,9 +125,9 @@ struct YAML::convert<Module> {
};
template<>
struct YAML::convert<Action> {
static YAML::Node encode(const Action& rhs);
static bool decode(const YAML::Node& node, Action& rhs);
struct YAML::convert<Command> {
static YAML::Node encode(const Command& rhs);
static bool decode(const YAML::Node& node, Command& rhs);
};

Loading…
Cancel
Save