Aggiunto typename
This commit is contained in:
parent
ad6d5c2bed
commit
a1a41a9718
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.3 2004/03/31 22:36:44 ganovelli
|
||||||
|
First Working Release (with this comment)
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
#ifndef __VCGLIB_TRACED_VECTOR__
|
#ifndef __VCGLIB_TRACED_VECTOR__
|
||||||
|
@ -31,20 +34,22 @@ $Log: not supported by cvs2svn $
|
||||||
|
|
||||||
|
|
||||||
#include <vcg/container/container_allocation_table.h>
|
#include <vcg/container/container_allocation_table.h>
|
||||||
|
#include <vcg/container/entries_allocation_table.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
|
|
||||||
template <class VALUE_TYPE>
|
template <class VALUE_TYPE>
|
||||||
class TVector: public std::vector<VALUE_TYPE>{
|
class TVector: public std::vector<VALUE_TYPE>{
|
||||||
typedef TVector<VALUE_TYPE> THIS_TYPE;
|
typedef typename TVector<VALUE_TYPE> ThisType;
|
||||||
typedef typename CATEntry<THIS_TYPE,EntryCATMulti<THIS_TYPE> >::EntryType EntryTypeMulti;
|
|
||||||
public:
|
public:
|
||||||
TVector():std::vector<VALUE_TYPE>(){reserve(1);}
|
TVector():std::vector<VALUE_TYPE>(){reserve(1);}
|
||||||
~TVector();
|
~TVector();
|
||||||
|
|
||||||
|
|
||||||
std::list < CATBase<THIS_TYPE>* > attributes;
|
std::list < CATBase<ThisType>* > attributes;
|
||||||
// override di tutte le funzioni che possono spostare
|
// override di tutte le funzioni che possono spostare
|
||||||
// l'allocazione in memoria del container
|
// l'allocazione in memoria del container
|
||||||
void push_back(const VALUE_TYPE & v);
|
void push_back(const VALUE_TYPE & v);
|
||||||
|
@ -54,16 +59,16 @@ public:
|
||||||
|
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
void EnableAttribute(){
|
void EnableAttribute(){
|
||||||
CAT<THIS_TYPE,ATTR_TYPE> * cat = new CAT<THIS_TYPE,ATTR_TYPE>();
|
CAT<ThisType,ATTR_TYPE> * cat = new CAT<ThisType,ATTR_TYPE>();
|
||||||
cat->Insert(*this);
|
cat->Insert(*this);
|
||||||
attributes.push_back(cat);
|
attributes.push_back(cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
void DisableAttribute(){
|
void DisableAttribute(){
|
||||||
std::list < CATBase<THIS_TYPE> * >::iterator ia;
|
std::list < CATBase<ThisType> * >::iterator ia;
|
||||||
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
|
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
|
||||||
if((*ia)->Id() == CAT<THIS_TYPE,ATTR_TYPE>::Id())
|
if((*ia)->Id() == CAT<ThisType,ATTR_TYPE>::Id())
|
||||||
{
|
{
|
||||||
(*ia)->Remove(*this);
|
(*ia)->Remove(*this);
|
||||||
delete (*ia);
|
delete (*ia);
|
||||||
|
@ -73,22 +78,24 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
TempData<THIS_TYPE,ATTR_TYPE> NewTempData(){
|
TempData<ThisType,ATTR_TYPE> NewTempData(){
|
||||||
CATEntry<THIS_TYPE,EntryTypeMulti>::Insert(*this);
|
typedef typename CATEntry<ThisType,EntryCATMulti<ThisType> >::EntryType EntryTypeMulti;
|
||||||
EntryTypeMulti entry = CATEntry<THIS_TYPE,EntryTypeMulti >::GetEntry(&*begin());
|
CATEntry<ThisType,EntryTypeMulti>::Insert(*this);
|
||||||
|
EntryTypeMulti entry = CATEntry<ThisType,EntryTypeMulti >::GetEntry(&*begin());
|
||||||
entry.Data().push_back(new Wrap< ATTR_TYPE>);
|
entry.Data().push_back(new Wrap< ATTR_TYPE>);
|
||||||
|
|
||||||
((Wrap<ATTR_TYPE>*)entry.Data().back())->reserve(capacity());
|
((Wrap<ATTR_TYPE>*)entry.Data().back())->reserve(capacity());
|
||||||
((Wrap<ATTR_TYPE>*)entry.Data().back())->resize(size());
|
((Wrap<ATTR_TYPE>*)entry.Data().back())->resize(size());
|
||||||
|
|
||||||
return TempData<THIS_TYPE,ATTR_TYPE>((Wrap<ATTR_TYPE>*) entry.Data().back());
|
return TempData<ThisType,ATTR_TYPE>((Wrap<ATTR_TYPE>*) entry.Data().back());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
void DeleteTempData(TempData<THIS_TYPE,ATTR_TYPE> & td){
|
void DeleteTempData(TempData<ThisType,ATTR_TYPE> & td){
|
||||||
CATEntry<THIS_TYPE,EntryTypeMulti >::RemoveIfEmpty(*this);
|
typedef typename CATEntry<ThisType,EntryCATMulti<ThisType> >::EntryType EntryTypeMulti;
|
||||||
|
CATEntry<ThisType,EntryTypeMulti >::RemoveIfEmpty(*this);
|
||||||
EntryTypeMulti
|
EntryTypeMulti
|
||||||
entry = CATEntry<THIS_TYPE,EntryCATMulti<THIS_TYPE> >::GetEntry(&*begin());
|
entry = CATEntry<ThisType,EntryCATMulti<ThisType> >::GetEntry(&*begin());
|
||||||
|
|
||||||
entry.Data().remove((Wrap<ATTR_TYPE>*)td.Item());
|
entry.Data().remove((Wrap<ATTR_TYPE>*)td.Item());
|
||||||
delete ((Wrap<ATTR_TYPE>*)td.Item());
|
delete ((Wrap<ATTR_TYPE>*)td.Item());
|
||||||
|
@ -104,7 +111,7 @@ template <class VALUE_TYPE>
|
||||||
void TVector<VALUE_TYPE>::push_back(const VALUE_TYPE & v){
|
void TVector<VALUE_TYPE>::push_back(const VALUE_TYPE & v){
|
||||||
std::vector<VALUE_TYPE>::push_back(v);
|
std::vector<VALUE_TYPE>::push_back(v);
|
||||||
Update();
|
Update();
|
||||||
std::list < CATBase<THIS_TYPE> * >::iterator ia;
|
std::list < CATBase<ThisType> * >::iterator ia;
|
||||||
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
|
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
|
||||||
(*ia)->AddDataElem(&(*(this->begin())),1);
|
(*ia)->AddDataElem(&(*(this->begin())),1);
|
||||||
|
|
||||||
|
@ -118,7 +125,7 @@ void TVector<VALUE_TYPE>::pop_back(){
|
||||||
template <class VALUE_TYPE>
|
template <class VALUE_TYPE>
|
||||||
void TVector<VALUE_TYPE>::resize(const unsigned int & size){
|
void TVector<VALUE_TYPE>::resize(const unsigned int & size){
|
||||||
std::vector<VALUE_TYPE>::resize(size);
|
std::vector<VALUE_TYPE>::resize(size);
|
||||||
std::list < CATBase<THIS_TYPE> * >::iterator ia;
|
std::list < CATBase<ThisType> * >::iterator ia;
|
||||||
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
|
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
|
||||||
(*ia)->
|
(*ia)->
|
||||||
Update();
|
Update();
|
||||||
|
@ -133,7 +140,7 @@ void TVector<VALUE_TYPE>::reserve(const unsigned int & size){
|
||||||
template <class VALUE_TYPE>
|
template <class VALUE_TYPE>
|
||||||
void TVector<VALUE_TYPE>::
|
void TVector<VALUE_TYPE>::
|
||||||
Update(){
|
Update(){
|
||||||
std::list < CATBase<THIS_TYPE> * >::iterator ia;
|
std::list < CATBase<ThisType> * >::iterator ia;
|
||||||
if(&(*begin()) != old_start)
|
if(&(*begin()) != old_start)
|
||||||
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
|
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
|
||||||
(*ia)->Resort(old_start,&(*begin()));
|
(*ia)->Resort(old_start,&(*begin()));
|
||||||
|
@ -145,7 +152,7 @@ template <class VALUE_TYPE>
|
||||||
|
|
||||||
template <class VALUE_TYPE>
|
template <class VALUE_TYPE>
|
||||||
TVector<VALUE_TYPE>::~TVector(){
|
TVector<VALUE_TYPE>::~TVector(){
|
||||||
std::list < CATBase<THIS_TYPE> * >::iterator ia;
|
std::list < CATBase<ThisType> * >::iterator ia;
|
||||||
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
|
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
|
||||||
{
|
{
|
||||||
(*ia)->Remove(*this);
|
(*ia)->Remove(*this);
|
||||||
|
|
Loading…
Reference in New Issue