tagging release
[dasher.git] / Src / DasherCore / NodeManager.h
blob10aa788c82cf094dd398be09e61c5f7dd6ecdb88
1 // NodeManager.h
2 //
3 // Copyright (c) 2007 The Dasher Team
4 //
5 // This file is part of Dasher.
6 //
7 // Dasher is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
12 // Dasher is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with Dasher; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef __nodemanager_h__
22 #define __nodemanager_h__
24 #include "DasherTypes.h"
26 namespace Dasher {
27 class CDasherNode; // Forward declaration
29 /// \ingroup Model
30 /// @{
32 /// The node management process assigns an instance of a subclass of
33 /// CNodeManager to each Dasher node in the tree. Typically a
34 /// contiguous subtree will be represented by a single CNodeManager,
35 /// but multiple subtrees will often share the same
36 /// CNodeManager. CNodeManagers implement reference counting to
37 /// ensure that they are deleted when no longer required.
38 ///
39 /// This mechanism allows broad classes of nodes to be defined with
40 /// their own behaviour, for example, regular 'alphabet' nodes are
41 /// managed by an instance of CAlphabetManager. CNodeManagers also
42 /// currently exist for control nodes, and subtrees representing the
43 /// conversion process in certain languages.
44 ///
45 /// The node manager is responsible for the following aspects of the
46 /// lifespan of a node:
47 ///
48 /// 1. Construction of the root node for the subtree.
49 ///
50 /// 2. Population of the children of a node, and regeneration of the
51 /// parent node where necessary
52 ///
53 /// 3. Behaviour when the node enters or leaves the crosshair.
54 ///
55 /// 4. Behaviour when the node's flag status changes.
56 ///
57 /// 5. Deletion of manager-specific data when the node is deleted.
58 ///
59 /// The CDasherNode class provides a 'user data' pointer which is
60 /// intended for the node manager to use as a store for any
61 /// manager-specific status information.
62 ///
63 class CNodeManager {
64 public:
65 CNodeManager(int iID) {
66 m_iID = iID;
69 virtual int GetID() {
70 return m_iID;
73 /// Increment reference count
74 ///
75 virtual void Ref() = 0;
77 /// Decrement reference count
78 ///
79 virtual void Unref() = 0;
81 ///
82 /// Get a new root node owned by this manager
83 ///
86 virtual CDasherNode *GetRoot(CDasherNode *pParent, int iLower, int iUpper, void *pUserData) = 0;
88 ///
89 /// Provide children for the supplied node
90 ///
92 virtual void PopulateChildren( CDasherNode *pNode ) = 0;
94 ///
95 /// Delete any storage alocated for this node
96 ///
98 virtual void ClearNode( CDasherNode *pNode ) = 0;
101 /// Called whenever a node belonging to this manager first
102 /// moves under the crosshair
105 virtual void Output( CDasherNode *pNode, Dasher::VECTOR_SYMBOL_PROB* pAdded, int iNormalization) {};
106 virtual void Undo( CDasherNode *pNode ) {};
108 virtual void Enter(CDasherNode *pNode) {};
109 virtual void Leave(CDasherNode *pNode) {};
111 virtual CDasherNode *RebuildParent(CDasherNode *pNode, int iGeneration) {
112 return 0;
115 virtual void SetFlag(CDasherNode *pNode, int iFlag, bool bValue) {};
117 virtual void SetControlOffset(CDasherNode *pNode, int iOffset) {};
119 private:
120 int m_iID;
122 /// @}
125 #endif