Ocean
|
This class implements the platform independent base class for all resource managers which can be specialized for specific applications. More...
Public Types | |
typedef std::vector< uint8_t > | Buffer |
Definition of a vector holding 8 bit values. More... | |
typedef ObjectRef< Buffer > | BufferRef |
Definition of an object reference holding a buffer. More... | |
Public Member Functions | |
void | addFrameResolution (const unsigned int id, const FrameRef &frame) |
Adds a new frame resolution of/for a specified resource frame. More... | |
void | addData (const unsigned int id, const BufferRef &buffer) |
Adds a new data/buffer resource. More... | |
void | addData (const unsigned int id, Buffer &&buffer) |
Adds a new data/buffer resource (moves the buffer into this manager). More... | |
FrameRef | frame (const unsigned int id, const unsigned int width=0u, const unsigned int height=0u, const bool downscaleIfNecessary=true) |
Returns a specific resource frame. More... | |
FrameRef | frame (const unsigned int id, const double scaleFactor) |
Returns a specific resource frame for a specified screen scaling factor. More... | |
BufferRef | data (const unsigned int id) |
Returns a specified resource buffer (any kind of arbitrary resource data which is not a frame/image). More... | |
void | release () |
Releases the entire resources of this manager. More... | |
Protected Types | |
typedef std::unordered_map< unsigned int, FrameRefs > | FrameMap |
Definition of a map mapping resource ids to frames with individual resolutions. More... | |
typedef std::unordered_map< unsigned int, BufferRef > | BufferMap |
Definition of a map mapping resource ids to buffer objects. More... | |
Protected Member Functions | |
ResourceManager () | |
The protected default constructor. More... | |
virtual | ~ResourceManager () |
Destructs the resource manager. More... | |
FrameRef | interpolatedFrame (const unsigned int id, const unsigned int width, const unsigned int height) |
Returns the interpolated frame of a specified resource frame. More... | |
Static Protected Member Functions | |
static FrameRef | largestFrame (const FrameRefs &frames) |
Returns the largest frame from a set of given frames. More... | |
Protected Attributes | |
FrameMap | nativeFrames_ |
The frame map of the native resource frames. More... | |
FrameMap | interpolatedFrames_ |
The frame map of the interpolated frames. More... | |
BufferMap | bufferMap_ |
The map of resource buffers. More... | |
Lock | lock_ |
The manager's lock. More... | |
This class implements the platform independent base class for all resource managers which can be specialized for specific applications.
Application specific resource manager should be implemented as singletons and should be derived from this base class.
typedef std::vector<uint8_t> Ocean::Platform::ResourceManager::Buffer |
Definition of a vector holding 8 bit values.
|
protected |
Definition of a map mapping resource ids to buffer objects.
Definition of an object reference holding a buffer.
|
protected |
Definition of a map mapping resource ids to frames with individual resolutions.
|
protected |
The protected default constructor.
|
protectedvirtual |
Destructs the resource manager.
void Ocean::Platform::ResourceManager::addData | ( | const unsigned int | id, |
Buffer && | buffer | ||
) |
Adds a new data/buffer resource (moves the buffer into this manager).
id | The application-wide unique id of the resource |
buffer | The buffer of the resource to be moved |
void Ocean::Platform::ResourceManager::addData | ( | const unsigned int | id, |
const BufferRef & | buffer | ||
) |
Adds a new data/buffer resource.
id | The application-wide unique id of the resource |
buffer | The buffer of the resource |
void Ocean::Platform::ResourceManager::addFrameResolution | ( | const unsigned int | id, |
const FrameRef & | frame | ||
) |
Adds a new frame resolution of/for a specified resource frame.
Beware: The first resolution of a unique resource frame is expected to be the native resolution for screens without any explicit DPI scaling.
id | The application-wide unique id of the resource frame for which a frame with specific resolution will be registered |
frame | The frame representing one specific resolution of the specified resource frame |
BufferRef Ocean::Platform::ResourceManager::data | ( | const unsigned int | id | ) |
Returns a specified resource buffer (any kind of arbitrary resource data which is not a frame/image).
id | The application-wide unique id of the requested resource data |
FrameRef Ocean::Platform::ResourceManager::frame | ( | const unsigned int | id, |
const double | scaleFactor | ||
) |
Returns a specific resource frame for a specified screen scaling factor.
The provided factor is the relation between the current screen scaling and a native scaling.
I.e., The resulting frame for a scaling of 2 has twice of the dimension as the frame for a scaling of 1.
id | The application-wide unique id of the requested resource frame |
scaleFactor | The screen scaling factor for which the frame with matching resolution is determined, with range (0, infinity) |
FrameRef Ocean::Platform::ResourceManager::frame | ( | const unsigned int | id, |
const unsigned int | width = 0u , |
||
const unsigned int | height = 0u , |
||
const bool | downscaleIfNecessary = true |
||
) |
Returns a specific resource frame.
This function allows to specified the dimension of the resulting frame.
id | The application-wide unique id of the requested resource frame |
width | Optional width of the resulting frame in pixel, with range [1u, infinity), 0 to return the frame with native resolution |
height | Optional height of the resulting frame in pixel, with range [1u, infinity), 0 to return the frame with native resolution |
downscaleIfNecessary | True, to return a frame exactly with the specified frame dimension, otherwise the next larger frame will be returned |
|
protected |
Returns the interpolated frame of a specified resource frame.
If the specified frame dimension is larger than the dimension of the largest native frame, the largest native frame will be returned.
id | The id of the resource frame for which the interpolated frame will be returned |
width | The width of the resulting interpolated frame in pixel, with range [1, infinity) |
height | The height of the resulting interpolated frame in pixel, with range [1, infinity) |
|
staticprotected |
Returns the largest frame from a set of given frames.
frames | The set of given frames, at least one |
void Ocean::Platform::ResourceManager::release | ( | ) |
Releases the entire resources of this manager.
|
protected |
The map of resource buffers.
|
protected |
The frame map of the interpolated frames.
|
protected |
The manager's lock.
|
protected |
The frame map of the native resource frames.