179 explicit Awaitable(super&& other,
ResourceStreamData& streamData) : super(std::move(other)), streamData(streamData) {
193 explicit Awaitable(super&& other,
ResourceStreamData& streamData) : super(std::move(other)), streamData(streamData) {
293 return mStream->isSeekable(mode);
365 return mStream->isSeekable(mode);
#define CE_FLAGS_OPERATORS(Enum)
Defines global operators for a Flags<Enum, Storage> implementation.
Definition Flags.hpp:216
#define CE_ASSERT(...)
Definition Macros.hpp:323
A retain-release type of smart pointer.
Definition SmartPtr.hpp:132
A stream associated to a resource.
Definition ResourceStream.hpp:430
Async< ResourceOutputStream > openOutputStream()
Creates a new resource stream.
HResourceStream(const HResourceStream &)=delete
HResourceStream & operator=(const HResourceStream &)=delete
ResourceStreamDataPtr mData
The stream data pointer. If null, the stream is null.
Definition ResourceStream.hpp:436
HResourceStream(HResourceStream &&) noexcept=default
Async< ResourceInputStream > openInputStream() const
Opens a resource stream for reading.
HResourceStream()=default
A stream that provides write-only stream functionality.
Definition Stream.hpp:233
A specialized OutputStream for a ResourceStream.
Definition ResourceStream.hpp:250
OutputStream mStream
Definition ResourceStream.hpp:254
An interface that all data streams must implement.
Definition Stream.hpp:58
Seek
An enumeration that describes how a data stream should be seeked.
Definition Stream.hpp:72
A ResourceStream stored fully in memory.
Definition ResourceStream.hpp:486
Async< ResourceOutputStream > openOutputStream() override
Async< ResourceInputStream > openInputStream() override
~InMemoryResourceStreamData() noexcept override=default
MemoryDataStream mStream
The backing data stream.
Definition ResourceStream.hpp:489
InMemoryResourceStreamData(ResourceData &resourceData, const ResourceStreamID &streamID, const ResourceStreamFlags &flags)
Creates a new InMemoryResourceStream for the given resource and with the given stream ID.
Definition ResourceStream.hpp:497
A data stream that reads or writes data into a memory buffer.
Definition Stream.hpp:693
A stream that provides write-only stream functionality.
Definition Stream.hpp:307
A pointer type that has value semantics.
Definition Poly.hpp:57
IResourceInputStream * get()
Definition Poly.hpp:367
A simple reference counter base class.
Definition SmartPtr.hpp:438
An object, provided by the resource manager, to view and alter data from the resource itself.
Definition Resource.hpp:89
Definition ResourceHandle.hpp:166
A base class that all resources must extend from.
Definition Resource.hpp:186
The ResourceManager is the main class responsible for managing and handling all resources in the engi...
Definition ResourceManager.hpp:47
A specialized OutputStream for a ResourceStream.
Definition ResourceStream.hpp:261
ResourceOutputStream(ResourceStreamLock &&lock, OutputStream &&stream)
An object that allows storing side-band data for a resource.
Definition ResourceStream.hpp:129
virtual Async< ResourceOutputStream > openOutputStream()=0
virtual Async< ResourceInputStream > openInputStream()=0
const ResourceStreamFlags flags
A set of flags that determine the behavior of the resource stream.
Definition ResourceStream.hpp:139
virtual ~ResourceStreamData() noexcept=default
Destroys the resource stream data.
bool isCompressible() const noexcept
If defined, will indicate that the stream can be compressed.
Definition ResourceStream.hpp:170
const ResourceStreamID streamID
The resource stream ID.
Definition ResourceStream.hpp:136
auto acquireWriteLock()
Asynchronously acquires a write lock on the stream.
Definition ResourceStream.hpp:188
ResourceStreamLockMutex mMutex
A mutex that provides synchronized access to the resource stream.
Definition ResourceStream.hpp:143
bool isSeekable() const noexcept
If defined, indicates that returned stream must be seekable.
Definition ResourceStream.hpp:167
ResourceData & resourceData
A handle to the resource that owns the stream.
Definition ResourceStream.hpp:132
ResourceStreamData(ResourceData &resourceData, const ResourceStreamID &streamID, const ResourceStreamFlags &flags)
Creates a new ResourceStreamData for the given resource and with the given stream ID.
auto acquireReadLock()
Asynchronously acquires a read lock on the stream.
Definition ResourceStream.hpp:174
A base class for InputStream and OutputStream of a ResourceStream.
Definition ResourceStream.hpp:209
ResourceStreamLock mStreamLock
A lock acquired for the stream. Must be kept for as long as the stream is open.
Definition ResourceStream.hpp:212
HResource getResource() const
Gets the resource to which this stream belongs to.
ResourceStream(ResourceStreamLock &&lock)
Definition ResourceStream.hpp:215
ResourceManager * getResourceManager() const
Gets the resource manager of the resource that owns the stream.
A lock that allows either reading or writing to the stream.
Definition ResourceStream.hpp:98
ResourceStreamDataPtr mData
The resource stream data instance to which this lock corresponds to.
Definition ResourceStream.hpp:108
ResourceStreamData & getStreamData() const noexcept
The resource stream data instance to which this lock corresponds to.
Definition ResourceStream.hpp:120
ScopedLock mScopedLock
The low-level scoped lock, usually acquired and managed from the owning ResourceStreamData instance.
Definition ResourceStream.hpp:105
ResourceStreamLock(ResourceStreamData &data, ScopedLock &&lock)
Creates a new ResourceStreamLock for the given resource stream and an acquired scoped lock.
Definition ResourceStream.hpp:113
bool isExclusive() const noexcept
Determines if the lock is exclusive (writing) or shared (reading).
Definition ResourceStream.hpp:117
ResourceStreamLockMutex::Lock ScopedLock
A type that represents the low-level scoped lock.
Definition ResourceStream.hpp:101
LockOperation lock_shared()
Locks the mutex in a shared state.
Definition AsyncMutex.hpp:312
friend class LockOperation
Definition AsyncMutex.hpp:269
LockOperation lock()
Locks the mutex in an exclusive state.
Definition AsyncMutex.hpp:315
A specialized OutputStream for a ResourceStream.
Definition ResourceStream.hpp:347
bool isWritable() const noexcept override
Definition ResourceStream.hpp:400
bool flush() override
Definition ResourceStream.hpp:412
bool isSeekable(const Seek mode=Seek::Start) const noexcept override
Checks if the stream is seekable.
Definition ResourceStream.hpp:363
size_t write(const void *data, const size_t n) override
Definition ResourceStream.hpp:406
bool isTellable() const noexcept override
Checks if the stream knows it's current absolute position.
Definition ResourceStream.hpp:375
OutputStream & getDataStream() noexcept
Definition ResourceStream.hpp:356
bool isSizeKnown() const noexcept override
Checks if the stream knows the size of the data.
Definition ResourceStream.hpp:387
void seek(const std::streamsize position, const Seek mode=Seek::Start) override
Changes the position of the data stream.
Definition ResourceStream.hpp:369
WrappedResourceOutputStream(ResourceStreamLock &&lock, OutputStream &&stream)
Definition ResourceStream.hpp:352
const OutputStream & getDataStream() const noexcept
Definition ResourceStream.hpp:359
OutputStream mStream
Definition ResourceStream.hpp:349
size_t size() override
Gets the number of bytes available on the stream.
Definition ResourceStream.hpp:393
size_t tell() override
Gets the absolute stream position, in bytes.
Definition ResourceStream.hpp:381
Definition Application.hpp:19
std::uint64_t UInt64
Definition DataTypes.hpp:26
decltype(auto) lock(Func &&func, Ts &... objects)
Definition Threading.hpp:667
ResourceStreamWriteFlag
Definition ResourceStream.hpp:64
cti::continuable< Args... > Async
Defines a non-copyable continuation type which uses the function2 backend for type erasure.
Definition Async.hpp:22
ResourceStreamFlag
A set of flags that can be given when creating a new resource stream.
Definition ResourceStream.hpp:38
@ Seekable
If defined, indicates that returned stream must be seekable.
@ Compressible
If defined, will indicate that the stream can be compressed.
auto move(Vector3 position)
Moves a entity to the given position.
Definition Helpers.hpp:22
@ Truncate
Truncate the file if it exists.
ResourceStreamReadFlag
Definition ResourceStream.hpp:55
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
RC< ResourceStreamData > ResourceStreamDataPtr
A base class for InputStream and OutputStream of a ResourceStream.
Definition Forward.hpp:37
Wrapper around an enum that allows simple use of bitwise logic operations.
Definition Flags.hpp:19
constexpr bool isSet(Enum value) const noexcept
Checks whether all of the provided bits are set.
Definition Flags.hpp:54
A structure that describes the creation of a resource stream.
Definition ResourceStream.hpp:78
bool allowCompression
If defined, will indicate that the stream can be compressed by the implementation.
Definition ResourceStream.hpp:86
bool isSeekable
If defined, indicates that returned stream must be seekable.
Definition ResourceStream.hpp:82
Type that uniquely represents a stream in the resource system.
Definition ResourceStream.hpp:24
ResourceStreamID(const UUID &uuid)
Converts a raw UUID into a ResourceStreamID.
Definition ResourceStream.hpp:28
static const ResourceStreamID null
A null (or empty) resource ID.
Definition ResourceStream.hpp:31
Represents a universally unique identifier (UUID).
Definition UUID.hpp:27
constexpr UUID()=default
Initializes an empty UUID.