Cafu Engine
SetCompVar.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_SET_COMPONENT_VARIABLE_HPP_INCLUDED
8 #define CAFU_SET_COMPONENT_VARIABLE_HPP_INCLUDED
9 
10 #include "CommandPattern.hpp"
11 #include "Network/State.hpp"
12 
13 
14 class DocAdapterI;
15 namespace cf { namespace TypeSys { template<class T> class VarT; } }
16 namespace cf { namespace TypeSys { template<class T> class VarArrayT; } }
17 
18 
19 template<class T>
21 {
22  public:
23 
24  /// The constructor for setting the given variable to a new value.
25  CommandSetCompVarT(DocAdapterI& DocAdapter, cf::TypeSys::VarT<T>& Var, const T& NewValue);
26 
27  /// The constructor to be used when the variable has already been set to the new value.
28  /// With this constructor, the command is initialized in the "already done" state.
29  CommandSetCompVarT(DocAdapterI& DocAdapter, cf::TypeSys::VarT<T>& Var, const cf::Network::StateT& OldState);
30 
31  // CommandT implementation.
32  bool Do();
33  void Undo();
34  wxString GetName() const;
35 
36 
37  private:
38 
39  DocAdapterI& m_DocAdapter;
40  cf::TypeSys::VarT<T>& m_Var;
41  const cf::Network::StateT m_OldState;
42  const T m_NewValue;
43 };
44 
45 
46 template<class T>
48 {
49  public:
50 
51  /// The constructor for setting the given arry to a new set of values.
52  CommandSetCompVarArrayT(DocAdapterI& DocAdapter, cf::TypeSys::VarArrayT<T>& Var, const ArrayT<T>& NewValues);
53 
54  /// The constructor to be used when the array has already been set to the new set of values.
55  /// With this constructor, the command is initialized in the "already done" state.
57 
58  // CommandT implementation.
59  bool Do();
60  void Undo();
61  wxString GetName() const;
62 
63 
64  private:
65 
66  DocAdapterI& m_DocAdapter;
68  const cf::Network::StateT m_OldState;
69  const ArrayT<T> m_NewValues;
70 };
71 
72 #endif
This is a "wrapper" around a normal C++ variable specifically of type ArrayT<T>.
Definition: SetCompVar.hpp:16
This file provides the classes for the Command pattern as described in the book by the GoF...
void Undo()
This method un-does the command.
Definition: SetCompVar.cpp:132
Definition: SetCompVar.hpp:47
This is a "wrapper" around a normal C++ variable.
Definition: SetCompVar.hpp:15
void Undo()
This method un-does the command.
Definition: SetCompVar.cpp:66
wxString GetName() const
Returns the name (a description) of the command.
Definition: SetCompVar.cpp:84
This class holds the serialized state of another object (typically a game entity).
Definition: State.hpp:46
This class provides a common interface to the documents of the map, GUI or model editor.
Definition: DocumentAdapter.hpp:25
CommandSetCompVarArrayT(DocAdapterI &DocAdapter, cf::TypeSys::VarArrayT< T > &Var, const ArrayT< T > &NewValues)
The constructor for setting the given arry to a new set of values.
Definition: SetCompVar.cpp:95
wxString GetName() const
Returns the name (a description) of the command.
Definition: SetCompVar.cpp:149
CommandSetCompVarT(DocAdapterI &DocAdapter, cf::TypeSys::VarT< T > &Var, const T &NewValue)
The constructor for setting the given variable to a new value.
Definition: SetCompVar.cpp:31
Definition: SetCompVar.hpp:20
bool Do()
This method executes the command.
Definition: SetCompVar.cpp:52
This class represents a general command for implementing modifications to the applications document...
Definition: CommandPattern.hpp:30
bool Do()
This method executes the command.
Definition: SetCompVar.cpp:116
Definition: Renderer.hpp:16