3 // Copyright (c) 2007 The Dasher Team
5 // This file is part of Dasher.
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"
27 class CDasherNode
; // Forward declaration
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.
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.
45 /// The node manager is responsible for the following aspects of the
46 /// lifespan of a node:
48 /// 1. Construction of the root node for the subtree.
50 /// 2. Population of the children of a node, and regeneration of the
51 /// parent node where necessary
53 /// 3. Behaviour when the node enters or leaves the crosshair.
55 /// 4. Behaviour when the node's flag status changes.
57 /// 5. Deletion of manager-specific data when the node is deleted.
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.
65 CNodeManager(int iID
) {
73 /// Increment reference count
75 virtual void Ref() = 0;
77 /// Decrement reference count
79 virtual void Unref() = 0;
82 /// Get a new root node owned by this manager
86 virtual CDasherNode
*GetRoot(CDasherNode
*pParent
, int iLower
, int iUpper
, void *pUserData
) = 0;
89 /// Provide children for the supplied node
92 virtual void PopulateChildren( CDasherNode
*pNode
) = 0;
95 /// Delete any storage alocated for this node
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
) {
115 virtual void SetFlag(CDasherNode
*pNode
, int iFlag
, bool bValue
) {};
117 virtual void SetControlOffset(CDasherNode
*pNode
, int iOffset
) {};