Table of Contents

Class PartitionedDataStorage

Namespace
NominalSystems.Classes
Assembly
NominalSystems.Classes.dll

[Nominal] The partitioned data storage unit acts as a hard-drive for storing data on an object. The unit is able to have clusters of data units, with a maximum amount of storage available within each unit. The storage system can partition the data units into groups for easier access management and storage.


public class PartitionedDataStorage : PhysicalObject
Inheritance
PartitionedDataStorage

Constructors

PartitionedDataStorage()

Default constructor

protected PartitionedDataStorage()

Fields

Out_DataStorageMsg

The output message for the data storage system that contains information about the current state of the storage units and systems.

public DataStorageMessage? Out_DataStorageMsg

Field Value

DataStorageMessage

Units

A mapping of data storage name to the data storage unit so that each of the data objects can be stored by keys. This will be useful for reading and writing data within the system.

[Hidden]
public Dictionary<string, DataStorageUnit> Units

Field Value

Dictionary<string, DataStorageUnit>

Properties

Allocated

The allocated memory is the total amount of memory that has been used by all data storage units.

[Unit("B")]
[ReadOnly]
[Metadata(ContainedIn = "Out_DataStorageMsg")]
public int Allocated { get; }

Property Value

int

Capacity

The capacity of the data storage unit will be the maximum amount of data that can be stored on the unit as a total of all clusters that are created.

[Unit("B")]
[Range(1024, 2147483647)]
[Metadata(ContainedIn = "Out_DataStorageMsg")]
public int Capacity { get; set; }

Property Value

int

NumUnits

The total number of units that exist on the storage system

[Unit(UnitType.NONE)]
[ReadOnly]
[Metadata(ContainedIn = "Out_DataStorageMsg", ContainedName = "Partitions")]
public int NumUnits { get; }

Property Value

int

Methods

Delete(PartitionedDataPointer)

Deletes a particular partitioned data pointer from the storage system. This will delete the memory used by a particular unit.

[Hidden]
public bool Delete(PartitionedDataPointer ptr)

Parameters

ptr PartitionedDataPointer

The pointer to the memory used.

Returns

bool

A successful deletion flag

DeleteAll()

Deletes all units and data from the storage system. This will remove all the data stored within the system and will reset the system.

public void DeleteAll()

DeletePartition(string)

Deletes a particular partition from the storage system. This will delete the entire partition and all the data stored within it.

public bool DeletePartition(string partition)

Parameters

partition string

The partition to delete

Returns

bool

A successful deletion flag

OnCreate()

Called when the 'Component' is created from the controller.

protected override void OnCreate()

ReadBytes(PartitionedDataPointer)

Reads the raw data stored within a particular partition based on the pointer provided. If the partition does not exist, it will return an empty array of bytes.

[Hidden]
public byte[] ReadBytes(PartitionedDataPointer ptr)

Parameters

ptr PartitionedDataPointer

The partitioned data pointer

Returns

byte[]

The byte array from the storage system

ReadJSON(PartitionedDataPointer)

Reads the JSON data stored within a particular partition based on the pointer provided. If the partition does not exist, it will return a null reference. This will also attempt to parse the JSON object.

[Hidden]
public JToken? ReadJSON(PartitionedDataPointer ptr)

Parameters

ptr PartitionedDataPointer

The partitioned data pointer

Returns

JToken

The JSON object stored in the storage system

ReadMessage(PartitionedDataPointer, Message)

Reads the message data stored in a particular location within the data storage unit and will return a success flag if able to read correctly. This also requires a reference to the message that will be written to, as it will not be creating a new message from the data, rather it will update the variables in the current message passed in.

[Hidden]
public bool ReadMessage(PartitionedDataPointer ptr, Message msg)

Parameters

ptr PartitionedDataPointer

The partitioned data pointer

msg Message

The message that is being read into

Returns

bool

A successful read operation

ReadString(PartitionedDataPointer)

Reads the string data stored within a particular partition based on the pointer provided. If the partition does not exist, it will return an empty string.

[Hidden]
public string ReadString(PartitionedDataPointer ptr)

Parameters

ptr PartitionedDataPointer

The partitioned data pointer

Returns

string

The string stored in the storage system

WriteBytes(byte[], string)

Attempts to write data to the storage system. This will return a pointer to the data with a particular partition. If the partition does not exist, it will attempt to create a new partition. If there is no available data to fit the data, it will return an empty pointer.

[Hidden]
public PartitionedDataPointer WriteBytes(byte[] data, string partition = "")

Parameters

data byte[]

The data as a byte array

partition string

The partition name to write to

Returns

PartitionedDataPointer

A partitioned data pointer for the reference

WriteJSON(JToken, string)

Attempts to write data to the storage system. This will return a pointer to the data with a particular partition. If the partition does not exist, it will attempt to create a new partition. If there is no available data to fit the data, it will return an empty pointer. This will be in a JSON format of data.

[Hidden]
public PartitionedDataPointer WriteJSON(JToken data, string partition = "")

Parameters

data JToken

The data as a JSON object

partition string

The partition name to write to

Returns

PartitionedDataPointer

A partitioned data pointer for the reference

WriteMessage(Message, string)

Attempts to write data to the storage system. This will return a pointer to the data with a particular partition. If the partition does not exist, it will attempt to create a new partition. If there is no available data to fit the data, it will return an empty pointer. This will be in a standard Nominal message format.

[Hidden]
public PartitionedDataPointer WriteMessage(Message msg, string partition = "")

Parameters

msg Message

The message to write in the storage system

partition string

The partition name to write to

Returns

PartitionedDataPointer

A partitioned data pointer for the reference

WriteString(string, string)

Attempts to write data to the storage system. This will return a pointer to the data with a particular partition. If the partition does not exist, it will attempt to create a new partition. If there is no available data to fit the data, it will return an empty pointer. This will be in a string format of data.

[Hidden]
public PartitionedDataPointer WriteString(string data, string partition = "")

Parameters

data string

The data as a string

partition string

The partition name to write to

Returns

PartitionedDataPointer

A partitioned data pointer for the reference