|
Beatmup
|
Writable ChunkCollection implementation for Python. More...
#include <chunk_collection.h>
Public Member Functions | |
| WritableChunkCollection () | |
| pybind11::buffer & | operator[] (const std::string &id) |
| void | open () |
| Opens the collection to read chunks from it. More... | |
| void | close () |
| Closes the collection after a reading session. More... | |
| size_t | size () const |
| Returns the number of chunks available in the collection after it is opened. More... | |
| bool | chunkExists (const std::string &id) const |
| Check if a specific chunk exists. More... | |
| chunksize_t | chunkSize (const std::string &id) const |
| Retrieves size of a specific chunk. More... | |
| chunksize_t | fetch (const std::string &id, void *data, const chunksize_t limit) |
| Reads a chunk. More... | |
| void | save (const std::string &filename, bool append=false) |
| Saves the collection to a file. More... | |
Public Member Functions inherited from Beatmup::ChunkCollection | |
| template<typename datatype > | |
| datatype | read (const std::string &id) |
| Reads a chunk and casts it into a given type. More... | |
| template<typename datatype > | |
| std::vector< datatype > | readVector (const std::string &id) |
| Reads a chunk into a vector of a specific type. More... | |
| template<> | |
| std::string | read (const std::string &id) |
Public Member Functions inherited from Beatmup::Object | |
| virtual | ~Object () |
Private Attributes | |
| std::map< std::string, pybind11::buffer > | data |
Writable ChunkCollection implementation for Python.
Allows to exchange binary data without copying.
Definition at line 35 of file chunk_collection.h.
|
inline |
Definition at line 40 of file chunk_collection.h.
|
inline |
Definition at line 42 of file chunk_collection.h.
|
inlinevirtual |
Opens the collection to read chunks from it.
Implements Beatmup::ChunkCollection.
Definition at line 46 of file chunk_collection.h.
|
inlinevirtual |
Closes the collection after a reading session.
Implements Beatmup::ChunkCollection.
Definition at line 47 of file chunk_collection.h.
|
inlinevirtual |
Returns the number of chunks available in the collection after it is opened.
Implements Beatmup::ChunkCollection.
Definition at line 49 of file chunk_collection.h.
|
inlinevirtual |
Check if a specific chunk exists.
| [in] | id | The chunk id |
true if the chunk exists in the collection. Implements Beatmup::ChunkCollection.
Definition at line 51 of file chunk_collection.h.
|
virtual |
Retrieves size of a specific chunk.
| [in] | id | The chunk id |
Implements Beatmup::ChunkCollection.
Definition at line 104 of file chunk_collection.cpp.
|
virtual |
Reads a chunk.
The collection is expected to be opened.
| [in] | id | Wanted chunk id. |
| [out] | data | A buffer to write out the wanted chunk content. |
| [in] | limit | The buffer capacity in bytes. |
limit is returned (number of bytes actually written); if no chunk found, 0 is returned. Implements Beatmup::ChunkCollection.
Definition at line 113 of file chunk_collection.cpp.
|
virtual |
Saves the collection to a file.
| [in] | filename | The name of the file to write chunks to |
| [in] | append | If true, writing to the end of the file (keeping the existing content). Rewriting the file otherwise. |
Implements Beatmup::ChunkCollection.
Definition at line 122 of file chunk_collection.cpp.
|
private |
Definition at line 37 of file chunk_collection.h.