2021-05-08 03:36:26 +02:00
|
|
|
#include "controller.h"
|
|
|
|
#include "policy.h"
|
2021-05-16 01:44:19 +02:00
|
|
|
#include "modificator.h"
|
2021-05-08 03:36:26 +02:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
Controller::Controller(Initializer&& initializer) :
|
|
|
|
_keywords(initializer.keywords),
|
2021-05-16 01:44:19 +02:00
|
|
|
_interaction_message(initializer.message),
|
|
|
|
_validator(nullptr)
|
2021-05-08 03:36:26 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
Controller::~Controller()
|
|
|
|
{}
|
|
|
|
|
|
|
|
bool Controller::validateInput(const std::string &input_word) const
|
|
|
|
{
|
|
|
|
return std::find(_keywords.begin(), _keywords.end(), input_word) != _keywords.end();
|
|
|
|
}
|
|
|
|
|
2021-05-16 01:44:19 +02:00
|
|
|
void Controller::runModificators() const
|
2021-05-08 03:36:26 +02:00
|
|
|
{
|
2021-05-16 01:44:19 +02:00
|
|
|
for (const auto& modificator : _modificators)
|
|
|
|
modificator->run();
|
2021-05-08 03:36:26 +02:00
|
|
|
}
|
|
|
|
|
2021-05-16 01:44:19 +02:00
|
|
|
void Controller::setValidator(const std::shared_ptr<Validator>& validator)
|
2021-05-08 03:36:26 +02:00
|
|
|
{
|
2021-05-16 01:44:19 +02:00
|
|
|
_validator = validator;
|
|
|
|
}
|
2021-05-08 03:36:26 +02:00
|
|
|
|
2021-05-16 01:44:19 +02:00
|
|
|
void Controller::setModificators(const std::list<std::shared_ptr<Modificator>>& modificators)
|
|
|
|
{
|
|
|
|
_modificators = modificators;
|
2021-05-08 03:36:26 +02:00
|
|
|
}
|