1
0
Fork 0

data pending synchronization can be a nullptr until feature is used

This commit is contained in:
Kevin Matz 2021-08-26 16:49:58 -04:00
parent 3c78f0570d
commit 8392d2e433
2 changed files with 31 additions and 17 deletions

View File

@ -33,7 +33,15 @@ Universe::Universe()
: DMX::Universe(E131_NETWORK_DATA_LOSS_TIMEOUT)
, ACN::DMP::Device()
{
sync_data_.clear();
}
/**
* @brief Universe::~Universe
*/
Universe::~Universe()
{
delete sync_data_;
}
@ -42,7 +50,7 @@ Universe::Universe()
* @param dmp
* @param source
*/
void Universe::set(std::shared_ptr<ACN::DMP::Pdu> dmp,
void Universe::set(ACN::PDU::Message<ACN::DMP::Pdu> dmp,
std::shared_ptr<Provenance> source)
{
/// \cite sACN
@ -101,14 +109,18 @@ void Universe::set(std::shared_ptr<ACN::DMP::Pdu> dmp,
if ((source->syncAddress() == 0) ||
(isSyncronized() && source->isForced() && rxRate() == 0))
{
sync_data_.clear();
if (sync_data_)
{
delete sync_data_;
sync_data_ = nullptr;
}
/// \cite sACN 7.7 Property Values (DMX512-A Data)
/// The DMP Layer's Property values field is used to encode the
/// DMX512-A [DMX] START Code and data.
DMX::Universe::setData(data);
}
else
sync_data_ = data;
sync_data_ = new std::vector<uint8_t>(data);
}
@ -128,7 +140,7 @@ void Universe::setProvenance(std::shared_ptr<Provenance> source)
*/
bool Universe::isSyncronized() const
{
return (sync_data_.size() > 0);
return (sync_data_ != nullptr);
};
@ -142,23 +154,24 @@ std::shared_ptr<Provenance> Universe::source() const
}
/**
*/
{
}
/**
* @brief Universe::synchronize
*/
void Universe::synchronize()
{
if (!isSyncronized())
return;
if (sync_data_)
{
DMX::Universe::setData(*sync_data_);
delete sync_data_;
sync_data_ = nullptr;
}
}
/**
*/
{
DMX::Universe::setData(sync_data_);
sync_data_.clear();
}
}; // namespace SACN

View File

@ -42,6 +42,7 @@ class Universe
{
public:
Universe();
~Universe();
virtual bool isSyncronized() const;;
virtual std::shared_ptr<Provenance> source() const;
@ -53,7 +54,7 @@ public:
private:
std::shared_ptr<Provenance> provenance_;
std::vector<uint8_t> sync_data_;
std::vector<uint8_t> * sync_data_ = nullptr;
};
} // SACN namespace