-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR #11489 from Eran: fix cppcheck warnings in dds code
- Loading branch information
Showing
8 changed files
with
300 additions
and
330 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +0,0 @@ | ||
E uninitvar src/context.cpp+803 Uninitialized variables: prof.bpp, prof.intrinsics | ||
E danglingTempReference src/context.cpp+843 Using reference to dangling temporary. | ||
E danglingTempReference src/context.cpp+844 Using reference to dangling temporary. | ||
E danglingTempReference src/context.cpp+845 Using reference to dangling temporary. | ||
E danglingTempReference src/context.cpp+846 Using reference to dangling temporary. | ||
E danglingTempReference src/context.cpp+847 Using reference to dangling temporary. | ||
E danglingTempReference src/context.cpp+848 Using reference to dangling temporary. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,48 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2022 Intel Corporation. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
|
||
#include <fastdds/dds/log/Log.hpp> | ||
#include <memory> | ||
|
||
|
||
namespace realdds { | ||
|
||
|
||
// Convert FastDDS Log::Entry to EasyLogging log (see ELPP_WRITE_LOG) | ||
#define LOG_DDS_ENTRY( ENTRY, LEVEL, ... ) \ | ||
do \ | ||
{ \ | ||
char const * filename = ( ENTRY ).context.filename; \ | ||
char const * func = ( ENTRY ).context.function; \ | ||
if( ! func ) \ | ||
func = "n/a"; \ | ||
if( ! filename ) \ | ||
filename = func; \ | ||
el::base::Writer writer( el::Level::LEVEL, filename, ( ENTRY ).context.line, func ); \ | ||
writer.construct( 1, "librealsense" ); \ | ||
writer << __VA_ARGS__; \ | ||
writer << " [DDS]"; \ | ||
if( ( ENTRY ).context.category ) \ | ||
writer << "[" << ( ENTRY ).context.category << "]"; \ | ||
} \ | ||
while( false ) | ||
|
||
|
||
struct log_consumer : eprosima::fastdds::dds::LogConsumer | ||
{ | ||
static std::unique_ptr< eprosima::fastdds::dds::LogConsumer > create() | ||
{ | ||
return std::unique_ptr< eprosima::fastdds::dds::LogConsumer >( new log_consumer ); | ||
} | ||
|
||
void Consume( const eprosima::fastdds::dds::Log::Entry & e ) override; | ||
|
||
private: | ||
log_consumer() = default; | ||
}; | ||
|
||
|
||
} // namespace realdds | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2022 Intel Corporation. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
|
||
#include <fastdds/dds/log/Log.hpp> | ||
#include <memory> | ||
|
||
|
||
namespace realdds { | ||
|
||
|
||
// Convert FastDDS Log::Entry to EasyLogging log (see ELPP_WRITE_LOG) | ||
#define LOG_DDS_ENTRY( ENTRY, LEVEL, ... ) \ | ||
do \ | ||
{ \ | ||
char const * filename = ( ENTRY ).context.filename; \ | ||
char const * func = ( ENTRY ).context.function; \ | ||
if( ! func ) \ | ||
func = "n/a"; \ | ||
if( ! filename ) \ | ||
filename = func; \ | ||
el::base::Writer writer( el::Level::LEVEL, filename, ( ENTRY ).context.line, func ); \ | ||
writer.construct( 1, "librealsense" ); \ | ||
writer << __VA_ARGS__; \ | ||
writer << " [DDS]"; \ | ||
if( ( ENTRY ).context.category ) \ | ||
writer << "[" << ( ENTRY ).context.category << "]"; \ | ||
} \ | ||
while( false ) | ||
|
||
|
||
struct log_consumer : eprosima::fastdds::dds::LogConsumer | ||
{ | ||
static std::unique_ptr< eprosima::fastdds::dds::LogConsumer > create() | ||
{ | ||
return std::unique_ptr< eprosima::fastdds::dds::LogConsumer >( new log_consumer ); | ||
} | ||
|
||
void Consume( const eprosima::fastdds::dds::Log::Entry & e ) override; | ||
|
||
private: | ||
log_consumer() = default; | ||
}; | ||
|
||
|
||
} // namespace realdds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,90 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2022 Intel Corporation. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include <fastdds/dds/subscriber/DataReaderListener.hpp> | ||
#include <fastdds/dds/subscriber/qos/DataReaderQos.hpp> | ||
|
||
#include <functional> | ||
#include <memory> | ||
|
||
|
||
namespace eprosima { | ||
namespace fastdds { | ||
namespace dds { | ||
class Subscriber; | ||
} // namespace dds | ||
} // namespace fastdds | ||
} // namespace eprosima | ||
|
||
|
||
namespace realdds { | ||
|
||
|
||
class dds_topic; | ||
class dds_subscriber; | ||
|
||
// The 'reader' is the entity used to subscribe to updated values of data in a topic. It is bound at creation to this | ||
// topic. | ||
// | ||
// You may choose to create one via a 'subscriber' that manages the activities of several readers. | ||
// on_data_available callback will be called when a sample is received. | ||
// | ||
class dds_topic_reader : public eprosima::fastdds::dds::DataReaderListener | ||
{ | ||
std::shared_ptr< dds_topic > const _topic; | ||
std::shared_ptr < dds_subscriber > const _subscriber; | ||
|
||
eprosima::fastdds::dds::DataReader * _reader = nullptr; | ||
|
||
public: | ||
dds_topic_reader( std::shared_ptr< dds_topic > const & topic ); | ||
dds_topic_reader( std::shared_ptr< dds_topic > const & topic, std::shared_ptr< dds_subscriber > const & subscriber ); | ||
~dds_topic_reader(); | ||
|
||
eprosima::fastdds::dds::DataReader * get() const { return _reader; } | ||
eprosima::fastdds::dds::DataReader * operator->() const { return get(); } | ||
|
||
bool is_running() const { return ( get() != nullptr ); } | ||
|
||
std::shared_ptr< dds_topic > const & topic() const { return _topic; } | ||
|
||
typedef std::function< void() > on_data_available_callback; | ||
typedef std::function< void( eprosima::fastdds::dds::SubscriptionMatchedStatus const & ) > | ||
on_subscription_matched_callback; | ||
|
||
void on_data_available( on_data_available_callback callback ) { _on_data_available = std::move( callback ); } | ||
void on_subscription_matched( on_subscription_matched_callback callback ) | ||
{ | ||
_on_subscription_matched = std::move( callback ); | ||
} | ||
|
||
class qos : public eprosima::fastdds::dds::DataReaderQos | ||
{ | ||
using super = eprosima::fastdds::dds::DataReaderQos; | ||
|
||
public: | ||
qos( eprosima::fastdds::dds::ReliabilityQosPolicyKind reliability | ||
= eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS, // default | ||
eprosima::fastdds::dds::DurabilityQosPolicyKind durability | ||
= eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS ); // default is transient local | ||
}; | ||
|
||
// The callbacks should be set before we actually create the underlying DDS objects, so the reader does not | ||
void run( qos const & = qos() ); | ||
|
||
// DataReaderListener | ||
protected: | ||
void on_subscription_matched( eprosima::fastdds::dds::DataReader *, | ||
eprosima::fastdds::dds::SubscriptionMatchedStatus const & info ) override; | ||
|
||
void on_data_available( eprosima::fastdds::dds::DataReader * ) override; | ||
|
||
private: | ||
on_data_available_callback _on_data_available; | ||
on_subscription_matched_callback _on_subscription_matched; | ||
}; | ||
|
||
|
||
} // namespace realdds | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2022 Intel Corporation. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include <fastdds/dds/subscriber/DataReaderListener.hpp> | ||
#include <fastdds/dds/subscriber/qos/DataReaderQos.hpp> | ||
|
||
#include <functional> | ||
#include <memory> | ||
|
||
|
||
namespace eprosima { | ||
namespace fastdds { | ||
namespace dds { | ||
class Subscriber; | ||
} // namespace dds | ||
} // namespace fastdds | ||
} // namespace eprosima | ||
|
||
|
||
namespace realdds { | ||
|
||
|
||
class dds_topic; | ||
class dds_subscriber; | ||
|
||
// The 'reader' is the entity used to subscribe to updated values of data in a topic. It is bound at creation to this | ||
// topic. | ||
// | ||
// You may choose to create one via a 'subscriber' that manages the activities of several readers. | ||
// on_data_available callback will be called when a sample is received. | ||
// | ||
class dds_topic_reader : public eprosima::fastdds::dds::DataReaderListener | ||
{ | ||
std::shared_ptr< dds_topic > const _topic; | ||
std::shared_ptr < dds_subscriber > const _subscriber; | ||
|
||
eprosima::fastdds::dds::DataReader * _reader = nullptr; | ||
|
||
public: | ||
dds_topic_reader( std::shared_ptr< dds_topic > const & topic ); | ||
dds_topic_reader( std::shared_ptr< dds_topic > const & topic, std::shared_ptr< dds_subscriber > const & subscriber ); | ||
~dds_topic_reader(); | ||
|
||
eprosima::fastdds::dds::DataReader * get() const { return _reader; } | ||
eprosima::fastdds::dds::DataReader * operator->() const { return get(); } | ||
|
||
bool is_running() const { return ( get() != nullptr ); } | ||
|
||
std::shared_ptr< dds_topic > const & topic() const { return _topic; } | ||
|
||
typedef std::function< void() > on_data_available_callback; | ||
typedef std::function< void( eprosima::fastdds::dds::SubscriptionMatchedStatus const & ) > | ||
on_subscription_matched_callback; | ||
|
||
void on_data_available( on_data_available_callback callback ) { _on_data_available = std::move( callback ); } | ||
void on_subscription_matched( on_subscription_matched_callback callback ) | ||
{ | ||
_on_subscription_matched = std::move( callback ); | ||
} | ||
|
||
class qos : public eprosima::fastdds::dds::DataReaderQos | ||
{ | ||
using super = eprosima::fastdds::dds::DataReaderQos; | ||
|
||
public: | ||
qos( eprosima::fastdds::dds::ReliabilityQosPolicyKind reliability | ||
= eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS, // default | ||
eprosima::fastdds::dds::DurabilityQosPolicyKind durability | ||
= eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS ); // default is transient local | ||
}; | ||
|
||
// The callbacks should be set before we actually create the underlying DDS objects, so the reader does not | ||
void run( qos const & = qos() ); | ||
|
||
// DataReaderListener | ||
protected: | ||
void on_subscription_matched( eprosima::fastdds::dds::DataReader *, | ||
eprosima::fastdds::dds::SubscriptionMatchedStatus const & info ) override; | ||
|
||
void on_data_available( eprosima::fastdds::dds::DataReader * ) override; | ||
|
||
private: | ||
on_data_available_callback _on_data_available; | ||
on_subscription_matched_callback _on_subscription_matched; | ||
}; | ||
|
||
|
||
} // namespace realdds |
Oops, something went wrong.