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

OSGDepthFirstStateAction.h

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 #ifndef _OSGDEPTHFIRSTSTATEACTION_H_
00040 #define _OSGDEPTHFIRSTSTATEACTION_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044 
00045 //----------------------------------------------------------------------------
00046 //    Includes
00047 //----------------------------------------------------------------------------
00048 
00049 #include <OSGConfig.h>
00050 #include <OSGSystemDef.h>
00051 
00052 #include "OSGNewActionBase.h"
00053 #include "OSGActorBase.h"
00054 
00055 #include <deque>
00056 #include <list>
00057 
00058 OSG_BEGIN_NAMESPACE
00059 
00060 class ExtendActorBase;
00061 class BasicActorBase;
00062 
00063 class OSG_SYSTEMLIB_DLLMAPPING DepthFirstStateAction : public NewActionBase
00064 {
00065     /*==== PUBLIC ===========================================================*/
00066   public:
00067 #ifdef OSG_NEWACTION_STATISTICS
00068     /*-----------------------------------------------------------------------*/
00072     static StatElemDesc<StatIntElem> statStateClones;
00073     static StatElemDesc<StatIntElem> statStateRestores;
00074 
00076 #endif /* OSG_NEWACTION_STATISTICS */
00077     /*-----------------------------------------------------------------------*/
00081     virtual ~DepthFirstStateAction(void);
00082 
00084     /*-----------------------------------------------------------------------*/
00088     static DepthFirstStateAction *create(void);
00089 
00091     /*-----------------------------------------------------------------------*/
00095     virtual ResultE apply(NodePtr pRoot);
00096 
00098     /*==== PROTECTED ========================================================*/
00099   protected:
00100     /*-----------------------------------------------------------------------*/
00104     DepthFirstStateAction(void);
00105 
00107     /*-----------------------------------------------------------------------*/
00111     virtual void addExtendEvent     (ExtendActorBase *pActor,
00112                                      UInt32           actorIndex);
00113     virtual void subExtendEvent     (ExtendActorBase *pActor,
00114                                      UInt32           actorIndex);
00115 
00116     virtual void addBasicEvent      (BasicActorBase  *pActor,
00117                                      UInt32           actorIndex);
00118     virtual void subBasicEvent      (BasicActorBase  *pActor,
00119                                      UInt32           actorIndex);
00120 
00121     virtual void startEvent         (void                       );
00122     virtual void stopEvent          (void                       );
00123 
00124     virtual void beginEditStateEvent(ActorBase       *pActor,
00125                                      UInt32           actorId   );
00126     virtual void endEditStateEvent  (ActorBase       *pActor,
00127                                      UInt32           actorId   );
00128 
00130     /*==== PRIVATE ==========================================================*/
00131   private:
00132     /*-----------------------------------------------------------------------*/
00136     typedef NewActionBase             Inherited;
00137     typedef ActorBase::ActorBaseState ActorBaseState;
00138 
00139 #ifdef OSG_NEWACTION_STATESLOTINTERFACE
00140 
00141     class StateRefCount
00142     {
00143       public:
00144         inline          StateRefCount(const StateRefCount &source    );
00145 
00146         inline explicit StateRefCount(      UInt32         stateSlot );
00147         inline explicit StateRefCount(      UInt32         stateSlot,
00148                                             Int32          refCount  );
00149 
00150         inline UInt32 getStateSlot(void            ) const;
00151         inline void   setStateSlot(UInt32 stateSlot);
00152 
00153         inline Int32  getRefCount (void            ) const;
00154         inline void   incRefCount (Int32  inc      );
00155         inline void   decRefCount (Int32  dec      );
00156 
00157       private:
00158         UInt32 _stateSlot;
00159         Int32  _refCount;
00160     };
00161 
00162 #else /* OSG_NEWACTION_STATESLOTINTERFACE */
00163 
00164     typedef std::list<ActorBaseState *> StateStore;
00165     typedef StateStore::iterator        StateStoreIt;
00166     typedef StateStore::const_iterator  StateStoreConstIt;
00167 
00168     class StateRefCount
00169     {
00170       public:
00171         inline          StateRefCount(const StateRefCount &source  );
00172 
00173         inline explicit StateRefCount(const StateStoreIt  &itState );
00174         inline explicit StateRefCount(const StateStoreIt  &itState,
00175                                             Int32          refCount);
00176 
00177         inline StateStoreIt getState(      void                 ) const;
00178         inline void         setState(const StateStoreIt &itState);
00179 
00180         inline Int32        getRefCount(void         ) const;
00181         inline void         incRefCount(Int32 inc = 1);
00182         inline void         decRefCount(Int32 dec = 1);
00183 
00184       private:
00185         StateStoreIt _itState;
00186         Int32        _refCount;
00187     };
00188 
00189 #endif /* OSG_NEWACTION_STATESLOTINTERFACE */
00190 
00191     typedef std::list<StateRefCount>           StateRefCountStore;
00192     typedef StateRefCountStore::iterator       StateRefCountStoreIt;
00193     typedef StateRefCountStore::const_iterator StateRefCountStoreConstIt;
00194 
00195     class NodeStackEntry
00196     {
00197       public:
00198         inline NodeStackEntry(      void                                  );
00199         inline NodeStackEntry(const NodeStackEntry       &source          );
00200         inline NodeStackEntry(const NodePtr              &pNode,
00201                               const StateRefCountStoreIt &itStateRefCount,
00202                                     Int32                 passCount       );
00203 
00204         inline NodePtr getNode     (void           ) const;
00205 
00206         inline Int32   getPassCount(void           ) const;
00207         inline void    setPassCount(Int32 passCount);
00208 
00209         inline StateRefCountStoreIt getStateRefCount(void          ) const;
00210         inline void setStateRefCount(const StateRefCountStoreIt &itStateRefCount);
00211 
00212       private:
00213         NodePtr              _pNode;
00214         StateRefCountStoreIt _itStateRefCount;
00215         Int32                _passCount;
00216     };
00217 
00218     typedef std::deque<NodeStackEntry> NodeStack;
00219 
00221     /*-----------------------------------------------------------------------*/
00225            ResultE traverseEnter     (      void                          );
00226            ResultE traverseEnterLeave(      void                          );
00227 
00228            void    pushChildren      (const NodePtr &pNode, ResultE result);
00229 
00230     inline ResultE enterNode         (const NodePtr &pNode, UInt32  pass  );
00231     inline ResultE leaveNode         (const NodePtr &pNode, UInt32  pass  );
00232 
00233     inline StateRefCountStoreIt cloneState(void                                );
00234     inline StateRefCountStoreIt getState  (void                                );
00235     inline void                 setState  (StateRefCountStoreIt itStateRefCount);
00236 
00237     inline void incRefCount(StateRefCountStoreIt itStateRefCount, Int32 inc = 1);
00238     inline void decRefCount(StateRefCountStoreIt itStateRefCount, Int32 dec = 1);
00239 
00241     /*-----------------------------------------------------------------------*/
00242 
00243     NodeStack            _nodeStack;
00244     StateRefCountStore   _stateRefCountStore;
00245 
00246 #ifndef OSG_NEWACTION_STATESLOTINTERFACE
00247     StateStore           _stateStore;
00248 #endif
00249 
00250     StateRefCountStoreIt _itInitialState;
00251     StateRefCountStoreIt _itActiveState;
00252 
00253     bool                 _stateClonedFlag;
00254 
00255     ExtendActorStore     _extendEnterActors;
00256     ExtendActorStore     _extendLeaveActors;
00257 
00258     BasicActorStore      _basicEnterActors;
00259     BasicActorStore      _basicLeaveActors;
00260 };
00261 
00262 OSG_END_NAMESPACE
00263 
00264 #include "OSGDepthFirstStateAction.inl"
00265 
00266 #define OSGDEPTHFIRSTSTATEACTION_HEADER_CVSID "@(#)$Id: OSGDepthFirstStateAction.h,v 1.2 2004/09/17 14:09:42 neumannc Exp $"
00267 
00268 #endif /* _OSGDEPTHFIRSTSTATEACTION_H_ */

Generated on Thu Aug 25 04:02:47 2005 for OpenSG by  doxygen 1.4.3