BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
Command.h
1 #pragma once
2 
3 #include <string>
4 
5 #include <Poco/AutoPtr.h>
6 #include <Poco/RefCountedObject.h>
7 #include <Poco/SharedPtr.h>
8 
9 #include "core/Answer.h"
10 #include "core/Result.h"
11 #include "util/Castable.h"
12 
13 namespace BeeeOn {
14 
15 class CommandDispatcher;
16 class CommandHandler;
17 class CommandSender;
18 
19 /*
20  * Abstract class for Commands, which will be sent within the gates.
21  *
22  * All Command objects should have a protected destructor,
23  * to forbid explicit use of delete.
24  */
25 class Command : public Poco::RefCountedObject, public Castable {
26  // This way, we are hiding setSendingHandler() from the outer world.
27  friend CommandDispatcher;
28  friend CommandSender;
29 public:
30  typedef Poco::AutoPtr<Command> Ptr;
31 
32  Command();
33 
34  std::string name() const;
35 
42 
46  virtual std::string toString() const;
47 
57  virtual Result::Ptr deriveResult(Answer::Ptr answer) const;
58 
59 protected:
60  void setSendingHandler(CommandHandler *sender);
61 
62  virtual ~Command();
63 
64 protected:
65  CommandHandler *m_sendingHandler;
66 };
67 
68 }
virtual Result::Ptr deriveResult(Answer::Ptr answer) const
Definition: Command.cpp:37
Definition: Command.h:25
Definition: CommandHandler.h:18
Definition: Castable.h:7
Definition: CommandSender.h:20
Definition: CommandDispatcher.h:12
CommandHandler * sendingHandler() const
Definition: Command.cpp:27
virtual std::string toString() const
Definition: Command.cpp:32