Skip to content

Commit

Permalink
Adding explicit constructors (#129)
Browse files Browse the repository at this point in the history
Signed-off-by: CursedRock17 <[email protected]>
  • Loading branch information
CursedRock17 authored Jun 10, 2024
1 parent ac26507 commit aea0e9f
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion include/message_filters/message_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class MessageEvent
/**
* \todo Make this explicit in ROS 2.0. Keep as auto-converting for now to maintain backwards compatibility in some places (message_filters)
*/
MessageEvent(const ConstMessagePtr & message) // NOLINT(runtime/explicit)
explicit MessageEvent(const ConstMessagePtr & message)
{
init(message, rclcpp::Clock().now(), true, message_filters::DefaultMessageCreator<Message>());
}
Expand Down
2 changes: 1 addition & 1 deletion include/message_filters/pass_through.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PassThrough : public SimpleFilter<M>


template<typename F>
PassThrough(F & f) // NOLINT(runtime/explicit)
explicit PassThrough(F & f)
{
connectInput(f);
}
Expand Down
2 changes: 1 addition & 1 deletion include/message_filters/signal1.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CallbackHelper1T : public CallbackHelper1<M>
typedef std::function<void (typename Adapter::Parameter)> Callback;
typedef typename Adapter::Event Event;

CallbackHelper1T(const Callback & cb) // NOLINT(runtime/explicit)
explicit CallbackHelper1T(const Callback & cb)
: callback_(cb)
{
}
Expand Down
2 changes: 1 addition & 1 deletion include/message_filters/signal9.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class CallbackHelper9T
typename A5::Parameter, typename A6::Parameter, typename A7::Parameter,
typename A8::Parameter)> Callback;

CallbackHelper9T(const Callback & cb) // NOLINT(runtime/explicit)
explicit CallbackHelper9T(const Callback & cb)
: callback_(cb)
{
}
Expand Down
2 changes: 1 addition & 1 deletion include/message_filters/sync_policies/approximate_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct ApproximateTime : public PolicyBase<M0, M1, M2, M3, M4, M5, M6, M7, M8>
typedef std::tuple<M0Vector, M1Vector, M2Vector, M3Vector, M4Vector, M5Vector, M6Vector, M7Vector,
M8Vector> VectorTuple;

ApproximateTime(uint32_t queue_size) // NOLINT(runtime/explicit)
explicit ApproximateTime(uint32_t queue_size)
: parent_(0)
, queue_size_(queue_size)
, num_non_empty_deques_(0)
Expand Down
2 changes: 1 addition & 1 deletion include/message_filters/sync_policies/exact_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct ExactTime : public PolicyBase<M0, M1, M2, M3, M4, M5, M6, M7, M8>
typedef typename Super::M8Event M8Event;
typedef Events Tuple;

ExactTime(uint32_t queue_size) // NOLINT(runtime/explicit)
explicit ExactTime(uint32_t queue_size)
: parent_(0)
, queue_size_(queue_size)
{
Expand Down
2 changes: 1 addition & 1 deletion include/message_filters/synchronizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class Synchronizer : public noncopyable, public Policy
init();
}

Synchronizer(const Policy & policy) // NOLINT(runtime/explicit)
explicit Synchronizer(const Policy & policy)
: Policy(policy)
{
init();
Expand Down
2 changes: 1 addition & 1 deletion include/message_filters/time_synchronizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class TimeSynchronizer : public Synchronizer<sync_policies::ExactTime<M0, M1, M2
connectInput(f0, f1, f2, f3, f4, f5, f6, f7, f8);
}

