![]() |
Gorgon Game Engine
|
This is sound resource. More...
Public Types | |
typedef int | Type |
The type information related to the blob. More... | |
Public Member Functions | |
Blob () | |
Default constructor. More... | |
virtual | ~Blob () |
Destructor. More... | |
bool | AppendFile (const std::string &filename) |
Appends the given file to the end of the blob data. More... | |
void | Destroy () |
Destroys the data stored in the blob. More... | |
std::vector< Byte > & | GetData () |
Returns the data stored in this blob. More... | |
virtual GID::Type | GetGID () const override |
04010000h (Extended, Blob) More... | |
unsigned long | GetSize () const |
Size of the blob. More... | |
Type | GetType () const |
Returns the type of the blob. More... | |
bool | ImportFile (const std::string &filename) |
Imports the given file as data without changing the type of the blob. More... | |
bool | ImportFile (const std::string &filename, Type type) |
Imports the given file as data and sets the type. More... | |
bool | IsLoaded () const |
Returns whether the blob data is loaded. More... | |
bool | Load () |
Loads the blob from the disk. If blob is already loaded, this function will return true. More... | |
std::vector< Byte > & | Ready (unsigned long size, Type type=0) |
Readies the blob for data writing. More... | |
![]() | |
Base () | |
Default constructor. More... | |
const Containers::Collection< Base >::ConstIterator | begin () const |
Allows easy iteration through range based fors. More... | |
const Containers::Collection< Base >::ConstIterator | cbegin () const |
Beginning of children. More... | |
const Containers::Collection< Base >::ConstIterator | cend () const |
End of children. More... | |
bool | DeleteResource () |
Safely deletes the resource. More... | |
virtual void | Discard () |
This function shall discard any transitional data which is not vital after Prepare function is issued. More... | |
const Containers::Collection< Base >::ConstIterator | end () const |
Allows easy iteration through range based fors. More... | |
virtual SGuid | GetGuid () const |
Returns the guid of the object. More... | |
const std::string & | GetName () const |
Returns the name of this object. More... | |
Base & | GetParent () const |
Returns the parent. If no parent set, this function throws std::runtime_error. More... | |
Base * | GetParentPtr () const |
Returns the pointer to the parent. This function may return nullptr. More... | |
const Base & | GetRoot () const |
Returns the root of this resource. More... | |
bool | HasParent () const |
Returns whether this object has a parent. More... | |
virtual bool | IsEqual (const SGuid &guid) const |
This function tests whether this object has the given SGuid. More... | |
virtual void | Prepare () |
This function shall prepare this resource to be used after resource is loaded. More... | |
virtual void | Resolve (File &file) |
This function shall resolve links or similar constructs. More... | |
void | Save (Writer &writer) |
Saves this object into the given writer. The writer should be open prior to this call. More... | |
virtual void | SetGuid (SGuid guid) |
Changes the guid of the object. More... | |
virtual void | SetName (const std::string &name) |
Sets the name of the object. More... | |
Static Public Member Functions | |
static Blob * | LoadResource (std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long size) |
This function loads a blob resource from the given file. More... | |
Protected Member Functions | |
bool | load (std::shared_ptr< Reader > reader, unsigned long size, bool forceload) |
Loads the blob from the data stream. More... | |
void | save (Writer &writer) const override |
![]() | |
virtual | ~Base () |
Destructor, Always children gets destroyed first. More... | |
void | destroychildren () |
Destroys the children of this resource. More... | |
void | setparenttonullptr (Base &base) |
Sets the parent of an object to nullptr, provides access. More... | |
Protected Attributes | |
GID::Type | compression |
Compression mode of this blob. More... | |
std::vector< Byte > | data |
Blob data. More... | |
unsigned long | entrypoint |
Entry point of this resource within the physical file. More... | |
bool | isloaded |
Whether this blob is loaded or not. More... | |
bool | lateloading |
Whether to load this blob during initial loading. More... | |
std::shared_ptr< Reader > | reader |
Used to handle late loading. More... | |
Type | type |
Type of the blob data. More... | |
![]() | |
Containers::Collection< Base > | children |
Child objects that this resource object have. More... | |
SGuid | guid |
SGuid to identify this resource object. More... | |
std::string | name |
Name of this resource object, may not be loaded. More... | |
Base * | parent |
Immediate parent of this resource. More... | |
const Base * | root |
Root of this resource. More... | |
Additional Inherited Members | |
![]() | |
const Containers::Collection< Base > & | Children |
The children this object have. More... | |
unsigned long | refcount |
INTERNAL, Reference count, used in linking mechanism. More... | |
This is sound resource.
It may contain 22kHz or 44kHz mono or stereo wave files. Also supports LZMA compression. No native sound compression is supported.
typedef int Type |
The type information related to the blob.
Blob | ( | ) |
Default constructor.
|
virtual |
Destructor.
bool AppendFile | ( | const std::string & | filename | ) |
Appends the given file to the end of the blob data.
References Blob::data.
void Destroy | ( | ) |
Destroys the data stored in the blob.
References Blob::data, Blob::isloaded, and Blob::type.
std::vector<Byte>& GetData | ( | ) |
Returns the data stored in this blob.
It is safe to change its contents, even its size. However, its better to use reset to adjust the size and the type of the blob
References Blob::data.
|
overridevirtual |
unsigned long GetSize | ( | ) | const |
Size of the blob.
References Blob::data.
Type GetType | ( | ) | const |
Returns the type of the blob.
References Blob::type.
bool ImportFile | ( | const std::string & | filename | ) |
Imports the given file as data without changing the type of the blob.
References Blob::type.
bool ImportFile | ( | const std::string & | filename, |
Type | type | ||
) |
Imports the given file as data and sets the type.
bool IsLoaded | ( | ) | const |
Returns whether the blob data is loaded.
References Blob::isloaded.
bool Load | ( | ) |
Loads the blob from the disk. If blob is already loaded, this function will return true.
References Blob::entrypoint, Blob::isloaded, Blob::load(), and Blob::reader.
|
protected |
Loads the blob from the data stream.
References Gorgon::Utils::ASSERT_FALSE(), Gorgon::Resource::GID::Blob_Cmp_Data, Gorgon::Resource::GID::Blob_Data, Gorgon::Resource::GID::Blob_Props, Blob::compression, Blob::data, LZMA::Decode(), Blob::entrypoint, Gorgon::String::From(), Blob::isloaded, Blob::lateloading, Gorgon::Encoding::Lzma, Blob::reader, and Blob::type.
|
static |
This function loads a blob resource from the given file.
References Blob::Blob(), and Blob::reader.
Readies the blob for data writing.
Erases previous data, sets current size and type. Also marks blob as loaded. Returned vector which can be used to assign data to it. The returned vector should not be resized even though it will work (for now). It also discards any reader connections.
|
overrideprotectedvirtual |
Implements Base.
References Gorgon::Resource::GID::Blob_Cmp_Data, Gorgon::Resource::GID::Blob_Data, Gorgon::Resource::GID::Blob_Props, Blob::compression, Blob::data, LZMA::Encode(), Gorgon::String::From(), Writer::GetStream(), Blob::lateloading, Gorgon::Encoding::Lzma, Gorgon::Resource::GID::LZMA, Gorgon::Resource::GID::None, Blob::type, Writer::WriteBool(), Writer::WriteChunkHeader(), Writer::WriteChunkStart(), Writer::WriteEnd(), Writer::WriteGID(), Writer::WriteInt32(), Writer::WriteObjectStart(), Writer::WriteUInt32(), and Writer::WriteVector().
|
protected |
Compression mode of this blob.
|
protected |
Entry point of this resource within the physical file.
This value is stored for late loading purposes
|
protected |
Whether this blob is loaded or not.
|
protected |
Whether to load this blob during initial loading.
|
protected |
Used to handle late loading.
|
protected |
Type of the blob data.