1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2003 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
41 template <class ParentT>
42 template <class ValuePtr> inline
43 ValuePtr DataSlotMixin<ParentT>::getData(Int32 iSlotId) const
45 ValuePtr returnValue = NULL;
47 if(iSlotId >= 0 && static_cast<UInt32>(iSlotId) < _mfData.size())
49 StoredType pTmp = _mfData[iSlotId];
51 returnValue = dynamic_cast<ValuePtr>(pTmp);
57 template <class ParentT> inline
58 void DataSlotMixin<ParentT>::setData(StoredType pData, Int32 iSlotId)
63 if(_mfData.size() <= static_cast<UInt32>(iSlotId))
65 _mfData.resize(iSlotId + 1, NULL);
68 _mfData.replace(iSlotId, pData);
71 template <class ParentT> inline
72 void DataSlotMixin<ParentT>::dumpStore(void)
74 for(UInt32 i = 0; i < _mfData.size(); ++i)
76 fprintf(stderr, "(%d) : ", i);
77 Desc::dumpElement(_mfData[i]);
78 fprintf(stderr, "\n");
82 template <class ParentT> inline
83 void DataSlotMixin<ParentT>::clearData(FieldContainer *pContainer,
84 ConstFieldMaskArg whichField,
87 fprintf(stderr, "Clear Data %p %d\n",
94 if(_mfData.size() > static_cast<UInt32>(iSlotId))
96 _mfData.replace(iSlotId, NULL);
99 typename DestroyFunctorStore::iterator cfIt =
100 _mfDestroyedFunctors.begin();
102 typename DestroyFunctorStore::const_iterator cfEnd=
103 _mfDestroyedFunctors.end();
107 if((*cfIt).second == pContainer)
109 cfIt = _mfDestroyedFunctors.erase(cfIt);
110 cfEnd = _mfDestroyedFunctors.end();
119 template <class ParentT> inline
120 DataSlotMixin<ParentT>::DataSlotMixin(void) :
123 _mfDestroyedFunctors()
127 template <class ParentT> inline
128 DataSlotMixin<ParentT>::DataSlotMixin(const DataSlotMixin &source) :
131 _mfDestroyedFunctors( )
135 template <class ParentT> inline
136 void DataSlotMixin<ParentT>::addDestroyedFunctorFor( DestroyFunctor func,
137 const FieldContainer *pCnt)
139 DestroyedFunctorElem tmpElem;
141 tmpElem.first = func;
142 tmpElem.second = pCnt;
144 _mfDestroyedFunctors.push_back(tmpElem);
147 template <class ParentT> inline
148 DataSlotMixin<ParentT>::~DataSlotMixin(void)
150 for(UInt32 i = 0; i < _mfData.size(); ++i)
152 _mfData.replace(i, NULL);
155 for(UInt32 i = 0; i < _mfDestroyedFunctors.size(); ++i)
157 fprintf(stderr, "DF (%d) (%p)\n",
160 (_mfDestroyedFunctors[i].first)(this);