diff options
Diffstat (limited to 'LoadFilesCommand.cpp')
-rw-r--r-- | LoadFilesCommand.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/LoadFilesCommand.cpp b/LoadFilesCommand.cpp index ae9f30a..82ede60 100644 --- a/LoadFilesCommand.cpp +++ b/LoadFilesCommand.cpp @@ -11,26 +11,22 @@ using namespace std; -void LoadFilesCommand::execute(int argc, char ** argv) { +LoadFilesCommand::LoadFilesCommand(Museum & m, int argc, char ** argv) : museum(m) { vector<string> files = {}; for (size_t i = 0; i < argc; i++) { files.push_back(string(argv[i])); } - return this->execute(files); + this->files = files; } -void LoadFilesCommand::execute(vector<string> files) { - try { - this->load_files(files); - } catch (Exception & e) { - throw Exception("LoadFilesCommand error: %s", e.what()); - } +LoadFilesCommand::LoadFilesCommand(Museum & m, vector<string> files) : museum(m) { + this->files = files; } -void LoadFilesCommand::load_files(vector<string> files) { - ToggleMuseumPauseCommand(this).set(true); +void LoadFilesCommand::load_files() { + ToggleMuseumPauseCommand(this->museum, true).execute(); - MuseumDeserializer deserializer { this->get_museum() }; + MuseumDeserializer deserializer { this->museum }; for (string url : files) { unique_ptr<FileReader> file = FileReaderFactory::open(url); try { @@ -41,3 +37,11 @@ void LoadFilesCommand::load_files(vector<string> files) { } } +void LoadFilesCommand::execute() { + try { + this->load_files(); + } catch (Exception & e) { + throw Exception("LoadFilesCommand error: %s", e.what()); + } +} + |