Main Page
Modules
Namespaces
Classes
Files
File List
File Members
Observable.h
Go to the documentation of this file.
1
/* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2
3
This file is part of the TerraLib - a Framework for building GIS enabled applications.
4
5
TerraLib is free software: you can redistribute it and/or modify
6
it under the terms of the GNU Lesser General Public License as published by
7
the Free Software Foundation, either version 3 of the License,
8
or (at your option) any later version.
9
10
TerraLib is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU Lesser General Public License for more details.
14
15
You should have received a copy of the GNU Lesser General Public License
16
along with TerraLib. See COPYING. If not, write to
17
TerraLib Team at <terralib-team@terralib.org>.
18
*/
19
20
/*!
21
\file Observable.h
22
23
\brief Abstract class to represent an observable. "Model" part of MVC component.
24
25
\ingroup layout
26
*/
27
28
#ifndef __TERRALIB_LAYOUT_INTERNAL_OBSERVABLE_H
29
#define __TERRALIB_LAYOUT_INTERNAL_OBSERVABLE_H
30
31
// TerraLib
32
#include "../../ContextItem.h"
33
#include "../../../../geometry/Envelope.h"
34
#include "../../../../geometry/Coord2D.h"
35
#include "../../../../color/RGBAColor.h"
36
#include "../../enum/AbstractType.h"
37
#include "../../Utils.h"
38
#include "../../enum/EnumType.h"
39
#include "../../Config.h"
40
41
// STL
42
#include <vector>
43
44
namespace
te
45
{
46
namespace
layout
47
{
48
class
Observer;
49
class
Properties;
50
51
/*!
52
\brief Abstract class to represent an observable. "Model" part of MVC component.
53
54
\ingroup layout
55
*/
56
class
TELAYOUTEXPORT
Observable
57
{
58
public
:
59
60
/*!
61
\brief Destructor
62
*/
63
virtual
~Observable
(
void
) {}
64
65
/*!
66
\brief Adds the specified observer to the set of observers for this object.
67
Reimplement this function in a Observable subclass to provide the model's addObserver implementation.
68
69
\param o specified observer
70
\return true if add, false otherwise
71
*/
72
virtual
bool
addObserver(
Observer
* o) = 0;
73
74
/*!
75
\brief Removes an observer from the set of observers of this object.
76
Reimplement this function in a Observable subclass to provide the model's removeObserver implementation.
77
78
\param o specified observer
79
\return true if remove, false otherwise
80
*/
81
virtual
bool
removeObserver(
Observer
* o) = 0;
82
83
/*!
84
\brief Returns the model state as properties.
85
Reimplement this function in a Observable subclass to provide the model's getProperties implementation.
86
87
\return properties
88
*/
89
virtual
te::layout::Properties
* getProperties()
const
= 0;
90
91
/*!
92
\brief Updated model state with properties.
93
Reimplement this function in a Observable subclass to provide the model's updateProperties implementation.
94
95
\param properties
96
*/
97
virtual
void
updateProperties(
te::layout::Properties
* properties) = 0;
98
99
/*!
100
\brief Returns the model state just the public properties.
101
Reimplement this function in a Observable subclass to provide the model's getProperties implementation.
102
103
\return properties
104
*/
105
virtual
te::layout::Properties
* getPublicProperties()
const
= 0;
106
107
/*!
108
\brief Returns the bounding rectangle of the component in scene coordinates(millimeters).
109
Starting point is llx, lly.
110
Reimplement this function in a Observable subclass to provide the model's getBox implementation.
111
112
\return bounding rectangle of the component
113
*/
114
virtual
te::gm::Envelope
getBox() = 0;
115
116
/*!
117
\brief Returns the type of component
118
Reimplement this function in a Observable subclass to provide the model's getType implementation.
119
120
\return Type of component
121
*/
122
virtual
EnumType
* getType() = 0;
123
124
/*!
125
\brief Change the type of component.
126
Reimplement this function in a Observable subclass to provide the model's setType implementation.
127
128
\param type Type of component
129
*/
130
virtual
void
setType(
EnumType
* type) = 0;
131
132
/*!
133
\brief Return the Z value.
134
Reimplement this function in a Observable subclass to provide the model's getZValue implementation.
135
136
\return Z value
137
*/
138
virtual
int
getZValue() = 0;
139
140
/*!
141
\brief The Z value decides the stacking order of drawing.
142
Reimplement this function in a Observable subclass to provide the model's addObserver implementation.
143
144
\param Z Value
145
*/
146
virtual
void
setZValue(
int
zValue) = 0;
147
148
/*!
149
\brief Method that returns the name of the MVC component.
150
Reimplement this function in a Observable subclass to provide the model's getName implementation.
151
152
\return name
153
*/
154
virtual
std::string getName() = 0;
155
156
/*!
157
\brief Returns the id of a MVC component. Id is calculated as the number of components of the same type already created.
158
The Id to be created is the amount at the time + 1. This number is used to create the object name.
159
Reimplement this function in a Observable subclass to provide the model's getId implementation.
160
161
\return hashCode
162
*/
163
virtual
int
getId() = 0;
164
165
/*!
166
\brief Change the id of a MVC component. Id is calculated as the number of components of the same type already created.
167
The Id to be created is the amount at the time + 1. This number is used to create the object name.
168
Reimplement this function in a Observable subclass to provide the model's setId implementation.
169
170
\param id hashCode
171
*/
172
virtual
void
setId(
int
id
) = 0;
173
174
/*!
175
\brief Returns the hashcode of a MVC component.
176
Reimplement this function in a Observable subclass to provide the model's getHashCode implementation.
177
178
\return hashCode
179
*/
180
virtual
int
getHashCode() = 0;
181
182
/*!
183
\brief Change the component state for resizable or not
184
Reimplement this function in a Observable subclass to provide the model's setResizable implementation.
185
186
\param resize true if resizable, false otherwise
187
*/
188
virtual
void
setResizable(
bool
resize) = 0;
189
190
/*!
191
\brief Returns whether or not the component is resizable.
192
Reimplement this function in a Observable subclass to provide the model's isResizable implementation.
193
194
\return true if resizable, false otherwise
195
*/
196
virtual
bool
isResizable() = 0;
197
198
protected
:
199
200
/*!
201
\brief Notifies all set of observers that the state of model changed
202
Reimplement this function in a Observable subclass to provide the model's notifyAll implementation.
203
204
\param context maintaining the drawing context of a MVC component.
205
*/
206
virtual
void
notifyAll(
ContextItem
context) = 0;
207
208
/*!
209
\brief Returns a new hashcode.
210
211
\return hashCode
212
*/
213
virtual
int
calculateHashCode() = 0;
214
};
215
}
216
}
217
218
#endif
te::layout::Observable
Abstract class to represent an observable. "Model" part of MVC component.
Definition:
Observable.h:56
te::layout::ContextItem
Class responsible for maintaining the drawing context of a MVC component. It is always used by the "M...
Definition:
ContextItem.h:49
TELAYOUTEXPORT
#define TELAYOUTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition:
Config.h:96
te::layout::Properties
The Properties class represents a persistent set of properties. The Properties can be saved to a file...
Definition:
Properties.h:52
te::layout::Observer
Abstract class to represent an observer. "View" part of MVC component.
Definition:
Observer.h:48
te::gm::Envelope
An Envelope defines a 2D rectangular region.
Definition:
Envelope.h:51
te
URI C++ Library.
Definition:
AddressGeocodingOp.h:51
te::layout::EnumType
Class that represents the value of an enumeration. An enumeration is made of "1..n" objects EnumType...
Definition:
EnumType.h:48
te::layout::Observable::~Observable
virtual ~Observable(void)
Destructor.
Definition:
Observable.h:63
git_master
terralib5
src
terralib
layout
core
pattern
mvc
Observable.h
Generated on Tue Jan 12 2016 08:40:55 for TerraLib by
1.8.9.1