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

OSGNewActionBase.cpp

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 //----------------------------------------------------------------------------
00040 //    Includes
00041 //----------------------------------------------------------------------------
00042 
00043 #include "OSGNewActionBase.h"
00044 
00045 #include "OSGActorBase.h"
00046 #include "OSGExtendActorBase.h"
00047 #include "OSGBasicActorBase.h"
00048 
00049 OSG_USING_NAMESPACE
00050 
00051 //----------------------------------------------------------------------------
00052 //    Description
00053 //----------------------------------------------------------------------------
00054 
00055 // Abstract function doc
00056 
00099 #ifdef OSG_NEWACTION_STATISTICS
00100 
00101 //----------------------------------------------------------------------------
00102 //    Statistics
00103 //----------------------------------------------------------------------------
00104 
00105 StatElemDesc<StatIntElem>
00106 NewActionBase::statNodesEnter("NewActionBase::nodesEnter",
00107                               "Number of nodes entered"   );
00108 StatElemDesc<StatIntElem>
00109 NewActionBase::statNodesLeave("NewActionBase::nodesLeave",
00110                               "Number of nodes left"      );
00111 
00112 
00113 #endif /* OSG_NEWACTION_STATISTICS */
00114 
00115 //----------------------------------------------------------------------------
00116 //    Destructor
00117 //----------------------------------------------------------------------------
00118 
00122 NewActionBase::~NewActionBase(void)
00123 {
00124 }
00125 
00126 //----------------------------------------------------------------------------
00127 //    Generic Actor Management
00128 //----------------------------------------------------------------------------
00129 
00143 UInt32
00144 NewActionBase::addActor(ActorBase *pActor)
00145 {
00146     return pActor->addHelper(this);
00147 }
00148 
00158 void
00159 NewActionBase::subActor(ActorBase *pActor)
00160 {
00161     pActor->subHelper(this);
00162 }
00163 
00176 UInt32
00177 NewActionBase::findActor(ActorBase *pActor) const
00178 {
00179     return pActor->findHelper(this);
00180 }
00181 
00185 UInt32
00186 NewActionBase::getNumActors(void) const
00187 {
00188     return _extendActors.size() + _basicActors.size();
00189 }
00190 
00191 //----------------------------------------------------------------------------
00192 //    Extend Actor Management
00193 //----------------------------------------------------------------------------
00194 
00201 UInt32
00202 NewActionBase::addExtendActor(ExtendActorBase *pActor)
00203 {
00204     return addExtendActor(pActor, _extendActors.size());
00205 }
00206 
00213 UInt32
00214 NewActionBase::addExtendActor(ExtendActorBase *pActor, UInt32 pos)
00215 {
00216     UInt32 actorId = getNumActors();
00217 
00218     pActor       ->addEvent      (this,                        actorId);
00219     _extendActors. insert        (_extendActors.begin() + pos, pActor );
00220     this         ->addExtendEvent(pActor,                      pos    );
00221 
00222     return pos;
00223 }
00224 
00229 void
00230 NewActionBase::subExtendActor(UInt32 pos)
00231 {
00232     ExtendActorStoreIt  itActor = _extendActors.begin() + pos;
00233     ExtendActorBase    *pActor  = *itActor;
00234 
00235     this  ->subExtendEvent(pActor, pos                 );
00236     pActor->subEvent      (this,   pActor->getActorId());
00237 
00238     _extendActors.erase(itActor);
00239 }
00240 
00246 UInt32
00247 NewActionBase::findExtendActor(ExtendActorBase *pActor) const
00248 {
00249     ExtendActorStoreConstIt itActors  = _extendActors.begin();
00250     ExtendActorStoreConstIt endActors = _extendActors.end  ();
00251 
00252     UInt32             pos       = 0;
00253     bool               found     = false;
00254 
00255     for(; (itActors != endActors) && !found; ++itActors, ++pos)
00256     {
00257         if(*itActors == pActor)
00258         {
00259             found = true;
00260             break;
00261         }
00262     }
00263 
00264     return (found ? pos : TypeTraits<UInt32>::getMax());
00265 }
00266 
00270 UInt32
00271 NewActionBase::getNumExtendActors(void) const
00272 {
00273     return _extendActors.size();
00274 }
00275 
00276 //----------------------------------------------------------------------------
00277 //    Basic Actor Management
00278 //----------------------------------------------------------------------------
00279 
00286 UInt32
00287 NewActionBase::addBasicActor(BasicActorBase *pActor)
00288 {
00289     return addBasicActor(pActor, _basicActors.size());
00290 }
00291 
00298 UInt32
00299 NewActionBase::addBasicActor(BasicActorBase *pActor, UInt32 pos)
00300 {
00301     UInt32 actorId = getNumActors();
00302 
00303     pActor      ->addEvent     (this,                       actorId);
00304     _basicActors. insert       (_basicActors.begin() + pos, pActor );
00305     this        ->addBasicEvent(pActor,                     pos    );
00306 
00307     return pos;
00308 }
00309 
00314 void
00315 NewActionBase::subBasicActor(UInt32 pos)
00316 {
00317     BasicActorStoreIt  itActor = _basicActors.begin() + pos;
00318     BasicActorBase    *pActor  = *itActor;
00319 
00320     this  ->subBasicEvent(pActor, pos                 );
00321     pActor->subEvent     (this,   pActor->getActorId());
00322 
00323     _basicActors.erase(itActor);
00324 }
00325 
00331 UInt32
00332 NewActionBase::findBasicActor(BasicActorBase *pActor) const
00333 {
00334     BasicActorStoreConstIt itActors  = _basicActors.begin();
00335     BasicActorStoreConstIt endActors = _basicActors.end  ();
00336 
00337     UInt32            pos       = 0;
00338     bool              found     = false;
00339 
00340     for(; (itActors != endActors) && !found; ++itActors, ++pos)
00341     {
00342         if(*itActors == pActor)
00343             found = true;
00344     }
00345 
00346     return (found ? pos : TypeTraits<UInt32>::getMax());
00347 }
00348 
00352 UInt32
00353 NewActionBase::getNumBasicActors(void) const
00354 {
00355     return _basicActors.size();
00356 }
00357 
00358 //----------------------------------------------------------------------------
00359 //    Constructor
00360 //----------------------------------------------------------------------------
00361 
00362 NewActionBase::NewActionBase(void)
00363     : _extendActors       (                           ),
00364       _basicActors        (                           ),
00365 #ifdef OSG_NEWACTION_STATISTICS
00366       _pStatistics        (NULL                       ),
00367       _ownStatistics      (false                      ),
00368 #endif /* OSG_NEWACTION_STATISTICS */
00369       _travMask           (TypeTraits<UInt32>::BitsSet),
00370       _numPasses          (1                          ),
00371       _childrenListEnabled(false                      ),
00372       _childrenList       (                           ),
00373       _extraChildrenList  (                           )
00374 {
00375 }
00376 
00377 //----------------------------------------------------------------------------
00378 //    Events
00379 //----------------------------------------------------------------------------
00380 
00385 void
00386 NewActionBase::startEvent(void)
00387 {
00388 #ifdef OSG_NEWACTION_STATISTICS
00389     if(_pStatistics == NULL)
00390     {
00391         _pStatistics   = StatCollector::create();
00392         _ownStatistics = true;
00393     }
00394     else
00395     {
00396         _ownStatistics = false;
00397     }
00398 
00399     getStatistics()->getElem(statNodesEnter)->reset();
00400     getStatistics()->getElem(statNodesLeave)->reset();
00401 #endif /* OSG_NEWACTION_STATISTICS */
00402 }
00403 
00408 void
00409 NewActionBase::stopEvent(void)
00410 {
00411 #ifdef OSG_NEWACTION_STATISTICS
00412     if(_ownStatistics == true)
00413     {
00414         delete _pStatistics;
00415         _pStatistics = NULL;
00416     }
00417 #endif /* OSG_NEWACTION_STATISTICS */
00418 }
00419 
00420 //----------------------------------------------------------------------------
00421 //    Actor Access
00422 //----------------------------------------------------------------------------
00423 
00424 NewActionBase::ResultE
00425 NewActionBase::startActors(void)
00426 {
00427     ResultE            result      = NewActionTypes::Continue;
00428 
00429     ExtendActorStoreIt itExtend    = beginExtend();
00430     ExtendActorStoreIt endItExtend = endExtend  ();
00431 
00432     for(; (itExtend != endItExtend         ) &&
00433          !(result   &  NewActionTypes::Quit);    ++itExtend)
00434     {
00435         result = (*itExtend)->start();
00436     }
00437 
00438     BasicActorStoreIt itBasic    = beginBasic();
00439     BasicActorStoreIt endItBasic = endBasic  ();
00440 
00441     for(;  (itBasic != endItBasic          ) &&
00442           !(result  &  NewActionTypes::Quit);    ++itBasic)
00443     {
00444         result = (*itBasic)->start();
00445     }
00446 
00447     return result;
00448 }
00449 
00450 NewActionBase::ResultE
00451 NewActionBase::stopActors(void)
00452 {
00453     ResultE            result      = NewActionTypes::Continue;
00454 
00455     ExtendActorStoreIt itExtend    = beginExtend();
00456     ExtendActorStoreIt endItExtend = endExtend  ();
00457 
00458     for(; (itExtend != endItExtend         ) &&
00459          !(result   &  NewActionTypes::Quit);    ++itExtend)
00460     {
00461         result = (*itExtend)->stop();
00462     }
00463 
00464     BasicActorStoreIt itBasic    = beginBasic();
00465     BasicActorStoreIt endItBasic = endBasic  ();
00466 
00467     for(;  (itBasic != endItBasic          ) &&
00468           !(result  &  NewActionTypes::Quit);    ++itBasic)
00469     {
00470         result = (*itBasic)->stop();
00471     }
00472 
00473     return result;
00474 }
00475 
00476 /*------------------------------------------------------------------------*/
00477 /*                              cvs id's                                  */
00478 
00479 #ifdef OSG_SGI_CC
00480 #pragma set woff 1174
00481 #endif
00482 
00483 #ifdef OSG_LINUX_ICC
00484 #pragma warning(disable : 177)
00485 #endif
00486 
00487 namespace
00488 {
00489     static Char8 cvsid_cpp       [] = "@(#)$Id: OSGNewActionBase.cpp,v 1.3 2005/03/31 19:50:57 dirk Exp $";
00490     static Char8 cvsid_hpp       [] = OSGNEWACTIONBASE_HEADER_CVSID;
00491     static Char8 cvsid_inl       [] = OSGNEWACTIONBASE_INLINE_CVSID;
00492 }
00493 
00494 #ifdef OSG_LINUX_ICC
00495 #pragma warning(enable : 177)
00496 #endif
00497 
00498 #ifdef OSG_SGI_CC
00499 #pragma reset woff 1174
00500 #endif

Generated on Thu Aug 25 04:07:55 2005 for OpenSG by  doxygen 1.4.3