Ocean
Ocean::Platform::ResourceManager Class Reference

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< BufferBufferRef
 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, FrameRefsFrameMap
 Definition of a map mapping resource ids to frames with individual resolutions. More...
 
typedef std::unordered_map< unsigned int, BufferRefBufferMap
 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...
 

Detailed Description

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.

Member Typedef Documentation

◆ Buffer

typedef std::vector<uint8_t> Ocean::Platform::ResourceManager::Buffer

Definition of a vector holding 8 bit values.

◆ BufferMap

typedef std::unordered_map<unsigned int, BufferRef> Ocean::Platform::ResourceManager::BufferMap
protected

Definition of a map mapping resource ids to buffer objects.

◆ BufferRef

Definition of an object reference holding a buffer.

◆ FrameMap

typedef std::unordered_map<unsigned int, FrameRefs> Ocean::Platform::ResourceManager::FrameMap
protected

Definition of a map mapping resource ids to frames with individual resolutions.

Constructor & Destructor Documentation

◆ ResourceManager()

Ocean::Platform::ResourceManager::ResourceManager ( )
protected

The protected default constructor.

◆ ~ResourceManager()

virtual Ocean::Platform::ResourceManager::~ResourceManager ( )
protectedvirtual

Destructs the resource manager.

Member Function Documentation

◆ addData() [1/2]

void Ocean::Platform::ResourceManager::addData ( const unsigned int  id,
Buffer &&  buffer 
)

Adds a new data/buffer resource (moves the buffer into this manager).

Parameters
idThe application-wide unique id of the resource
bufferThe buffer of the resource to be moved

◆ addData() [2/2]

void Ocean::Platform::ResourceManager::addData ( const unsigned int  id,
const BufferRef buffer 
)

Adds a new data/buffer resource.

Parameters
idThe application-wide unique id of the resource
bufferThe buffer of the resource

◆ addFrameResolution()

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.

Parameters
idThe application-wide unique id of the resource frame for which a frame with specific resolution will be registered
frameThe frame representing one specific resolution of the specified resource frame

◆ data()

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).

Parameters
idThe application-wide unique id of the requested resource data
Returns
The requested data, if any

◆ frame() [1/2]

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.

Parameters
idThe application-wide unique id of the requested resource frame
scaleFactorThe screen scaling factor for which the frame with matching resolution is determined, with range (0, infinity)
Returns
The requested frame, if any

◆ frame() [2/2]

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.

Parameters
idThe application-wide unique id of the requested resource frame
widthOptional width of the resulting frame in pixel, with range [1u, infinity), 0 to return the frame with native resolution
heightOptional height of the resulting frame in pixel, with range [1u, infinity), 0 to return the frame with native resolution
downscaleIfNecessaryTrue, to return a frame exactly with the specified frame dimension, otherwise the next larger frame will be returned
Returns
The specified frame, if any

◆ interpolatedFrame()

FrameRef Ocean::Platform::ResourceManager::interpolatedFrame ( const unsigned int  id,
const unsigned int  width,
const unsigned int  height 
)
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.

Parameters
idThe id of the resource frame for which the interpolated frame will be returned
widthThe width of the resulting interpolated frame in pixel, with range [1, infinity)
heightThe height of the resulting interpolated frame in pixel, with range [1, infinity)
Returns
The resulting interpolated frame, or the largest available native frame if the largest native frame is smaller than the requested one

◆ largestFrame()

static FrameRef Ocean::Platform::ResourceManager::largestFrame ( const FrameRefs frames)
staticprotected

Returns the largest frame from a set of given frames.

Parameters
framesThe set of given frames, at least one
Returns
The largest frame from the specified set

◆ release()

void Ocean::Platform::ResourceManager::release ( )

Releases the entire resources of this manager.

Field Documentation

◆ bufferMap_

BufferMap Ocean::Platform::ResourceManager::bufferMap_
protected

The map of resource buffers.

◆ interpolatedFrames_

FrameMap Ocean::Platform::ResourceManager::interpolatedFrames_
protected

The frame map of the interpolated frames.

◆ lock_

Lock Ocean::Platform::ResourceManager::lock_
protected

The manager's lock.

◆ nativeFrames_

FrameMap Ocean::Platform::ResourceManager::nativeFrames_
protected

The frame map of the native resource frames.


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