OpenASIP  2.0
Model.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file Model.hh
26  *
27  * Declaration of Model class.
28  *
29  * @author Tommi Rantanen 2003 (tommi.rantanen-no.spam-tut.fi)
30  */
31 
32 #ifndef TTA_MODEL_HH
33 #define TTA_MODEL_HH
34 
35 #include <vector>
36 #include <string>
37 #include <deque>
38 #include "Exception.hh"
39 
40 class wxDocument;
41 class ModelObserver;
42 
43 namespace TTAMachine {
44  class Machine;
45 }
46 
47 /**
48  * An interface for modifying the Machine Object Model.
49  */
50 class Model {
51 public:
52  Model();
53  Model(const std::string& fileName);
54  ~Model();
55 
57  void undo();
58  void redo();
59  bool canUndo();
60  bool canRedo();
61  void addObserver(ModelObserver* observer);
62  void notifyObservers(bool modified = true);
63  void pushToStack();
64  void popFromStack(bool modified = false);
65  void setNotModified() { modified_ = false; }
66  bool isModified() const { return modified_; }
67 private:
68 
69  /// Maximum undo stack size.
70  static const unsigned int UNDO_STACK_MAX_SIZE;
71 
72  /// Machine assigned for this Model. Singleton within a Model.
74 
75  /// Table of model observers.
76  typedef std::vector<ModelObserver*> ObserverTable;
77 
78  /// Model observers.
80 
81  /// Copying not allowed.
82  Model(const Model&);
83  /// Assignment not allowed.
84  Model& operator=(const Model&);
85 
86  /// Maximum size of the undo stack.
87  unsigned undoStackSize_;
88  /// Machine stack for undo functionality.
89  typedef std::deque<TTAMachine::Machine*> UndoStack;
91  /// Undone modification cache for the redo funciton.
93 
94  bool modified_;
95 };
96 
97 #endif
Model::undo
void undo()
Definition: Model.cc:97
Model::undone_
TTAMachine::Machine * undone_
Undone modification cache for the redo funciton.
Definition: Model.hh:92
Exception.hh
Model::UNDO_STACK_MAX_SIZE
static const unsigned int UNDO_STACK_MAX_SIZE
Maximum undo stack size.
Definition: Model.hh:70
Model::canUndo
bool canUndo()
Definition: Model.cc:213
Model::UndoStack
std::deque< TTAMachine::Machine * > UndoStack
Machine stack for undo functionality.
Definition: Model.hh:89
Model::observers_
ObserverTable observers_
Model observers.
Definition: Model.hh:79
Model::pushToStack
void pushToStack()
Definition: Model.cc:167
Model::Model
Model()
Definition: Model.cc:53
Model::notifyObservers
void notifyObservers(bool modified=true)
Definition: Model.cc:152
Model::setNotModified
void setNotModified()
Definition: Model.hh:65
Model::~Model
~Model()
Definition: Model.cc:60
Model::addObserver
void addObserver(ModelObserver *observer)
Definition: Model.cc:143
Model::modified_
bool modified_
Definition: Model.hh:94
Model::canRedo
bool canRedo()
Definition: Model.cc:228
Model::popFromStack
void popFromStack(bool modified=false)
Definition: Model.cc:195
Model::operator=
Model & operator=(const Model &)
Assignment not allowed.
Model::machine_
TTAMachine::Machine * machine_
Machine assigned for this Model. Singleton within a Model.
Definition: Model.hh:73
Model::undoStack_
UndoStack undoStack_
Definition: Model.hh:90
Model
Definition: Model.hh:50
ModelObserver
Definition: ModelObserver.hh:38
Model::undoStackSize_
unsigned undoStackSize_
Maximum size of the undo stack.
Definition: Model.hh:87
TTAMachine
Definition: Assembler.hh:48
Model::isModified
bool isModified() const
Definition: Model.hh:66
Model::redo
void redo()
Definition: Model.cc:118
Model::getMachine
TTAMachine::Machine * getMachine()
Definition: Model.cc:88
TTAMachine::Machine
Definition: Machine.hh:73
Model::ObserverTable
std::vector< ModelObserver * > ObserverTable
Table of model observers.
Definition: Model.hh:76