const VarCharType& VarCharType::InstanceInternal(const std::size_t length) { static PtrMap<size_t, VarCharType> instance_map; PtrMap<size_t, VarCharType>::iterator imit = instance_map.find(length); if (imit == instance_map.end()) { imit = instance_map.insert(length, new VarCharType(length, nullable_internal)).first; } return *(imit->second); }
/** * @brief Get a reference to the singleton instance of this Operation. * * @param target_type The target type to coerce input values to. * @return A reference to the singleton instance of this Operation. **/ static const NumericCastOperation& Instance(const Type &target_type) { static PtrMap<const Type*, NumericCastOperation> instance_map; PtrMap<const Type*, NumericCastOperation>::iterator instance_map_it = instance_map.find(&target_type); if (instance_map_it == instance_map.end()) { instance_map_it = instance_map.insert(&target_type, new NumericCastOperation(target_type)).first; } return *(instance_map_it->second); }
void updatePositions(MWWorld::Ptr ptr) { // Find the reference (if any) PtrMap::iterator it = sounds.find(ptr); if(it != sounds.end()) { // Then find all sounds in it (if any) IDMap::iterator it2 = it->second.begin(); for(;it2 != it->second.end(); it2++) { // Get the sound (if it still exists) SoundPtr snd = it2->second.lock(); if(snd) // Update position setPos(snd, ptr); } } }
bool isPlaying(MWWorld::Ptr ptr, const std::string &id) const { PtrMap::const_iterator it = sounds.find(ptr); if(it != sounds.end()) { IDMap::const_iterator it2 = it->second.find(id); if(it2 != it->second.end()) { // Get a shared_ptr from the weak_ptr SoundPtr snd = it2->second.lock();; // Is it still alive? if(snd) { // Then return its status! return snd->isPlaying(); } } } // Nothing found, sound is not playing return false; }
// Stop a sound and remove it from the list. If id="" then // remove the entire object and stop all its sounds. void remove(MWWorld::Ptr ptr, const std::string &id = "") { PtrMap::iterator it = sounds.find(ptr); if(it != sounds.end()) { if(id == "") // Kill all references to 'ptr' clearAll(it); else { // Only find the id we're looking for IDMap::iterator it2 = it->second.find(id); if(it2 != it->second.end()) { // Stop the sound and remove it from the list SoundPtr snd = it2->second.lock(); if(snd) snd->stop(); it->second.erase(it2); } } } }