Skip to content

Commit

Permalink
Merge pull request #40 from vimaec/mavimaec/om_v5.4.0
Browse files Browse the repository at this point in the history
Mavimaec/om v5.4.0
  • Loading branch information
mavimaec authored Nov 26, 2024
2 parents 864e87f + e28c5b4 commit 923961e
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/object-model-schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"VimFormatVersion": "1.0.0",
"SchemaVersion": "5.3.0",
"SchemaVersion": "5.4.0",
"Tables": {
"Vim.Area": [
"byte:IsGrossInterior",
Expand Down Expand Up @@ -198,6 +198,7 @@
"float:Translation.Z",
"index:Vim.Element:Element",
"index:Vim.Element:Host",
"index:Vim.Element:SuperComponent",
"index:Vim.FamilyType:FamilyType",
"index:Vim.Room:FromRoom",
"index:Vim.Room:ToRoom"
Expand Down
5 changes: 5 additions & 0 deletions docs/schema-diff.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,10 @@
"Added": [
"Vim.ParameterDescriptor__int:StorageType"
]
},
"5.3.0 to 5.4.0": {
"Added": [
"Vim.FamilyInstance__index:Vim.Element:SuperComponent"
]
}
}
18 changes: 18 additions & 0 deletions src/cpp/vim/object-model.h
Original file line number Diff line number Diff line change
Expand Up @@ -5302,6 +5302,8 @@ namespace Vim
Room* mFromRoom;
int mToRoomIndex;
Room* mToRoom;
int mSuperComponentIndex;
Element* mSuperComponent;
int mElementIndex;
Element* mElement;

Expand Down Expand Up @@ -5352,6 +5354,7 @@ namespace Vim
familyInstance->mHostIndex = GetHostIndex(familyInstanceIndex);
familyInstance->mFromRoomIndex = GetFromRoomIndex(familyInstanceIndex);
familyInstance->mToRoomIndex = GetToRoomIndex(familyInstanceIndex);
familyInstance->mSuperComponentIndex = GetSuperComponentIndex(familyInstanceIndex);
familyInstance->mElementIndex = GetElementIndex(familyInstanceIndex);
return familyInstance;
}
Expand Down Expand Up @@ -5385,6 +5388,7 @@ namespace Vim
bool existsHost = mEntityTable.column_exists("index:Vim.Element:Host");
bool existsFromRoom = mEntityTable.column_exists("index:Vim.Room:FromRoom");
bool existsToRoom = mEntityTable.column_exists("index:Vim.Room:ToRoom");
bool existsSuperComponent = mEntityTable.column_exists("index:Vim.Element:SuperComponent");
bool existsElement = mEntityTable.column_exists("index:Vim.Element:Element");

const auto count = GetCount();
Expand Down Expand Up @@ -5511,6 +5515,7 @@ namespace Vim
const std::vector<int>& hostData = mEntityTable.column_exists("index:Vim.Element:Host") ? mEntityTable.mIndexColumns["index:Vim.Element:Host"] : std::vector<int>();
const std::vector<int>& fromRoomData = mEntityTable.column_exists("index:Vim.Room:FromRoom") ? mEntityTable.mIndexColumns["index:Vim.Room:FromRoom"] : std::vector<int>();
const std::vector<int>& toRoomData = mEntityTable.column_exists("index:Vim.Room:ToRoom") ? mEntityTable.mIndexColumns["index:Vim.Room:ToRoom"] : std::vector<int>();
const std::vector<int>& superComponentData = mEntityTable.column_exists("index:Vim.Element:SuperComponent") ? mEntityTable.mIndexColumns["index:Vim.Element:SuperComponent"] : std::vector<int>();
const std::vector<int>& elementData = mEntityTable.column_exists("index:Vim.Element:Element") ? mEntityTable.mIndexColumns["index:Vim.Element:Element"] : std::vector<int>();

for (int i = 0; i < count; ++i)
Expand Down Expand Up @@ -5567,6 +5572,7 @@ namespace Vim
entity.mHostIndex = existsHost ? hostData[i] : -1;
entity.mFromRoomIndex = existsFromRoom ? fromRoomData[i] : -1;
entity.mToRoomIndex = existsToRoom ? toRoomData[i] : -1;
entity.mSuperComponentIndex = existsSuperComponent ? superComponentData[i] : -1;
entity.mElementIndex = existsElement ? elementData[i] : -1;
familyInstance->push_back(entity);
}
Expand Down Expand Up @@ -6290,6 +6296,18 @@ namespace Vim
return mEntityTable.mIndexColumns["index:Vim.Room:ToRoom"][familyInstanceIndex];
}

