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 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGATTACHMENTMAPSFIELDS_H_
40 #define _OSGATTACHMENTMAPSFIELDS_H_
45 #include "OSGSField.h"
46 #include "OSGAttachmentMapFieldTraits.h"
47 #include "OSGTypeBasePredicates.h"
48 #include "OSGReflexiveContainerTypePredicates.h"
52 #ifndef DOXYGEN_SHOULD_SKIP_THIS
54 /*! \ingroup GrpBaseFieldContainerFieldSFields */
55 typedef SField
<AttachmentMap
> SFAttachmentPtrMap
;
57 #else // these are the doxygen hacks
59 /*! \ingroup GrpBaseFieldContainerFieldSFields \ingroup GrpLibOSGBase */
60 struct SFAttachmentPtrMap
: public SField
<AttachmentMap
> {};
62 #endif // these are the doxygen hacks
64 /*! \ingroup GrpBaseFieldContainerFields
65 \ingroup GrpLibOSGBase
69 class OSG_BASE_DLLMAPPING GetSFieldHandle
<SFAttachmentPtrMap
> :
70 public GetMapFieldHandle
72 /*========================= PROTECTED ===============================*/
76 typedef GetMapFieldHandle Inherited
;
77 typedef GetFieldHandle Base
;
79 /*========================== PUBLIC =================================*/
83 typedef boost::shared_ptr
<GetSFieldHandle
> Ptr
;
85 /*---------------------------------------------------------------------*/
87 GetSFieldHandle(const GetSFieldHandle
&source
);
88 GetSFieldHandle(const SFAttachmentPtrMap
*pField
,
89 const FieldDescriptionBase
*pDescription
,
90 FieldContainer
*pContainer
);
92 /*---------------------------------------------------------------------*/
94 virtual const FieldType
&getType (void) const;
95 virtual bool isPointerField(void) const;
97 /*---------------------------------------------------------------------*/
99 virtual void traverse(TraverseCallback oCallBack
);
101 /*---------------------------------------------------------------------*/
103 virtual bool empty (void );
104 virtual void flatten(MapList
&vList
);
105 virtual void flatten(ContainerList
&vList
);
107 /*---------------------------------------------------------------------*/
109 virtual void pushValueToStream(OutStream
&str
) const;
110 virtual void pushSizeToStream (OutStream
&str
) const;
112 /*---------------------------------------------------------------------*/
114 virtual bool equal(Base::Ptr rhs
) const;
116 /*---------------------------------------------------------------------*/
118 SFAttachmentPtrMap
const * operator ->(void);
119 SFAttachmentPtrMap
const & operator * (void);
122 /*! \ingroup GrpBaseFieldContainerFields
123 \ingroup GrpLibOSGBase
127 class OSG_BASE_DLLMAPPING
128 EditSFieldHandle
<SFAttachmentPtrMap
> : public EditMapFieldHandle
130 /*========================= PROTECTED ===============================*/
134 void operator =(const EditSFieldHandle
&other
);
136 /*========================= PROTECTED ===============================*/
140 typedef EditMapFieldHandle Inherited
;
141 typedef EditFieldHandle Base
;
143 typedef boost::function
<void(Attachment
* const,
146 typedef boost::function
<void(Attachment
* const,
147 Attachment
* const)> ReplaceMethod
;
149 /*========================== PUBLIC =================================*/
151 FieldContainer
*_pContainer
;
152 AddMethod _fAddMethod
;
153 ReplaceMethod _fReplaceMethod
;
157 typedef boost::shared_ptr
<EditSFieldHandle
> Ptr
;
159 /*---------------------------------------------------------------------*/
161 EditSFieldHandle(const EditSFieldHandle
&source
);
162 EditSFieldHandle( SFAttachmentPtrMap
*pField
,
163 const FieldDescriptionBase
*pDescription
,
164 FieldContainer
*pContainer
);
166 /*---------------------------------------------------------------------*/
168 virtual const FieldType
&getType (void) const;
169 virtual bool isPointerField(void) const;
171 /*---------------------------------------------------------------------*/
173 virtual void add ( FieldContainer
* rhs
,
174 const std::string
& szBindings
);
176 virtual void replaceByObj( Attachment
* const pOld
,
177 Attachment
* const pNew
);
179 /*---------------------------------------------------------------------*/
181 virtual void traverse(TraverseCallback oCallBack
);
183 /*---------------------------------------------------------------------*/
185 virtual bool empty (void );
186 virtual void flatten(MapList
&vList
);
187 virtual void flatten(ContainerList
&vList
);
189 /*---------------------------------------------------------------------*/
191 virtual bool loadFromBin( BinaryDataHandler
*pMem
,
192 UInt32 uiNumElements
,
194 std::vector
<UInt16
> &vBindings
,
195 std::vector
<UInt32
> &vIds
);
197 virtual void fillFrom (const std::vector
<UInt16
> &vBindings
,
198 const std::vector
<UInt32
> &vIds
,
199 const std::map
<UInt32
, UInt32
> &vIdMap
);
201 /*---------------------------------------------------------------------*/
203 virtual void pushValueToStream(OutStream
&str
) const;
204 virtual void pushSizeToStream (OutStream
&str
) const;
206 /*---------------------------------------------------------------------*/
208 void setAddMethod (AddMethod fMethod
);
209 void setReplaceMethod(ReplaceMethod fMethod
);
211 virtual bool equal (Base::Ptr rhs
) const;
213 /*---------------------------------------------------------------------*/
215 virtual void pushValueFromCString(const Char8
*str
);
217 virtual void copyValues ( GetFieldHandlePtr source
) const;
218 virtual void shareValues ( GetFieldHandlePtr source
) const;
220 /*---------------------------------------------------------------------*/
222 virtual void cloneValues(
223 GetFieldHandlePtr pSrc
,
224 const TypePtrVector
&shareTypes
= TypePtrVector(),
225 const TypePtrVector
&ignoreTypes
= TypePtrVector(),
226 const TypeIdVector
&shareGroupIds
= TypeIdVector (),
227 const TypeIdVector
&ignoreGroupIds
= TypeIdVector ()) const;
233 #include "OSGAttachmentMapSFields.inl"
235 #endif /* _OSGATTACHMENTMAPSFIELDS_H_ */