Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

c:/home/kevn/src/animaniac/ani/Dynamics/operators/GlobalOperator.h

Go to the documentation of this file.
00001 #ifndef GLOBAL_OPERATOR
00002 #define GLOBAL_OPERATOR
00003 
00004 #include <boost/smart_ptr.hpp>
00005 #include <gmtl/Vec.h>
00006 #include "ani/Dynamics/Operator.h"
00007 #include "ani/Dynamics/DynamicSystem.h"
00008 
00009 namespace ani
00010 {
00012    template<class __EntityType>
00013    class GlobalOperator : public ani::Operator<__EntityType>
00014    {
00015    public:
00016       typedef boost::shared_ptr<__EntityType> EntityTypePtr;
00017 
00018    public:
00019       GlobalOperator() : mIgnoreList() {}
00020       virtual ~GlobalOperator() {}
00021       void ignore( EntityTypePtr p )
00022       {
00023          assert( p->isInSystem() == true && "can't ignore particles not in the system" );
00024          mIgnoreList.push_back( p );
00025          assert( this->isIgnored( p ) == true && "sanity check, it is really in the list now?");
00026       }
00027       
00031       bool isIgnored( EntityTypePtr p )
00032       {
00033          // bool found = false;
00034          std::vector<EntityTypePtr>::iterator it;
00035          std::list< std::vector<EntityTypePtr>::iterator > toKill;
00036          for (it = mIgnoreList.begin(); it != mIgnoreList.end(); ++it)
00037          {
00038             if ((*it)->isInSystem() == false)
00039             {
00040                toKill.push_back( it );
00041             }
00042 
00043             EntityTypePtr crap = (*it);
00044             if (crap == p )
00045             {
00046                return true;
00047             }
00048          }
00049 
00050          if (toKill.size() > 0)
00051          {
00052             std::list< std::vector<EntityTypePtr>::iterator >::iterator kit;
00053             for (kit = toKill.begin(); kit != toKill.end(); ++kit)
00054             {
00055                mIgnoreList.erase( (*kit) );
00056             }
00057          }
00058          return false;
00059       }
00060    protected:
00061       std::vector<EntityTypePtr> mIgnoreList;
00062    };
00063 } // end of namespace
00064 
00065 #endif

Generated on Wed Jun 12 01:54:01 2002 for Animaniac by doxygen1.2.15