Classes | Enumerations | Functions
thor::Resources Namespace Reference

Namespace for resource-related functionality. More...

Classes

struct  CentralOwner
 Centralized ownership policy. More...
 
struct  RefCounted
 Reference-counted ownership policy. More...
 

Enumerations

enum  KnownIdStrategy { AssumeNew, Reuse, Reload }
 Strategy to deal with already known resource IDs. More...
 

Functions

template<class R >
ResourceLoader< R > fromFile (const std::string &filename)
 Load the resource from a file on hard disk. More...
 
template<class R , typename T >
ResourceLoader< R > fromFile (const std::string &filename, T arg1)
 Load the resource from a file on hard disk. More...
 
template<class R , typename T , typename U >
ResourceLoader< R > fromMemory (T arg1, U arg2)
 Load the resource from a file in memory. More...
 
template<class R , typename T , typename U , typename V >
ResourceLoader< R > fromMemory (T arg1, U arg2, V arg3)
 Load the resource from a file in memory. More...
 
template<class R >
ResourceLoader< R > fromStream (sf::InputStream &stream)
 Load the resource from an input stream. More...
 
template<class R >
ResourceLoader< R > fromStream (sf::InputStream &vertexShaderStream, sf::InputStream &fragmentShaderStream)
 Load the resource (usually sf::Shader) from two streams. More...
 
template<class R , typename T >
ResourceLoader< R > fromStream (sf::InputStream &stream, T arg1)
 Load the resource from a stream with additional information. More...
 
template<class R >
ResourceLoader< R > fromSamples (const sf::Int16 *samples, std::size_t sampleCount, unsigned int channelCount, unsigned int sampleRate)
 Load sf::SoundBuffer from array of audio samples in memory. More...
 
template<class R >
ResourceLoader< R > fromPixels (unsigned int width, unsigned int height, const sf::Uint8 *pixels)
 Load resource (usually sf::Image) from array of pixels. More...
 
template<class R >
ResourceLoader< R > fromColor (unsigned int width, unsigned int height, const sf::Color &color)
 Load resource (usually sf::Image) from size and fill color. More...
 
template<class R >
ResourceLoader< R > fromImage (const sf::Image &image, const sf::IntRect area=sf::IntRect())
 Load the resource (usually sf::Texture) from a sf::Image. More...
 

Detailed Description

Namespace for resource-related functionality.

Enumeration Type Documentation

Strategy to deal with already known resource IDs.

Determines what happens if the user calls ResourceHolder::acquire() with an ID that is already associated with a different resource.

Enumerator
AssumeNew 

Loads a new resource if the ID is unknown. Otherwise, a ResourceAccessException is thrown.

Reuse 

Loads a new resource if the ID is unknown. Otherwise, the resource associated with the ID is reused.

Reload 

Always loads a new resource. If the ID is already known, the corresponding resource is released.

Function Documentation

template<class R >
ResourceLoader<R> thor::Resources::fromColor ( unsigned int  width,
unsigned int  height,
const sf::Color &  color 
)

Load resource (usually sf::Image) from size and fill color.

Parameters
width,heightThe size of the image.
colorThe color used to fill the image.
Returns
Resource loader which is going to invoke create(width, height, color).
template<class R >
ResourceLoader<R> thor::Resources::fromFile ( const std::string &  filename)

Load the resource from a file on hard disk.

Parameters
filenameThe name of the file from which you want to load the resource.
Returns
Resource loader which is going to invoke loadFromFile(filename).
template<class R , typename T >
ResourceLoader<R> thor::Resources::fromFile ( const std::string &  filename,
arg1 
)

Load the resource from a file on hard disk.

Parameters
filenameThe name of the file from which you want to load the resource.
arg1An additional argument (for example sf::IntRect at sf::Texture or std::string / sf::Shader::Type at sf::Shader).
Returns
Resource loader which is going to invoke loadFromFile(filename, arg1).
template<class R >
ResourceLoader<R> thor::Resources::fromImage ( const sf::Image &  image,
const sf::IntRect  area = sf::IntRect() 
)

Load the resource (usually sf::Texture) from a sf::Image.

Parameters
imageImage to load into the texture.
areaArea of the image to load.
Returns
Resource loader which is going to invoke loadFromImage(image, area).
template<class R , typename T , typename U >
ResourceLoader<R> thor::Resources::fromMemory ( arg1,
arg2 
)

Load the resource from a file in memory.

Parameters
arg1Usually const void* for a pointer in memory; alternatively std::string for shader.
arg2Usually std::size_t for the data length in bytes; alternatively std::string or sf::Shader::Type for shader.
Returns
Resource loader which is going to invoke loadFromMemory(arg1, arg2).
template<class R , typename T , typename U , typename V >
ResourceLoader<R> thor::Resources::fromMemory ( arg1,
arg2,
arg3 
)

Load the resource from a file in memory.

Parameters
arg1Usually const void* for a pointer in memory; alternatively std::string for shader.
arg2Usually std::size_t for the data length in bytes; alternatively std::string or sf::Shader::Type for shader.
arg3An additional argument (for example sf::IntRect at sf::Texture).
Returns
Resource loader which is going to invoke loadFromMemory(arg1, arg2, arg3).
template<class R >
ResourceLoader<R> thor::Resources::fromPixels ( unsigned int  width,
unsigned int  height,
const sf::Uint8 *  pixels 
)

Load resource (usually sf::Image) from array of pixels.

Parameters
width,heightThe size of the image.
pixelsPointer to the pixels in memory.
Returns
Resource loader which is going to invoke create(width, height, pixels).
template<class R >
ResourceLoader<R> thor::Resources::fromSamples ( const sf::Int16 *  samples,
std::size_t  sampleCount,
unsigned int  channelCount,
unsigned int  sampleRate 
)

Load sf::SoundBuffer from array of audio samples in memory.

Parameters
samplesPointer to the samples array.
sampleCountNumber of samples in the array.
channelCountNumber of channels (1 = mono, 2 = stereo, ...).
sampleRateSample rate (number of samples to play per second).
Returns
Resource loader which is going to invoke loadFromSamples(width, height, color).
template<class R >
ResourceLoader<R> thor::Resources::fromStream ( sf::InputStream &  stream)

Load the resource from an input stream.

Parameters
streamSource stream to read from.
Returns
Resource loader which is going to invoke loadFromStream(stream).
template<class R >
ResourceLoader<R> thor::Resources::fromStream ( sf::InputStream &  vertexShaderStream,
sf::InputStream &  fragmentShaderStream 
)

Load the resource (usually sf::Shader) from two streams.

Parameters
vertexShaderStreamSource stream to read the vertex shader from.
fragmentShaderStreamSource stream to read the fragment shader from.
Returns
Resource loader which is going to invoke loadFromStream(vertexShaderStream, fragmentShaderStream).
template<class R , typename T >
ResourceLoader<R> thor::Resources::fromStream ( sf::InputStream &  stream,
arg1 
)

Load the resource from a stream with additional information.

Parameters
streamSource stream to read from.
arg1An additional argument (for example sf::IntRect at sf::Texture or std::string / sf::Shader::Type at sf::Shader).
Returns
Resource loader which is going to invoke loadFromStream(stream, arg1).