126 lines
2.7 KiB
Plaintext
126 lines
2.7 KiB
Plaintext
unit SharedMLAdapters;
|
|
interface
|
|
|
|
type Relationships = class
|
|
public
|
|
function create(_obj: Relationships);
|
|
function Init();
|
|
|
|
function GetRelationshipById(_key: string);
|
|
function GetRelationshipByTarget(_key: string);
|
|
function AddRelationship(_value: Relationship);
|
|
|
|
property RelationshipCount: uinteger read relationship_count_;
|
|
|
|
private
|
|
object_: Relationships;
|
|
relationship_id_hash_: hash;
|
|
relationship_target_hash_: hash;
|
|
relationship_count_: uinteger;
|
|
end;
|
|
|
|
type Types = class
|
|
public
|
|
function create(_obj: Types);
|
|
function Init();
|
|
|
|
function GetDefaultByExtension(_key: string);
|
|
function AddDefault(_value: Default);
|
|
function GetOverrideByPartName(_key: string);
|
|
function AddOverride(_value: Override);
|
|
|
|
property DefaultCount: uinteger read default_count_;
|
|
property OverrideCount: uinteger read override_count_;
|
|
|
|
private
|
|
object_: Types;
|
|
default_extension_hash_: hash;
|
|
default_count_: uinteger;
|
|
override_partname_hash_: hash;
|
|
override_count_: uinteger;
|
|
end;
|
|
|
|
implementation
|
|
|
|
function Relationships.create(_obj: Relationships);
|
|
begin
|
|
object_ := _obj;
|
|
relationship_count_ := 0;
|
|
relationship_id_hash_ := array();
|
|
relationship_target_hash_ := array();
|
|
{self.}Init();
|
|
end;
|
|
|
|
function Relationships.Init();
|
|
begin
|
|
elements := object_.Relationships();
|
|
for k,v in elements do
|
|
begin
|
|
relationship_id_hash_[v.Id] := v;
|
|
relationship_target_hash_[v.Target] := v;
|
|
relationship_count_++;
|
|
end
|
|
end;
|
|
|
|
function Relationships.GetRelationshipById(_key: string);
|
|
begin
|
|
return relationship_id_hash_[_key];
|
|
end;
|
|
|
|
function Relationships.GetRelationshipByTarget(_key: string);
|
|
begin
|
|
return relationship_target_hash_[_key];
|
|
end;
|
|
|
|
function Relationships.AddRelationship(_value: Relationship);
|
|
begin
|
|
relationship_id_hash_[_value.Id] := _value;
|
|
relationship_target_hash_[_value.Target] := _value;
|
|
relationship_count_++;
|
|
end;
|
|
|
|
function Types.create(_obj: Types);
|
|
begin
|
|
object_ := _obj;
|
|
default_count_ := 0;
|
|
default_extension_hash_ := array();
|
|
override_count_ := 0;
|
|
override_partname_hash_ := array();
|
|
{self.}Init();
|
|
end;
|
|
|
|
function Types.Init();
|
|
begin
|
|
elements := object_.Defaults();
|
|
for k,v in elements do
|
|
default_extension_hash_[v.Extension] := v;
|
|
default_count_++;
|
|
elements := object_.Overrides();
|
|
for k,v in elements do
|
|
override_partname_hash_[v.PartName] := v;
|
|
override_count_++;
|
|
end;
|
|
|
|
function Types.GetDefaultByExtension(_key: string);
|
|
begin
|
|
return default_extension_hash_[_key];
|
|
end;
|
|
|
|
function Types.AddDefault(_value: Default);
|
|
begin
|
|
default_extension_hash_[_value.Extension] := _value;
|
|
default_count_++;
|
|
end;
|
|
|
|
function Types.GetOverrideByPartName(_key: string);
|
|
begin
|
|
return override_partname_hash_[_key];
|
|
end;
|
|
|
|
function Types.AddOverride(_value: Override);
|
|
begin
|
|
override_partname_hash_[_value.PartName] := _value;
|
|
override_count_++;
|
|
end;
|
|
|
|
end. |