Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGSingleFunctorStore.inl

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-2002 by the OpenSG Forum                   *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 OSG_BEGIN_NAMESPACE
00040 
00041 /*-------------------------------------------------------------------------*/
00042 /*    Constructors                                                         */
00043 
00044 inline
00045 SingleFunctorStore::SingleFunctorStore(void)
00046     : _uiTypeId          (0    ),
00047       _func              (     ),
00048       _defaultFunc       (     ),
00049       _bHasFunctor       (false),
00050       _bHasDefaultFunctor(false)
00051 {
00052 }
00053 
00054 /*-------------------------------------------------------------------------*/
00055 /*    Destructor                                                           */
00056 
00057 inline
00058 SingleFunctorStore::~SingleFunctorStore(void)
00059 {
00060 }
00061 
00062 /*-------------------------------------------------------------------------*/
00063 /*    Empty                                                                */
00064 
00065 inline bool
00066 SingleFunctorStore::empty(void) const
00067 {
00068     return _bHasFunctor | _bHasDefaultFunctor;
00069 }
00070 
00071 /*-------------------------------------------------------------------------*/
00072 /*    Functor Registration                                                 */
00073 
00074 inline void
00075 SingleFunctorStore::regFunctor(
00076     const Functor &refFunc, const FieldContainerType &refType)
00077 {
00078     _uiTypeId    = refType.getId();
00079     _func        = refFunc;
00080     _bHasFunctor = true;
00081 }
00082 
00083 inline void
00084 SingleFunctorStore::unregFunctor(void)
00085 {
00086     _bHasFunctor = false;
00087 }
00088 
00089 inline void
00090 SingleFunctorStore::regDefaultFunctor(const Functor &refFunc)
00091 {
00092     _defaultFunc        = refFunc;
00093     _bHasDefaultFunctor = true;
00094 }
00095 
00096 inline void
00097 SingleFunctorStore::unregDefaultFunctor(void)
00098 {
00099     _bHasDefaultFunctor = false;
00100 }
00101 
00102 /*-------------------------------------------------------------------------*/
00103 /*    Functor Access                                                       */
00104 
00105 inline SingleFunctorStore::Functor *
00106 SingleFunctorStore::getFunctor(const FieldContainerType &refType)
00107 {
00108     Functor *pRetFunc = NULL;
00109 
00110     if(_bHasFunctor && (refType.getId() == _uiTypeId))
00111     {
00112         pRetFunc = &_func;
00113     }
00114     else if(_bHasDefaultFunctor)
00115     {
00116         pRetFunc = &_defaultFunc;
00117     }
00118 
00119     return pRetFunc;
00120 }
00121 
00122 inline SingleFunctorStore::Functor *
00123 SingleFunctorStore::getDefaultFunctor(void)
00124 {
00125     if(_bHasDefaultFunctor)
00126     {
00127         return &_defaultFunc;
00128     }
00129     else
00130     {
00131         return NULL;
00132     }
00133 }
00134 
00135 OSG_END_NAMESPACE
00136 
00137 #define OSGSINGLEFUNCTORSTORE_INLINE_CVSID "@(#)$Id: OSGSingleFunctorStore.inl,v 1.4 2004/04/20 13:47:08 neumannc Exp $"

Generated on Thu Aug 25 04:10:17 2005 for OpenSG by  doxygen 1.4.3