Gorgon Game Engine
Blob Class Reference

This is sound resource. More...

Inheritance diagram for Blob:
[legend]

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...
 
- Public Member Functions inherited from Base
 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...
 
BaseGetParent () const
 Returns the parent. If no parent set, this function throws std::runtime_error. More...
 
BaseGetParentPtr () const
 Returns the pointer to the parent. This function may return nullptr. More...
 
const BaseGetRoot () 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 BlobLoadResource (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
 
- Protected Member Functions inherited from Base
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< Bytedata
 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< Readerreader
 Used to handle late loading. More...
 
Type type
 Type of the blob data. More...
 
- Protected Attributes inherited from Base
Containers::Collection< Basechildren
 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...
 
Baseparent
 Immediate parent of this resource. More...
 
const Baseroot
 Root of this resource. More...
 

Additional Inherited Members

- Public Attributes inherited from Base
const Containers::Collection< Base > & Children
 The children this object have. More...
 
unsigned long refcount
 INTERNAL, Reference count, used in linking mechanism. More...
 

Detailed Description

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.

Member Typedef Documentation

◆ Type

typedef int Type

The type information related to the blob.

Constructor & Destructor Documentation

◆ Blob()

Blob ( )

Default constructor.

◆ ~Blob()

virtual ~Blob ( )
virtual

Destructor.

Member Function Documentation

◆ AppendFile()

bool AppendFile ( const std::string &  filename)

Appends the given file to the end of the blob data.

References Blob::data.

◆ Destroy()

void Destroy ( )

Destroys the data stored in the blob.

References Blob::data, Blob::isloaded, and Blob::type.

◆ GetData()

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.

◆ GetGID()

virtual GID::Type GetGID ( ) const
overridevirtual

04010000h (Extended, Blob)

Implements Base.

References Gorgon::Resource::GID::Blob.

◆ GetSize()

unsigned long GetSize ( ) const

Size of the blob.

References Blob::data.

◆ GetType()

Type GetType ( ) const

Returns the type of the blob.

References Blob::type.

◆ ImportFile() [1/2]

bool ImportFile ( const std::string &  filename)

Imports the given file as data without changing the type of the blob.

References Blob::type.

◆ ImportFile() [2/2]

bool ImportFile ( const std::string &  filename,
Type  type 
)

Imports the given file as data and sets the type.

◆ IsLoaded()

bool IsLoaded ( ) const

Returns whether the blob data is loaded.

References Blob::isloaded.

◆ Load()

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.

◆ load()

◆ LoadResource()

Blob * LoadResource ( std::weak_ptr< File file,
std::shared_ptr< Reader reader,
unsigned long  size 
)
static

This function loads a blob resource from the given file.

References Blob::Blob(), and Blob::reader.

◆ Ready()

std::vector< Byte > & Ready ( unsigned long  size,
Type  type = 0 
)

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.

◆ save()

Member Data Documentation

◆ compression

GID::Type compression
protected

Compression mode of this blob.

◆ data

std::vector<Byte> data
protected

Blob data.

◆ entrypoint

unsigned long entrypoint
protected

Entry point of this resource within the physical file.

This value is stored for late loading purposes

◆ isloaded

bool isloaded
protected

Whether this blob is loaded or not.

◆ lateloading

bool lateloading
protected

Whether to load this blob during initial loading.

◆ reader

std::shared_ptr<Reader> reader
protected

Used to handle late loading.

◆ type

Type type
protected

Type of the blob data.


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