bazaar: Gen: Value for Instancer, Tree: small fixes, Detach fix

git-svn-id: svn://ultimatepp.org/upp/trunk@2927 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
kohait 2010-12-24 13:11:48 +00:00
parent 60ca16bfce
commit d9f07ec4c2
3 changed files with 21 additions and 21 deletions

View file

@ -2,9 +2,9 @@
NAMESPACE_UPP
VectorMap<String, GlobalInstancerType>& GetGlobalInstancerMap()
VectorMap<Value, GlobalInstancerType>& GetGlobalInstancerMap()
{
static VectorMap<String, GlobalInstancerType> map;
static VectorMap<Value, GlobalInstancerType> map;
return map;
}

View file

@ -167,7 +167,7 @@ public:
};
typedef void*(*GlobalInstancerType)();
VectorMap<String, GlobalInstancerType>& GetGlobalInstancerMap();
VectorMap<Value, GlobalInstancerType>& GetGlobalInstancerMap();
//Instancer help class, for maps of Instancers. the static Map should
//somewhere be ONCELOCK initialized with the elements
@ -186,7 +186,7 @@ public:
static InstancerType GetInstancer() { return &GetInstance; }
static GlobalInstancerType GetGlobalInstancer() { return (GlobalInstancerType)&GetInstance; }
};
static VectorMap<String, InstancerType>& Map() { static VectorMap<String, InstancerType> map; return map; }
static VectorMap<Value, InstancerType>& Map() { static VectorMap<Value, InstancerType> map; return map; }
};
//in polymorph environment, type info is needed, i.e. when xmlizing/serializing elements

View file

@ -10,28 +10,28 @@ class Tree
{
protected:
typedef Array<T> B;
T * parent;
T * root;
T* parent;
T* root;
inline void Link(T & t) { t.root = root; t.parent = (T *)this; }
inline void Unlink(T & t) { t.root = NULL; t.parent = NULL; }
inline void Link(T& t) { t.root = root; t.parent = (T *)this; }
inline void Unlink(T& t) { t.root = NULL; t.parent = NULL; }
void Relink() { for(int i = 0; i < B::GetCount(); i++) { T & t = B::operator[](i); Link(t); t.Relink();} }
public:
T *GetPtr() { return (T *) this; }
const T *GetPtr() const { return (const T *) this; }
T *GetParent() { return parent; }
const T *GetParent() const { return parent; }
T *GetRoot() { return root; }
const T *GetRoot() const { return root; }
void SetAsRoot() { ASSERT(parent == NULL); root = (T *)this; Relink(); }
T* GetPtr() { return (T*) this; }
const T* GetPtr() const { return (const T *) this; }
T* GetParent() { return parent; }
const T* GetParent() const { return parent; }
T* GetRoot() { return root; }
const T* GetRoot() const { return root; }
void SetAsRoot() { ASSERT(parent == NULL); root = (T*)this; Relink(); }
// Array interface
T& Add() { T & t = B::Add(); Link(t); return t; }
void Add(const T& x) { T & t = B::Add(DeepCopyNew(x)); Link(t); }// return t; }
void AddPick(pick_ T& x) { T & t = B::Add(new T(x)); Link(t); }// return t; }
T& Add() { T& t = B::Add(); Link(t); return t; }
void Add(const T& x) { T& t = B::Add(DeepCopyNew(x)); Link(t); }// return t; }
void AddPick(pick_ T& x) { T& t = B::Add(new T(x)); Link(t); }// return t; }
T& Add(T *newt) { ASSERT(newt->parent == NULL); T & t = B::Add(newt); Link(t); return t; }
using B::operator[];
@ -47,21 +47,21 @@ public:
T& At(int i, const T& x) { if(i >= GetCount()) SetCountR(i + 1, x); return B::Get(i); }
using B::Remove;
T& Insert(int i) { T & t = B::Insert(i); Link(t); return t; }
T& Insert(int i) { T& t = B::Insert(i); Link(t); return t; }
void InsertPick(int i, pick_ T& x) { Link(x); B::InsertPick(i, x); }
using B::GetIndex;
using B::Swap;
using B::Move;
T *Detach(int i) { T *t = B::Detach(i); Unlink(t); }
T* Detach(int i) { T* t = B::Detach(i); Unlink(*t); return t;}
T& Set(int i, T *newt) { ASSERT(newt->parent == NULL); T & t = B::Set(i, newt); Link(t); return t; }
void Insert(int i, T *newt) { ASSERT(newt->parent == NULL); B::Insert(i, newt); Link(*newt); }
using B::Drop;
using B::Top;
T *PopDetach() { T * t = B::PopDetach(); Unlink(*t); return t; }
T* PopDetach() { T* t = B::PopDetach(); Unlink(*t); return t; }
using B::Begin;
using B::End;