Skip to content

Commit

Permalink
Merge pull request #124 from orocos/rtt_std_srvs-for-standard-operations
Browse files Browse the repository at this point in the history
Add wrappers for common operation signatures to rtt_std_srvs (follow-up)
  • Loading branch information
francisco-miguel-almeida authored May 13, 2019
2 parents 8586e84 + f90432f commit a9e9bed
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions rtt_roscomm/include/rtt_roscomm/rtt_rosservice_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ class ROSServiceServerOperationCaller : public ROSServiceServerOperationCallerBa
typedef typename Wrapper::ProxyOperationCallerType ProxyOperationCallerType;
typedef boost::shared_ptr<ProxyOperationCallerType> ProxyOperationCallerTypePtr;

static Ptr connect(RTT::OperationInterfacePart* operation) {
ProxyOperationCallerTypePtr proxy_operation_caller
= boost::make_shared<ProxyOperationCallerType>(operation->getLocalOperation(), RTT::internal::GlobalEngine::Instance());
if (proxy_operation_caller->ready()) {
return Ptr(new ROSServiceServerOperationCaller<ROS_SERVICE_T, variant>(proxy_operation_caller));
}
return NextVariant<void>::connect(operation);
}

virtual bool call(typename ROS_SERVICE_T::Request& request, typename ROS_SERVICE_T::Response& response) const {
// Check if the operation caller is ready, and then call it.
if (!proxy_operation_caller_->ready()) return false;
return Wrapper::call(*proxy_operation_caller_, request, response);
}

private:
template<typename Dummy> struct Void { typedef void type; };

Expand All @@ -97,22 +112,6 @@ class ROSServiceServerOperationCaller : public ROSServiceServerOperationCallerBa
}
};

public:
static Ptr connect(RTT::OperationInterfacePart* operation) {
ProxyOperationCallerTypePtr proxy_operation_caller
= boost::make_shared<ProxyOperationCallerType>(operation->getLocalOperation(), RTT::internal::GlobalEngine::Instance());
if (proxy_operation_caller->ready()) {
return Ptr(new ROSServiceServerOperationCaller<ROS_SERVICE_T, variant>(proxy_operation_caller));
}
return NextVariant<void>::connect(operation);
}

virtual bool call(typename ROS_SERVICE_T::Request& request, typename ROS_SERVICE_T::Response& response) const {
// Check if the operation caller is ready, and then call it.
if (!proxy_operation_caller_->ready()) return false;
return Wrapper::call(*proxy_operation_caller_, request, response);
}

ROSServiceServerOperationCaller(const boost::shared_ptr<ProxyOperationCallerType>& impl)
: proxy_operation_caller_(impl) {}

Expand Down

0 comments on commit a9e9bed

Please sign in to comment.