use dynamic casts if RTTI is an available feature
This commit is contained in:
parent
4975c7e809
commit
0c9c85830e
|
@ -1,6 +1,7 @@
|
|||
project(${PROJECT_NAME}_sacn VERSION 0.3.1 LANGUAGES CXX)
|
||||
|
||||
add_library(${PROJECT_NAME} SHARED)
|
||||
configure_file(../../config.h.in config.h)
|
||||
|
||||
target_sources(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "arbitratinguniverse.h"
|
||||
#include <map>
|
||||
#include "config.h"
|
||||
|
||||
namespace sACN {
|
||||
|
||||
|
@ -151,7 +152,11 @@ void ArbitratingUniverse::deleteSourceUniverse(const DATA::data_header& src)
|
|||
*/
|
||||
void ArbitratingUniverse::dataChangedNotifier(DMX::Universe* dmx)
|
||||
{
|
||||
#ifdef RTTI_ENABLED
|
||||
auto sacn = dynamic_cast<sACN::Universe*>(dmx);
|
||||
#else
|
||||
auto sacn = static_cast<sACN::Universe*>(dmx);
|
||||
#endif
|
||||
auto universe = dominant_();
|
||||
if (!universe)
|
||||
return;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "pdu.h"
|
||||
#include "receiver.h"
|
||||
|
||||
|
@ -137,7 +138,11 @@ void Receiver::dataReceiver(ACN::PDU::Message<ACN::RLP::Pdu> root)
|
|||
// a PDU::Block is guaranteed to have been instantiated, but if the input
|
||||
// stream failed, it will not list any PDU. OK to loop without checking
|
||||
// the state of the stream.
|
||||
#ifdef RTTI_ENABLED
|
||||
auto block = std::dynamic_pointer_cast<ACN::PDU::Block<DATA::Pdu>>(root->data());
|
||||
#else
|
||||
auto block = std::static_pointer_cast<ACN::PDU::Block<DATA::Pdu>>(root->data());
|
||||
#endif
|
||||
for(auto const &frame : *block->pdu)
|
||||
{
|
||||
/// > \cite sACN 6.2.1 E1.31 Data Packet: Vector
|
||||
|
@ -168,7 +173,11 @@ void Receiver::extendedReceiver(ACN::PDU::Message<ACN::RLP::Pdu> root)
|
|||
// a PDU::Block is guaranteed to have been instantiated, but if the input
|
||||
// stream failed, it will not list any PDU. OK to loop without checking
|
||||
// the state of the stream.
|
||||
#ifdef RTTI_ENABLED
|
||||
auto block = std::dynamic_pointer_cast<ACN::PDU::Block<EXTENDED::Pdu>>(root->data());
|
||||
#else
|
||||
auto block = std::static_pointer_cast<ACN::PDU::Block<EXTENDED::Pdu>>(root->data());
|
||||
#endif
|
||||
for(auto const &frame : *block->pdu)
|
||||
{
|
||||
switch(frame->vector()) {
|
||||
|
@ -196,10 +205,13 @@ void Receiver::extendedReceiver(ACN::PDU::Message<ACN::RLP::Pdu> root)
|
|||
*
|
||||
* Merging will be based on frame header. PDU data will be read as a block of
|
||||
* DMP PDUs and passed to the universe.
|
||||
*
|
||||
*/
|
||||
void Receiver::dataFrameHandler(ACN::PDU::Message<DATA::Pdu> frame) {
|
||||
auto metadata = std::static_pointer_cast<DATA::data_header>(frame->header());
|
||||
#ifdef RTTI_ENABLED
|
||||
auto metadata = std::dynamic_pointer_cast<DATA::data_header>(frame->header());
|
||||
#else
|
||||
auto metadata = std::static_pointer_cast<DATA::data_header>(frame->header());
|
||||
#endif
|
||||
|
||||
if (!universes_.count(metadata->universe))
|
||||
return; // not subscribed to this universe
|
||||
|
@ -263,11 +275,20 @@ void Receiver::dataFrameHandler(ACN::PDU::Message<DATA::Pdu> frame) {
|
|||
else
|
||||
{
|
||||
subscribe(metadata->sync_address);
|
||||
#ifdef RTTI_ENABLED
|
||||
auto block = std::dynamic_pointer_cast<ACN::PDU::Block<ACN::DMP::Pdu>>(frame->data());
|
||||
#else
|
||||
auto block = std::static_pointer_cast<ACN::PDU::Block<ACN::DMP::Pdu>>(frame->data());
|
||||
#endif
|
||||
if (!block->pdu->empty())
|
||||
{
|
||||
#ifdef RTTI_ENABLED
|
||||
auto dmp = std::dynamic_pointer_cast<ACN::DMP::Pdu>(block->pdu->front());
|
||||
auto list = std::dynamic_pointer_cast<ACN::DMP::address_pair_list>(dmp->data());
|
||||
#else
|
||||
auto dmp = std::static_pointer_cast<ACN::DMP::Pdu>(block->pdu->front());
|
||||
auto list = std::static_pointer_cast<ACN::DMP::address_pair_list>(dmp->data());
|
||||
#endif
|
||||
if (!list->properties.empty())
|
||||
{
|
||||
const auto & [_, data] = list->properties.front();
|
||||
|
@ -293,7 +314,11 @@ void Receiver::dataFrameHandler(ACN::PDU::Message<DATA::Pdu> frame) {
|
|||
return; // too far out of sequence
|
||||
|
||||
// PDU data will be a block of DMP
|
||||
#ifdef RTTI_ENABLED
|
||||
auto block = std::dynamic_pointer_cast<ACN::PDU::Block<ACN::DMP::Pdu>>(frame->data());
|
||||
#else
|
||||
auto block = std::static_pointer_cast<ACN::PDU::Block<ACN::DMP::Pdu>>(frame->data());
|
||||
#endif
|
||||
universe->setMetadata(metadata);
|
||||
universe->DmpReceiver(block);
|
||||
}
|
||||
|
@ -305,7 +330,11 @@ void Receiver::dataFrameHandler(ACN::PDU::Message<DATA::Pdu> frame) {
|
|||
*/
|
||||
void Receiver::syncFrameHandler(ACN::PDU::Message<EXTENDED::Pdu> frame)
|
||||
{
|
||||
#ifdef RTTI_ENABLED
|
||||
auto header = std::dynamic_pointer_cast<EXTENDED::sync_header>(frame->header());
|
||||
#else
|
||||
auto header = std::static_pointer_cast<EXTENDED::sync_header>(frame->header());
|
||||
#endif
|
||||
universes_.at(header->sync_address)->synchronize(header->sequence_number);
|
||||
}
|
||||
|
||||
|
@ -315,7 +344,11 @@ void Receiver::syncFrameHandler(ACN::PDU::Message<EXTENDED::Pdu> frame)
|
|||
* @param frame
|
||||
*/
|
||||
void Receiver::discoveryFrameHandler(ACN::PDU::Message<EXTENDED::Pdu> frame) {
|
||||
#ifdef RTTI_ENABLED
|
||||
auto block = std::dynamic_pointer_cast<ACN::PDU::Block<EXTENDED::DISCOVERY::Pdu>>(frame->data());
|
||||
#else
|
||||
auto block = std::static_pointer_cast<ACN::PDU::Block<EXTENDED::DISCOVERY::Pdu>>(frame->data());
|
||||
#endif
|
||||
for(auto const &pdu : *block->pdu)
|
||||
{
|
||||
/// > \cite sACN 8 Universe Discovery Layer
|
||||
|
@ -339,14 +372,25 @@ void Receiver::discoveryFrameHandler(ACN::PDU::Message<EXTENDED::Pdu> frame) {
|
|||
* @param pdu
|
||||
*/
|
||||
void Receiver::discoveryListHanlder(ACN::PDU::Message<EXTENDED::DISCOVERY::Pdu> pdu) {
|
||||
auto rlpHeader = std::static_pointer_cast<ACN::RLP::rlp_header>
|
||||
(pdu->parent()->parent()->header());
|
||||
auto frameHeader = std::static_pointer_cast<EXTENDED::discovery_header>
|
||||
(pdu->parent()->header());
|
||||
auto header = std::static_pointer_cast<EXTENDED::DISCOVERY::discovery_list_header>
|
||||
(pdu->header());
|
||||
auto data = std::static_pointer_cast<EXTENDED::DISCOVERY::discovery_list_data>
|
||||
(pdu->data());
|
||||
#ifdef RTTI_ENABLED
|
||||
auto rlpHeader = std::dynamic_pointer_cast<ACN::RLP::rlp_header>
|
||||
(pdu->parent()->parent()->header());
|
||||
auto frameHeader = std::dynamic_pointer_cast<EXTENDED::discovery_header>
|
||||
(pdu->parent()->header());
|
||||
auto header = std::dynamic_pointer_cast<EXTENDED::DISCOVERY::discovery_list_header>
|
||||
(pdu->header());
|
||||
auto data = std::dynamic_pointer_cast<EXTENDED::DISCOVERY::discovery_list_data>
|
||||
(pdu->data());
|
||||
#else
|
||||
auto rlpHeader = std::static_pointer_cast<ACN::RLP::rlp_header>
|
||||
(pdu->parent()->parent()->header());
|
||||
auto frameHeader = std::static_pointer_cast<EXTENDED::discovery_header>
|
||||
(pdu->parent()->header());
|
||||
auto header = std::static_pointer_cast<EXTENDED::DISCOVERY::discovery_list_header>
|
||||
(pdu->header());
|
||||
auto data = std::static_pointer_cast<EXTENDED::DISCOVERY::discovery_list_data>
|
||||
(pdu->data());
|
||||
#endif
|
||||
|
||||
// on the first page:
|
||||
if (header->page == 0)
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "universe.h"
|
||||
|
||||
namespace sACN {
|
||||
|
@ -278,7 +279,11 @@ void Universe::rxDmpSetProperty(ACN::PDU::Message<ACN::DMP::Pdu> message)
|
|||
// only act on the first property pair in the data
|
||||
if (!message->data())
|
||||
return;
|
||||
#ifdef RTTI_ENABLED
|
||||
auto set_data = std::dynamic_pointer_cast<ACN::DMP::address_pair_list>(message->data());
|
||||
#else
|
||||
auto set_data = std::static_pointer_cast<ACN::DMP::address_pair_list>(message->data());
|
||||
#endif
|
||||
if (set_data->properties.empty())
|
||||
return;
|
||||
const auto& [range, data] = set_data->properties.front();
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "universesender.h"
|
||||
#include "universe.h"
|
||||
#include "source.h"
|
||||
|
@ -199,7 +201,11 @@ void UniverseSender::update_dmp_()
|
|||
std::unique_lock lk_ctl(mtx_control);
|
||||
|
||||
// header segment
|
||||
#ifdef RTTI_ENABLED
|
||||
auto addrtyp = std::dynamic_pointer_cast<ACN::DMP::address_type>(dmp_->header());
|
||||
#else
|
||||
auto addrtyp = std::static_pointer_cast<ACN::DMP::address_type>(dmp_->header());
|
||||
#endif
|
||||
|
||||
// property range
|
||||
ACN::DMP::Range pr(*addrtyp);
|
||||
|
|
Loading…
Reference in New Issue