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

X3DProcessor.h

Go to the documentation of this file.
00001 
00002 //                            X3DProcessor.h                                  //
00004 
00005 #ifndef X3DPROCESSOR_H
00006 #define X3DPROCESSOR_H
00007 
00008 #include "GraphTraversal.h"
00009 
00010 #include <list>
00011 #include <typeinfo>
00012 
00013 #include <iostream>
00014 
00015 namespace X3DTK {
00016 
00018 
00019 class X3DProcessor
00020 {
00021 public:
00023   X3DProcessor();
00025   virtual ~X3DProcessor() = 0;
00026 
00028   template <class P>
00029   static P *getInstanceOf()
00030   {
00031     for (std::list<X3DProcessor *>::iterator it = _X3DProcessorList.begin(); it != _X3DProcessorList.end(); ++it)
00032     {
00033       if (typeid(*(*it)) == typeid(P))
00034         return static_cast<P *>(*it);       
00035     }
00036     P *p = new P();
00037     _X3DProcessorList.push_back(p);
00038     return p;
00039   };
00040 
00042   template <class P>
00043   static void removeInstanceOf()
00044   {
00045     for (std::list<X3DProcessor *>::iterator it = _X3DProcessorList.begin(); it != _X3DProcessorList.end(); ++it)
00046     {
00047       if (typeid(*(*it)) == typeid(P))
00048       {
00049         delete *it;
00050         _X3DProcessorList.erase(it);
00051         break;
00052       }  
00053     }
00054   };
00055   
00057   static void removeAllInstances();
00058   
00059 private:
00060   static std::list<X3DProcessor *> _X3DProcessorList;
00061 };
00062 
00063 }
00064 
00065 #endif

Generated on Thu Dec 4 13:25:50 2003 for X3DToolKit by doxygen1.2.18