some comment
This commit is contained in:
parent
21bac43cd8
commit
b8ef9d77a9
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.5 2005/07/06 15:28:10 ganovelli
|
||||||
|
aggiornamento di alcuni path
|
||||||
|
|
||||||
Revision 1.4 2004/04/05 18:20:50 ganovelli
|
Revision 1.4 2004/04/05 18:20:50 ganovelli
|
||||||
Aggiunto typename
|
Aggiunto typename
|
||||||
Eliminata bug di ricorsione nell'istanzazione dei template
|
Eliminata bug di ricorsione nell'istanzazione dei template
|
||||||
|
@ -43,9 +46,17 @@ First Working Release (with this comment)
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <vcg/container/entries_allocation_table.h>
|
#include <vcg/container/entries_allocation_table.h>
|
||||||
|
|
||||||
namespace vcg {
|
|
||||||
|
|
||||||
// CATBase: abstract base class for all the allocation tables
|
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.
|
||||||
|
* The goal is to know (given a pointer to a memory location), which is the vector the pointed
|
||||||
|
* element is in
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
template <typename STL_CONT>
|
template <typename STL_CONT>
|
||||||
class CATBase{
|
class CATBase{
|
||||||
public:
|
public:
|
||||||
|
@ -63,8 +74,8 @@ static int & Id(){
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// CATEntry: first derivation templated on the type of entry
|
/// CATEntry: first derivation templated on the type of entry
|
||||||
// It implements all the methods to trace and access TVector element
|
/// It implements all the methods to trace and access TVector element
|
||||||
template <typename STL_CONT, class ENTRY_TYPE>
|
template <typename STL_CONT, class ENTRY_TYPE>
|
||||||
class CATEntry: public CATBase<STL_CONT>{
|
class CATEntry: public CATBase<STL_CONT>{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.4 2004/04/05 18:20:08 ganovelli
|
||||||
|
Aggiunto typename
|
||||||
|
|
||||||
Revision 1.3 2004/03/31 22:36:44 ganovelli
|
Revision 1.3 2004/03/31 22:36:44 ganovelli
|
||||||
First Working Release (with this comment)
|
First Working Release (with this comment)
|
||||||
|
|
||||||
|
@ -39,6 +42,14 @@ First Working Release (with this comment)
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
|
/*@{*/
|
||||||
|
/*!
|
||||||
|
* This class represent a Traced Vector. A TVector is derived by a std::vector.
|
||||||
|
* The characteristic of a TVector 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,
|
||||||
|
* which is a (unique) list of TVector positions.
|
||||||
|
*/
|
||||||
|
|
||||||
template <class VALUE_TYPE>
|
template <class VALUE_TYPE>
|
||||||
class TVector: public std::vector<VALUE_TYPE>{
|
class TVector: public std::vector<VALUE_TYPE>{
|
||||||
|
@ -57,6 +68,7 @@ public:
|
||||||
void resize(const unsigned int & size);
|
void resize(const unsigned int & size);
|
||||||
void reserve(const unsigned int & size);
|
void reserve(const unsigned int & size);
|
||||||
|
|
||||||
|
/// this function enable the use of an optional attribute (see...)
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
void EnableAttribute(){
|
void EnableAttribute(){
|
||||||
CAT<ThisType,ATTR_TYPE> * cat = new CAT<ThisType,ATTR_TYPE>();
|
CAT<ThisType,ATTR_TYPE> * cat = new CAT<ThisType,ATTR_TYPE>();
|
||||||
|
@ -64,6 +76,8 @@ public:
|
||||||
attributes.push_back(cat);
|
attributes.push_back(cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// this function disable the use of an optional attribute (see...)
|
||||||
|
/// Note: once an attribute is disabled, its data is lost (the memory freed)
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
void DisableAttribute(){
|
void DisableAttribute(){
|
||||||
std::list < CATBase<ThisType> * >::iterator ia;
|
std::list < CATBase<ThisType> * >::iterator ia;
|
||||||
|
@ -77,6 +91,13 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// this function create a new attribute of type ATTR_TYPE and return an handle to
|
||||||
|
/// access the value of the attribute. Ex:
|
||||||
|
/// TVector<float> tv;
|
||||||
|
/// TempData<TVect,int> handle = tv.NewTempData<int>();
|
||||||
|
/// // now handle[&tv[123]] is the value of integer attribute associate with the position 123 on the vector
|
||||||
|
/// // NOTE: it works also if you do some push_back, resize, pop_back, reserve that cause the relocation
|
||||||
|
/// // of the TVector
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
TempData<ThisType,ATTR_TYPE> NewTempData(){
|
TempData<ThisType,ATTR_TYPE> NewTempData(){
|
||||||
typedef typename CATEntry<ThisType,EntryCATMulti<ThisType> >::EntryType EntryTypeMulti;
|
typedef typename CATEntry<ThisType,EntryCATMulti<ThisType> >::EntryType EntryTypeMulti;
|
||||||
|
@ -90,6 +111,7 @@ public:
|
||||||
return TempData<ThisType,ATTR_TYPE>((Wrap<ATTR_TYPE>*) entry.Data().back());
|
return TempData<ThisType,ATTR_TYPE>((Wrap<ATTR_TYPE>*) entry.Data().back());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// reciprocal of NewTempData
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
void DeleteTempData(TempData<ThisType,ATTR_TYPE> & td){
|
void DeleteTempData(TempData<ThisType,ATTR_TYPE> & td){
|
||||||
typedef typename CATEntry<ThisType,EntryCATMulti<ThisType> >::EntryType EntryTypeMulti;
|
typedef typename CATEntry<ThisType,EntryCATMulti<ThisType> >::EntryType EntryTypeMulti;
|
||||||
|
@ -107,6 +129,8 @@ private:
|
||||||
void Update();
|
void Update();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*@}*/
|
||||||
|
|
||||||
template <class VALUE_TYPE>
|
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);
|
||||||
|
|
Loading…
Reference in New Issue