added: travMask to csm viewport
[opensg.git] / Source / Base / Field / OSGSField.inl
blob2dccfc993623fde91374884366ab3b70d178fb09
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 /*-------------------------------------------------------------------------*/
42 /*                            Constructors                                 */
44 template<class ValueT, Int32 iNamespace> inline
45 SField<ValueT, iNamespace>::SField(void) : 
46      Inherited (),
47     _fieldValue()
51 template <class ValueT, Int32 iNamespace> inline
52 SField<ValueT, iNamespace>::SField(const SField &obj) :
53      Inherited (obj            ),
54     _fieldValue(obj._fieldValue)
58 template <class ValueT, Int32 iNamespace> inline
59 SField<ValueT, iNamespace>::SField(ArgumentType value) :
60      Inherited(     ),
61     _fieldValue    (value)
65 /*-------------------------------------------------------------------------*/
66 /*                             Destructor                                  */
68 template<class ValueT, Int32 iNamespace> inline
69 SField<ValueT, iNamespace>::~SField(void)
73 /*-------------------------------------------------------------------------*/
74 /*                               Get                                       */
76 template <class ValueT, Int32 iNamespace> inline
77 typename SField<ValueT, iNamespace>::reference 
78     SField<ValueT, iNamespace>::getValue(void)
81     return _fieldValue;
84 template <class ValueT, Int32 iNamespace> inline
85 typename SField<ValueT, iNamespace>::const_reference
86     SField<ValueT, iNamespace>::getValue(void) const
88     return _fieldValue;
91 /*-------------------------------------------------------------------------*/
92 /*                                Set                                      */
94 template <class ValueT, Int32 iNamespace> inline
95 void SField<ValueT, iNamespace>::setValue(ArgumentType value)
97     _fieldValue = value;
100 template <class ValueT, Int32 iNamespace> inline
101 void SField<ValueT, iNamespace>::setValue(const Self &obj)
103     _fieldValue = obj._fieldValue;
106 template <class ValueT, Int32 iNamespace> inline
107 void SField<ValueT, iNamespace>::setValueFromCString(const Char8 *str)
109     typedef typename boost::mpl::if_c<
110       (SFieldTraits   ::Convertible &
111        FieldTraitsBase::FromStringConvertible) != 0, 
112       SFieldTraits, 
113       StringConversionError<ValueT, iNamespace> >::type Converter;
114     
115     Converter::getFromCString(_fieldValue, str);
118 template <class ValueT, Int32 iNamespace> inline
119 void SField<ValueT, iNamespace>::pushValueToString  (std::string  &str) const
121     typedef typename boost::mpl::if_c<
122       (SFieldTraits   ::Convertible &
123        FieldTraitsBase::ToStringConvertible) != 0, 
124       SFieldTraits, 
125       StringConversionError<ValueT, iNamespace> >::type Converter;
126     
127     Converter::putToString(_fieldValue, str);
130 template <class ValueT, Int32 iNamespace> inline
131 void SField<ValueT, iNamespace>::pushValueFromStream(std::istream &str)
133     typedef typename boost::mpl::if_c<
134       (SFieldTraits   ::Convertible &
135        FieldTraitsBase::FromStreamConvertible) != 0, 
136       SFieldTraits, 
137       StreamConversionError<ValueT, iNamespace> >::type Converter;
138     
139     Converter::getFromStream(_fieldValue, str);
142 template <class ValueT, Int32 iNamespace> inline
143 void SField<ValueT, iNamespace>::pushValueToStream  (OutStream &str) const
145     typedef typename boost::mpl::if_c<
146       (SFieldTraits   ::Convertible &
147        FieldTraitsBase::ToStreamConvertible) != 0, 
148       SFieldTraits, 
149       StreamConversionError<ValueT, iNamespace> >::type Converter;
150     
151     Converter::putToStream(_fieldValue, str);
154 template <class ValueT, Int32 iNamespace> inline
155 void SField<ValueT, iNamespace>::pushSizeToStream  (OutStream &str) const
157     str << 1;
160 /*-------------------------------------------------------------------------*/
161 /*                         Binary Interface                                */
163 template <class ValueTypeT, Int32 iNameSpace> inline
164 SizeT SField<ValueTypeT, iNameSpace>::getBinSize(void) const
166     return SFieldTraits::getBinSize(_fieldValue);
169 template <class ValueTypeT, Int32 iNameSpace> inline
170 void SField<ValueTypeT, iNameSpace>::copyToBin(BinaryDataHandler &pMem) const
172     SFieldTraits::copyToBin( pMem, 
173                             _fieldValue);
176 template <class ValueTypeT, Int32 iNameSpace> inline
177 void SField<ValueTypeT, iNameSpace>::copyFromBin(BinaryDataHandler &pMem)
179     SFieldTraits::copyFromBin( pMem, 
180                               _fieldValue);
183 /*-------------------------------------------------------------------------*/
184 /*                              MT Sync                                    */
186 #ifdef OSG_MT_CPTR_ASPECT
187 template <class ValueT, Int32 iNamespace> inline
188 void SField<ValueT, iNamespace>::syncWith(Self &source)
190     setValue(source);
192 #endif
194 /*-------------------------------------------------------------------------*/
195 /*                              MT Sync                                    */
197 template <class ValueT, Int32 iNamespace> inline
198 bool SField<ValueT, iNamespace>::operator ==(const SField &source) const
200     return _fieldValue == source._fieldValue;
203 /*-------------------------------------------------------------------------*/
204 /*                              MT Sync                                    */
206 template <class ValueT, Int32 iNamespace> inline
207 void SField<ValueT, iNamespace>::operator =(const SField &source)
209     if(this != &source)
210     {
211         _fieldValue = source._fieldValue;
212     }
215 OSG_END_NAMESPACE