diff --git a/vcg/container/container_allocation_table.h b/vcg/container/container_allocation_table.h index 0b970972..5cdef982 100644 --- a/vcg/container/container_allocation_table.h +++ b/vcg/container/container_allocation_table.h @@ -24,11 +24,14 @@ History $Log: not supported by cvs2svn $ +Revision 1.9 2006/12/03 18:01:01 ganovelli +versione compliant vs2005 + Revision 1.8 2006/06/08 20:28:57 ganovelli aggiunto qualche const sui parametri Revision 1.7 2005/10/15 16:21:48 ganovelli -Working release (compilata solo su MSVC), vector_occ è migrato da component_opt +Working release (compilata solo su MSVC), vector_occ � migrato da component_opt Revision 1.6 2005/07/07 13:33:51 ganovelli some comment @@ -59,8 +62,8 @@ First Working Release (with this comment) 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 kepth in memory. + * 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. * The goal is to know (given a pointer to a memory location), which is the vector the pointed * element is in * @@ -69,7 +72,7 @@ namespace vcg { template class CATBase{ public: -typedef typename typename STL_CONT::value_type ValueType; +typedef typename STL_CONT::value_type ValueType; virtual void Resort(ValueType*,ValueType*) =0; virtual void Remove(const STL_CONT&) = 0; @@ -89,8 +92,8 @@ static int & Id(){ template class CATEntry: public CATBase{ public: -typedef typename typename STL_CONT::value_type ValueType; -typedef typename ENTRY_TYPE EntryType; +typedef typename STL_CONT::value_type ValueType; +typedef ENTRY_TYPE EntryType; CATEntry(){if(Id()==0){ Id() = CATBase::Id()+1; @@ -131,7 +134,7 @@ static ValueType *& Upper() { } static typename std::list::iterator & Curr(){ // container that was last accessed - static std::list::iterator currEntry; + static typename std::list::iterator currEntry; return currEntry; } @@ -168,7 +171,7 @@ typename std::list::iterator CATEntry:: FindBase(const ValueType * pt) { -std::list::iterator ite,curr_base,_; +typename std::list::iterator ite,curr_base,_; ite = AT().begin(); curr_base = AT().end(); @@ -196,7 +199,7 @@ void CATEntry< STL_CONT, ENTRY_TYPE>:: Update(const ValueType * pt) { if(!IsTheSameAsLast(pt)){ - std::list::iterator lower_ite,upper_ite; + typename std::list::iterator lower_ite,upper_ite; lower_ite = FindBase(pt); assert( lower_ite!=AT().end()); @@ -228,7 +231,7 @@ void CATEntry:: Remove( const STL_CONT & c ) { -std::list::iterator ite; +typename std::list::iterator ite; for(ite = AT().begin(); ite != AT().end(); ++ite) if((*ite).C() == &c) { @@ -243,7 +246,7 @@ void CATEntry:: RemoveIfEmpty( const STL_CONT & c ) { -std::list::iterator ite; +typename std::list::iterator ite; for(ite = AT().begin(); ite != AT().end(); ++ite) if((*ite).C() == &c) if(!(*ite).Empty()) @@ -256,7 +259,7 @@ void CATEntry:: Remove(ValueType * pt) { - std::list::iterator lower_ite; + typename std::list::iterator lower_ite; lower_ite = FindBase(pt); AT().erase(lower_ite); UTD() = false; @@ -269,7 +272,7 @@ void CATEntry:: Insert( STL_CONT & c,bool cond ) { ENTRY_TYPE entry(c); -std::list::iterator lower_ite,upper_ite; +typename std::list::iterator lower_ite,upper_ite; upper_ite = FindBase( c.Pointer2begin()); bool isIn = (upper_ite != AT().end()); if(isIn){ @@ -314,7 +317,8 @@ Curr()->Resize(n); //-------------------------------------------------------------------------------------------- template class CAT:public CATEntry >{ -typedef typename typename STL_CONT::value_type ValueType; +typedef typename STL_CONT::value_type ValueType; +typedef CATEntry > TT; public: static ATTR_TYPE & Get(const ValueType * pt); static CAT * New(); @@ -327,8 +331,8 @@ 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 Curr()->Data()[ord]; +//int ord = pt- &(* ((*AT().begin()).C()->begin())); se AT() contiene un solo elemento funziona anche cos +return TT::Curr()->Data()[ord]; } template @@ -344,7 +348,24 @@ New(){ //--------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------- +// TempData implements a handle to one of the vector od data stored in EntryCATMulti +template +class TempData{ +public: + TempData(std::vector *d):item(d){}; + typedef ATTR_TYPE attr_type; + + std::vector * Item(){return item;}; + std::vector * item; + ATTR_TYPE & operator []( typename STL_CONT::value_type * v) + { + int pos = CATEntry >::Ord(v); + return (*item)[pos]; + } + }; +//---------------------------------------------------------------------------------- };//end namespace vcg -#endif \ No newline at end of file +#endif diff --git a/vcg/container/entries_allocation_table.h b/vcg/container/entries_allocation_table.h index b0d2839d..78803822 100644 --- a/vcg/container/entries_allocation_table.h +++ b/vcg/container/entries_allocation_table.h @@ -25,6 +25,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.7 2007/01/18 01:31:12 cignoni +Many small syntax changes for mac compiling + Revision 1.6 2006/12/03 18:01:01 ganovelli versione compliant vs2005 @@ -42,6 +45,7 @@ First Working Release (with this comment) #ifndef __VCGLIB_ENTRIES__ #define __VCGLIB_ENTRIES__ + namespace vcg { // EntryCATBase: base class for the entry of the allocation table @@ -145,25 +149,8 @@ private: //---------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------- -// TempData implements a handle to one of the vector od data stored in EntryCATMulti -template -class TempData{ -public: - TempData(std::vector *d):item(d){}; - typedef ATTR_TYPE attr_type; - - std::vector * Item(){return item;}; - std::vector * item; - ATTR_TYPE & operator []( typename STL_CONT::value_type * v) - { - int pos = CATEntry >::Ord(v); - return (*item)[pos]; - } - }; -//---------------------------------------------------------------------------------- }; // end namespace vcg -#endif \ No newline at end of file +#endif diff --git a/vcg/container/vector_occ.h b/vcg/container/vector_occ.h index 659de935..a713d0b7 100644 --- a/vcg/container/vector_occ.h +++ b/vcg/container/vector_occ.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.4 2006/12/04 11:11:07 ganovelli +add const to IsEnabledAttribute + Revision 1.3 2006/12/03 18:01:01 ganovelli versione compliant vs2005 @@ -31,7 +34,7 @@ Revision 1.2 2006/06/08 20:28:38 ganovelli Corretto IsEnabledAttribute Revision 1.1 2005/10/15 16:21:49 ganovelli -Working release (compilata solo su MSVC), vector_occ è migrato da component_opt +Working release (compilata solo su MSVC), vector_occ � migrato da component_opt Revision 1.5 2005/07/07 13:33:52 ganovelli some comment @@ -56,7 +59,7 @@ First Working Release (with this comment) namespace vcg { /*@{*/ /*! - * This class represent a Traced Vector. A vector_occ is derived by a std::vector. + * This class represent a vector_occ. A vector_occ is derived by a std::vector. * The characteristic of a vector_occ is that you can add (at run time) new attributes * to the container::value_type elements contained in the vector. (see the example..) * The position in memory of a traced vector is kept by the Container Allocation Table, @@ -65,14 +68,15 @@ namespace vcg { template class vector_occ: public std::vector{ - typedef typename vector_occ ThisType; + typedef vector_occ ThisType; + typedef std::vector TT; public: vector_occ():std::vector(){id = ID(); ID()=ID()+1; reserve(1);} ~vector_occ(); VALUE_TYPE * Pointer2begin(){ - if(empty()) return (VALUE_TYPE *)id; else return &*std::vector::begin(); + if(TT::empty()) return (VALUE_TYPE *)id; else return &*std::vector::begin(); } std::list < CATBase* > attributes; // override di tutte le funzioni che possono spostare @@ -94,7 +98,7 @@ public: /// Note: once an attribute is disabled, its data is lost (the memory freed) template bool IsEnabledAttribute() const{ - std::list < CATBase * >::const_iterator ia; + typename std::list < CATBase * >::const_iterator ia; for(ia = attributes.begin(); ia != attributes.end(); ++ia) if((*ia)->Id() == CAT::Id()) return true; @@ -106,7 +110,7 @@ public: /// Note: once an attribute is disabled, its data is lost (the memory freed) template void DisableAttribute(){ - std::list < CATBase * >::iterator ia; + typename std::list < CATBase * >::iterator ia; for(ia = attributes.begin(); ia != attributes.end(); ++ia) if((*ia)->Id() == CAT::Id()) { @@ -131,8 +135,8 @@ public: EntryTypeMulti entry = CATEntry::GetEntry(Pointer2begin()); entry.Data().push_back(new Wrap< ATTR_TYPE>); - ((Wrap*)entry.Data().back())->reserve(capacity()); - ((Wrap*)entry.Data().back())->resize(size()); + ((Wrap*)entry.Data().back())->reserve(TT::capacity()); + ((Wrap*)entry.Data().back())->resize(TT::size()); return TempData((Wrap*) entry.Data().back()); } @@ -163,7 +167,7 @@ template void vector_occ::push_back(const VALUE_TYPE & v){ std::vector::push_back(v); Update(); - std::list < CATBase * >::iterator ia; + typename std::list < CATBase * >::iterator ia; for(ia = attributes.begin(); ia != attributes.end(); ++ia) (*ia)->AddDataElem(&(*(this->begin())),1); @@ -178,7 +182,7 @@ template void vector_occ::resize(const unsigned int & size){ std::vector::resize(size); Update(); - std::list < CATBase * >::iterator ia; + typename std::list < CATBase * >::iterator ia; for(ia = attributes.begin(); ia != attributes.end(); ++ia) (*ia)-> Resize(&(*(this->begin())),size); @@ -193,7 +197,7 @@ void vector_occ::reserve(const unsigned int & size){ template void vector_occ:: Update(){ - std::list < CATBase * >::iterator ia; + typename std::list < CATBase * >::iterator ia; if(Pointer2begin() != old_start) for(ia = attributes.begin(); ia != attributes.end(); ++ia) (*ia)->Resort(old_start,Pointer2begin()); @@ -205,7 +209,7 @@ template template vector_occ::~vector_occ(){ - std::list < CATBase * >::iterator ia; + typename std::list < CATBase * >::iterator ia; for(ia = attributes.begin(); ia != attributes.end(); ++ia) { (*ia)->Remove(*this);