-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add mechanism to pass rmw impl specific payloads during pub/sub creat…
…ion (#882) * add mechanism to pass rmw impl specific payloads during pub/sub creation Signed-off-by: William Woodall <william@osrfoundation.org> * use class instead of struct Signed-off-by: William Woodall <william@osrfoundation.org> * narrow API of rmw payload to just use rmw_*_options_t's Signed-off-by: William Woodall <william@osrfoundation.org> * fixup after recent change Signed-off-by: William Woodall <william@osrfoundation.org>
- Loading branch information
Showing
11 changed files
with
300 additions
and
2 deletions.
There are no files selected for viewing
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
51 changes: 51 additions & 0 deletions
51
rclcpp/include/rclcpp/detail/rmw_implementation_specific_payload.hpp
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2019 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef RCLCPP__DETAIL__RMW_IMPLEMENTATION_SPECIFIC_PAYLOAD_HPP_ | ||
#define RCLCPP__DETAIL__RMW_IMPLEMENTATION_SPECIFIC_PAYLOAD_HPP_ | ||
|
||
#include "rclcpp/visibility_control.hpp" | ||
|
||
namespace rclcpp | ||
{ | ||
namespace detail | ||
{ | ||
|
||
/// Mechanism for passing rmw implementation specific settings through the ROS interfaces. | ||
class RCLCPP_PUBLIC RMWImplementationSpecificPayload | ||
{ | ||
public: | ||
virtual | ||
~RMWImplementationSpecificPayload() = default; | ||
|
||
/// Return false if this class has not been customized, otherwise true. | ||
/** | ||
* It does this based on the value of the rmw implementation identifier that | ||
* this class reports, and so it is important for a specialization of this | ||
* class to override the get_rmw_implementation_identifier() method to return | ||
* something other than nullptr. | ||
*/ | ||
bool | ||
has_been_customized() const; | ||
|
||
/// Derrived classes should override this and return the identifier of its rmw implementation. | ||
virtual | ||
const char * | ||
get_implementation_identifier() const; | ||
}; | ||
|
||
} // namespace detail | ||
} // namespace rclcpp | ||
|
||
#endif // RCLCPP__DETAIL__RMW_IMPLEMENTATION_SPECIFIC_PAYLOAD_HPP_ |
52 changes: 52 additions & 0 deletions
52
rclcpp/include/rclcpp/detail/rmw_implementation_specific_publisher_payload.hpp
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2019 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef RCLCPP__DETAIL__RMW_IMPLEMENTATION_SPECIFIC_PUBLISHER_PAYLOAD_HPP_ | ||
#define RCLCPP__DETAIL__RMW_IMPLEMENTATION_SPECIFIC_PUBLISHER_PAYLOAD_HPP_ | ||
|
||
#include "rcl/publisher.h" | ||
|
||
#include "rclcpp/detail/rmw_implementation_specific_payload.hpp" | ||
#include "rclcpp/visibility_control.hpp" | ||
|
||
namespace rclcpp | ||
{ | ||
namespace detail | ||
{ | ||
|
||
class RCLCPP_PUBLIC RMWImplementationSpecificPublisherPayload | ||
: public RMWImplementationSpecificPayload | ||
{ | ||
public: | ||
~RMWImplementationSpecificPublisherPayload() override = default; | ||
|
||
/// Opportunity for a derived class to inject information into the rcl options. | ||
/** | ||
* This is called after the rcl_publisher_options_t has been prepared by | ||
* rclcpp, but before rcl_publisher_init() is called. | ||
* | ||
* The passed option is the rmw_publisher_options field of the | ||
* rcl_publisher_options_t that will be passed to rcl_publisher_init(). | ||
* | ||
* By default the options are unmodified. | ||
*/ | ||
virtual | ||
void | ||
modify_rmw_publisher_options(rmw_publisher_options_t & rmw_publisher_options) const; | ||
}; | ||
|
||
} // namespace detail | ||
} // namespace rclcpp | ||
|
||
#endif // RCLCPP__DETAIL__RMW_IMPLEMENTATION_SPECIFIC_PUBLISHER_PAYLOAD_HPP_ |
53 changes: 53 additions & 0 deletions
53
rclcpp/include/rclcpp/detail/rmw_implementation_specific_subscription_payload.hpp
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2019 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef RCLCPP__DETAIL__RMW_IMPLEMENTATION_SPECIFIC_SUBSCRIPTION_PAYLOAD_HPP_ | ||
#define RCLCPP__DETAIL__RMW_IMPLEMENTATION_SPECIFIC_SUBSCRIPTION_PAYLOAD_HPP_ | ||
|
||
#include "rcl/subscription.h" | ||
|
||
#include "rclcpp/detail/rmw_implementation_specific_payload.hpp" | ||
#include "rclcpp/visibility_control.hpp" | ||
|
||
namespace rclcpp | ||
{ | ||
namespace detail | ||
{ | ||
|
||
/// Subscription payload that may be rmw implementation specific. | ||
class RCLCPP_PUBLIC RMWImplementationSpecificSubscriptionPayload | ||
: public RMWImplementationSpecificPayload | ||
{ | ||
public: | ||
~RMWImplementationSpecificSubscriptionPayload() override = default; | ||
|
||
/// Opportunity for a derived class to inject information into the rcl options. | ||
/** | ||
* This is called after the rcl_subscription_options_t has been prepared by | ||
* rclcpp, but before rcl_subscription_init() is called. | ||
* | ||
* The passed option is the rmw_subscription_options field of the | ||
* rcl_subscription_options_t that will be passed to rcl_subscription_init(). | ||
* | ||
* By default the options are unmodified. | ||
*/ | ||
virtual | ||
void | ||
modify_rmw_subscription_options(rmw_subscription_options_t & rmw_subscription_options) const; | ||
}; | ||
|
||
} // namespace detail | ||
} // namespace rclcpp | ||
|
||
#endif // RCLCPP__DETAIL__RMW_IMPLEMENTATION_SPECIFIC_SUBSCRIPTION_PAYLOAD_HPP_ |
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
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
35 changes: 35 additions & 0 deletions
35
rclcpp/src/rclcpp/detail/rmw_implementation_specific_payload.cpp
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2019 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <rclcpp/detail/rmw_implementation_specific_payload.hpp> | ||
|
||
namespace rclcpp | ||
{ | ||
namespace detail | ||
{ | ||
|
||
bool | ||
RMWImplementationSpecificPayload::has_been_customized() const | ||
{ | ||
return nullptr != this->get_implementation_identifier(); | ||
} | ||
|
||
const char * | ||
RMWImplementationSpecificPayload::get_implementation_identifier() const | ||
{ | ||
return nullptr; | ||
} | ||
|
||
} // namespace detail | ||
} // namespace rclcpp |
33 changes: 33 additions & 0 deletions
33
rclcpp/src/rclcpp/detail/rmw_implementation_specific_publisher_payload.cpp
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2019 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <rclcpp/detail/rmw_implementation_specific_publisher_payload.hpp> | ||
|
||
#include "rcl/publisher.h" | ||
|
||
namespace rclcpp | ||
{ | ||
namespace detail | ||
{ | ||
|
||
void | ||
RMWImplementationSpecificPublisherPayload::modify_rmw_publisher_options( | ||
rmw_publisher_options_t & rmw_publisher_options) const | ||
{ | ||
// By default, do not mutate the rmw publisher options. | ||
(void)rmw_publisher_options; | ||
} | ||
|
||
} // namespace detail | ||
} // namespace rclcpp |
33 changes: 33 additions & 0 deletions
33
rclcpp/src/rclcpp/detail/rmw_implementation_specific_subscription_payload.cpp
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2019 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <rclcpp/detail/rmw_implementation_specific_subscription_payload.hpp> | ||
|
||
#include "rcl/subscription.h" | ||
|
||
namespace rclcpp | ||
{ | ||
namespace detail | ||
{ | ||
|
||
void | ||
RMWImplementationSpecificSubscriptionPayload::modify_rmw_subscription_options( | ||
rmw_subscription_options_t & rmw_subscription_options) const | ||
{ | ||
// By default, do not mutate the rmw subscription options. | ||
(void)rmw_subscription_options; | ||
} | ||
|
||
} // namespace detail | ||
} // namespace rclcpp |