Command.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00024 #ifndef _APPBASE_COMMAND_H
00025 #define _APPBASE_COMMAND_H
00026 
00027 #include <string>
00028 
00029 
00030 namespace AppBase {
00031     
00032 
00037 template <class StringType = std::string>
00038 class Command
00039 {
00040     
00041     public:
00042         //
00043         Command()
00044             : m_successful(false)
00045         {};
00046         
00048         Command(const StringType& commandName)
00049             : m_name(commandName), m_successful(false)
00050         {};
00051 
00053         virtual ~Command() {};
00054 
00055         
00056     public:
00061         virtual void execute() = 0;
00062         
00068         virtual void undo() = 0;
00069         
00074         virtual void redo()
00075             { execute(); };
00076         
00077         
00078     public:
00080         virtual StringType getName() const 
00081             { return m_name; }
00082         
00084         virtual void setName(const StringType& newName)
00085             { m_name = newName; }
00086         
00087         
00088     public:
00090         virtual bool wasSuccessful()
00091             { return m_successful;}
00092         
00093     protected:
00095         virtual void setSuccessful(bool success = true)
00096             { m_successful = success; }
00097         
00098         
00099     private:
00100         bool m_successful;
00101         StringType m_name;
00102 };
00103 
00104 
00105 } //namespace
00106 
00107 typedef AppBase::Command<> Command;
00108 
00109 #endif // _H

Generated on 23 Oct 2014 for Hugintrunk by  doxygen 1.4.7