Accelerated Computation Engine
Public Slots | Signals | Public Member Functions | List of all members
Ace::DataObject Class Reference

#include <ace_dataobject.h>

Inheritance diagram for Ace::DataObject:

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 EMetadatasystemMeta () const
 
const EMetadatauserMeta () const
 
void seek (qint64 index) const
 
const EDataStreamstream () const
 
void allocate (int size)
 
EDataStreamstream ()
 
EAbstractDatadata ()
 
void setUserMeta (const EMetadata &newRoot)
 
void finalize ()
 
void read (char *data, qint64 size) const
 
void write (const char *data, qint64 size)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ DataObject() [1/2]

DataObject::DataObject ( const QString &  path,
QObject *  parent = nullptr 
)
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.

Parameters
pathPath of the data object file to open.
parentParent for this data object.

◆ DataObject() [2/2]

DataObject::DataObject ( const QString &  path,
quint16  type,
const EMetadata system,
QObject *  parent = nullptr 
)
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.

Parameters
pathPath for this new data object's file that is overwritten.
typeData object type for this newly created data object.
systemSystem metadata for this new data object. The metadata must be an object type or an exception is thrown.
parentParent for this data object.

Member Function Documentation

◆ allocate()

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.

Parameters
sizeThe number of bytes to allocate after this data object's current cursor position.

◆ data()

EAbstractData * DataObject::data ( )

Returns a pointer to the abstract data object for this data object.

Returns
Pointer to abstract data object.

◆ dataOverwritten

void DataObject::dataOverwritten ( const QString &  canonicalPath,
Ace::DataObject object 
)
slot

Called when a new data object has overwritten the given file path.

Parameters
canonicalPathCanonical path of the file a new data object is overwriting.
objectPointer to the new data object overwriting the given file path.

◆ fileName()

QString DataObject::fileName ( ) const

Returns the file name for this data object.

Returns
Name of this data object's file.

◆ finalize()

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.

◆ overwritten

void Ace::DataObject::overwritten ( )
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.

◆ path()

QString DataObject::path ( ) const

Returns the path for this data object's file in absolute canonical terms.

Returns
Canonical path to this data object's file.

◆ rawPath()

QString DataObject::rawPath ( ) const

Returns the raw path for this data object's file that was passed to it as a constructor argument.

Returns
Raw path that was passed to this data object's constructor.

◆ read()

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.

Parameters
dataPointer to character array that is written to from the data read in this data object.
sizeNumber of bytes to read from this data object.

◆ seek()

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.

Parameters
indexThe index that the cursor position in this data object is set to.

◆ setUserMeta()

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.

Parameters
newRootNew root metadata value that this data object's user metadata is set to.

◆ size()

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.

Returns
Size of this data object.

◆ stream() [1/2]

const EDataStream & DataObject::stream ( ) const

Returns a read only reference to the data stream for this data object.

Returns
Read only reference to this objects data stream.

◆ stream() [2/2]

EDataStream & DataObject::stream ( )

Returns a reference to the data stream for this data object.

Returns
Reference to this objects data stream.

◆ systemMeta()

const EMetadata & DataObject::systemMeta ( ) const

Returns the read only system metadata for this data object. The root metadata object is always an object type.

Returns
Root of system metadata for this data object.

◆ type()

quint16 DataObject::type ( ) const

Returns the data type for this data object.

Returns
Data object type.

◆ userMeta()

const EMetadata & DataObject::userMeta ( ) const

Returns the user metadata for this data object. The root metadata object is always an object type.

Returns
Root of user metadata for this data object.

◆ write()

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.

Parameters
dataPointer to character array whose data is written to this data object.
sizeThe number of bytes to write to this data object from the given character array.

The documentation for this class was generated from the following files: