|
|
|
@ -233,20 +233,29 @@ class ObjectId
|
|
|
|
|
{
|
|
|
|
|
private id: number;
|
|
|
|
|
private obj: CADObject;
|
|
|
|
|
private constructor()
|
|
|
|
|
|
|
|
|
|
//对外隐藏构造函数,如果需要构造一个id,请使用 Create 静态方法.
|
|
|
|
|
private constructor(index: number = -1, obj?: CADObject)
|
|
|
|
|
{
|
|
|
|
|
this.id = -1;
|
|
|
|
|
this.id = index;
|
|
|
|
|
this.obj = obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建一个id, 如果db中已经存在id,那么自动获得该id,如果不存在,new一个新的id,并且加入到db中
|
|
|
|
|
/*
|
|
|
|
|
创建一个id, 如果db中已经存在id,那么自动获得该id,如果不存在,new一个新的id,并且加入到db中
|
|
|
|
|
该方法的使用场景:
|
|
|
|
|
1.对象加入到db中时
|
|
|
|
|
2.对象从数据从读取时.
|
|
|
|
|
3.对象redo创建时
|
|
|
|
|
4.引用读取时
|
|
|
|
|
*/
|
|
|
|
|
static Create(db: Database, index: number): ObjectId
|
|
|
|
|
{
|
|
|
|
|
let id = db.GetObjectId(index);
|
|
|
|
|
if (!id)
|
|
|
|
|
{
|
|
|
|
|
id = new ObjectId();
|
|
|
|
|
id = new ObjectId(index);
|
|
|
|
|
db.SetObjectId(index, id);
|
|
|
|
|
id.id = index;
|
|
|
|
|
}
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
@ -616,13 +625,22 @@ class Database
|
|
|
|
|
console.warn("警告:对象不属于该数据库!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//获得指定索引的id,注意该id可能为空,如果需要创建,请使用 ObjectId.Create 如果需要自动分配 请使用 AllocateId
|
|
|
|
|
/*
|
|
|
|
|
private 请不要调用该方法,只暴露给 ObjectId使用.
|
|
|
|
|
|
|
|
|
|
获得指定索引的id, 注意该id可能为空, 如果需要创建, 请使用 ObjectId.Create,如果需要自动分配,请使用,AllocateId
|
|
|
|
|
*/
|
|
|
|
|
GetObjectId(index: number): ObjectId
|
|
|
|
|
{
|
|
|
|
|
return this.idMap.get(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//在id池中加入新建的id. 该方法暴露给 Objectid.Cretes使用.
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
private 请不要调用该方法,只暴露给 ObjectId使用.
|
|
|
|
|
|
|
|
|
|
在id池中加入新建的id. 该方法暴露给 Objectid.Cretes使用.
|
|
|
|
|
*/
|
|
|
|
|
SetObjectId(index: number, id: ObjectId)
|
|
|
|
|
{
|
|
|
|
|
if (this.idMap.has(index))
|
|
|
|
|