comparison Applications/Commands/ICommand.h @ 307:be2660b6e40a am-callable-and-promise

wip: commands + status update
author am@osimis.io
date Tue, 25 Sep 2018 15:14:53 +0200
parents b04b13810540
children daa04d15192c
comparison
equal deleted inserted replaced
304:6c22e0506587 307:be2660b6e40a
28 namespace OrthancStone 28 namespace OrthancStone
29 { 29 {
30 class ICommand // TODO noncopyable 30 class ICommand // TODO noncopyable
31 { 31 {
32 protected: 32 protected:
33 const char* name_; 33 std::string name_;
34 ICommand(const char* name) 34 ICommand(const std::string& name)
35 : name_(name) 35 : name_(name)
36 {} 36 {}
37 public: 37 public:
38 virtual void Execute() = 0; 38 virtual void Execute() = 0;
39 virtual void Configure(const Json::Value& arguments) = 0; 39 // virtual void Configure(const Json::Value& arguments) = 0;
40 const char* GetName() 40 const std::string& GetName() const
41 { 41 {
42 return name_; 42 return name_;
43 } 43 }
44 }; 44 };
45 45
46 46
47 template <typename TCommand> 47 template <typename TCommand>
48 class BaseCommand : ICommand 48 class BaseCommand : public ICommand
49 { 49 {
50 protected: 50 protected:
51 BaseCommand(const char* name) 51 BaseCommand(const std::string& name)
52 : ICommand(name) 52 : ICommand(name)
53 {} 53 {}
54 54
55 public: 55 public:
56 static ICommand* Create() { 56 static ICommand* Create() {
68 : BaseCommand("noop") 68 : BaseCommand("noop")
69 {} 69 {}
70 virtual void Execute() {} 70 virtual void Execute() {}
71 }; 71 };
72 72
73 class SimpleCommand : public BaseCommand<SimpleCommand>
74 {
75 public:
76 SimpleCommand(const std::string& name)
77 : BaseCommand(name)
78 {}
79 virtual void Execute() {} // TODO currently not used but this is not nice at all !
80 };
73 81
74 } 82 }