XManager

Inherited from NULL

Inherited by NULL

Friend class NULL

Description

XManager是XT框架数据管理的核心,XT中所有的数据对象均从XItem继承,数据对象的创建、销毁以及索引均由对应的数据对象管理器完成,所有的数据对象管理器均从XManager继承而来。

原则上,一种数据对象管理器只负责管理概念上属于同一种类的对象(同一种类的对象可细分为若干子类型),这里将种类定义为管理器的域类型(DomainType),对于外部访问,它是一个不大于16个字符的字符串类型名(ctypeString()),在注册时给定;对于内部访问,它是一个不大于256的整型识别码(ctype()),在注册时自动生成或者显式设定。数据对象管理器与对象域一一对应,一种数据对象管理器对应一个静态的字符串域类型名和一个动态生成的整数域标识码;每种数据对象也唯一的对应一个静态的字符串对象类型名和一个动态生成的整数对象识别码。XManager维护了一份全局的域类型映射表和对象类型映射表,域类型名被唯一的映射到域识别码,对象类型名被唯一的映射到对象识别码,域识别码表示对象管理器的序号,对象识别码表示了对象在对象管理器中的序号,因此XManager可以使用统一的接口去访问任意一个对象。

从XManager继承的任意数据对象管理器维护了它所管理的对象的构造函数列表和析构函数列表,并开辟一个独立的内存池空间(XMemPool)和散列索引(XHash),创建对象时均从内存池中分配内存并初始化,赋给其唯一的身份ID,插入到散列索引中,然后,通过ID就可以快速的访问到指定对象。

Members

Public interface

Protected interface


OpnRecorder * m_pOpnRecorder

bool m_bAutomaticItemType = false

bool m_bAutomaticDomainType = false

ulong m_ulNextItemId

TypeID m_iDomainID

TypeID m_iDomainType

XHash<XItem> * m_pItemHash

AllocItemFunc * m_fpItemAlloc

FreeItemFunc * m_fpItemFree

XMemPool * m_pXMemPool


XManager(TypeID domainType, int initHashSize, XMemPool * memPool, int defaultMemSize)

XManager(TypeID domainType)

static ulong registerCItem(const char * itemTypeString, TypeID domainType, AllocItemFunc itemAlloc, FreeItemFunc itemFree, TypeID itemType = DItem_Unknown)

static ulong registerDomain(const char * domainTypeString, TypeID domainType = Domain_Unknown)

static const char * getCtypeString(ulong ctype)

static ulong getCtype(const char * typeString)

static ulong getNextDomainType()

static bool updateNextDomainType(ulong curType)

static TypeID getNextCtype(ulong domain)

static AllocItemFunc * getItemAllocTable(TypeID domainType)

static FreeItemFunc * getItemFreeTable(TypeID domainType)

DomainType getDomainType() const

bool isAutomaticItemType() const

void registerToRecorder(OpnRecorder * rec, int domainID = -1)

virtual void addItem(XItem * item)

virtual void collectItems(vector<const XItem*> * itemArr, TypeID tid = DItem_Unknown)

virtual void updateAfterRenumber(TypeID tid = DItem_Unknown)

XItem * newItem(int tid = 0)

XItem * createItem(ulong id = 0, int tid = 0)

virtual void removeItem(XItem * item)

void destroyItem(XItem * itm, bool bDestruct = true)

const XItem * getItem(ulong id) const

virtual void setPrevNext(XItem * item, int prevID, int nextID)

virtual void serializePrevNext(XBinaryIO * io, XItem * obj, bool bSave)

virtual void write(XH5IO * io, H5Obj * grp)

XItem * serializeRecord(XBinaryIO * io, int & opn, bool bUndo)

virtual void serialize(XBinaryIO * io, XItem * obj, bool bSave) = 0

virtual void serializeLinks(XBinaryIO * io, XItem * obj, bool bSave)

virtual void linkItem(XItem * master, const XItem * slave, bool bAttach)

virtual const XItem * getLinkItem(TypeID type, ulong id)

virtual void bindLinkManager(TypeID domanType, XManager * mgr)

void serializeLinkItem(XBinaryIO * record, const XItem *& obj, bool bSave)

void bindItemIterator(ItemIterator * iter) const

ulong getItemCount() const

virtual void clear()

virtual void recordExchange(XItem * item, XBinaryIO * io)

ulong getNextItemId() const

void setNextItemId(ulong id)

void getNextItemName(const char * curName, string * name) const

void sortItemById(vector<ItemPtr> * item_list) const

void sortItemByName(vector<NItem*> * item_list)

const NItem * getItemByName(const char * name, ulong excludeID = 0)

void updateAllCache()

virtual bool getObjectPropertySheet(const XItem * obj, vector<ObjPropertyEntry> * prpSheet)


void reIndexItem(const XItem * item, ulong ulNewID)

virtual void updatePrevNext(XItem * item, int prevID, int nextID)