OpenASIP 2.2
Loading...
Searching...
No Matches
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
40class wxDocument;
41class ModelObserver;
42
43namespace TTAMachine {
44 class Machine;
45}
46
47/**
48 * An interface for modifying the Machine Object Model.
49 */
50class Model {
51public:
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_; }
67private:
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.
85
86 /// Maximum size of the undo stack.
88 /// Machine stack for undo functionality.
89 typedef std::deque<TTAMachine::Machine*> UndoStack;
91 /// Undone modification cache for the redo funciton.
93
95};
96
97#endif
Definition Model.hh:50
Model(const Model &)
Copying not allowed.
void addObserver(ModelObserver *observer)
Definition Model.cc:143
bool isModified() const
Definition Model.hh:66
bool modified_
Definition Model.hh:94
std::vector< ModelObserver * > ObserverTable
Table of model observers.
Definition Model.hh:76
void pushToStack()
Definition Model.cc:167
void notifyObservers(bool modified=true)
Definition Model.cc:152
static const unsigned int UNDO_STACK_MAX_SIZE
Maximum undo stack size.
Definition Model.hh:70
void undo()
Definition Model.cc:97
TTAMachine::Machine * machine_
Machine assigned for this Model. Singleton within a Model.
Definition Model.hh:73
unsigned undoStackSize_
Maximum size of the undo stack.
Definition Model.hh:87
void setNotModified()
Definition Model.hh:65
void redo()
Definition Model.cc:118
UndoStack undoStack_
Definition Model.hh:90
bool canUndo()
Definition Model.cc:213
bool canRedo()
Definition Model.cc:228
std::deque< TTAMachine::Machine * > UndoStack
Machine stack for undo functionality.
Definition Model.hh:89
Model & operator=(const Model &)
Assignment not allowed.
ObserverTable observers_
Model observers.
Definition Model.hh:79
void popFromStack(bool modified=false)
Definition Model.cc:195
TTAMachine::Machine * getMachine()
Definition Model.cc:88
~Model()
Definition Model.cc:60
Model()
Definition Model.cc:53
TTAMachine::Machine * undone_
Undone modification cache for the redo funciton.
Definition Model.hh:92