InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EntryNode.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Yeming Liu
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //
23 // Comments: Templatized Node class allowing an arbitrary number of children in the tree.
24 // This structure is used to support multi level sorting.
25 //
26 //========================================================================================
27 
28 #ifndef __ENTRYNODE__
29 #define __ENTRYNODE__
30 
37 template <class T>
38 class EntryNode
39 {
40  public:
43  EntryNode() : fData(), fLevel(0), fChild(nil), fSibling(nil), fPrevious(nil), fPreviousIsParent(kFalse) { }
44 
48  EntryNode(const T& data) : fData(data), fLevel(1), fChild(nil), fSibling(nil), fPrevious(nil), fPreviousIsParent(kFalse) { }
49 
58  EntryNode(const T& data, int32 level, EntryNode<T>* child, EntryNode<T>* sibling, EntryNode<T>* previous, bool16 isParent) :
59  fData(data), fLevel(level), fChild(child), fSibling(sibling), fPrevious(previous), fPreviousIsParent(isParent) { }
60 
63  virtual ~EntryNode() {}
64 
69  virtual const T& GetData() { return fData; }
70 
74  virtual void SetData(const T& data) { fData = data; }
75 
80  virtual int32 GetNodeLevel() { return fLevel; }
81 
85  virtual void SetNodeLevel(int32 level) { fLevel = level; }
86 
91  virtual EntryNode<T>* GetChild() { return fChild; }
92 
96  virtual void SetChild(EntryNode<T>* child) { fChild = child; }
97 
102  virtual EntryNode<T>* GetSibling() { return fSibling; }
103 
107  virtual void SetSibling(EntryNode<T>* sibling) { fSibling = sibling; }
108 
113  virtual EntryNode<T>* GetPrevious() { return fPrevious; }
114 
118  virtual void SetPrevious(EntryNode<T>* previous) { fPrevious = previous; }
119 
125  virtual bool16 IsPreviousParent() { return fPreviousIsParent; }
126 
130  virtual void SetPreviousIsParent(bool16 isParent) { fPreviousIsParent = isParent; }
131 
132  private:
133  T fData; // any data in the entry node
134  int32 fLevel; // level where the data will be
135  EntryNode<T>* fChild; // the node's child
136  EntryNode<T>* fSibling; // the node's sibling
137  EntryNode<T>* fPrevious;// the node's previous node
138  bool16 fPreviousIsParent;// flag indicates if thie nodes has parent or not(such as non-first child of a node)
139 };
140 
141 #endif // __ENTRYNODE__