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

OSGAction.inl

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *                 Copyright (C) 2000 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 //---------------------------------------------------------------------------
00040 //  Includes
00041 //---------------------------------------------------------------------------
00042 
00043 
00044 #include <stdlib.h>
00045 #include <stdio.h>
00046 
00047 #include "OSGConfig.h"
00048 
00049 #include <OSGNode.h>
00050 #include <OSGNodeCore.h>
00051 
00052 OSG_BEGIN_NAMESPACE
00053 
00054 
00055 inline NodePtr Action::getActNode( void )
00056 {
00057     return _actNode;
00058 }
00059 
00060     
00061 inline void Action::setActNode(NodePtr node)
00062 {
00063     _actNode = node;
00064 }
00065 
00066 inline
00067 const NodePtr Action::getNode( int index )
00068 {
00069     if ( ! _actList )
00070     {
00071         return _actNode->getChild( index );
00072     }
00073     else
00074     {
00075         return (*_actList)[ index ];
00076     }
00077 }
00078 
00079 inline
00080 void Action::addNode( NodePtr node )
00081 {
00082     _newList.push_back( node );
00083 }
00084 
00085 inline
00086 void Action::useNodeList( void )
00087 {
00088     _useNewList = true;
00089 }
00090 
00091 inline
00092 UInt32 Action::getNNodes( void ) const
00093 {
00094     if ( ! _actList )
00095     {
00096         return _actNode->getNChildren();
00097     }
00098     else
00099     {
00100         return (*_actList).size();
00101     }
00102 }
00103 
00104 
00105 inline
00106 UInt32 Action::getTravMask(void) const
00107 {
00108     return _travMask;
00109 }
00110 
00111 inline
00112 void Action::setTravMask(UInt32 val)
00113 {
00114     _travMask = val;
00115 }
00116 
00117 /*-------------------------- your_category---------------------------------*/
00118 
00119 // callEnter/callLeave: call the right functor. If the type is unknown and new
00120 // (i.e. its index is larger than the vector) try to find the function in the
00121 // default list.
00122 
00123 inline
00124 Action::ResultE Action::callEnter( NodePtr node )
00125 {
00126     ResultE result;
00127 
00128     UInt32 uiFunctorIndex = node->getCore()->getType().getId();
00129     CNodePtr cnode(node);
00130 
00131     if ( uiFunctorIndex < _enterFunctors.size() )
00132         result = _enterFunctors[uiFunctorIndex].call(cnode,this);
00133     else if (  getDefaultEnterFunctors() &&
00134                 uiFunctorIndex < getDefaultEnterFunctors()->size() )
00135     {
00136         // field container registered method after this action was instantiated
00137         // copy the new functors from default vector
00138         std::vector<Functor> *defaultEnter = getDefaultEnterFunctors();
00139 
00140         while ( defaultEnter->size() > _enterFunctors.size() )
00141         {
00142             _enterFunctors.push_back( (*defaultEnter)[_enterFunctors.size()] );
00143         }
00144         result = _enterFunctors[uiFunctorIndex].call(cnode,this);
00145     }
00146     else // unknown field container
00147         result = _defaultEnterFunction(cnode,this);
00148 
00149     return result;
00150 }
00151 
00152 inline
00153 Action::ResultE Action::callLeave( NodePtr node )
00154 {
00155     ResultE result;
00156 
00157     UInt32 uiFunctorIndex = node->getCore()->getType().getId();
00158     CNodePtr cnode(node);
00159 
00160     if ( uiFunctorIndex < _leaveFunctors.size() )
00161         result = _leaveFunctors[uiFunctorIndex].call(cnode,this);
00162     else if (   getDefaultLeaveFunctors() &&
00163                 uiFunctorIndex < getDefaultLeaveFunctors()->size() )
00164     {
00165         // field container registered method after this action was instantiated
00166         // copy the new functors from default vector
00167         std::vector<Functor> *defaultLeave = getDefaultLeaveFunctors();
00168 
00169         while ( defaultLeave->size() > _leaveFunctors.size() )
00170         {
00171             _leaveFunctors.push_back( (*defaultLeave)[_leaveFunctors.size()] );
00172         }
00173         result = _leaveFunctors[uiFunctorIndex].call(cnode,this);
00174     }
00175     else // unknown field container
00176         result = _defaultLeaveFunction(cnode,this);
00177 
00178     return result;
00179 }
00180 
00181 /*-------------------------- assignment -----------------------------------*/
00182 
00187 /*-------------------------- comparison -----------------------------------*/
00188 
00202 /*-------------------------------------------------------------------------*\
00203  -  protected                                                              -
00204 \*-------------------------------------------------------------------------*/
00205 
00206 
00207 
00208 /*-------------------------------------------------------------------------*\
00209  -  private                                                                -
00210 \*-------------------------------------------------------------------------*/
00211 
00212 OSG_END_NAMESPACE
00213 
00217 //:  Example for the head comment of a function
00220 //p: Paramaters:
00221 //p:
00223 //g: GlobalVars:
00224 //g:
00226 //r: Return:
00227 //r:
00229 //c: Caution:
00230 //c:
00232 //a: Assumptions:
00233 //a:
00235 //d: Description:
00236 //d:
00238 //s: SeeAlso:
00239 //s:
00241 

Generated on Thu Aug 25 04:00:59 2005 for OpenSG by  doxygen 1.4.3