Accelerated Computation Engine
|
#include <ace_dataobject.h>
Public Slots | |
void | dataOverwritten (const QString &canonicalPath, Ace::DataObject *object) |
Signals | |
void | overwritten () |
Public Member Functions | |
DataObject (const QString &path, QObject *parent=nullptr) | |
DataObject (const QString &path, quint16 type, const EMetadata &system, QObject *parent=nullptr) | |
QString | rawPath () const |
QString | path () const |
QString | fileName () const |
quint16 | type () const |
qint64 | size () const |
const EMetadata & | systemMeta () const |
const EMetadata & | userMeta () const |
void | seek (qint64 index) const |
const EDataStream & | stream () const |
void | allocate (int size) |
EDataStream & | stream () |
EAbstractData * | data () |
void | setUserMeta (const EMetadata &newRoot) |
void | finalize () |
void | read (char *data, qint64 size) const |
void | write (const char *data, qint64 size) |
This is the file handler object for an open ACE data object. It works like a very basic Qt file device object but much simpler. Most importantly it hides the very beginning of the file which is the header of the data object, preventing it from accidentally being overwritten. This class is also unique in treating any read operation to its underlying file as constant. So things such as seeking and reading functions are declared constant. This is because ACE is made towards big data where it is impossible to just read an entire file into system memory.
|
explicit |
Creates a new data object from the file with the given path and optional parent. If the path does not exist or it is corrupt then an exception is thrown.
path | Path of the data object file to open. |
parent | Parent for this data object. |
|
explicit |
Creates a new data object file with the given type, the given file path, and the given system metadata. Optionally a parent for this data object is given. The file at the given path is overwritten. If the file truncation fails, writing to it fails, or the given system metadata is not an object type then an exception is thrown.
path | Path for this new data object's file that is overwritten. |
type | Data object type for this newly created data object. |
system | System metadata for this new data object. The metadata must be an object type or an exception is thrown. |
parent | Parent for this data object. |
void DataObject::allocate | ( | int | size | ) |
Allocates new space in this data object by the given number of bytes. The new space requested is in addition to the current cursor position of this data object. So if the cursor position is at the end of the data object then this will grow the data object by the given amount. However if the cursor position is at the beginning of the data object then this will only grow the data object by the difference of the amount given and this data object's current size. If the given size is less than 0 or resizing fails then an exception is thrown.
size | The number of bytes to allocate after this data object's current cursor position. |
EAbstractData * DataObject::data | ( | ) |
Returns a pointer to the abstract data object for this data object.
|
slot |
Called when a new data object has overwritten the given file path.
canonicalPath | Canonical path of the file a new data object is overwriting. |
object | Pointer to the new data object overwriting the given file path. |
QString DataObject::fileName | ( | ) | const |
Returns the file name for this data object.
void DataObject::finalize | ( | ) |
Finalizes this new data object by writing out the user metadata to an empty object if it has not already been written. If it has already been written or this is not a new data object then this does nothing.
|
signal |
Signals that the file of this data object has been overwritten by another data object being created. The owner of this data object must delete this data object immediately to avoid undefined behavior.
QString DataObject::path | ( | ) | const |
Returns the path for this data object's file in absolute canonical terms.
QString DataObject::rawPath | ( | ) | const |
Returns the raw path for this data object's file that was passed to it as a constructor argument.
void DataObject::read | ( | char * | data, |
qint64 | size | ||
) | const |
Reads in the given number of bytes from this data object at its current cursor position and writes it to the given character pointer. If reading failed then an exception is thrown.
data | Pointer to character array that is written to from the data read in this data object. |
size | Number of bytes to read from this data object. |
void DataObject::seek | ( | qint64 | index | ) | const |
Seeks to the given index within this data object. This does not allow seeking to the hidden header of this data object so seeking to 0 is one byte after the header. If the given index is less than 0 or seeking fails then an exception is thrown.
index | The index that the cursor position in this data object is set to. |
void DataObject::setUserMeta | ( | const EMetadata & | newRoot | ) |
Sets the user metadata for this data object with the given metadata object as this object's new root. The given metadata value must be an object type.
newRoot | New root metadata value that this data object's user metadata is set to. |
qint64 DataObject::size | ( | ) | const |
Returns the current size of this data object in bytes. This does not include the hidden header portion of the file of this data object.
const EDataStream & DataObject::stream | ( | ) | const |
Returns a read only reference to the data stream for this data object.
EDataStream & DataObject::stream | ( | ) |
Returns a reference to the data stream for this data object.
const EMetadata & DataObject::systemMeta | ( | ) | const |
Returns the read only system metadata for this data object. The root metadata object is always an object type.
quint16 DataObject::type | ( | ) | const |
Returns the data type for this data object.
const EMetadata & DataObject::userMeta | ( | ) | const |
Returns the user metadata for this data object. The root metadata object is always an object type.
void DataObject::write | ( | const char * | data, |
qint64 | size | ||
) |
Write out the given number of bytes to this data object at its current cursor position from the given character pointer. If writing failed then an exception is thrown.
data | Pointer to character array whose data is written to this data object. |
size | The number of bytes to write to this data object from the given character array. |