Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00025
00028
00029 #ifndef THOR_AUDIOKEYS_HPP
00030 #define THOR_AUDIOKEYS_HPP
00031
00032 #include <Thor/Resources/ResourceKeyTraits.hpp>
00033 #include <Thor/SmartPtr/MovedPtr.hpp>
00034 #include <Thor/Detail/Swap.hpp>
00035 #include <Thor/Config.hpp>
00036
00037 #include <SFML/Config.hpp>
00038
00039 #include THOR_TR1_HEADER(functional)
00040 #include <string>
00041
00042
00043 namespace thor
00044 {
00045
00048
00051 namespace Resources
00052 {
00053
00056 class THOR_API SoundBufferKey
00057 {
00058
00059
00060 public:
00065 static SoundBufferKey FromFile(const std::string& fileName, const std::string& tag = "");
00066
00072 static SoundBufferKey FromMemory(const void* data, std::size_t size, const std::string& tag = "");
00073
00081 static SoundBufferKey FromSamples(const sf::Int16* samples, std::size_t samplesCount,
00082 unsigned int channelsCount, unsigned int sampleRate, const std::string& tag = "");
00083
00088 static SoundBufferKey FromStream(sf::InputStream& stream, const std::string& tag = "");
00089
00093 MovedPtr<sf::SoundBuffer, NoCopy> Load() const;
00094
00097 void Swap(SoundBufferKey& other);
00098
00099
00100
00101
00102 private:
00103
00104 SoundBufferKey();
00105
00106
00107
00108
00109 private:
00110 std::tr1::function<bool(sf::SoundBuffer&)> mLoader;
00111 std::string mKey;
00112
00113
00114
00115
00116 friend struct detail::KeyInfoAccessor;
00117 };
00118
00119
00126 class THOR_API MusicKey
00127 {
00128
00129
00130 public:
00135 static MusicKey FromFile(const std::string& fileName, const std::string& tag = "");
00136
00142 static MusicKey FromMemory(const void* data, std::size_t size, const std::string& tag = "");
00143
00148 static MusicKey FromStream(sf::InputStream& stream, const std::string& tag = "");
00149
00153 MovedPtr<sf::Music, NoCopy> Load() const;
00154
00157 void Swap(MusicKey& other);
00158
00159
00160
00161
00162 private:
00163
00164 MusicKey();
00165
00166
00167
00168
00169 private:
00170 std::tr1::function<bool(sf::Music&)> mLoader;
00171 std::string mKey;
00172
00173
00174
00175
00176 friend struct detail::KeyInfoAccessor;
00177 };
00178
00179
00182 bool THOR_API operator< (const SoundBufferKey& lhs, const SoundBufferKey& rhs);
00183
00186 bool THOR_API operator< (const MusicKey& lhs, const MusicKey& rhs);
00187
00188
00191 THOR_GLOBAL_SWAP(SoundBufferKey)
00192
00193
00194
00195 THOR_GLOBAL_SWAP(MusicKey)
00196
00197 }
00198
00200
00201 }
00202
00203 #endif // THOR_AUDIOKEYS_HPP