diff options
author | Brad Kittenbrink <brad@lindenlab.com> | 2008-02-27 18:58:14 +0000 |
---|---|---|
committer | Brad Kittenbrink <brad@lindenlab.com> | 2008-02-27 18:58:14 +0000 |
commit | 6d52efe452aa8469e0343da1c7d108f3f52ab651 (patch) | |
tree | a87be48e9840d7fc1f7ee514d7c7f994e71fdb3c /indra/llmath/lltreenode.h | |
parent | 6027ad2630b8650cabcf00628ee9b0d25bedd67f (diff) |
Merge of windlight into release (QAR-286). This includes all changes in
windlight14 which have passed QA (up through r79932).
svn merge -r 80831:80833 svn+ssh://svn.lindenlab.com/svn/linden/branches/merge_windlight14_r80620
Diffstat (limited to 'indra/llmath/lltreenode.h')
-rw-r--r-- | indra/llmath/lltreenode.h | 89 |
1 files changed, 13 insertions, 76 deletions
diff --git a/indra/llmath/lltreenode.h b/indra/llmath/lltreenode.h index 6cafee01d4..6685915bcf 100644 --- a/indra/llmath/lltreenode.h +++ b/indra/llmath/lltreenode.h @@ -40,23 +40,6 @@ template <class T> class LLTreeTraveler; template <class T> class LLTreeListener; template <class T> -class LLTreeState -{ -public: - LLTreeState(LLTreeNode<T>* node) { setNode(node); } - virtual ~LLTreeState() { }; - virtual bool insert(T* data) = 0; - virtual bool remove(T* data) = 0; - virtual void setNode(LLTreeNode<T>* node); - virtual const LLTreeNode<T>* getNode() const { return mNode; } - virtual LLTreeNode<T>* getNode() { return mNode; } - virtual void accept(LLTreeTraveler<T>* traveler) const = 0; - virtual LLTreeListener<T>* getListener(U32 index) const; -private: - LLTreeNode<T>* mNode; -}; - -template <class T> class LLTreeListener: public LLRefCount { public: @@ -70,19 +53,14 @@ template <class T> class LLTreeNode { public: - LLTreeNode(LLTreeState<T>* state) { setState(state); } virtual ~LLTreeNode(); - LLTreeState<T>* getState() { return mState; } - const LLTreeState<T>* getState() const { return mState; } - - void setState(LLTreeState<T>* state); - void insert(T* data); - bool remove(T* data); - void notifyRemoval(T* data); - inline U32 getListenerCount() { return mListeners.size(); } - inline LLTreeListener<T>* getListener(U32 index) const { return mListeners[index]; } - inline void addListener(LLTreeListener<T>* listener) { mListeners.push_back(listener); } - inline void removeListener(U32 index) { mListeners.erase(mListeners.begin()+index); } + + virtual bool insert(T* data); + virtual bool remove(T* data); + virtual void notifyRemoval(T* data); + virtual U32 getListenerCount() { return mListeners.size(); } + virtual LLTreeListener<T>* getListener(U32 index) const { return mListeners[index]; } + virtual void addListener(LLTreeListener<T>* listener) { mListeners.push_back(listener); } protected: void destroyListeners() @@ -94,7 +72,6 @@ protected: mListeners.clear(); } - LLTreeState<T>* mState; public: std::vector<LLPointer<LLTreeListener<T> > > mListeners; }; @@ -105,7 +82,7 @@ class LLTreeTraveler public: virtual ~LLTreeTraveler() { }; virtual void traverse(const LLTreeNode<T>* node) = 0; - virtual void visit(const LLTreeState<T>* state) = 0; + virtual void visit(const LLTreeNode<T>* node) = 0; }; template <class T> @@ -115,25 +92,19 @@ LLTreeNode<T>::~LLTreeNode() }; template <class T> -void LLTreeNode<T>::insert(T* data) +bool LLTreeNode<T>::insert(T* data) { - if (mState->insert(data)) + for (U32 i = 0; i < mListeners.size(); i++) { - for (U32 i = 0; i < mListeners.size(); i++) - { - mListeners[i]->handleInsertion(this, data); - } + mListeners[i]->handleInsertion(this, data); } + return true; }; template <class T> bool LLTreeNode<T>::remove(T* data) { - if (mState->remove(data)) - { - return true; - } - return false; + return true; }; template <class T> @@ -145,38 +116,4 @@ void LLTreeNode<T>::notifyRemoval(T* data) } } -template <class T> -void LLTreeNode<T>::setState(LLTreeState<T>* state) -{ - mState = state; - if (state) - { - if (state->getNode() != this) - { - state->setNode(this); - } - - for (U32 i = 0; i < mListeners.size(); i++) - { - mListeners[i]->handleStateChange(this); - } - } -}; - -template <class T> -void LLTreeState<T>::setNode(LLTreeNode<T>* node) -{ - mNode = node; - if (node && node->getState() != this) - { - node->setState(this); - } -}; - -template <class T> -LLTreeListener<T>* LLTreeState<T>::getListener(U32 index) const -{ - return mNode->getListener(index); -} - #endif |