Data Type
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -11,6 +11,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Nocturnis.Generators\Nocturnis.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
|
||||
<ProjectReference Include="..\VirtualChemistry\VirtualChemistry.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -18,5 +19,7 @@
|
||||
<Folder Include="src\Enigmos\Modules\SubModules\" />
|
||||
<Folder Include="src\GlobalManagement\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="BaseTypes"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.Data;
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
|
||||
namespace Nocturnis.Communicators;
|
||||
@@ -7,8 +9,8 @@ namespace Nocturnis.Communicators;
|
||||
public interface IBaseCommunicator
|
||||
{
|
||||
ICommunicateModule PairedModule { get; set; }
|
||||
IData DataBuffer { get; set; }
|
||||
StringName CommunicationDataType { get; }
|
||||
DataVariable DataBuffer { get; set; }
|
||||
DataType CommunicationDataType { get; }
|
||||
StringName CommunicationDirection { get; }
|
||||
Texture2D IconTexture { get; }
|
||||
string CustomName { get; set; }
|
||||
|
||||
89
src/DataStructures/Data/DataVariable.cs
Normal file
89
src/DataStructures/Data/DataVariable.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System.Numerics;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Skeleton.Algebra;
|
||||
using Skeleton.Algebra.DimensionProviders;
|
||||
|
||||
namespace Nocturnis.DataStructures.Data;
|
||||
using R2 = CategoryOf<IDim2>.OnField<double>.FVector;
|
||||
using C2 = CategoryOf<IDim2>.OnField<Complex>.FVector;
|
||||
|
||||
public class DataVariable
|
||||
{
|
||||
public DataVariable()
|
||||
{
|
||||
Data = null;
|
||||
Type = new DataType();
|
||||
Type.Assign(DataTypeConstant.BaseDataTypes.Null);
|
||||
}
|
||||
|
||||
public void Assign(DataVariable oth)
|
||||
{
|
||||
Data = oth.Data;
|
||||
Type.Assign(oth.Type);
|
||||
}
|
||||
|
||||
public void Assign(object v, DataType t)
|
||||
{
|
||||
Data = v;
|
||||
Type.Assign(t);
|
||||
}
|
||||
|
||||
public object Data { get; set; }
|
||||
public DataType Type { get; set; }
|
||||
//StringName? Type { get; set; }
|
||||
int Int
|
||||
{
|
||||
get => (int)Data;
|
||||
set => Data = value;
|
||||
}
|
||||
|
||||
public double Real
|
||||
{
|
||||
get => (double)Data;
|
||||
set => Data = value;
|
||||
}
|
||||
|
||||
public Complex Complex
|
||||
{
|
||||
get => (Complex)Data;
|
||||
set => Data = value;
|
||||
}
|
||||
|
||||
public DataVariable[] Array
|
||||
{
|
||||
get => Data as DataVariable[];
|
||||
set => Data = value;
|
||||
}
|
||||
|
||||
public R2 R2
|
||||
{
|
||||
get => Data as R2;
|
||||
set => Data = value;
|
||||
}
|
||||
|
||||
public C2 C2
|
||||
{
|
||||
get => Data as C2;
|
||||
set => Data = value;
|
||||
}
|
||||
|
||||
public bool Bit
|
||||
{
|
||||
get => (bool)Data;
|
||||
set => Data = value;
|
||||
}
|
||||
|
||||
public string String
|
||||
{
|
||||
get => Data as string;
|
||||
set => Data = value;
|
||||
}
|
||||
|
||||
public Dictionary<StringName, DataVariable> Struct
|
||||
{
|
||||
get => Data as Dictionary<StringName, DataVariable>;
|
||||
set => Data = value;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,33 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.Data;
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Nocturnis.DataStructures;
|
||||
|
||||
public class DataCache : CacheItem<IData>
|
||||
public class DataCache : CacheItem<DataVariable>
|
||||
{
|
||||
public new static DataCache Null => new DataCache(x => (0, ""));
|
||||
public DataCache(Func<CacheItem?, IData> rec) : base(rec) => throw new Exception("CONSTRUCTION NOT ALLOWED");
|
||||
public new static DataCache Null => new (x => (0, GlobalProvider.DataStructureProvider!.NullDataType));
|
||||
public DataCache(Func<CacheItem, DataVariable> rec) : base(rec) => throw new Exception("CONSTRUCTION NOT ALLOWED");
|
||||
|
||||
public DataCache(Func<CacheItem?, (object, StringName)> rec)
|
||||
public DataCache(Func<CacheItem, (object, DataType)> rec)
|
||||
{
|
||||
Value = GlobalProvider.DataStructureProvider!.NewData(0, "");
|
||||
Value = GlobalProvider.DataStructureProvider!.NewData(0, DataTypeConstant.BaseDataTypes.Null);
|
||||
ProxyCalculator = rec;
|
||||
}
|
||||
|
||||
private new Func<CacheItem, (object, StringName)> ProxyCalculator { get; set; }
|
||||
private new Func<CacheItem, (object, DataType)> ProxyCalculator { get; set; }
|
||||
|
||||
public override IData? Get
|
||||
public override DataVariable Get
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Expired)
|
||||
{
|
||||
(object val, StringName type) = ProxyCalculator(this);
|
||||
Value!.Type = type;
|
||||
(object val, DataType type) = ProxyCalculator(this);
|
||||
Value!.Type.Assign(type);
|
||||
Value.Data = val;
|
||||
}
|
||||
|
||||
@@ -32,7 +35,7 @@ public class DataCache : CacheItem<IData>
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateCalculation(Func<CacheItem, (object, StringName)> rec)
|
||||
public void UpdateCalculation(Func<CacheItem, (object, DataType)> rec)
|
||||
{
|
||||
Expire();
|
||||
foreach (CacheItem item in Dependencies)
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
|
||||
namespace Nocturnis.DataStructures.DataPortGroups;
|
||||
|
||||
public interface IDataPortGroup
|
||||
{
|
||||
StringName SelectedType { get; set; }
|
||||
StringName[] TypeOptions { get; set; }
|
||||
DataType SelectedType { get; set; }
|
||||
DataType[] TypeOptions { get; set; }
|
||||
|
||||
void Inference();
|
||||
string Description { get; set; }
|
||||
}
|
||||
46
src/DataStructures/DataTypeOptions/DataTypeOption.cs
Normal file
46
src/DataStructures/DataTypeOptions/DataTypeOption.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Nocturnis.DataStructures.DataTypeOptions;
|
||||
|
||||
public class DataTypeOption : HashSet<DataType>
|
||||
{
|
||||
public DataTypeOption(params DataType[] options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DataTypeOption()
|
||||
{
|
||||
}
|
||||
|
||||
public new bool Contains(DataType type)
|
||||
{
|
||||
if (Count == 0)
|
||||
return true;
|
||||
DataType t = this.First();
|
||||
if (
|
||||
Count == 1 &&
|
||||
t == DataType.ArrayDataType(DataTypeConstant.BaseDataTypes.Null) &&
|
||||
type.Type == DataTypeConstant.NestedDataTypeNames.Array
|
||||
)
|
||||
return true;
|
||||
if (
|
||||
Count == 1 &&
|
||||
t == DataType.StructDataType(null) &&
|
||||
type.Type == DataTypeConstant.NestedDataTypeNames.Struct
|
||||
)
|
||||
return true;
|
||||
return base.Contains(type);
|
||||
}
|
||||
|
||||
public DataTypeOption Union(DataTypeOption oth)
|
||||
{
|
||||
DataTypeOption res = new();
|
||||
foreach (DataType t in this)
|
||||
res.Add(t);
|
||||
foreach (DataType t in oth)
|
||||
res.Add(t);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
108
src/DataStructures/DataTypes/DataType.cs
Normal file
108
src/DataStructures/DataTypes/DataType.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using Godot;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
|
||||
namespace Nocturnis.DataStructures.DataTypes;
|
||||
|
||||
public class DataType
|
||||
{
|
||||
public static DataType ArrayDataType(DataType elementType) => new()
|
||||
{
|
||||
Type = DataTypeConstant.NestedDataTypeNames.Array,
|
||||
ElementType = new DataType(elementType)
|
||||
};
|
||||
|
||||
|
||||
public static DataType StructDataType(StringName structName) => new()
|
||||
{
|
||||
Type = DataTypeConstant.NestedDataTypeNames.Struct,
|
||||
StructName = structName
|
||||
};
|
||||
|
||||
public static DataType BaseDataType(StringName baseType) => new()
|
||||
{
|
||||
Type = baseType
|
||||
};
|
||||
|
||||
public static DataType AutoDataType() => new()
|
||||
{
|
||||
Type = DataTypeConstant.BaseDataTypeNames.Null,
|
||||
Auto = true
|
||||
};
|
||||
|
||||
public static DataType AutoArrayType() => new()
|
||||
{
|
||||
Type = DataTypeConstant.NestedDataTypeNames.Array,
|
||||
ElementType = AutoDataType()
|
||||
};
|
||||
|
||||
public static DataType AutoStructType() => new()
|
||||
{
|
||||
Type = DataTypeConstant.NestedDataTypeNames.Struct,
|
||||
Auto = true,
|
||||
StructName = null
|
||||
};
|
||||
|
||||
public bool Equals(DataType other)
|
||||
{
|
||||
return this == other;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != this.GetType()) return false;
|
||||
return Equals((DataType)obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode() => Signature.GetHashCode();
|
||||
public DataType(StringName baseType, bool auto = false)
|
||||
{
|
||||
Type = baseType;
|
||||
ElementType = DataTypeConstant.BaseDataTypes.Null;
|
||||
}
|
||||
|
||||
public DataType(DataType oth)
|
||||
{
|
||||
Type = oth.Type;
|
||||
if (Type == DataTypeConstant.NestedDataTypeNames.Array)
|
||||
ElementType = new DataType(oth.ElementType);
|
||||
else
|
||||
ElementType = null;
|
||||
if (Type == DataTypeConstant.NestedDataTypeNames.Struct)
|
||||
StructName = oth.StructName;
|
||||
}
|
||||
|
||||
public DataType()
|
||||
{
|
||||
}
|
||||
|
||||
public StringName Type { get; set; }
|
||||
public StringName StructName { get; set; }
|
||||
public DataType ElementType { get; set; }
|
||||
public bool Auto { get; set; } = false;
|
||||
|
||||
public string Signature
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Type == DataTypeConstant.NestedDataTypeNames.Array)
|
||||
return Type + $"<{ElementType!.Signature}>";
|
||||
if (Type == DataTypeConstant.NestedDataTypeNames.Struct)
|
||||
return Type + $"[{StructName}]";
|
||||
return Type;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(DataType a, DataType b) => a.Signature == b.Signature;
|
||||
|
||||
public static bool operator !=(DataType a, DataType b) => a.Signature != b.Signature;
|
||||
|
||||
public void Assign(DataType oth)
|
||||
{
|
||||
Type = oth.Type;
|
||||
ElementType.Assign(oth.ElementType);
|
||||
StructName = oth.StructName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using Godot;
|
||||
using System.Numerics;
|
||||
using Skeleton.Algebra;
|
||||
using Skeleton.Algebra.DimensionProviders;
|
||||
|
||||
namespace Nocturnis.DataStructures;
|
||||
using R2 = CategoryOf<IDim2>.OnField<double>.FVector;
|
||||
using C2 = CategoryOf<IDim2>.OnField<Complex>.FVector;
|
||||
|
||||
public interface IData
|
||||
{
|
||||
public void Assign(IData oth);
|
||||
public void Assign(object v, StringName t);
|
||||
object? Data { get; set; }
|
||||
StringName? Type { get; set; }
|
||||
int Int { get; set; }
|
||||
double Double { get; set; }
|
||||
Complex Complex { get; set; }
|
||||
IData[] Array { get; set; }
|
||||
R2 R2 { get; set; }
|
||||
C2 C2 { get; set; }
|
||||
bool Bit { get; set; }
|
||||
StringName String { get; set; }
|
||||
IStruct Struct { get; set; }
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using Godot;
|
||||
|
||||
namespace Nocturnis.DataStructures;
|
||||
|
||||
public interface IStruct : IData
|
||||
{
|
||||
StringName TypeName { get; set; }
|
||||
Dictionary<StringName, IData> Properties { get; set; }
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.Data;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
@@ -6,8 +7,8 @@ namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
|
||||
public static class EBinaryComputationalModule
|
||||
{
|
||||
public static IData X(this IBinaryComputationalModule p, CacheItem x) => p.DataInPorts[0].GetData.GetFrom(x)!;
|
||||
public static IData Y(this IBinaryComputationalModule p, CacheItem x) => p.DataInPorts[1].GetData.GetFrom(x)!;
|
||||
public static DataVariable X(this IBinaryComputationalModule p, CacheItem x) => p.DataInPorts[0].GetData.GetFrom(x)!;
|
||||
public static DataVariable Y(this IBinaryComputationalModule p, CacheItem x) => p.DataInPorts[1].GetData.GetFrom(x)!;
|
||||
|
||||
public static void BinaryInit(this IBinaryComputationalModule p)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
@@ -6,13 +7,13 @@ namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
|
||||
public static class EDuplicateOutputModule
|
||||
{
|
||||
public static void Define(this IDuplicateOutputModule m, Func<CacheItem, (object, StringName)> define)
|
||||
public static void Define(this IDuplicateOutputModule m, Func<CacheItem, (object, DataType)> define)
|
||||
{
|
||||
foreach (IDataOutPort op in m.DataOutPorts)
|
||||
op.OutData.UpdateCalculation(define);
|
||||
}
|
||||
|
||||
public static void SetOutputType(this IDuplicateOutputModule m, StringName type)
|
||||
public static void SetOutputType(this IDuplicateOutputModule m, DataType type)
|
||||
{
|
||||
foreach (IDataOutPort op in m.DataOutPorts)
|
||||
op.SetDataType(type);
|
||||
|
||||
@@ -7,9 +7,9 @@ public static class ELogicModule
|
||||
{
|
||||
public static void LogicModuleInit(this ILogicModule lm)
|
||||
{
|
||||
foreach (IDataOutPort op in lm.DataOutPorts)
|
||||
op.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
foreach (IDataInPort ip in lm.DataInPorts)
|
||||
ip.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
//foreach (IDataOutPort op in lm.DataOutPorts)
|
||||
// op.SetDataType(DataTypeConstant.BaseDataTypes.Bit);
|
||||
//foreach (IDataInPort ip in lm.DataInPorts)
|
||||
// ip.SetDataType(DataTypeConstant.BaseDataTypes.Bit);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
|
||||
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
|
||||
public static class EOperationModule
|
||||
{
|
||||
public static void SetInputType(this IOperationModule m, StringName type)
|
||||
public static void SetInputType(this IOperationModule m, DataType type)
|
||||
{
|
||||
foreach (IDataInPort ip in m.DataInPorts)
|
||||
ip.SetDataType(type);
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.Data;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
|
||||
public static class ETernaryComputationalModule
|
||||
{
|
||||
public static IData X(this ITernaryComputationalModule m, CacheItem cache) =>
|
||||
public static DataVariable X(this ITernaryComputationalModule m, CacheItem cache) =>
|
||||
m.DataOutPorts[0].OutData.GetFrom(cache)!;
|
||||
public static IData Y(this ITernaryComputationalModule m, CacheItem cache) =>
|
||||
public static DataVariable Y(this ITernaryComputationalModule m, CacheItem cache) =>
|
||||
m.DataOutPorts[1].OutData.GetFrom(cache)!;
|
||||
public static IData Z(this ITernaryComputationalModule m, CacheItem cache) =>
|
||||
public static DataVariable Z(this ITernaryComputationalModule m, CacheItem cache) =>
|
||||
m.DataOutPorts[2].OutData.GetFrom(cache)!;
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.Data;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
|
||||
public static class EUnaryComputationalModule
|
||||
{
|
||||
public static IData X(this IUnaryComputationalModule m, CacheItem cache) =>
|
||||
public static DataVariable X(this IUnaryComputationalModule m, CacheItem cache) =>
|
||||
m.DataOutPorts[0].OutData.GetFrom(cache)!;
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
using Godot;
|
||||
using Nocturnis.Communicators;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.Data;
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
|
||||
namespace Nocturnis.Enigmos.Modules;
|
||||
|
||||
public interface ICommunicateModule : IBaseModule
|
||||
{
|
||||
IBaseCommunicator? PairedCommunicator { get; set; }
|
||||
StringName CommunicationDataType { get; }
|
||||
DataType CommunicationDataType { get; }
|
||||
StringName CommunicationDirection { get; }
|
||||
IData DataBuffer { get; set; }
|
||||
DataVariable DataBuffer { get; set; }
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.Data;
|
||||
|
||||
namespace Nocturnis.Enigmos.Modules;
|
||||
|
||||
public interface IEnumerableProcessingModule : ICompositeModule
|
||||
{
|
||||
IData[] CachedInputArray { get; set; }
|
||||
DataVariable[] CachedInputArray { get; set; }
|
||||
int ProcessingIndex { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.Data;
|
||||
|
||||
namespace Nocturnis.Enigmos.Modules;
|
||||
|
||||
public interface IFilterModule : IProgrammableModule
|
||||
{
|
||||
void Filter();
|
||||
IData[] CachedInputArray { get; set; }
|
||||
IData[] CachedResult { get; set; }
|
||||
DataVariable[] CachedInputArray { get; set; }
|
||||
DataVariable[] CachedResult { get; set; }
|
||||
int ProcessingIndex { get; set; }
|
||||
bool FilterFinished { get; set; }
|
||||
bool FilterStarted { get; set; }
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.Data;
|
||||
|
||||
namespace Nocturnis.Enigmos.Modules;
|
||||
|
||||
public interface IInternalComputationalModule : ICompositeModule
|
||||
{
|
||||
IData? CachedResult { get; set; }
|
||||
DataVariable? CachedResult { get; set; }
|
||||
void Compute();
|
||||
bool ComputationFinished { get; set; }
|
||||
bool ComputationStarted { get; set; }
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.Data;
|
||||
|
||||
namespace Nocturnis.Enigmos.Modules;
|
||||
|
||||
public interface IOptimizationModule : IProgrammableModule
|
||||
{
|
||||
IData CachedResult { get; set; }
|
||||
DataVariable CachedResult { get; set; }
|
||||
bool ComputationStarted { get; set; }
|
||||
bool ComputationFinished { get; set; }
|
||||
void Optimize();
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
|
||||
namespace Nocturnis.Enigmos.Ports.DataPorts;
|
||||
|
||||
public interface IDataPort : IBasePort
|
||||
{
|
||||
new IDataPort? ConnectedPort { get; set; }
|
||||
StringName? DataType { get; set; }
|
||||
void SetDataType(StringName type);
|
||||
DataType DataType { get; set; }
|
||||
void SetDataType(DataType type);
|
||||
}
|
||||
|
||||
33
src/GlobalManagement/Constants/DataTypeConstant.cs
Normal file
33
src/GlobalManagement/Constants/DataTypeConstant.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.DataTypeOptions;
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Nocturnis.GlobalManagement.Constants;
|
||||
|
||||
public static partial class DataTypeConstant
|
||||
{
|
||||
public static class NestedDataTypeNames
|
||||
{
|
||||
public static readonly StringName Array = "Array";
|
||||
public static readonly StringName Struct = "Struct";
|
||||
public static readonly StringName Auto = "Auto";
|
||||
}
|
||||
|
||||
public static class AutoDataTypes
|
||||
{
|
||||
public static readonly DataType Auto = DataType.AutoDataType();
|
||||
public static readonly DataType AutoArray = DataType.AutoArrayType();
|
||||
public static readonly DataType AutoStruct = DataType.AutoStructType();
|
||||
}
|
||||
|
||||
public static partial class DataTypeOptions
|
||||
{
|
||||
public static readonly DataTypeOption ScalarTypes = new(BaseDataTypes.Real, BaseDataTypes.Complex);
|
||||
public static readonly DataTypeOption VectorTypes = new(BaseDataTypes.R2, BaseDataTypes.C2);
|
||||
public static readonly DataTypeOption TensorTypes = ScalarTypes.Union(VectorTypes);
|
||||
public static readonly DataTypeOption AnyType = new();
|
||||
public static readonly DataTypeOption AnyArray = new(DataType.ArrayDataType(BaseDataTypes.Null));
|
||||
public static readonly DataTypeOption AnyStruct = new(DataType.StructDataType(null));
|
||||
}
|
||||
}
|
||||
@@ -4,23 +4,7 @@ namespace Nocturnis.GlobalManagement.Constants;
|
||||
|
||||
public static class EnigmosConstant
|
||||
{
|
||||
public static class DataPortTypes
|
||||
{
|
||||
public static readonly StringName Null = "Null";
|
||||
public static readonly StringName Bit = "Bit";
|
||||
public static readonly StringName Real = "Real";
|
||||
public static readonly StringName Complex = "Complex";
|
||||
public static readonly StringName R2 = "R2";
|
||||
public static readonly StringName C2 = "C2";
|
||||
public static readonly StringName RealArray = "RealArray";
|
||||
public static readonly StringName AnyArrayType = "AnyArrayType";
|
||||
public static readonly StringName[] NumericTypes = new[] { Real, Complex };
|
||||
public static readonly StringName[] AnyTensor = new[] { Real, Complex, R2, C2 };
|
||||
public static readonly StringName[] AnyType = new[] { Real, Complex, R2, C2 };
|
||||
public static readonly StringName[] VectorTypes = new[] { R2, C2 };
|
||||
public static readonly StringName[] AnyArray = Array.Empty<StringName>();
|
||||
|
||||
}
|
||||
|
||||
public static class CommunicationDirections
|
||||
{
|
||||
public static readonly StringName Send = "Send";
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.Data;
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Inventories.Items;
|
||||
|
||||
@@ -33,4 +35,15 @@ public static class GlobalProvider
|
||||
public static readonly Dictionary<string, PackedScene> SceneNameMapper = new();
|
||||
|
||||
public static Font? Font { get; set; }
|
||||
|
||||
public static class DataTypes
|
||||
{
|
||||
public static DataType Null { get; set; }
|
||||
public static DataType Bit { get; set; }
|
||||
public static DataType Real { get; set; }
|
||||
public static DataType Complex { get; set; }
|
||||
public static DataType R2 { get; set; }
|
||||
public static DataType C2 { get; set; }
|
||||
public static DataType Int { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.ConfigurableParameters;
|
||||
using Nocturnis.DataStructures.Data;
|
||||
using Nocturnis.DataStructures.DataPortGroups;
|
||||
using Nocturnis.DataStructures.DataTypeOptions;
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
@@ -10,20 +13,21 @@ namespace Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
public interface IDataStructureProvider
|
||||
{
|
||||
DataType NullDataType { get; }
|
||||
Variant NewVariantWithType(string type, Variant a);
|
||||
IBoolParameter NewBoolParameter(string d, string t, string f, bool def);
|
||||
|
||||
IDataPortGroup NewDataPortGroup(IBaseModule m, IDataPort[] pts, string desc, StringName defType, StringName[] typeOpts);
|
||||
IDataPortGroup NewDataPortGroup(IBaseModule m, IDataPort[] pts, string desc, DataType defType, DataTypeOption typeOpts);
|
||||
|
||||
IDataInGroup NewDataInGroup(IBaseModule m, IDataInPort[] pts, string desc, StringName defType, StringName[] typeOpts);
|
||||
IDataInGroup NewDataInGroup(IBaseModule m, IDataInPort[] pts, string desc, DataType defType, DataTypeOption typeOpts);
|
||||
|
||||
IDataOutGroup NewDataOutGroup(IBaseModule m, IDataOutPort[] pts, string desc, StringName defType, StringName[] typeOpts);
|
||||
IDataOutGroup NewDataOutGroup(IBaseModule m, IDataOutPort[] pts, string desc, DataType defType, DataTypeOption typeOpts);
|
||||
|
||||
IData NewData(object data, StringName type);
|
||||
DataVariable NewData(object data, DataType type);
|
||||
|
||||
IDoubleParameter NewDoubleParameter(string name, double min, double max, double def);
|
||||
IKeyParameter NewKeyParameter(string a, string b);
|
||||
IData NullData { get; }
|
||||
IData DefaultData { get; }
|
||||
DataVariable NullData { get; }
|
||||
DataVariable DefaultData { get; }
|
||||
StringName ArrayToElement(StringName arrayType);
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
|
||||
namespace Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
public interface IDataTypeProvider
|
||||
{
|
||||
bool IsComplexTensorType(StringName type);
|
||||
StringName ComplexVersionOf(StringName type);
|
||||
StringName BuildType(StringName nType, int i, int j);
|
||||
StringName GetBaseField(StringName type);
|
||||
bool DataPortTypeCompatible(StringName inType, StringName outType);
|
||||
StringName ToElement(StringName arrayType);
|
||||
bool IsComplexTensorType(DataType type);
|
||||
DataType ComplexVersionOf(DataType type);
|
||||
DataType BuildType(DataType nType, int i, int j);
|
||||
DataType GetBaseField(DataType type);
|
||||
bool DataPortTypeCompatible(DataType inType, DataType outType);
|
||||
DataType ToElement(DataType arrayType);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
|
||||
namespace Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
@@ -14,7 +15,7 @@ public interface IEnigmosProvider
|
||||
|
||||
PackedScene SignalCableScene { get; set; }
|
||||
PackedScene DataCableScene { get; set; }
|
||||
Dictionary<StringName, Texture2D> DataPortTypeMap { get; set; }
|
||||
Dictionary<DataType, Texture2D> DataPortTypeMap { get; set; }
|
||||
|
||||
bool CommunicationDirectionCompatible(StringName moduleDir, StringName communicatorDir);
|
||||
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.DataStructures.Data;
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
|
||||
namespace Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
public interface IPolymorphismProvider
|
||||
{
|
||||
(object, StringName) Square(IData a);
|
||||
(object, StringName) Neg(IData a);
|
||||
(object, StringName) Add(IData a, IData b);
|
||||
(object, StringName) Sub(IData a, IData b);
|
||||
(object, StringName) Div(IData a, IData b);
|
||||
(object, StringName) Dot(IData a, IData b);
|
||||
(object, StringName) Mul(IData a, IData b);
|
||||
(object, StringName) Pow(IData a, IData b);
|
||||
(object, StringName) ScalarDiv(IData a, IData b);
|
||||
(object, StringName) ScalarMul(IData a, IData b);
|
||||
(object, DataType) Square(DataVariable a);
|
||||
(object, DataType) Neg(DataVariable a);
|
||||
(object, DataType) Add(DataVariable a, DataVariable b);
|
||||
(object, DataType) Sub(DataVariable a, DataVariable b);
|
||||
(object, DataType) Div(DataVariable a, DataVariable b);
|
||||
(object, DataType) Dot(DataVariable a, DataVariable b);
|
||||
(object, DataType) Mul(DataVariable a, DataVariable b);
|
||||
(object, DataType) Pow(DataVariable a, DataVariable b);
|
||||
(object, DataType) ScalarDiv(DataVariable a, DataVariable b);
|
||||
(object, DataType) ScalarMul(DataVariable a, DataVariable b);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user