Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 915f1aa

Browse files
committedDec 8, 2021
Style fixes for the linters.
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
1 parent 2708d54 commit 915f1aa

8 files changed

+70
-69
lines changed
 

‎rclcpp/include/rclcpp/any_subscription_callback.hpp

+6-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#define RCLCPP__ANY_SUBSCRIPTION_CALLBACK_HPP_
1717

1818
#include <functional>
19-
#include <iostream> //TODO remove when removed std::cout s
2019
#include <memory>
2120
#include <stdexcept>
2221
#include <type_traits>
@@ -726,14 +725,14 @@ class AnySubscriptionCallback
726725
callback(message, message_info);
727726
}
728727
// conditions for ros message type
729-
else if constexpr (std::is_same_v<T, ConstRefROSMessageCallback>) { // NOLINT
728+
else if constexpr (std::is_same_v<T, ConstRefROSMessageCallback>) { // NOLINT[readability/braces]
730729
if constexpr (is_ta) {
731730
auto local = convert_custom_type_to_ros_message_unique_ptr(*message);
732731
callback(*local);
733732
} else {
734733
callback(*message);
735734
}
736-
} else if constexpr (std::is_same_v<T, ConstRefWithInfoROSMessageCallback>) {
735+
} else if constexpr (std::is_same_v<T, ConstRefWithInfoROSMessageCallback>) { // NOLINT[readability/braces]
737736
if constexpr (is_ta) {
738737
auto local = convert_custom_type_to_ros_message_unique_ptr(*message);
739738
callback(*local, message_info);
@@ -802,12 +801,11 @@ class AnySubscriptionCallback
802801
TRACEPOINT(callback_end, static_cast<const void *>(this));
803802
}
804803

805-
void
804+
void
806805
dispatch_intra_process(
807806
std::unique_ptr<SubscribedType, SubscribedTypeDeleter> message,
808807
const rclcpp::MessageInfo & message_info)
809808
{
810-
811809
TRACEPOINT(callback_start, static_cast<const void *>(this), true);
812810
// Check if the variant is "unset", throw if it is.
813811
if (callback_variant_.index() == 0) {
@@ -830,8 +828,7 @@ class AnySubscriptionCallback
830828
} else if constexpr ( // NOLINT[readability/braces]
831829
is_ta && (
832830
std::is_same_v<T, UniquePtrCallback>||
833-
std::is_same_v<T, SharedPtrCallback>)
834-
)
831+
std::is_same_v<T, SharedPtrCallback>))
835832
{
836833
callback(std::move(message));
837834
} else if constexpr ( // NOLINT[readability/braces]
@@ -857,14 +854,14 @@ class AnySubscriptionCallback
857854
callback(std::move(message), message_info);
858855
}
859856
// conditions for ros message type
860-
else if constexpr (std::is_same_v<T, ConstRefROSMessageCallback>) { // NOLINT
857+
else if constexpr (std::is_same_v<T, ConstRefROSMessageCallback>) { // NOLINT[readability/braces]
861858
if constexpr (is_ta) {
862859
auto local = convert_custom_type_to_ros_message_unique_ptr(*message);
863860
callback(*local);
864861
} else {
865862
callback(*message);
866863
}
867-
} else if constexpr (std::is_same_v<T, ConstRefWithInfoROSMessageCallback>) {
864+
} else if constexpr (std::is_same_v<T, ConstRefWithInfoROSMessageCallback>) { // NOLINT[readability/braces]
868865
if constexpr (is_ta) {
869866
auto local = convert_custom_type_to_ros_message_unique_ptr(*message);
870867
callback(*local, message_info);

‎rclcpp/include/rclcpp/experimental/intra_process_manager.hpp

+37-37
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class IntraProcessManager
210210
std::shared_ptr<PublishedType> msg = std::move(message);
211211

212212
this->template add_shared_msg_to_buffers<MessageT, PublishedType, ROSMessageType, Alloc,
213-
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator>(
213+
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator>(
214214
msg,
215215
sub_ids.take_shared_subscriptions,
216216
ros_message_type_allocator);
@@ -231,8 +231,8 @@ class IntraProcessManager
231231
sub_ids.take_ownership_subscriptions.end());
232232

233233
this->template add_owned_msg_to_buffers<MessageT, PublishedType, ROSMessageType, Alloc,
234-
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator, ROSMessageTypeDeleter,
235-
PublishedTypeAllocator>(
234+
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator, ROSMessageTypeDeleter,
235+
PublishedTypeAllocator>(
236236
std::move(message),
237237
concatenated_vector,
238238
published_type_allocator,
@@ -241,16 +241,18 @@ class IntraProcessManager
241241
} else {
242242
// Construct a new shared pointer from the message
243243
// for the buffers that do not require ownership
244-
auto shared_msg = std::allocate_shared<PublishedType, PublishedTypeAllocator>(published_type_allocator, *message);
244+
auto shared_msg = std::allocate_shared<PublishedType, PublishedTypeAllocator>(
245+
published_type_allocator,
246+
*message);
245247

246248
this->template add_shared_msg_to_buffers<MessageT, PublishedType, ROSMessageType, Alloc,
247-
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator>(
249+
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator>(
248250
shared_msg,
249251
sub_ids.take_shared_subscriptions,
250252
ros_message_type_allocator);
251-
this->template add_owned_msg_to_buffers<MessageT, PublishedType, ROSMessageType, Alloc, Deleter,
252-
ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator, ROSMessageTypeDeleter,
253-
PublishedTypeAllocator>(
253+
this->template add_owned_msg_to_buffers<MessageT, PublishedType, ROSMessageType, Alloc,
254+
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator, ROSMessageTypeDeleter,
255+
PublishedTypeAllocator>(
254256
std::move(message),
255257
sub_ids.take_ownership_subscriptions,
256258
published_type_allocator,
@@ -301,7 +303,7 @@ class IntraProcessManager
301303
std::shared_ptr<PublishedType> shared_msg = std::move(message);
302304
if (!sub_ids.take_shared_subscriptions.empty()) {
303305
this->template add_shared_msg_to_buffers<MessageT, PublishedType, ROSMessageType, Alloc,
304-
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator>(
306+
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator>(
305307
shared_msg,
306308
sub_ids.take_shared_subscriptions,
307309
ros_message_type_allocator);
@@ -310,19 +312,21 @@ class IntraProcessManager
310312
} else {
311313
// Construct a new shared pointer from the message for the buffers that
312314
// do not require ownership and to return.
313-
auto shared_msg = std::allocate_shared<PublishedType, PublishedTypeAllocator>(published_type_allocator, *message);
315+
auto shared_msg = std::allocate_shared<PublishedType, PublishedTypeAllocator>(
316+
published_type_allocator,
317+
*message);
314318

315319
if (!sub_ids.take_shared_subscriptions.empty()) {
316320
this->template add_shared_msg_to_buffers<MessageT, PublishedType, ROSMessageType, Alloc,
317-
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator>(
321+
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator>(
318322
shared_msg,
319323
sub_ids.take_shared_subscriptions,
320324
ros_message_type_allocator);
321325
}
322326

323327
this->template add_owned_msg_to_buffers<MessageT, PublishedType, ROSMessageType, Alloc,
324-
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator, ROSMessageTypeDeleter,
325-
PublishedTypeAllocator>(
328+
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator, ROSMessageTypeDeleter,
329+
PublishedTypeAllocator>(
326330
std::move(message),
327331
sub_ids.take_ownership_subscriptions,
328332
published_type_allocator,
@@ -359,7 +363,9 @@ class IntraProcessManager
359363
{
360364
auto ptr = ROSMessageTypeAllocatorTraits::allocate(ros_message_type_allocator, 1);
361365
ROSMessageTypeAllocatorTraits::construct(ros_message_type_allocator, ptr);
362-
auto unique_ros_msg = std::unique_ptr<ROSMessageType, ROSMessageTypeDeleter>(ptr, ros_message_type_deleter);
366+
auto unique_ros_msg = std::unique_ptr<ROSMessageType, ROSMessageTypeDeleter>(
367+
ptr,
368+
ros_message_type_deleter);
363369
rclcpp::TypeAdapter<MessageT>::convert_to_ros_message(*message, *unique_ros_msg);
364370

365371
std::shared_lock<std::shared_timed_mutex> lock(mutex_);
@@ -379,27 +385,29 @@ class IntraProcessManager
379385
std::shared_ptr<PublishedType> shared_msg = std::move(message);
380386
if (!sub_ids.take_shared_subscriptions.empty()) {
381387
this->template add_shared_msg_to_buffers<MessageT, PublishedType, ROSMessageType, Alloc,
382-
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator>(
388+
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator>(
383389
shared_msg,
384390
sub_ids.take_shared_subscriptions,
385391
ros_message_type_allocator);
386392
}
387393
} else {
388394
// Construct a new shared pointer from the message for the buffers that
389395
// do not require ownership and to return.
390-
auto shared_msg = std::allocate_shared<PublishedType, PublishedTypeAllocator>(published_type_allocator, *message);
396+
auto shared_msg = std::allocate_shared<PublishedType, PublishedTypeAllocator>(
397+
published_type_allocator,
398+
*message);
391399

392400
if (!sub_ids.take_shared_subscriptions.empty()) {
393401
this->template add_shared_msg_to_buffers<MessageT, PublishedType, ROSMessageType, Alloc,
394-
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator>(
402+
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator>(
395403
shared_msg,
396404
sub_ids.take_shared_subscriptions,
397405
ros_message_type_allocator);
398406
}
399407

400408
this->template add_owned_msg_to_buffers<MessageT, PublishedType, ROSMessageType, Alloc,
401-
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator, ROSMessageTypeDeleter,
402-
PublishedTypeAllocator>(
409+
Deleter, ROSMessageTypeAllocatorTraits, ROSMessageTypeAllocator, ROSMessageTypeDeleter,
410+
PublishedTypeAllocator>(
403411
std::move(message),
404412
sub_ids.take_ownership_subscriptions,
405413
published_type_allocator,
@@ -482,18 +490,17 @@ class IntraProcessManager
482490
auto subscription_base = subscription_it->second.lock();
483491
if (subscription_base) {
484492
auto subscription = std::dynamic_pointer_cast<
485-
rclcpp::experimental::SubscriptionIntraProcessBuffer<MessageT, PublishedType, Alloc, Deleter>
486-
>(subscription_base);
493+
rclcpp::experimental::SubscriptionIntraProcessBuffer<MessageT, PublishedType, Alloc,
494+
Deleter>>(subscription_base);
487495
if (nullptr == subscription) {
488-
489496
auto ros_message_subscription = std::dynamic_pointer_cast<
490497
rclcpp::experimental::ROSMessageIntraProcessBuffer<ROSMessageType, Alloc, Deleter>
491498
>(subscription_base);
492499

493500
if (nullptr == ros_message_subscription) {
494501
throw std::runtime_error(
495502
"failed to dynamic cast SubscriptionIntraProcessBase to "
496-
"SubscriptionIntraProcessBuffer<MessageT, PublishedType, Alloc, Deleter>, which "
503+
"SubscriptionIntraProcessBuffer, which "
497504
"can happen when the publisher and subscription use different "
498505
"allocator types, which is not supported");
499506
} else {
@@ -506,13 +513,10 @@ class IntraProcessManager
506513
} else {
507514
ros_message_subscription->provide_intra_process_message(message);
508515
}
509-
510516
}
511517
} else {
512518
subscription->provide_intra_process_data(message);
513519
}
514-
515-
516520
} else {
517521
subscriptions_.erase(id);
518522
}
@@ -538,7 +542,6 @@ class IntraProcessManager
538542
ROSMessageTypeAllocator & ros_message_type_allocator,
539543
ROSMessageTypeDeleter & ros_message_type_deleter)
540544
{
541-
542545
std::cout << "add owned msg to buffers" << std::endl;
543546

544547
std::cout << "message has type : " << typeid(message).name() << std::endl;
@@ -554,15 +557,13 @@ class IntraProcessManager
554557
auto subscription_base = subscription_it->second.lock();
555558
std::cout << "Subscription Base?" << std::endl;
556559
if (subscription_base) {
557-
558560
std::cout << "Typed Subscription" << std::endl;
559561

560562
auto subscription = std::dynamic_pointer_cast<
561-
rclcpp::experimental::SubscriptionIntraProcessBuffer<MessageT, PublishedType, Alloc, Deleter>
562-
>(subscription_base);
563+
rclcpp::experimental::SubscriptionIntraProcessBuffer<MessageT, PublishedType, Alloc,
564+
Deleter>>(subscription_base);
563565
if (nullptr == subscription) {
564-
565-
std::cout << "ROSMessage Subscription" << std::endl;
566+
std::cout << "ROSMessage Subscription" << std::endl;
566567

567568
auto ros_message_subscription = std::dynamic_pointer_cast<
568569
rclcpp::experimental::ROSMessageIntraProcessBuffer<ROSMessageType, Alloc, Deleter>
@@ -571,17 +572,18 @@ class IntraProcessManager
571572
if (nullptr == ros_message_subscription) {
572573
throw std::runtime_error(
573574
"failed to dynamic cast SubscriptionIntraProcessBase to "
574-
"SubscriptionIntraProcessBuffer<MessageT, PublishedType, Alloc, Deleter>, which "
575+
"SubscriptionIntraProcessBuffer, which "
575576
"can happen when the publisher and subscription use different "
576577
"allocator types, which is not supported");
577578
} else {
578-
579579
std::cout << "ROSMessage TypeAdapted Subscription" << std::endl;
580580

581581
if constexpr (rclcpp::TypeAdapter<MessageT>::is_specialized::value) {
582582
auto ptr = ROSMessageTypeAllocatorTraits::allocate(ros_message_type_allocator, 1);
583583
ROSMessageTypeAllocatorTraits::construct(ros_message_type_allocator, ptr);
584-
auto ros_msg = std::unique_ptr<ROSMessageType, ROSMessageTypeDeleter>(ptr, ros_message_type_deleter);
584+
auto ros_msg = std::unique_ptr<ROSMessageType, ROSMessageTypeDeleter>(
585+
ptr,
586+
ros_message_type_deleter);
585587
rclcpp::TypeAdapter<MessageT>::convert_to_ros_message(*message, *ros_msg);
586588
ros_message_subscription->provide_intra_process_message(std::move(ros_msg));
587589
} else {
@@ -600,7 +602,6 @@ class IntraProcessManager
600602
ros_message_subscription->provide_intra_process_message(std::move(copy_message));
601603
}
602604
}
603-
604605
}
605606
} else {
606607
std::cout << "Typed Subscription" << std::endl;
@@ -618,7 +619,6 @@ class IntraProcessManager
618619
subscription->provide_intra_process_data(std::move(copy_message));
619620
}
620621
}
621-
622622
} else {
623623
std::cout << "Erasing subscription" << std::endl;
624624
subscriptions_.erase(subscription_it);

‎rclcpp/include/rclcpp/experimental/ros_message_intra_process_buffer.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class ROSMessageIntraProcessBuffer : public SubscriptionIntraProcessBase
6161

6262
virtual void
6363
provide_intra_process_message(MessageUniquePtr message) = 0;
64-
6564
};
6665

6766
} // namespace experimental

‎rclcpp/include/rclcpp/experimental/subscription_intra_process.hpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ template<
4343
typename SubscribedType,
4444
typename SubscribedTypeAlloc = std::allocator<void>,
4545
typename SubscribedTypeDeleter = std::default_delete<SubscribedType>
46-
>
46+
>
4747
class SubscriptionIntraProcess
4848
: public SubscriptionIntraProcessBuffer<
49-
MessageT,
50-
SubscribedType,
51-
SubscribedTypeAlloc,
52-
SubscribedTypeDeleter
53-
>
49+
MessageT,
50+
SubscribedType,
51+
SubscribedTypeAlloc,
52+
SubscribedTypeDeleter
53+
>
5454
{
5555
using SubscriptionIntraProcessBufferT = SubscriptionIntraProcessBuffer<
5656
MessageT,
@@ -62,7 +62,8 @@ class SubscriptionIntraProcess
6262
public:
6363
RCLCPP_SMART_PTR_DEFINITIONS(SubscriptionIntraProcess)
6464

65-
using MessageAllocTraits = typename SubscriptionIntraProcessBufferT::SubscribedTypeAllocatorTraits;
65+
using MessageAllocTraits =
66+
typename SubscriptionIntraProcessBufferT::SubscribedTypeAllocatorTraits;
6667
using MessageAlloc = typename SubscriptionIntraProcessBufferT::SubscribedTypeAllocator;
6768
using ConstMessageSharedPtr = typename SubscriptionIntraProcessBufferT::ConstMessageSharedPtr;
6869
using MessageUniquePtr = typename SubscriptionIntraProcessBufferT::MessageUniquePtr;
@@ -75,7 +76,8 @@ class SubscriptionIntraProcess
7576
const std::string & topic_name,
7677
const rclcpp::QoS & qos_profile,
7778
rclcpp::IntraProcessBufferType buffer_type)
78-
: SubscriptionIntraProcessBuffer<MessageT, SubscribedType, SubscribedTypeAlloc, SubscribedTypeDeleter>(
79+
: SubscriptionIntraProcessBuffer<MessageT, SubscribedType, SubscribedTypeAlloc,
80+
SubscribedTypeDeleter>(
7981
allocator,
8082
context,
8183
topic_name,

0 commit comments

Comments
 (0)
Please sign in to comment.