/** * @RDE_HEADER@ * SoundArea class. * $Id$ * $HeadURL$ * $Author$ * Created by Filip Biedziak, NLE, 2020-08-10 */ #pragma once #include #include #include #include namespace EffectManagement { using SoundKey = QPair; struct SoundArea { SoundArea() = default; explicit SoundArea(const InfrastructureManagement::EffectArea &effectArea) : id(effectArea.id()) , areaEgcuId(effectArea.areaEgcuId()) #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) , egcuIds(QVector(effectArea.egcuIds().begin(), effectArea.egcuIds().end())) #else , egcuIds(QVector::fromStdVector(effectArea.egcuIds())) #endif , displayName(QString::fromStdString(effectArea.name())) { } bool addActiveSound(const SoundManagement::SoundState &soundState) { if (activeSounds.contains(soundState.id())) return false; activeSounds.insert(soundState.id(), soundState); return true; } bool removeActiveSound(const SoundManagement::SoundState &soundState) { return removeActiveSound(soundState.id()); } bool removeActiveSound(const int &id) { return activeSounds.remove(id) == 1; } bool hasActiveSound(const SoundManagement::SoundCategory &category, const int &id) const { for (const auto &sound : qAsConst(activeSounds)) if ( (sound.category() == category) && (sound.soundId() == id) ) return true; return false; } bool hasActiveSound(const int32_t &category, const int32_t &id) const { for (const auto &sound : qAsConst(activeSounds)) if ( (static_cast(sound.category().underlying()) == category) && (sound.soundId() == id) ) return true; return false; } bool hasActiveSound(const SoundKey &key) const { for (const auto &sound : qAsConst(activeSounds)) if ( (static_cast(sound.category().underlying()) == key.first) && (sound.soundId() == key.second) ) return true; return false; } QString toString() const { QString str; str += QStringLiteral("SoundArea ") + QString::number(id); str += QStringLiteral(" displayName: ") + displayName; str += QStringLiteral(" areaEgcuId: ") + QString::number(areaEgcuId); return str; } std::ostream& operator << (std::ostream& os) const { os << toString().toStdString(); return os; } bool operator == (const SoundArea &other) const { return id == other.id; } bool operator != (const SoundArea &other) const { return id != other.id; } int id{-1}; int32_t areaEgcuId{-1}; QVector egcuIds; QString displayName; QHash activeSounds; }; } // namespace EffectManagement