fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / Material / Base / OSGMaterialMapFields.inl
blob20c28875045507c537e57565aa60f5dc3affd580
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 inline
42 GetSFieldHandle<SFMaterialPtrMap>::GetSFieldHandle(
43     const GetSFieldHandle &source) :
45     Inherited(source)
49 inline
50 GetSFieldHandle<SFMaterialPtrMap>::GetSFieldHandle(
51     const SFMaterialPtrMap     *pField, 
52     const FieldDescriptionBase *pDescription,
53           FieldContainer       *pContainer  ) :
55     Inherited(pField, pDescription, pContainer)
59 inline
60 bool 
61    GetSFieldHandle<SFMaterialPtrMap>::isPointerField(void) const
63     return true;
66 inline
67 bool GetSFieldHandle<SFMaterialPtrMap>::empty(void)
69     bool returnValue = true;
71     SFMaterialPtrMap const *pLhs = 
72         static_cast<SFMaterialPtrMap const *>(_pField);
74     if(pLhs != NULL)
75     {
76         returnValue = pLhs->getValue().empty();
77     }
79     return returnValue;
82 inline
83 void GetSFieldHandle<SFMaterialPtrMap>::pushValueToStream(
84     OutStream &str) const
86     FWARNING(("illegal pushValueToStream called for %s\n", 
87               this->getName().c_str()));
88     OSG_ASSERT(false);
91 inline
92 void GetSFieldHandle<SFMaterialPtrMap>::pushSizeToStream(
93     OutStream &str) const
95     FWARNING(("illegal pushSizeToStream called for %s\n", 
96               this->getName().c_str()));
97     OSG_ASSERT(false);
100 inline
101 bool GetSFieldHandle<SFMaterialPtrMap>::equal(
102     Base::Ptr rhs) const
104     Ptr pOther = boost::dynamic_pointer_cast<GetSFieldHandle>(rhs);
106     if(pOther == NULL)
107     {
108         return false;
109     }
111     SFMaterialPtrMap const *pLhs = 
112         static_cast<SFMaterialPtrMap const *>(        _pField);
114     SFMaterialPtrMap const *pRhs = 
115         static_cast<SFMaterialPtrMap const *>(pOther->_pField);
117     return (*pLhs) == (*pRhs);
120 inline
121 SFMaterialPtrMap const *
122     GetSFieldHandle<SFMaterialPtrMap>::operator ->(void)
124     return static_cast<SFMaterialPtrMap const *>(_pField);
127 inline
128 SFMaterialPtrMap const &
129     GetSFieldHandle<SFMaterialPtrMap>::operator * (void)
131     return *(static_cast<SFMaterialPtrMap const *>(_pField));
134 /*---------------------------------------------------------------------*/
136 inline
137 EditSFieldHandle<SFMaterialPtrMap>::EditSFieldHandle(
138     const EditSFieldHandle &source) :
140      Inherited (source            ),
141     _pContainer(source._pContainer),
142     _fAddMethod(source._fAddMethod)
146 inline
147 EditSFieldHandle<SFMaterialPtrMap>::EditSFieldHandle(      
148           SFMaterialPtrMap     *pField, 
149     const FieldDescriptionBase *pDescription,
150           FieldContainer       *pContainer  ) :
152      Inherited (pField, 
153                 pDescription,
154                 pContainer  ),
155     _pContainer(NULL        ),
156     _fAddMethod(NULL        )
161 inline
162 bool EditSFieldHandle<SFMaterialPtrMap>::isPointerField(void) const
164     return true;
167 inline
168 bool EditSFieldHandle<SFMaterialPtrMap>::empty(void)
170     bool returnValue = true;
172     SFMaterialPtrMap *pLhs = static_cast<SFMaterialPtrMap *>(_pField);
174     if(pLhs != NULL)
175     {
176         returnValue = pLhs->getValue().empty();
177     }
179     return returnValue;
182 inline
183 void EditSFieldHandle<SFMaterialPtrMap>::pushValueToStream(
184     OutStream &str) const
186     FWARNING(("illegal pushValueToStream called for %s\n", 
187               this->getName().c_str()));
188     OSG_ASSERT(false);
191 inline
192 void EditSFieldHandle<SFMaterialPtrMap>::pushSizeToStream(
193     OutStream &str) const
195     FWARNING(("illegal pushSizeToStream called for %s\n", 
196               this->getName().c_str()));
197     OSG_ASSERT(false);
200 inline
201 bool EditSFieldHandle<SFMaterialPtrMap>::equal(
202     Base::Ptr rhs) const
204     Ptr pOther = boost::dynamic_pointer_cast<EditSFieldHandle>(rhs);
206     if(pOther == NULL)
207     {
208         return false;
209     }
211     SFMaterialPtrMap *pLhs = 
212         static_cast<SFMaterialPtrMap *>(        _pField);
214     SFMaterialPtrMap *pRhs = 
215         static_cast<SFMaterialPtrMap *>(pOther->_pField);
217     return (*pLhs) == (*pRhs);
220 inline
221 void EditSFieldHandle<SFMaterialPtrMap>::setAddMethod(
222     AddMethod fMethod)
224     _fAddMethod = fMethod;
227 inline
228 void EditSFieldHandle<SFMaterialPtrMap>::pushValueFromCString(
229     const Char8 *str)
231     FWARNING(("illegal pushValueFromCString called for %s\n", 
232               this->getName().c_str()));
233     OSG_ASSERT(false);
236 inline
237 void EditSFieldHandle<SFMaterialPtrMap>::copyValues(
238     GetFieldHandlePtr source) const
240     FWARNING(("illegal copyValues called for %s\n", 
241               this->getName().c_str()));
242     OSG_ASSERT(false);
245 inline
246 void EditSFieldHandle<SFMaterialPtrMap>::shareValues(
247     GetFieldHandlePtr source) const
249     SFMaterialPtrMap::GetHandlePtr pGetHandle = 
250         boost::dynamic_pointer_cast<
251             SFMaterialPtrMap::GetHandle>(source);
253     if(pGetHandle == NULL || pGetHandle->isValid() == false)
254         return;
256     const SFMaterialPtrMap &pMatMap = **pGetHandle;
258     MaterialMap::const_iterator mapIt  = pMatMap.getValue().begin();
259     MaterialMap::const_iterator mapEnd = pMatMap.getValue().end();
261     for(; mapIt != mapEnd; ++mapIt)
262     {
263         PrimeMaterial *att       = mapIt->second;
264         KeyType        uiBinding = mapIt->first;
266         if(_fAddMethod)
267         {
268             _fAddMethod(att, uiBinding);
269         }
270     }
273 OSG_END_NAMESPACE