Skip to content

Commit

Permalink
Refs #2951. Native getters restored.
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelCompany committed Jun 5, 2018
1 parent c859294 commit 2aa0cbb
Show file tree
Hide file tree
Showing 11 changed files with 433 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rmw_fastrtps_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ include_directories(include)

add_library(rmw_fastrtps_cpp
src/client_service_common.cpp
src/get_client.cpp
src/get_participant.cpp
src/get_publisher.cpp
src/get_service.cpp
src/get_subscriber.cpp
src/identifier.cpp
src/namespace_prefix.cpp
src/qos.cpp
Expand Down
50 changes: 50 additions & 0 deletions rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/get_client.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2017 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 RMW_FASTRTPS_CPP__GET_CLIENT_HPP_
#define RMW_FASTRTPS_CPP__GET_CLIENT_HPP_

#include "fastrtps/publisher/Publisher.h"
#include "fastrtps/subscriber/Subscriber.h"
#include "rmw/rmw.h"
#include "rmw_fastrtps_cpp/visibility_control.h"

namespace rmw_fastrtps_cpp
{

/// Return a native FastRTPS publisher handle for the request.
/**
* The function returns `NULL` when either the client handle is `NULL` or
* when the client handle is from a different rmw implementation.
*
* \return native FastRTPS publisher handle if successful, otherwise `NULL`
*/
RMW_FASTRTPS_CPP_PUBLIC
eprosima::fastrtps::Publisher *
get_request_publisher(rmw_client_t * client);

/// Return a native FastRTPS subscriber handle for the response.
/**
* The function returns `NULL` when either the client handle is `NULL` or
* when the client handle is from a different rmw implementation.
*
* \return native FastRTPS subscriber handle if successful, otherwise `NULL`
*/
RMW_FASTRTPS_CPP_PUBLIC
eprosima::fastrtps::Subscriber *
get_response_subscriber(rmw_client_t * client);

} // namespace rmw_fastrtps_cpp

#endif // RMW_FASTRTPS_CPP__GET_CLIENT_HPP_
38 changes: 38 additions & 0 deletions rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/get_participant.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2017 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 RMW_FASTRTPS_CPP__GET_PARTICIPANT_HPP_
#define RMW_FASTRTPS_CPP__GET_PARTICIPANT_HPP_

#include "fastrtps/participant/Participant.h"
#include "rmw/rmw.h"
#include "rmw_fastrtps_cpp/visibility_control.h"

namespace rmw_fastrtps_cpp
{

/// Return a native FastRTPS participant handle.
/**
* The function returns `NULL` when either the node handle is `NULL` or when the
* node handle is from a different rmw implementation.
*
* \return native FastRTPS participant handle if successful, otherwise `NULL`
*/
RMW_FASTRTPS_CPP_PUBLIC
eprosima::fastrtps::Participant *
get_participant(rmw_node_t * node);

} // namespace rmw_fastrtps_cpp

#endif // RMW_FASTRTPS_CPP__GET_PARTICIPANT_HPP_
38 changes: 38 additions & 0 deletions rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/get_publisher.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2017 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 RMW_FASTRTPS_CPP__GET_PUBLISHER_HPP_
#define RMW_FASTRTPS_CPP__GET_PUBLISHER_HPP_

#include "fastrtps/publisher/Publisher.h"
#include "rmw/rmw.h"
#include "rmw_fastrtps_cpp/visibility_control.h"

namespace rmw_fastrtps_cpp
{

/// Return a native FastRTPS publisher handle.
/**
* The function returns `NULL` when either the publisher handle is `NULL` or
* when the publisher handle is from a different rmw implementation.
*
* \return native FastRTPS publisher handle if successful, otherwise `NULL`
*/
RMW_FASTRTPS_CPP_PUBLIC
eprosima::fastrtps::Publisher *
get_publisher(rmw_publisher_t * publisher);

} // namespace rmw_fastrtps_cpp

#endif // RMW_FASTRTPS_CPP__GET_PUBLISHER_HPP_
50 changes: 50 additions & 0 deletions rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/get_service.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2017 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 RMW_FASTRTPS_CPP__GET_SERVICE_HPP_
#define RMW_FASTRTPS_CPP__GET_SERVICE_HPP_

#include "fastrtps/publisher/Publisher.h"
#include "fastrtps/subscriber/Subscriber.h"
#include "rmw/rmw.h"
#include "rmw_fastrtps_cpp/visibility_control.h"

namespace rmw_fastrtps_cpp
{

/// Return a native FastRTPS subscriber handle for the request.
/**
* The function returns `NULL` when either the service handle is `NULL` or
* when the service handle is from a different rmw implementation.
*
* \return native FastRTPS subscriber handle if successful, otherwise `NULL`
*/
RMW_FASTRTPS_CPP_PUBLIC
eprosima::fastrtps::Subscriber *
get_request_subscriber(rmw_service_t * service);

/// Return a native FastRTPS publisher handle for the response.
/**
* The function returns `NULL` when either the service handle is `NULL` or
* when the service handle is from a different rmw implementation.
*
* \return native FastRTPS publisher handle if successful, otherwise `NULL`
*/
RMW_FASTRTPS_CPP_PUBLIC
eprosima::fastrtps::Publisher *
get_response_publisher(rmw_service_t * service);

} // namespace rmw_fastrtps_cpp

#endif // RMW_FASTRTPS_CPP__GET_SERVICE_HPP_
38 changes: 38 additions & 0 deletions rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/get_subscriber.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2017 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 RMW_FASTRTPS_CPP__GET_SUBSCRIBER_HPP_
#define RMW_FASTRTPS_CPP__GET_SUBSCRIBER_HPP_

#include "fastrtps/subscriber/Subscriber.h"
#include "rmw/rmw.h"
#include "rmw_fastrtps_cpp/visibility_control.h"

namespace rmw_fastrtps_cpp
{

/// Return a native FastRTPS subscriber handle.
/**
* The function returns `NULL` when either the subscription handle is `NULL` or
* when the subscription handle is from a different rmw implementation.
*
* \return native FastRTPS subscriber handle if successful, otherwise `NULL`
*/
RMW_FASTRTPS_CPP_PUBLIC
eprosima::fastrtps::Subscriber *
get_subscriber(rmw_subscription_t * subscription);

} // namespace rmw_fastrtps_cpp

#endif // RMW_FASTRTPS_CPP__GET_SUBSCRIBER_HPP_
51 changes: 51 additions & 0 deletions rmw_fastrtps_cpp/src/get_client.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2017 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 "type_support_common.hpp"

#include "rmw_fastrtps_cpp/get_client.hpp"

#include "rmw_fastrtps_cpp/custom_client_info.hpp"
#include "rmw_fastrtps_cpp/identifier.hpp"

namespace rmw_fastrtps_cpp
{

eprosima::fastrtps::Publisher *
get_request_publisher(rmw_client_t * client)
{
if (!client) {
return nullptr;
}
if (client->implementation_identifier != eprosima_fastrtps_identifier) {
return nullptr;
}
auto impl = static_cast<CustomClientInfo *>(client->data);
return impl->request_publisher_;
}

eprosima::fastrtps::Subscriber *
get_response_subscriber(rmw_client_t * client)
{
if (!client) {
return nullptr;
}
if (client->implementation_identifier != eprosima_fastrtps_identifier) {
return nullptr;
}
auto impl = static_cast<CustomClientInfo *>(client->data);
return impl->response_subscriber_;
}

} // namespace rmw_fastrtps_cpp
36 changes: 36 additions & 0 deletions rmw_fastrtps_cpp/src/get_participant.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2017 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 "rmw_fastrtps_cpp/get_participant.hpp"

#include "rmw_fastrtps_cpp/custom_participant_info.hpp"
#include "rmw_fastrtps_cpp/identifier.hpp"

namespace rmw_fastrtps_cpp
{

eprosima::fastrtps::Participant *
get_participant(rmw_node_t * node)
{
if (!node) {
return nullptr;
}
if (node->implementation_identifier != eprosima_fastrtps_identifier) {
return nullptr;
}
auto impl = static_cast<CustomParticipantInfo *>(node->data);
return impl->participant;
}

} // namespace rmw_fastrtps_cpp
38 changes: 38 additions & 0 deletions rmw_fastrtps_cpp/src/get_publisher.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2017 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 "type_support_common.hpp"

#include "rmw_fastrtps_cpp/get_publisher.hpp"

#include "rmw_fastrtps_cpp/custom_publisher_info.hpp"
#include "rmw_fastrtps_cpp/identifier.hpp"

namespace rmw_fastrtps_cpp
{

eprosima::fastrtps::Publisher *
get_publisher(rmw_publisher_t * publisher)
{
if (!publisher) {
return nullptr;
}
if (publisher->implementation_identifier != eprosima_fastrtps_identifier) {
return nullptr;
}
auto impl = static_cast<CustomPublisherInfo *>(publisher->data);
return impl->publisher_;
}

} // namespace rmw_fastrtps_cpp
Loading

0 comments on commit 2aa0cbb

Please sign in to comment.