TimeSynchronizer(uint32_t queue_size) // NOLINT(runtime/explicit)
explicit TimeSynchronizer(uint32_t queue_size)
: Base(Policy(queue_size))
{
}
Expand Down
12 changes: 6 additions & 6 deletions test/test_approximate_time_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ApproximateTimeSynchronizerTest
const std::vector<TimeAndTopic> & input,
const std::vector<TimePair> & output,
uint32_t queue_size)
: input_(input), output_(output), output_position_(0), sync_(queue_size)
: input_(input), output_(output), output_position_(0), sync_(Policy2(queue_size))
{
sync_.registerCallback(
std::bind(
Expand Down Expand Up @@ -129,8 +129,8 @@ class ApproximateTimeSynchronizerTest
const std::vector<TimeAndTopic> & input_;
const std::vector<TimePair> & output_;
unsigned int output_position_;
typedef message_filters::Synchronizer<message_filters::sync_policies::ApproximateTime<Msg,
Msg>> Sync2;
typedef message_filters::sync_policies::ApproximateTime<Msg, Msg> Policy2;
typedef message_filters::Synchronizer<Policy2> Sync2;

public:
Sync2 sync_;
Expand All @@ -147,7 +147,7 @@ class ApproximateTimeSynchronizerTestQuad
const std::vector<TimeAndTopic> & input,
const std::vector<TimeQuad> & output,
uint32_t queue_size)
: input_(input), output_(output), output_position_(0), sync_(queue_size)
: input_(input), output_(output), output_position_(0), sync_(Policy4(queue_size))
{
sync_.registerCallback(
std::bind(
Expand Down Expand Up @@ -199,8 +199,8 @@ class ApproximateTimeSynchronizerTestQuad
const std::vector<TimeAndTopic> & input_;
const std::vector<TimeQuad> & output_;
unsigned int output_position_;
typedef message_filters::Synchronizer<message_filters::sync_policies::ApproximateTime<Msg,
Msg, Msg, Msg>> Sync4;
typedef message_filters::sync_policies::ApproximateTime<Msg, Msg, Msg, Msg> Policy4;
typedef message_filters::Synchronizer<Policy4> Sync4;

public:
Sync4 sync_;
Expand Down
12 changes: 8 additions & 4 deletions test/test_exact_time_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ typedef message_filters::Synchronizer<Policy3> Sync3;
//////////////////////////////////////////////////////////////////////////////////////////////////
TEST(ExactTime, multipleTimes)
{
Sync3 sync(2);
Policy3 p(2);
Sync3 sync(p);
Helper h;
sync.registerCallback(std::bind(&Helper::cb, &h));
MsgPtr m(std::make_shared<Msg>());
Expand All @@ -117,7 +118,8 @@ TEST(ExactTime, multipleTimes)

TEST(ExactTime, queueSize)
{
Sync3 sync(1);
Policy3 p(1);
Sync3 sync(p);
Helper h;
sync.registerCallback(std::bind(&Helper::cb, &h));
MsgPtr m(std::make_shared<Msg>());
Expand All @@ -143,7 +145,8 @@ TEST(ExactTime, queueSize)

TEST(ExactTime, dropCallback)
{
Sync2 sync(1);
Policy2 p(1);
Sync2 sync(p);
Helper h;
sync.registerCallback(std::bind(&Helper::cb, &h));
sync.getPolicy()->registerDropCallback(std::bind(&Helper::dropcb, &h));
Expand Down Expand Up @@ -174,7 +177,8 @@ struct EventHelper

TEST(ExactTime, eventInEventOut)
{
Sync2 sync(2);
Policy2 p(2);
Sync2 sync(p);
EventHelper h;
sync.registerCallback(&EventHelper::callback, &h);
message_filters::MessageEvent<Msg const> evt(std::make_shared<Msg>(), rclcpp::Time(4, 0));
Expand Down
2 changes: 1 addition & 1 deletion test/test_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ TEST(SimpleFilter, oldRegisterWithNewFilter)
{
OldFilter f;
Helper h;
f.registerCallback(std::bind(&Helper::cb3, &h, std::placeholders::_1));
f.registerCallback(std::bind(&Helper::cb0, &h, std::placeholders::_1));
}

int main(int argc, char ** argv)
Expand Down

0 comments on commit aea0e9f

Please sign in to comment.