diff --git a/vcg/container/container_allocation_table.h b/vcg/container/container_allocation_table.h index c0c190c2..6fd8829c 100644 --- a/vcg/container/container_allocation_table.h +++ b/vcg/container/container_allocation_table.h @@ -26,14 +26,20 @@ #define __VCGLIB_CAT__ #include +#include +#include #include #include #include #include - namespace vcg { /*@{*/ + + + + + /*! * CATBase is the abstract class for all the allocation tables. These table keep track of * where the traced vector (see traced_ector.h) are kept in memory. @@ -42,8 +48,14 @@ namespace vcg { * */ + struct CATBaseBase{ + + }; + + + template -class CATBase{ + class CATBase: public CATBaseBase{ public: typedef typename STL_CONT::value_type ValueType; @@ -304,17 +316,34 @@ ATTR_TYPE & CAT:: Get(const ValueType * pt) { int ord = Ord(pt); -//int ord = pt- &(* ((*AT().begin()).C()->begin())); se AT() contiene un solo elemento funziona anche cos return TT::Curr()->Data()[ord]; } +struct Env{ + + static std::map< std::string,CATBaseBase *> & TypeNameBounds(){ + static std::map< std::string,CATBaseBase *> ntb; return ntb;} + + template + static CAT * newCAT(){ + std::string n = std::string(typeid(TYPE_1).name())+std::string(typeid(TYPE_2).name()); + std::map< std::string,CATBaseBase *>::iterator ti = TypeNameBounds().find(n); + if(ti == TypeNameBounds().end()){ + CAT * res = new CAT(); + TypeNameBounds().insert(std::pair(n,res)); + return res; + } + else (CAT *) (*ti).second; + } +}; + template CAT * CAT:: - New(){ if(Instance()==NULL) { - Instance() = new CAT(); +// Instance() = new CAT(); + Instance() = Env::newCAT(); } return Instance(); }