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/Detail/Swap.hpp>
00034 #include <Thor/Config.hpp>
00035
00036 #include <SFML/Config.hpp>
00037
00038 #include THOR_TR1_HEADER(functional)
00039 #include <string>
00040
00041
00042 namespace thor
00043 {
00044
00047
00050 namespace Resources
00051 {
00052
00055 class THOR_API SoundBufferKey
00056 {
00057
00058
00059 public:
00064 static SoundBufferKey FromFile(const std::string& fileName, const std::string& tag = "");
00065
00071 static SoundBufferKey FromMemory(const void* data, std::size_t size, const std::string& tag = "");
00072
00080 static SoundBufferKey FromSamples(const sf::Int16* samples, std::size_t samplesCount,
00081 unsigned int channelsCount, unsigned int sampleRate, const std::string& tag = "");
00082
00086 MovedPtr<sf::SoundBuffer> Load() const;
00087
00090 void Swap(SoundBufferKey& other);
00091
00092
00093
00094
00095 private:
00096
00097 SoundBufferKey();
00098
00099
00100
00101
00102 private:
00103 std::tr1::function<bool(sf::SoundBuffer&)> mLoader;
00104 std::string mKey;
00105
00106
00107
00108
00109 friend struct detail::KeyInfoAccessor<true>;
00110 };
00111
00112
00119 class THOR_API MusicKey
00120 {
00121
00122
00123 public:
00128 static MusicKey FromFile(const std::string& fileName, const std::string& tag = "");
00129
00135 static MusicKey FromMemory(const void* data, std::size_t size, const std::string& tag = "");
00136
00140 MovedPtr<sf::Music> Load() const;
00141
00144 void Swap(MusicKey& other);
00145
00146
00147
00148
00149 private:
00150
00151 MusicKey();
00152
00153
00154
00155
00156 private:
00157 std::tr1::function<bool(sf::Music&)> mLoader;
00158 std::string mKey;
00159
00160
00161
00162
00163 friend struct detail::KeyInfoAccessor<true>;
00164 };
00165
00166
00169 bool THOR_API operator< (const SoundBufferKey& lhs, const SoundBufferKey& rhs);
00170
00173 bool THOR_API operator< (const MusicKey& lhs, const MusicKey& rhs);
00174
00175
00178 THOR_GLOBAL_SWAP(SoundBufferKey)
00179
00180
00181
00182 THOR_GLOBAL_SWAP(MusicKey)
00183
00184 }
00185
00187
00188 }
00189
00190 #endif // THOR_AUDIOKEYS_HPP