Class Index | File Index

Classes


Class dataTable


Extends component.
dataTable
Defined in: dataTable.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
A component that can store and import arbitrary data.
Fields borrowed from class component:
host, info, isDrawing, isStepping, onAttach, onDraw, onStep, tag
Method Summary
Method Attributes Method Name and Description
 
Removes all stored associations and data entries, restoring the container back to a default state.
 
Writes a pure data-form of the table's contents.
 
query(name)
Returns whether there is a datum-name association with the given name.
 
Retrieves a datum associated with a name.
 
readString(name)
Retrieves a datum associated with a name.
 
remove(name)
Removes the datum-name association.
 
setState(byteArray)
Sets the dataTable state to reflect the state defined by the input buffer.
 
writeByteArray(name, byteData)
Associates a datum with a name.
 
writeString(name, i)
Associates a datum with a name.
Methods borrowed from class component:
canHandleEvent, draw, emitEvent, getKnownEvents, installEvent, installHandler, installHook, step, uninstallEvent, uninstallHandler, uninstallHook
Class Detail
dataTable()
A component that can store and import arbitrary data. Instantiates with sandboxe.dataTable.create()

Provides a convenient interface for placing and retrieving named properties.

Often with programs, there is a need to preserve data beyond the execution of the program. Sometimes, it is enough to simply write to a text file, but this isn't always flexible, and has little resistance against device errors, forms of corruption, and user tampering. dataTable provides a non-sequential, corruption-resistant way to store data. Using the Write functions, you can store named variables , data, and even other dataTables in a safe manner. Then getState() can be used to retrieve a data buffer that represents the dataTable's exact state, which can then be used later in another instance.

Known component events:
- on-read: after reading a piece of data. 
- on-write: before writing a piece of data. The default handler actually performs the write, so stopping propogation will prevent writing.
- on-remove: before removing a piece of data. The default handler actually performs the removal, so stopping propogation will prevent removal. 
- on-read-state: after successfully reading a state
Method Detail
clear()
Removes all stored associations and data entries, restoring the container back to a default state.

{Array} getState()
Writes a pure data-form of the table's contents. This can then be passed into setState() turn the calling object into an exact copy of this one. getState() / setState() were intended to be used in tandem to preserve data contents of the dataTable across program invocations. Along with writing the exact state of the dataTable, the data includes header and checksum data to improve parity across execution states.
Returns:
{Array} An array of byte values to later be re-read with setState()

{boolean} query(name)
Returns whether there is a datum-name association with the given name.
Parameters:
{String} name
The name to look up.
Returns:
{boolean}

{Array} readByteArray(name)
Retrieves a datum associated with a name. If there is no such association, an empty Array is returned.
Parameters:
{String} name
The name associated with the data.
Returns:
{Array} The data for that name.

{String} readString(name)
Retrieves a datum associated with a name. If there is no such association, an empty string is returned.
Parameters:
{String} name
The name associated with the data.
Returns:
{String} The data for that name.

remove(name)
Removes the datum-name association.
Parameters:
{String} name
The name to remove.

setState(byteArray)
Sets the dataTable state to reflect the state defined by the input buffer. The buffer is implied to have been produced from a getState call. If not, or corruption on some device has occurred, there is a good chance that this function will detect it before applying the data. In the case that an error does occur, false will be returned and no action taken.
Parameters:
{Array} byteArray
An array of byte values assumed to be from getState().

writeByteArray(name, byteData)
Associates a datum with a name.
Parameters:
{String} name
The name that the data will be associated with
{Array} byteData
The data to store as an array of numbers, each being a byte value

writeString(name, i)
Associates a datum with a name.
Parameters:
{String} name
The name that the data will be associated with
{String} i
The data to store

Documentation generated by JsDoc Toolkit 2.4.0 on Sun Feb 03 2019 18:30:56 GMT-0500 (EST)