Home
Forum
Documentation
C++
|
Lua
Issue Tracker
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
ObserverPatternTools.hpp
Go to the documentation of this file.
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
/// @file
8
/// This file provides the classes for the Observer pattern as described in the book by the GoF.
9
/// These classes are specific to the tools. See the map document related observer classes for more details.
10
#ifndef CAFU_OBSERVER_PATTERN_TOOLS_HPP_INCLUDED
11
#define CAFU_OBSERVER_PATTERN_TOOLS_HPP_INCLUDED
12
13
#include "Templates/Array.hpp"
14
15
16
class
ToolT
;
17
class
ToolsSubjectT
;
18
19
20
/// An enumeration that determines the urgency with which observers should update themselves when their subject has changed.
21
enum
ToolsUpdatePriorityT
22
{
23
UPDATE_NOW
,
///< Update immediately, in real-time, before the function returns.
24
UPDATE_SOON
///< Update as soon as convenient, at the next opportunity.
25
};
26
27
28
class
ToolsObserverT
29
{
30
public
:
31
32
/// Notifies the observer that the current subject has been changed.
33
/// @param Subject The tools (tool manager) in which something has changed.
34
/// @param Tool The specific tool that has changed.
35
/// @param Priority The priority with which the update should be implemented.
36
virtual
void
NotifySubjectChanged
(
ToolsSubjectT
* Subject,
ToolT
* Tool,
ToolsUpdatePriorityT
Priority) { }
37
38
/// The virtual destructor.
39
virtual
~ToolsObserverT
() { }
40
41
42
protected
:
43
44
/// The constructor. It is protected so that only derived classes can create instances of this class.
45
ToolsObserverT
() { }
46
};
47
48
49
class
ToolsSubjectT
50
{
51
public
:
52
53
/// Registers the observer Obs for notification on changes in this class.
54
/// @param Obs The observer that is to be registered.
55
void
RegisterObserver
(
ToolsObserverT
* Obs);
56
57
/// Unregisters the observer Obs from further notification on changes in this class.
58
/// @param Obs The observer that is to be unregistered.
59
void
UnregisterObserver
(
ToolsObserverT
* Obs);
60
61
/// Notifies all observers that something in the given tool changed so that they update themselves.
62
/// @param Tool The specific tool that has changed.
63
/// @param Priority The priority with which the update should be implemented.
64
void
UpdateAllObservers
(
ToolT
* Tool,
ToolsUpdatePriorityT
Priority);
65
66
/// The virtual destructor.
67
virtual
~ToolsSubjectT
();
68
69
70
protected
:
71
72
/// The constructor. It is protected so that only derived classes can create instances of this class.
73
ToolsSubjectT
();
74
75
76
private
:
77
78
/// The list of the observers that have registered for notification on updates of this class.
79
ArrayT<ToolsObserverT*>
m_Observers;
80
};
81
82
#endif
ToolsSubjectT::UpdateAllObservers
void UpdateAllObservers(ToolT *Tool, ToolsUpdatePriorityT Priority)
Notifies all observers that something in the given tool changed so that they update themselves...
Definition:
ObserverPatternTools.cpp:34
ToolsUpdatePriorityT
ToolsUpdatePriorityT
An enumeration that determines the urgency with which observers should update themselves when their s...
Definition:
ObserverPatternTools.hpp:21
ToolsObserverT::NotifySubjectChanged
virtual void NotifySubjectChanged(ToolsSubjectT *Subject, ToolT *Tool, ToolsUpdatePriorityT Priority)
Notifies the observer that the current subject has been changed.
Definition:
ObserverPatternTools.hpp:36
ToolsSubjectT::UnregisterObserver
void UnregisterObserver(ToolsObserverT *Obs)
Unregisters the observer Obs from further notification on changes in this class.
Definition:
ObserverPatternTools.cpp:26
UPDATE_SOON
Update as soon as convenient, at the next opportunity.
Definition:
ObserverPatternTools.hpp:24
ToolsSubjectT::~ToolsSubjectT
virtual ~ToolsSubjectT()
The virtual destructor.
Definition:
ObserverPatternTools.cpp:41
UPDATE_NOW
Update immediately, in real-time, before the function returns.
Definition:
ObserverPatternTools.hpp:23
ToolsSubjectT::ToolsSubjectT
ToolsSubjectT()
The constructor. It is protected so that only derived classes can create instances of this class...
Definition:
ObserverPatternTools.cpp:10
ToolsSubjectT::RegisterObserver
void RegisterObserver(ToolsObserverT *Obs)
Registers the observer Obs for notification on changes in this class.
Definition:
ObserverPatternTools.cpp:15
ToolsObserverT::ToolsObserverT
ToolsObserverT()
The constructor. It is protected so that only derived classes can create instances of this class...
Definition:
ObserverPatternTools.hpp:45
ToolsObserverT
Definition:
ObserverPatternTools.hpp:28
ToolT
This is the base class for all tools in the map editor.
Definition:
Tool.hpp:34
ArrayT< ToolsObserverT * >
ToolsObserverT::~ToolsObserverT
virtual ~ToolsObserverT()
The virtual destructor.
Definition:
ObserverPatternTools.hpp:39
ToolsSubjectT
Definition:
ObserverPatternTools.hpp:49
CaWE
MapEditor
ObserverPatternTools.hpp
Generated on Wed Jun 22 2016 11:29:35 for Cafu Engine by
1.8.6
Copyright © 2002-2016 Carsten Fuchs Software.