-
Notifications
You must be signed in to change notification settings - Fork 0
/
SelectOutputNameOption.cpp
44 lines (38 loc) · 1.43 KB
/
SelectOutputNameOption.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "SelectOutputNameOption.h"
SelectOutputNameOption::SelectOutputNameOption(const std::string& name, std::shared_ptr<Communicator> communicator) :
Option(name, communicator)
{
outputName = nullptr;
}
void SelectOutputNameOption::connectNotifiers(std::shared_ptr<OneArgNotifier<std::string>> formatChangedNotifier, std::shared_ptr<OneArgNotifier<std::string>> outputNameChangedNotifier)
{
formatChangedNotifier->notified += [this](auto format) {this->onFormatChanged(); };
outputNameChangedNotifier->notified += [this](auto name) {this->onOutputNameChanged(name); };
this->outputNameChangedNotifier = outputNameChangedNotifier;
}
void SelectOutputNameOption::execute()
{
displayText("Give output image name.");
std::string imageName = handleInput();
auto outputName = std::shared_ptr<std::string>(new std::string(imageName));
outputNameChangedNotifier->notifyListeners(outputName);
}
std::string SelectOutputNameOption::getDescription()
{
if (outputName != nullptr)
{
return "Select output image name, current name: " + *outputName;
}
else
{
return "Select output image name, current name: undefined";
}
}
void SelectOutputNameOption::onFormatChanged(std::shared_ptr<std::string> newFormat)
{
outputNameChangedNotifier->notifyListeners(nullptr);
}
void SelectOutputNameOption::onOutputNameChanged(std::shared_ptr<std::string> newOutputName)
{
outputName = newOutputName;
}