Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Command.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
24 #include "Command.h"
25 
26 namespace PanoCommand
27 {
28 
29 PanoCommand::~PanoCommand()
30 {
31  if (m_memento != NULL)
32  {
33  delete m_memento;
34  };
35  if (m_redoMemento != NULL)
36  {
37  delete m_redoMemento;
38  };
39 }
40 
41 void PanoCommand::execute()
42 {
43  saveMemento();
44  bool success = processPanorama(m_pano);
45  setSuccessful(success);
46  if (success)
47  {
48  // notify all observers about changes
50  if (m_clearDirty)
51  {
53  };
54  }
55  else
56  {
57  // [TODO] warning!
59  };
60 }
61 
62 void PanoCommand::undo()
63 {
64  DEBUG_ASSERT(m_memento != NULL);
68 }
69 
70 void PanoCommand::redo()
71 {
72  if (m_redoMemento == NULL)
73  {
74  execute();
75  }
76  else
77  {
80  };
81 }
82 
83 std::string PanoCommand::getName() const
84 {
85  return m_name;
86 }
87 
88 void PanoCommand::setName(const std::string& newName)
89 {
90  m_name = newName;
91 }
92 
93 bool PanoCommand::wasSuccessful() const
94 {
95  return m_successful;
96 }
97 
98 void PanoCommand::setSuccessful(bool success)
99 {
100  m_successful = success;
101 }
102 
103 void PanoCommand::saveMemento()
104 {
105  if (m_memento != NULL)
106  {
107  delete m_memento;
108  };
110 };
111 
112 void PanoCommand::saveRedoMemento()
113 {
114  if (m_redoMemento != NULL)
115  {
116  delete m_redoMemento;
117  };
119 }
120 
121 bool PanoCommand::processPanorama(HuginBase::Panorama& panoramaData)
122 {
123  return true;
124 }
125 
126 } // namespace
HuginBase::PanoramaDataMemento * m_redoMemento
Definition: Command.h:97
Base class for all panorama commands.
Definition: Command.h:38
virtual void setSuccessful(bool success=true)
Definition: Command.cpp:98
virtual void saveMemento()
saves the state for undo
Definition: Command.cpp:103
HuginBase::Panorama & m_pano
internal variables
Definition: Command.h:95
HuginBase::PanoramaDataMemento * m_memento
Definition: Command.h:96
#define DEBUG_ASSERT(cond)
Definition: utils.h:80
virtual bool setMementoToCopyOf(const PanoramaDataMemento *const memento)
set the internal state
Definition: Panorama.cpp:1484
virtual void clearDirty()
clear dirty flag.
Definition: Panorama.h:645
Model for a panorama.
Definition: Panorama.h:152
std::string m_name
Definition: Command.h:103
virtual PanoramaDataMemento * getNewMemento() const
get the internal state
Definition: Panorama.cpp:1526
virtual void execute()
execute the command.
Definition: Command.cpp:41
virtual bool processPanorama(HuginBase::Panorama &pano)
Called by execute().
Definition: Command.cpp:121
void changeFinished(bool keepDirty)
notify observers about changes in this class
Definition: Panorama.cpp:831
virtual void saveRedoMemento()
saves the state for redo
Definition: Command.cpp:112