Bromeon
Static Public Member Functions | Public Member Functions | Related Functions
thor::Resources::MusicKey Class Reference

Predefined key class for sf::Music resources. More...

List of all members.

Static Public Member Functions

static MusicKey FromFile (const std::string &fileName, const std::string &tag="")
 Open sf::Music from file name.
static MusicKey FromMemory (const void *data, std::size_t size, const std::string &tag="")
 Open sf::Music from file in memory.
static MusicKey FromStream (sf::InputStream &stream, const std::string &tag="")
 Open sf::Music from input stream.

Public Member Functions

MovedPtr< sf::Music, NoCopyLoad () const
 Loads the music as specified by the static functions.
void Swap (MusicKey &other)
 Exchanges the contents of *this with other.

Related Functions

bool thor::Resources::operator< (const MusicKey &lhs, const MusicKey &rhs)
 Comparison operator for strict weak ordering.
void thor::Resources::swap (MusicKey &lhs, MusicKey &rhs)
 Swaps two sf::Music resource keys.

Detailed Description

Predefined key class for sf::Music resources.

You can use this class to specifiy the access and loading of sf::Music resources in a ResourceManager. Note that unlike the other SFML resources, sf::Music is not copied completely into memory, rather streamed continuously. Therefore, it is only suited to a limited extend as a resource in a resource manager. While ResourceManager allows easy loading and error-checking, a single sf::Music instance cannot be meaningfully shared, therefore the access through multiple ResourcePtr objects isn't recommended. Also note that const pointers to sf::Music aren't useful at all.


Member Function Documentation

static MusicKey thor::Resources::MusicKey::FromFile ( const std::string &  fileName,
const std::string &  tag = "" 
) [static]

Open sf::Music from file name.

Parameters:
fileNameThe name of the file from which you want to load the sf::Music.
tagIf an existing key has the same loading parameters, you can use this ID to create a distinct key.
See also:
sf::Music::OpenFromFile()
static MusicKey thor::Resources::MusicKey::FromMemory ( const void *  data,
std::size_t  size,
const std::string &  tag = "" 
) [static]

Open sf::Music from file in memory.

Parameters:
dataPointer to the file data in memory.
sizeSize of the data to load, in bytes.
tagIf an existing key has the same loading parameters, you can use this ID to create a distinct key.
See also:
sf::Music::OpenFromMemory()
static MusicKey thor::Resources::MusicKey::FromStream ( sf::InputStream &  stream,
const std::string &  tag = "" 
) [static]

Open sf::Music from input stream.

Parameters:
streamSource stream to read from.
tagIf an existing key has the same loading parameters, you can use this ID to create a distinct key.
See also:
sf::Music::OpenFromStream()

Loads the music as specified by the static functions.

This function is mainly provided for ResourceManager, you don't need to call it directly.

Returns:
Movable smart pointer to the allocated sf::Music, or null pointer at loading failure.

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