int GetSuperComponentIndex(int familyInstanceIndex)
{
if (!mEntityTable.column_exists("index:Vim.Element:SuperComponent")) {
return -1;
}

if (familyInstanceIndex < 0 || familyInstanceIndex >= GetCount())
return -1;

return mEntityTable.mIndexColumns["index:Vim.Element:SuperComponent"][familyInstanceIndex];
}

int GetElementIndex(int familyInstanceIndex)
{
if (!mEntityTable.column_exists("index:Vim.Element:Element")) {
Expand Down
8 changes: 7 additions & 1 deletion src/cs/vim/Vim.Format/ObjectModel/ObjectModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public static class SchemaVersion
// ReSharper disable MemberHidesStaticFromOuterClass
public static class History
{
// Schema additions
// Vim.FamilyInstance__index:Vim.Element:SuperComponent
public const string v5_4_0 = "5.4.0";

// Schema additions
// Vim.ParameterDescriptor__int:StorageType
public const string v5_3_0 = "5.3.0";
Expand Down Expand Up @@ -163,7 +167,8 @@ public static class History
// ReSharper enable MemberHidesStaticFromOuterClass

// [MAINTAIN] Add more object model SerializableVersions below and update the current one.
public static SerializableVersion Current => v5_3_0;
public static SerializableVersion Current => v5_4_0;
public static SerializableVersion v5_4_0 => SerializableVersion.Parse(History.v5_4_0);
public static SerializableVersion v5_3_0 => SerializableVersion.Parse(History.v5_3_0);
public static SerializableVersion v5_2_0 => SerializableVersion.Parse(History.v5_2_0);
public static SerializableVersion v5_1_0 => SerializableVersion.Parse(History.v5_1_0);
Expand Down Expand Up @@ -817,6 +822,7 @@ public Vector3 HandOrientation
public Relation<Element> _Host;
public Relation<Room> _FromRoom;
public Relation<Room> _ToRoom;
public Relation<Element> _SuperComponent;
}

/// <summary>
Expand Down
8 changes: 8 additions & 0 deletions src/cs/vim/Vim.Format/ObjectModel/ObjectModelGenerated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -669,13 +669,15 @@ public partial class FamilyInstance
public Vim.Format.ObjectModel.Element Host => _Host.Value;
public Vim.Format.ObjectModel.Room FromRoom => _FromRoom.Value;
public Vim.Format.ObjectModel.Room ToRoom => _ToRoom.Value;
public Vim.Format.ObjectModel.Element SuperComponent => _SuperComponent.Value;
public Vim.Format.ObjectModel.Element Element => _Element.Value;
public FamilyInstance()
{
_FamilyType = new Relation<Vim.Format.ObjectModel.FamilyType>();
_Host = new Relation<Vim.Format.ObjectModel.Element>();
_FromRoom = new Relation<Vim.Format.ObjectModel.Room>();
_ToRoom = new Relation<Vim.Format.ObjectModel.Room>();
_SuperComponent = new Relation<Vim.Format.ObjectModel.Element>();
_Element = new Relation<Vim.Format.ObjectModel.Element>();
}

Expand Down Expand Up @@ -712,6 +714,7 @@ public override bool FieldsAreEqual(object obj)
(_Host?.Index == other._Host?.Index) &&
(_FromRoom?.Index == other._FromRoom?.Index) &&
(_ToRoom?.Index == other._ToRoom?.Index) &&
(_SuperComponent?.Index == other._SuperComponent?.Index) &&
(_Element?.Index == other._Element?.Index);
if (!fieldsAreEqual)
{
Expand Down Expand Up @@ -2612,6 +2615,8 @@ public FamilyType GetFamilyType(int n)
public int GetFamilyInstanceFromRoomIndex(int index) => FamilyInstanceFromRoomIndex?.ElementAtOrDefault(index, EntityRelation.None) ?? EntityRelation.None;
public IArray<int> FamilyInstanceToRoomIndex { get; }
public int GetFamilyInstanceToRoomIndex(int index) => FamilyInstanceToRoomIndex?.ElementAtOrDefault(index, EntityRelation.None) ?? EntityRelation.None;
public IArray<int> FamilyInstanceSuperComponentIndex { get; }
public int GetFamilyInstanceSuperComponentIndex(int index) => FamilyInstanceSuperComponentIndex?.ElementAtOrDefault(index, EntityRelation.None) ?? EntityRelation.None;
public IArray<int> FamilyInstanceElementIndex { get; }
public int GetFamilyInstanceElementIndex(int index) => FamilyInstanceElementIndex?.ElementAtOrDefault(index, EntityRelation.None) ?? EntityRelation.None;
public int NumFamilyInstance => FamilyInstanceEntityTable?.NumRows ?? 0;
Expand Down Expand Up @@ -2649,6 +2654,7 @@ public FamilyInstance GetFamilyInstance(int n)
r._Host = new Relation<Vim.Format.ObjectModel.Element>(GetFamilyInstanceHostIndex(n), GetElement);
r._FromRoom = new Relation<Vim.Format.ObjectModel.Room>(GetFamilyInstanceFromRoomIndex(n), GetRoom);
r._ToRoom = new Relation<Vim.Format.ObjectModel.Room>(GetFamilyInstanceToRoomIndex(n), GetRoom);
r._SuperComponent = new Relation<Vim.Format.ObjectModel.Element>(GetFamilyInstanceSuperComponentIndex(n), GetElement);
r._Element = new Relation<Vim.Format.ObjectModel.Element>(GetFamilyInstanceElementIndex(n), GetElement);
return r;
}
Expand Down Expand Up @@ -4174,6 +4180,7 @@ public DocumentModel(Document d, bool inParallel = true)
FamilyInstanceHostIndex = FamilyInstanceEntityTable?.GetIndexColumnValues("index:Vim.Element:Host") ?? Array.Empty<int>().ToIArray();
FamilyInstanceFromRoomIndex = FamilyInstanceEntityTable?.GetIndexColumnValues("index:Vim.Room:FromRoom") ?? Array.Empty<int>().ToIArray();
FamilyInstanceToRoomIndex = FamilyInstanceEntityTable?.GetIndexColumnValues("index:Vim.Room:ToRoom") ?? Array.Empty<int>().ToIArray();
FamilyInstanceSuperComponentIndex = FamilyInstanceEntityTable?.GetIndexColumnValues("index:Vim.Element:SuperComponent") ?? Array.Empty<int>().ToIArray();
FamilyInstanceElementIndex = FamilyInstanceEntityTable?.GetIndexColumnValues("index:Vim.Element:Element") ?? Array.Empty<int>().ToIArray();
ViewCameraIndex = ViewEntityTable?.GetIndexColumnValues("index:Vim.Camera:Camera") ?? Array.Empty<int>().ToIArray();
ViewFamilyTypeIndex = ViewEntityTable?.GetIndexColumnValues("index:Vim.FamilyType:FamilyType") ?? Array.Empty<int>().ToIArray();
Expand Down Expand Up @@ -4617,6 +4624,7 @@ public static EntityTableBuilder ToFamilyInstanceTableBuilder(this IEnumerable<E
tb.AddIndexColumn("index:Vim.Element:Host", typedEntities.Select(x => x._Host?.Index ?? EntityRelation.None));
tb.AddIndexColumn("index:Vim.Room:FromRoom", typedEntities.Select(x => x._FromRoom?.Index ?? EntityRelation.None));
tb.AddIndexColumn("index:Vim.Room:ToRoom", typedEntities.Select(x => x._ToRoom?.Index ?? EntityRelation.None));
tb.AddIndexColumn("index:Vim.Element:SuperComponent", typedEntities.Select(x => x._SuperComponent?.Index ?? EntityRelation.None));
tb.AddIndexColumn("index:Vim.Element:Element", typedEntities.Select(x => x._Element?.Index ?? EntityRelation.None));
return tb;
}
Expand Down
29 changes: 29 additions & 0 deletions src/ts/src/objectModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3919,6 +3919,8 @@ export interface IFamilyInstance {
fromRoom?: IRoom
toRoomIndex?: number
toRoom?: IRoom
superComponentIndex?: number
superComponent?: IElement
elementIndex?: number
element?: IElement
}
Expand Down Expand Up @@ -3987,6 +3989,9 @@ export interface IFamilyInstanceTable {
getToRoomIndex(familyInstanceIndex: number): Promise<number | undefined>
getAllToRoomIndex(): Promise<number[] | undefined>
getToRoom(familyInstanceIndex: number): Promise<IRoom | undefined>
getSuperComponentIndex(familyInstanceIndex: number): Promise<number | undefined>
getAllSuperComponentIndex(): Promise<number[] | undefined>
getSuperComponent(familyInstanceIndex: number): Promise<IElement | undefined>
getElementIndex(familyInstanceIndex: number): Promise<number | undefined>
getAllElementIndex(): Promise<number[] | undefined>
getElement(familyInstanceIndex: number): Promise<IElement | undefined>
Expand Down Expand Up @@ -4026,6 +4031,8 @@ export class FamilyInstance implements IFamilyInstance {
fromRoom?: IRoom
toRoomIndex?: number
toRoom?: IRoom
superComponentIndex?: number
superComponent?: IElement
elementIndex?: number
element?: IElement

Expand Down Expand Up @@ -4061,6 +4068,7 @@ export class FamilyInstance implements IFamilyInstance {
table.getHostIndex(index).then(v => result.hostIndex = v),
table.getFromRoomIndex(index).then(v => result.fromRoomIndex = v),
table.getToRoomIndex(index).then(v => result.toRoomIndex = v),
table.getSuperComponentIndex(index).then(v => result.superComponentIndex = v),
table.getElementIndex(index).then(v => result.elementIndex = v),
])

Expand Down Expand Up @@ -4124,6 +4132,7 @@ export class FamilyInstanceTable implements IFamilyInstanceTable {
let hostIndex: number[] | undefined
let fromRoomIndex: number[] | undefined
let toRoomIndex: number[] | undefined
let superComponentIndex: number[] | undefined
let elementIndex: number[] | undefined

await Promise.all([
Expand Down Expand Up @@ -4154,6 +4163,7 @@ export class FamilyInstanceTable implements IFamilyInstanceTable {
(async () => { hostIndex = (await localTable.getNumberArray("index:Vim.Element:Host")) })(),
(async () => { fromRoomIndex = (await localTable.getNumberArray("index:Vim.Room:FromRoom")) })(),
(async () => { toRoomIndex = (await localTable.getNumberArray("index:Vim.Room:ToRoom")) })(),
(async () => { superComponentIndex = (await localTable.getNumberArray("index:Vim.Element:SuperComponent")) })(),
(async () => { elementIndex = (await localTable.getNumberArray("index:Vim.Element:Element")) })(),
])

Expand Down Expand Up @@ -4190,6 +4200,7 @@ export class FamilyInstanceTable implements IFamilyInstanceTable {
hostIndex: hostIndex ? hostIndex[i] : undefined,
fromRoomIndex: fromRoomIndex ? fromRoomIndex[i] : undefined,
toRoomIndex: toRoomIndex ? toRoomIndex[i] : undefined,
superComponentIndex: superComponentIndex ? superComponentIndex[i] : undefined,
elementIndex: elementIndex ? elementIndex[i] : undefined
})
}
Expand Down Expand Up @@ -4453,6 +4464,24 @@ export class FamilyInstanceTable implements IFamilyInstanceTable {
return await this.document.room?.get(index)
}

async getSuperComponentIndex(familyInstanceIndex: number): Promise<number | undefined> {
return await this.entityTable.getNumber(familyInstanceIndex, "index:Vim.Element:SuperComponent")
}

async getAllSuperComponentIndex(): Promise<number[] | undefined> {
return await this.entityTable.getNumberArray("index:Vim.Element:SuperComponent")
}

async getSuperComponent(familyInstanceIndex: number): Promise<IElement | undefined> {
const index = await this.getSuperComponentIndex(familyInstanceIndex)

if (index === undefined) {
return undefined
}

return await this.document.element?.get(index)
}

async getElementIndex(familyInstanceIndex: number): Promise<number | undefined> {
return await this.entityTable.getNumber(familyInstanceIndex, "index:Vim.Element:Element")
}
Expand Down

0 comments on commit 923961e

Please sign in to comment.