fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FieldContainer / Mixins / OSGTraversalDataHandlerMixin.inl
blob1184403f1ad84c78a2eb0451ce26005e991cfd39
1 /*---------------------------------------------------------------------------*\
2  *                                OpenSG                                     *
3  *                                                                           *
4  *                                                                           *
5  *           Copyright (C) 2003 by the OpenSG Forum                          *
6  *                                                                           *
7  *                            www.opensg.org                                 *
8  *                                                                           *
9  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
10  *                                                                           *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13  *                                License                                    *
14  *                                                                           *
15  * This library is free software; you can redistribute it and/or modify it   *
16  * under the terms of the GNU Library General Public License as published    *
17  * by the Free Software Foundation, version 2.                               *
18  *                                                                           *
19  * This library is distributed in the hope that it will be useful, but       *
20  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
22  * Library General Public License for more details.                          *
23  *                                                                           *
24  * You should have received a copy of the GNU Library General Public         *
25  * License along with this library; if not, write to the Free Software       *
26  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
27  *                                                                           *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30  *                                Changes                                    *
31  *                                                                           *
32  *                                                                           *
33  *                                                                           *
34  *                                                                           *
35  *                                                                           *
36  *                                                                           *
37 \*---------------------------------------------------------------------------*/
39 OSG_BEGIN_NAMESPACE
41 template <class ParentT> inline
42 void TraversalDataHandlerMixin<ParentT>::changed(ConstFieldMaskArg whichField, 
43                                                  UInt32            origin,
44                                                  BitVector         details)
46     Inherited::changed(whichField, origin, details);
49 template <class ParentT> inline
50 void TraversalDataHandlerMixin<ParentT>::setData(
51     TraversalData    *pData, 
52     Int32             iDataSlotId,
53     RenderActionBase *pAction)
55     TraversalData *pStoredData = 
56         pAction->template getData<TraversalData *>(this->_iDataSlotId);
58     bool bCheckCallback = false;
60     OSG_ASSERT(iDataSlotId == this->_iDataSlotId);
62     if(pStoredData == NULL)
63     {
64         pAction->setData(pData, this->_iDataSlotId);
65         bCheckCallback = true;
66     }
67     else if(pStoredData != pData)
68     {
69         pData->copyFrom(pStoredData);
71         pAction->setData(pData, this->_iDataSlotId);
72         bCheckCallback = true;
73     }
75     if(bCheckCallback == true)
76     {
77         if(this->hasDestroyedFunctor(
78                boost::bind(&DataSlotHandler::clearData,
79                            pAction,
80                            _1,
81                            _2,
82                            this->_iDataSlotId)) == false)
83         {
84             this->addDestroyedFunctor(
85                 boost::bind(&DataSlotHandler::clearData,
86                             static_cast<DataSlotHandler *>(pAction),
87                             _1,
88                             _2,
89                             this->_iDataSlotId), "");
91             pAction->addDestroyedFunctorFor(
92                 boost::bind(
93                     &Self::template clearDestroyedFunctorFor<DataSlotHandler>,
94                     this,
95                     _1),
96                 this);
97         }
99         if(pData != NULL)
100         {
101             this->addChangedFunctor(
102                 boost::bind(&TraversalData::updateData, 
103                             pData, 
104                             _1, 
105                             _2,
106                             _3),
107                 "");
109             pData->addChangedFunctor(
110                 boost::bind(&Self::dataDestroyed, 
111                             this, 
112                             _1, 
113                             _2,
114                             _3),
115                 "");
116         }
117         if(pStoredData != NULL)
118         {
119             this->subChangedFunctor(
120                 boost::bind(&TraversalData::updateData, 
121                             pStoredData, 
122                             _1, 
123                             _2,
124                             _3));
125             
126             pStoredData->subChangedFunctor(
127                 boost::bind(&Self::dataDestroyed, 
128                             this, 
129                             _1, 
130                             _2,
131                             _3));
132          }
133     }
137 /*-------------------------------------------------------------------------*/
138 /*                                Set                                      */
140 /*-------------------------------------------------------------------------*/
141 /* Binary access                                                           */
143 /*-------------------------------------------------------------------------*/
144 /*                             Assignment                                  */
147 /*-------------------------------------------------------------------------*/
148 /*                            Constructors                                 */
150 template <class ParentT> inline
151 TraversalDataHandlerMixin<ParentT>::TraversalDataHandlerMixin(void) :
152     Inherited()
156 template <class ParentT> inline
157 TraversalDataHandlerMixin<ParentT>::TraversalDataHandlerMixin(
158     const TraversalDataHandlerMixin &source) :
160     Inherited(source)
164 template <class ParentT> inline
165 TraversalDataHandlerMixin<ParentT>::~TraversalDataHandlerMixin(void)
169 template <class ParentT> inline
170 void TraversalDataHandlerMixin<ParentT>::dataDestroyed(
171     FieldContainer *pCore,
172     BitVector       whichField,
173     UInt32          origin    )
175     if(whichField == 0x0000)
176     {
177         this->subChangedFunctor(
178             boost::bind(&TraversalData::updateData, 
179                         dynamic_cast<TraversalData *>(pCore), 
180                         _1, 
181                         _2,
182                         _3));
183     }
186 template <class ParentT> inline
187 void TraversalDataHandlerMixin<ParentT>::dump(      UInt32    uiIndent,
188                                               const BitVector bvFlags ) const
192 /*-------------------------------------------------------------------------*/
193 /*                             Destructor                                  */
195 /*-------------------------------------------------------------------------*/
196 /*                             Assignment                                  */
198 /*-------------------------------------------------------------------------*/
199 /*                             Comparison                                  */
201 OSG_END_NAMESPACE