refactor class and file name
This commit is contained in:
parent
89716e1af5
commit
6da7001c67
|
@ -14,13 +14,13 @@ target_sources(${PROJECT_NAME}
|
|||
data.h
|
||||
extended.cpp
|
||||
extended.h
|
||||
arbitratinguniverse.cpp
|
||||
arbitratinguniverse.h
|
||||
node.cpp
|
||||
receiver.cpp
|
||||
sacn.h
|
||||
source.cpp
|
||||
universe.cpp
|
||||
universearbitrator.cpp
|
||||
universearbitrator.h
|
||||
universemerger.h
|
||||
universemerger.cpp
|
||||
universesender.h
|
||||
|
|
|
@ -64,7 +64,7 @@ void Receiver::subscribe(const uint16_t num)
|
|||
{
|
||||
if (num == sACN::E131_DISCOVERY_UNIVERSE || universes_.count(num))
|
||||
return;
|
||||
universes_.emplace(num, std::make_shared<ArbitratingUniverse>());
|
||||
universes_.emplace(num, std::make_shared<UniverseArbitrator>());
|
||||
universes_.at(num)->expectedUniverse = num;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "rlp/component.h"
|
||||
#include "data.h"
|
||||
#include "extended.h"
|
||||
#include "arbitratinguniverse.h"
|
||||
#include "universearbitrator.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <set>
|
||||
|
@ -96,7 +96,7 @@ protected:
|
|||
void discoveryListHanlder(ACN::PDU::Message<EXTENDED::DISCOVERY::Pdu>);
|
||||
|
||||
private:
|
||||
std::unordered_map<uint16_t, std::shared_ptr<ArbitratingUniverse>> universes_;
|
||||
std::unordered_map<uint16_t, std::shared_ptr<UniverseArbitrator>> universes_;
|
||||
std::vector<std::function<void()>> discoveryCallbacks_;
|
||||
bool discovery_enabled_;
|
||||
};
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "arbitratinguniverse.h"
|
||||
#include "universearbitrator.h"
|
||||
#include "universemerger.h"
|
||||
#include <map>
|
||||
#include "config.h"
|
||||
|
@ -32,7 +32,7 @@ namespace sACN {
|
|||
/**
|
||||
* @brief ArbitratingUniverse::MergeProxyUniverse
|
||||
*/
|
||||
ArbitratingUniverse::ArbitratingUniverse()
|
||||
UniverseArbitrator::UniverseArbitrator()
|
||||
: sACN::Universe()
|
||||
, expectedUniverse(0)
|
||||
, hold_last_look_(true)
|
||||
|
@ -44,7 +44,7 @@ ArbitratingUniverse::ArbitratingUniverse()
|
|||
* @brief ArbitratingUniverse::setHoldLastLook
|
||||
* @param state
|
||||
*/
|
||||
void ArbitratingUniverse::setHoldLastLook(const bool state)
|
||||
void UniverseArbitrator::setHoldLastLook(const bool state)
|
||||
{
|
||||
std::unique_lock lk_ctl(mtx_control);
|
||||
hold_last_look_ = state;
|
||||
|
@ -55,14 +55,14 @@ void ArbitratingUniverse::setHoldLastLook(const bool state)
|
|||
* @brief ArbitratingUniverse::getHoldLastLook
|
||||
* @return
|
||||
*/
|
||||
bool ArbitratingUniverse::getHoldLastLook() const
|
||||
bool UniverseArbitrator::getHoldLastLook() const
|
||||
{
|
||||
std::shared_lock lk_ctl(mtx_control);
|
||||
return hold_last_look_;
|
||||
}
|
||||
|
||||
|
||||
const std::vector<DATA::data_header> ArbitratingUniverse::sources() const
|
||||
const std::vector<DATA::data_header> UniverseArbitrator::sources() const
|
||||
{
|
||||
std::shared_lock lk_ctl(mtx_control);
|
||||
std::vector<DATA::data_header> keys;
|
||||
|
@ -77,7 +77,7 @@ const std::vector<DATA::data_header> ArbitratingUniverse::sources() const
|
|||
* @param src
|
||||
* @return
|
||||
*/
|
||||
std::shared_ptr<Universe> ArbitratingUniverse::sourceUniverse(const DATA::data_header &src)
|
||||
std::shared_ptr<Universe> UniverseArbitrator::sourceUniverse(const DATA::data_header &src)
|
||||
{
|
||||
std::shared_lock lk_ctl(mtx_control);
|
||||
if (!hasSourceUniverse(src))
|
||||
|
@ -92,14 +92,14 @@ std::shared_ptr<Universe> ArbitratingUniverse::sourceUniverse(const DATA::data_h
|
|||
* @param src
|
||||
* @return
|
||||
*/
|
||||
bool ArbitratingUniverse::hasSourceUniverse(const DATA::data_header& src) const
|
||||
bool UniverseArbitrator::hasSourceUniverse(const DATA::data_header& src) const
|
||||
{
|
||||
std::shared_lock lk_ctl(mtx_control);
|
||||
return (sources_.count(src));
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<Universe> ArbitratingUniverse::addNewSource(const DATA::data_header &src)
|
||||
std::shared_ptr<Universe> UniverseArbitrator::addNewSource(const DATA::data_header &src)
|
||||
{
|
||||
{
|
||||
std::unique_lock lk_ctl(mtx_control);
|
||||
|
@ -108,9 +108,9 @@ std::shared_ptr<Universe> ArbitratingUniverse::addNewSource(const DATA::data_hea
|
|||
return nullptr;
|
||||
auto univ = itr->second;
|
||||
source_data_tokens.push_back(univ->onDataChange(
|
||||
std::bind(&sACN::ArbitratingUniverse::dataChangedNotifier, this, std::placeholders::_1)));
|
||||
std::bind(&sACN::UniverseArbitrator::dataChangedNotifier, this, std::placeholders::_1)));
|
||||
source_status_tokens.push_back(univ->onStatusChange(
|
||||
std::bind(&sACN::ArbitratingUniverse::doStatusCallbacks, this)));
|
||||
std::bind(&sACN::UniverseArbitrator::doStatusCallbacks, this)));
|
||||
}
|
||||
|
||||
doListChangeCallbacks();
|
||||
|
@ -125,7 +125,7 @@ std::shared_ptr<Universe> ArbitratingUniverse::addNewSource(const DATA::data_hea
|
|||
* @brief ArbitratingUniverse::deleteSourceUniverse
|
||||
* @param src
|
||||
*/
|
||||
void ArbitratingUniverse::deleteSourceUniverse(const DATA::data_header& src)
|
||||
void UniverseArbitrator::deleteSourceUniverse(const DATA::data_header& src)
|
||||
{
|
||||
if (!hasSourceUniverse(src))
|
||||
return;
|
||||
|
@ -154,7 +154,7 @@ void ArbitratingUniverse::deleteSourceUniverse(const DATA::data_header& src)
|
|||
* @brief ArbitratingUniverse::dataChangedNotifier
|
||||
* @param dmx
|
||||
*/
|
||||
void ArbitratingUniverse::dataChangedNotifier(DMX::Universe* dmx)
|
||||
void UniverseArbitrator::dataChangedNotifier(DMX::Universe* dmx)
|
||||
{
|
||||
#ifdef RTTI_ENABLED
|
||||
auto sacn = dynamic_cast<sACN::Universe*>(dmx);
|
||||
|
@ -174,7 +174,7 @@ void ArbitratingUniverse::dataChangedNotifier(DMX::Universe* dmx)
|
|||
* @param cb
|
||||
* @return
|
||||
*/
|
||||
std::shared_ptr<void> ArbitratingUniverse::onSourceListChange(std::function<void()> cb)
|
||||
std::shared_ptr<void> UniverseArbitrator::onSourceListChange(std::function<void()> cb)
|
||||
{
|
||||
std::unique_lock lk_ctl(mtx_control);
|
||||
// wrap the callback with a shared pointer
|
||||
|
@ -189,7 +189,7 @@ std::shared_ptr<void> ArbitratingUniverse::onSourceListChange(std::function<void
|
|||
/**
|
||||
* @brief ArbitratingUniverse::doListChangeCallbacks
|
||||
*/
|
||||
void ArbitratingUniverse::doListChangeCallbacks()
|
||||
void UniverseArbitrator::doListChangeCallbacks()
|
||||
{
|
||||
for (auto it = cb_sourceListChange.cbegin(); it != cb_sourceListChange.cend();)
|
||||
{
|
||||
|
@ -211,7 +211,7 @@ void ArbitratingUniverse::doListChangeCallbacks()
|
|||
* @brief ArbitratingUniverse::isSyncronized
|
||||
* @return
|
||||
*/
|
||||
bool ArbitratingUniverse::isSyncronized() const
|
||||
bool UniverseArbitrator::isSyncronized() const
|
||||
{
|
||||
auto universe = dominant_();
|
||||
if (!universe)
|
||||
|
@ -224,7 +224,7 @@ bool ArbitratingUniverse::isSyncronized() const
|
|||
* @brief ArbitratingUniverse::metadata
|
||||
* @return
|
||||
*/
|
||||
std::shared_ptr<DATA::data_header> ArbitratingUniverse::metadata() const
|
||||
std::shared_ptr<DATA::data_header> UniverseArbitrator::metadata() const
|
||||
{
|
||||
auto universe = dominant_();
|
||||
if (universe)
|
||||
|
@ -238,7 +238,7 @@ std::shared_ptr<DATA::data_header> ArbitratingUniverse::metadata() const
|
|||
}
|
||||
|
||||
|
||||
uint8_t ArbitratingUniverse::status() const
|
||||
uint8_t UniverseArbitrator::status() const
|
||||
{
|
||||
auto universe = dominant_();
|
||||
if (!universe)
|
||||
|
@ -251,7 +251,7 @@ uint8_t ArbitratingUniverse::status() const
|
|||
* @brief ArbitratingUniverse::synchronize
|
||||
* @param sequence_number
|
||||
*/
|
||||
void ArbitratingUniverse::synchronize(uint8_t sequence_number)
|
||||
void UniverseArbitrator::synchronize(uint8_t sequence_number)
|
||||
{
|
||||
std::shared_lock lk_ctl(mtx_control);
|
||||
for ( auto& [_, uni] : sources_)
|
||||
|
@ -259,13 +259,13 @@ void ArbitratingUniverse::synchronize(uint8_t sequence_number)
|
|||
}
|
||||
|
||||
|
||||
bool ArbitratingUniverse::isEditable() const
|
||||
bool UniverseArbitrator::isEditable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
uint16_t ArbitratingUniverse::activeSlots() const
|
||||
uint16_t UniverseArbitrator::activeSlots() const
|
||||
{
|
||||
auto universe = dominant_();
|
||||
if (!universe)
|
||||
|
@ -279,7 +279,7 @@ uint16_t ArbitratingUniverse::activeSlots() const
|
|||
* @param address
|
||||
* @return
|
||||
*/
|
||||
uint8_t ArbitratingUniverse::slot(const uint16_t address) const
|
||||
uint8_t UniverseArbitrator::slot(const uint16_t address) const
|
||||
{
|
||||
auto universe = dominant_();
|
||||
if (!universe)
|
||||
|
@ -292,7 +292,7 @@ uint8_t ArbitratingUniverse::slot(const uint16_t address) const
|
|||
* @brief ArbitratingUniverse::rxRate
|
||||
* @return
|
||||
*/
|
||||
double ArbitratingUniverse::rxRate()
|
||||
double UniverseArbitrator::rxRate()
|
||||
{
|
||||
purge_stale_sources_();
|
||||
auto universe = dominant_();
|
||||
|
@ -306,7 +306,7 @@ double ArbitratingUniverse::rxRate()
|
|||
* @brief ArbitratingUniverse::rxDmpSetProperty
|
||||
* @param message
|
||||
*/
|
||||
void ArbitratingUniverse::rxDmpSetProperty(ACN::PDU::Message<ACN::DMP::Pdu> message)
|
||||
void UniverseArbitrator::rxDmpSetProperty(ACN::PDU::Message<ACN::DMP::Pdu> message)
|
||||
{
|
||||
(void)message;
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ void ArbitratingUniverse::rxDmpSetProperty(ACN::PDU::Message<ACN::DMP::Pdu> mess
|
|||
* @brief MergeProxyUniverse::dominant_
|
||||
* @return
|
||||
*/
|
||||
std::shared_ptr<Universe> ArbitratingUniverse::dominant_() const
|
||||
std::shared_ptr<Universe> UniverseArbitrator::dominant_() const
|
||||
{
|
||||
if (sources_.empty())
|
||||
return nullptr;
|
||||
|
@ -363,7 +363,7 @@ std::shared_ptr<Universe> ArbitratingUniverse::dominant_() const
|
|||
/**
|
||||
* @brief ArbitratingUniverse::purge_stale_sources_
|
||||
*/
|
||||
void ArbitratingUniverse::purge_stale_sources_()
|
||||
void UniverseArbitrator::purge_stale_sources_()
|
||||
{
|
||||
std::unordered_map<DATA::data_header,uint> ages;
|
||||
{
|
|
@ -51,11 +51,11 @@ namespace sACN {
|
|||
* The universe with the highest priority will be determined to be the
|
||||
* dominant source.
|
||||
*/
|
||||
class ArbitratingUniverse
|
||||
class UniverseArbitrator
|
||||
: public sACN::Universe
|
||||
{
|
||||
public:
|
||||
explicit ArbitratingUniverse();
|
||||
explicit UniverseArbitrator();
|
||||
|
||||
uint16_t expectedUniverse; ///< Expected universe number
|
||||
|
Loading…
Reference in New Issue