diff options
author | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
commit | cd17687f01420952712a500107e0f93e7ab8d5f8 (patch) | |
tree | ce48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/llmath/lltreenode.h | |
parent | Second Life viewer sources 1.19.0.5 (diff) | |
download | meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2 meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz |
Second Life viewer sources 1.19.1.0
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llmath/lltreenode.h | 89 |
1 files changed, 13 insertions, 76 deletions
diff --git a/linden/indra/llmath/lltreenode.h b/linden/indra/llmath/lltreenode.h index 160a5bd..64beed8 100644 --- a/linden/indra/llmath/lltreenode.h +++ b/linden/indra/llmath/lltreenode.h | |||
@@ -40,23 +40,6 @@ template <class T> class LLTreeTraveler; | |||
40 | template <class T> class LLTreeListener; | 40 | template <class T> class LLTreeListener; |
41 | 41 | ||
42 | template <class T> | 42 | template <class T> |
43 | class LLTreeState | ||
44 | { | ||
45 | public: | ||
46 | LLTreeState(LLTreeNode<T>* node) { setNode(node); } | ||
47 | virtual ~LLTreeState() { }; | ||
48 | virtual bool insert(T* data) = 0; | ||
49 | virtual bool remove(T* data) = 0; | ||
50 | virtual void setNode(LLTreeNode<T>* node); | ||
51 | virtual const LLTreeNode<T>* getNode() const { return mNode; } | ||
52 | virtual LLTreeNode<T>* getNode() { return mNode; } | ||
53 | virtual void accept(LLTreeTraveler<T>* traveler) const = 0; | ||
54 | virtual LLTreeListener<T>* getListener(U32 index) const; | ||
55 | private: | ||
56 | LLTreeNode<T>* mNode; | ||
57 | }; | ||
58 | |||
59 | template <class T> | ||
60 | class LLTreeListener: public LLRefCount | 43 | class LLTreeListener: public LLRefCount |
61 | { | 44 | { |
62 | public: | 45 | public: |
@@ -70,19 +53,14 @@ template <class T> | |||
70 | class LLTreeNode | 53 | class LLTreeNode |
71 | { | 54 | { |
72 | public: | 55 | public: |
73 | LLTreeNode(LLTreeState<T>* state) { setState(state); } | ||
74 | virtual ~LLTreeNode(); | 56 | virtual ~LLTreeNode(); |
75 | LLTreeState<T>* getState() { return mState; } | 57 | |
76 | const LLTreeState<T>* getState() const { return mState; } | 58 | virtual bool insert(T* data); |
77 | 59 | virtual bool remove(T* data); | |
78 | void setState(LLTreeState<T>* state); | 60 | virtual void notifyRemoval(T* data); |
79 | void insert(T* data); | 61 | virtual U32 getListenerCount() { return mListeners.size(); } |
80 | bool remove(T* data); | 62 | virtual LLTreeListener<T>* getListener(U32 index) const { return mListeners[index]; } |
81 | void notifyRemoval(T* data); | 63 | virtual void addListener(LLTreeListener<T>* listener) { mListeners.push_back(listener); } |
82 | inline U32 getListenerCount() { return mListeners.size(); } | ||
83 | inline LLTreeListener<T>* getListener(U32 index) const { return mListeners[index]; } | ||
84 | inline void addListener(LLTreeListener<T>* listener) { mListeners.push_back(listener); } | ||
85 | inline void removeListener(U32 index) { mListeners.erase(mListeners.begin()+index); } | ||
86 | 64 | ||
87 | protected: | 65 | protected: |
88 | void destroyListeners() | 66 | void destroyListeners() |
@@ -94,7 +72,6 @@ protected: | |||
94 | mListeners.clear(); | 72 | mListeners.clear(); |
95 | } | 73 | } |
96 | 74 | ||
97 | LLTreeState<T>* mState; | ||
98 | public: | 75 | public: |
99 | std::vector<LLPointer<LLTreeListener<T> > > mListeners; | 76 | std::vector<LLPointer<LLTreeListener<T> > > mListeners; |
100 | }; | 77 | }; |
@@ -105,7 +82,7 @@ class LLTreeTraveler | |||
105 | public: | 82 | public: |
106 | virtual ~LLTreeTraveler() { }; | 83 | virtual ~LLTreeTraveler() { }; |
107 | virtual void traverse(const LLTreeNode<T>* node) = 0; | 84 | virtual void traverse(const LLTreeNode<T>* node) = 0; |
108 | virtual void visit(const LLTreeState<T>* state) = 0; | 85 | virtual void visit(const LLTreeNode<T>* node) = 0; |
109 | }; | 86 | }; |
110 | 87 | ||
111 | template <class T> | 88 | template <class T> |
@@ -115,25 +92,19 @@ LLTreeNode<T>::~LLTreeNode() | |||
115 | }; | 92 | }; |
116 | 93 | ||
117 | template <class T> | 94 | template <class T> |
118 | void LLTreeNode<T>::insert(T* data) | 95 | bool LLTreeNode<T>::insert(T* data) |
119 | { | 96 | { |
120 | if (mState->insert(data)) | 97 | for (U32 i = 0; i < mListeners.size(); i++) |
121 | { | 98 | { |
122 | for (U32 i = 0; i < mListeners.size(); i++) | 99 | mListeners[i]->handleInsertion(this, data); |
123 | { | ||
124 | mListeners[i]->handleInsertion(this, data); | ||
125 | } | ||
126 | } | 100 | } |
101 | return true; | ||
127 | }; | 102 | }; |
128 | 103 | ||
129 | template <class T> | 104 | template <class T> |
130 | bool LLTreeNode<T>::remove(T* data) | 105 | bool LLTreeNode<T>::remove(T* data) |
131 | { | 106 | { |
132 | if (mState->remove(data)) | 107 | return true; |
133 | { | ||
134 | return true; | ||
135 | } | ||
136 | return false; | ||
137 | }; | 108 | }; |
138 | 109 | ||
139 | template <class T> | 110 | template <class T> |
@@ -145,38 +116,4 @@ void LLTreeNode<T>::notifyRemoval(T* data) | |||
145 | } | 116 | } |
146 | } | 117 | } |
147 | 118 | ||
148 | template <class T> | ||
149 | void LLTreeNode<T>::setState(LLTreeState<T>* state) | ||
150 | { | ||
151 | mState = state; | ||
152 | if (state) | ||
153 | { | ||
154 | if (state->getNode() != this) | ||
155 | { | ||
156 | state->setNode(this); | ||
157 | } | ||
158 | |||
159 | for (U32 i = 0; i < mListeners.size(); i++) | ||
160 | { | ||
161 | mListeners[i]->handleStateChange(this); | ||
162 | } | ||
163 | } | ||
164 | }; | ||
165 | |||
166 | template <class T> | ||
167 | void LLTreeState<T>::setNode(LLTreeNode<T>* node) | ||
168 | { | ||
169 | mNode = node; | ||
170 | if (node && node->getState() != this) | ||
171 | { | ||
172 | node->setState(this); | ||
173 | } | ||
174 | }; | ||
175 | |||
176 | template <class T> | ||
177 | LLTreeListener<T>* LLTreeState<T>::getListener(U32 index) const | ||
178 | { | ||
179 | return mNode->getListener(index); | ||
180 | } | ||
181 | |||
182 | #endif | 119 | #endif |