Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose more native handles #146

Merged
merged 2 commits into from
Aug 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions rmw_fastrtps_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ include_directories(include)
add_library(rmw_fastrtps_cpp
src/client_service_common.cpp
src/demangle.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
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef TYPES__CUSTOM_CLIENT_INFO_HPP_
#define TYPES__CUSTOM_CLIENT_INFO_HPP_
#ifndef RMW_FASTRTPS_CPP__CUSTOM_CLIENT_INFO_HPP_
#define RMW_FASTRTPS_CPP__CUSTOM_CLIENT_INFO_HPP_

#include <atomic>
#include <list>
Expand Down Expand Up @@ -142,4 +142,4 @@ class ClientListener : public eprosima::fastrtps::SubscriberListener
std::condition_variable * conditionVariable_;
};

#endif // TYPES__CUSTOM_CLIENT_INFO_HPP_
#endif // RMW_FASTRTPS_CPP__CUSTOM_CLIENT_INFO_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef TYPES__CUSTOM_PUBLISHER_INFO_HPP_
#define TYPES__CUSTOM_PUBLISHER_INFO_HPP_
#ifndef RMW_FASTRTPS_CPP__CUSTOM_PUBLISHER_INFO_HPP_
#define RMW_FASTRTPS_CPP__CUSTOM_PUBLISHER_INFO_HPP_

#include "fastrtps/publisher/Publisher.h"

Expand All @@ -27,4 +27,4 @@ typedef struct CustomPublisherInfo
const char * typesupport_identifier_;
} CustomPublisherInfo;

#endif // TYPES__CUSTOM_PUBLISHER_INFO_HPP_
#endif // RMW_FASTRTPS_CPP__CUSTOM_PUBLISHER_INFO_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef TYPES__CUSTOM_SERVICE_INFO_HPP_
#define TYPES__CUSTOM_SERVICE_INFO_HPP_
#ifndef RMW_FASTRTPS_CPP__CUSTOM_SERVICE_INFO_HPP_
#define RMW_FASTRTPS_CPP__CUSTOM_SERVICE_INFO_HPP_

#include <atomic>
#include <list>
Expand Down Expand Up @@ -143,4 +143,4 @@ class ServiceListener : public eprosima::fastrtps::SubscriberListener
std::condition_variable * conditionVariable_;
};

#endif // TYPES__CUSTOM_SERVICE_INFO_HPP_
#endif // RMW_FASTRTPS_CPP__CUSTOM_SERVICE_INFO_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef TYPES__CUSTOM_SUBSCRIBER_INFO_HPP_
#define TYPES__CUSTOM_SUBSCRIBER_INFO_HPP_
#ifndef RMW_FASTRTPS_CPP__CUSTOM_SUBSCRIBER_INFO_HPP_
#define RMW_FASTRTPS_CPP__CUSTOM_SUBSCRIBER_INFO_HPP_

#include <condition_variable>
#include <mutex>
Expand Down Expand Up @@ -109,4 +109,4 @@ class SubListener : public eprosima::fastrtps::SubscriberListener
std::condition_variable * conditionVariable_;
};

#endif // TYPES__CUSTOM_SUBSCRIBER_INFO_HPP_
#endif // RMW_FASTRTPS_CPP__CUSTOM_SUBSCRIBER_INFO_HPP_
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_
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace rmw_fastrtps_cpp

/// Return a native FastRTPS participant handle.
/**
* The function return `NULL` when either the node handle is `NULL` or when the
* 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`
Expand Down
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_
49 changes: 49 additions & 0 deletions rmw_fastrtps_cpp/src/get_client.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// 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_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 NULL;
}
if (client->implementation_identifier != eprosima_fastrtps_identifier) {
return NULL;
}
CustomClientInfo * impl = static_cast<CustomClientInfo *>(client->data);
return impl->request_publisher_;
}

eprosima::fastrtps::Subscriber *
get_response_subscriber(rmw_client_t * client)
{
if (!client) {
return NULL;
}
if (client->implementation_identifier != eprosima_fastrtps_identifier) {
return NULL;
}
CustomClientInfo * 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_publisher.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_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 NULL;
}
if (publisher->implementation_identifier != eprosima_fastrtps_identifier) {
return NULL;
}
CustomPublisherInfo * impl = static_cast<CustomPublisherInfo *>(publisher->data);
return impl->publisher_;
}

} // namespace rmw_fastrtps_cpp
Loading