Mercurial > hg > orthanc-stone
view Applications/Commands/ICommand.h @ 309:14ef1227120f am-callable-and-promise
web services: better handling of failures
author | am@osimis.io |
---|---|
date | Fri, 28 Sep 2018 15:02:43 +0200 |
parents | be2660b6e40a |
children | daa04d15192c |
line wrap: on
line source
/** * Stone of Orthanc * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics * Department, University Hospital of Liege, Belgium * Copyright (C) 2017-2018 Osimis S.A., Belgium * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ #pragma once #include <json/json.h> // TODO: must be reworked completely (check trello) namespace OrthancStone { class ICommand // TODO noncopyable { protected: std::string name_; ICommand(const std::string& name) : name_(name) {} public: virtual void Execute() = 0; // virtual void Configure(const Json::Value& arguments) = 0; const std::string& GetName() const { return name_; } }; template <typename TCommand> class BaseCommand : public ICommand { protected: BaseCommand(const std::string& name) : ICommand(name) {} public: static ICommand* Create() { return new TCommand(); } virtual void Configure(const Json::Value& arguments) { } }; class NoopCommand : public BaseCommand<NoopCommand> { public: NoopCommand() : BaseCommand("noop") {} virtual void Execute() {} }; class SimpleCommand : public BaseCommand<SimpleCommand> { public: SimpleCommand(const std::string& name) : BaseCommand(name) {} virtual void Execute() {} // TODO currently not used but this is not nice at all ! }; }