#include <ResourceManager.hxx>
Definition at line 16 of file ResourceManager.hxx.
◆ MAX_RESOURCE_BYTES
◆ ResourceManager()
ResourceManager::ResourceManager |
( |
| ) |
|
Creates the ResourceManager.
- Exceptions
-
Definition at line 36 of file ResourceManager.cxx.
40 json config_json = json::parse(jsonFileContent,
nullptr,
false);
43 if (config_json.is_discarded())
46 m_audioConfig = config_json;
◆ get()
template<typename ResourceID >
Fetches and return a Soundtrack.
- Parameters
-
ResourceID | the id of the resource |
- Exceptions
-
AudioError | when loading the file results in an error |
Definition at line 14 of file ResourceManager.inl.hxx.
18 if constexpr (std::is_same_v<ResourceID, SoundtrackID>)
19 return m_soundtracks.at(
id).resource;
◆ prune()
void ResourceManager::prune |
( |
| ) |
|
Cleans up the cache of unused resources.
Definition at line 171 of file ResourceManager.cxx.
174 size_t total_size = 0;
175 total_size += m_soundtracks.size();
178 std::vector<uint32_t> all_ages;
179 using AgeIt = AgeIterator<Mapping<SoundtrackID, SoundtrackResource>::iterator>;
180 all_ages.insert<AgeIt>(all_ages.cend(), AgeIterator{m_soundtracks.begin()}, AgeIterator{m_soundtracks.end()});
181 std::nth_element(all_ages.begin(), all_ages.begin() + total_size, all_ages.end());
182 uint32_t median = all_ages[total_size];
183 for (
auto it = m_soundtracks.begin(); it != m_soundtracks.end();)
185 if (it->second.age < median and !it->second.resource->isPlaying)
188 alGetBufferi(it->second.resource->buffer, AL_SIZE, &sizeBytes);
190 it = m_soundtracks.erase(it);
◆ m_Age
uint32_t ResourceManager::m_Age |
|
private |
◆ m_CacheSize
uint32_t ResourceManager::m_CacheSize |
|
private |
The documentation for this class was generated from the following files: