init
This commit is contained in:
30
unitree_SDK/include/ddscxx/dds/topic/detail/AnyTopic.hpp
Normal file
30
unitree_SDK/include/ddscxx/dds/topic/detail/AnyTopic.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef OMG_DDS_TOPIC_DETAIL_ANY_TOPIC_HPP_
|
||||
#define OMG_DDS_TOPIC_DETAIL_ANY_TOPIC_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
// Implementation
|
||||
|
||||
#include <dds/topic/detail/TAnyTopicImpl.hpp>
|
||||
#include <org/eclipse/cyclonedds/topic/AnyTopicDelegate.hpp>
|
||||
|
||||
namespace dds { namespace topic { namespace detail {
|
||||
typedef dds::topic::TAnyTopic<org::eclipse::cyclonedds::topic::AnyTopicDelegate> AnyTopic;
|
||||
} } }
|
||||
|
||||
// End of implementation
|
||||
|
||||
#endif /* OMG_DDS_TOPIC_DETAIL_ANY_TOPIC_HPP_ */
|
||||
46
unitree_SDK/include/ddscxx/dds/topic/detail/BuiltinTopic.hpp
Normal file
46
unitree_SDK/include/ddscxx/dds/topic/detail/BuiltinTopic.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef OMG_DDS_TOPIC_DETAIL_BUILTIN_TOPIC_HPP_
|
||||
#define OMG_DDS_TOPIC_DETAIL_BUILTIN_TOPIC_HPP_
|
||||
|
||||
/* Copyright 2010, Object Management Group, Inc.
|
||||
* Copyright 2010, PrismTech, Corp.
|
||||
* Copyright 2010, Real-Time Innovations, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 <dds/topic/Topic.hpp>
|
||||
#include <dds/topic/detail/TTopicImpl.hpp>
|
||||
#include <dds/topic/detail/TBuiltinTopicImpl.hpp>
|
||||
#include <org/eclipse/cyclonedds/topic/BuiltinTopicDelegate.hpp>
|
||||
#include <org/eclipse/cyclonedds/topic/BuiltinTopic.hpp>
|
||||
|
||||
namespace dds { namespace topic { namespace detail {
|
||||
|
||||
typedef dds::topic::TParticipantBuiltinTopicData<org::eclipse::cyclonedds::topic::ParticipantBuiltinTopicDataDelegate>
|
||||
ParticipantBuiltinTopicData;
|
||||
|
||||
typedef dds::topic::TTopicBuiltinTopicData<org::eclipse::cyclonedds::topic::TopicBuiltinTopicDataDelegate>
|
||||
TopicBuiltinTopicData;
|
||||
|
||||
typedef dds::topic::TPublicationBuiltinTopicData<org::eclipse::cyclonedds::topic::PublicationBuiltinTopicDataDelegate>
|
||||
PublicationBuiltinTopicData;
|
||||
|
||||
typedef dds::topic::TSubscriptionBuiltinTopicData<org::eclipse::cyclonedds::topic::SubscriptionBuiltinTopicDataDelegate>
|
||||
SubscriptionBuiltinTopicData;
|
||||
|
||||
} } }
|
||||
|
||||
|
||||
|
||||
#endif /* OMG_DDS_TOPIC_DETAIL_BUILTIN_TOPIC_HPP_ */
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef OMG_DDS_TOPIC_DETAIL_BUILTIN_TOPIC_KEY_HPP_
|
||||
#define OMG_DDS_TOPIC_DETAIL_BUILTIN_TOPIC_KEY_HPP_
|
||||
|
||||
/* Copyright 2010, Object Management Group, Inc.
|
||||
* Copyright 2010, PrismTech, Corp.
|
||||
* Copyright 2010, Real-Time Innovations, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 <org/eclipse/cyclonedds/topic/BuiltinTopicKeyDelegate.hpp>
|
||||
#include <dds/topic/detail/TBuiltinTopicKeyImpl.hpp>
|
||||
|
||||
namespace dds { namespace topic { namespace detail {
|
||||
typedef dds::topic::TBuiltinTopicKey<org::eclipse::cyclonedds::topic::BuiltinTopicKeyDelegate> BuiltinTopicKey;
|
||||
} } }
|
||||
|
||||
#endif /* OMG_DDS_TOPIC_DETAIL_BUILTIN_TOPIC_KEY_HPP_ */
|
||||
@@ -0,0 +1,470 @@
|
||||
#ifndef OMG_DDS_TOPIC_DETAIL_CONTENTFILTEREDTOPIC_HPP_
|
||||
#define OMG_DDS_TOPIC_DETAIL_CONTENTFILTEREDTOPIC_HPP_
|
||||
|
||||
/* Copyright 2010, Object Management Group, Inc.
|
||||
* Copyright 2010, PrismTech, Inc.
|
||||
* Copyright 2010, Real-Time Innovations, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 <string>
|
||||
#include <vector>
|
||||
|
||||
#include <dds/core/detail/conformance.hpp>
|
||||
#include <dds/core/types.hpp>
|
||||
#include <dds/topic/Topic.hpp>
|
||||
#include <dds/topic/Filter.hpp>
|
||||
#include <org/eclipse/cyclonedds/topic/TopicDescriptionDelegate.hpp>
|
||||
#include <org/eclipse/cyclonedds/core/ScopedLock.hpp>
|
||||
#include <org/eclipse/cyclonedds/sub/AnyDataReaderDelegate.hpp>
|
||||
|
||||
#ifdef OMG_DDS_CONTENT_SUBSCRIPTION_SUPPORT
|
||||
|
||||
// Required for C++11
|
||||
#if __cplusplus == 201103L
|
||||
#include <org/eclipse/cyclonedds/core/Missing.hpp>
|
||||
#endif
|
||||
|
||||
// meta-programming helpers
|
||||
namespace detail
|
||||
{
|
||||
template<typename T>
|
||||
struct remove_first_from_tuple;
|
||||
|
||||
template<typename T, typename ... Ts>
|
||||
struct remove_first_from_tuple<std::tuple<T, Ts...>>
|
||||
{
|
||||
using type = std::tuple<Ts...>;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
using remove_first_from_tuple_t = typename remove_first_from_tuple<T>::type;
|
||||
|
||||
template<class F>
|
||||
struct callable_traits;
|
||||
|
||||
template<class R, class ... Args>
|
||||
struct callable_traits<R(Args...)>
|
||||
{
|
||||
using return_type = R;
|
||||
|
||||
static constexpr std::size_t Arity = sizeof...(Args);
|
||||
|
||||
template < std::size_t N, std::enable_if_t<N<Arity> * = nullptr>
|
||||
struct argument
|
||||
{
|
||||
using type = typename std::tuple_element<N, std::tuple<Args...>>::type;
|
||||
};
|
||||
|
||||
using argument_tuple = std::tuple<Args...>;
|
||||
};
|
||||
|
||||
// function pointer
|
||||
template<class R, class ... Args>
|
||||
struct callable_traits<R (*)(Args...)>
|
||||
: public callable_traits<R(Args...)> {};
|
||||
|
||||
// member function pointer
|
||||
template<class C, class R, class ... Args>
|
||||
struct callable_traits<R (C::*)(Args...)>
|
||||
: public callable_traits<R(C &, Args...)> {};
|
||||
|
||||
// const member function pointer
|
||||
template<class C, class R, class ... Args>
|
||||
struct callable_traits<R (C::*)(Args...) const>
|
||||
: public callable_traits<R(C &, Args...)> {};
|
||||
|
||||
// member object pointer
|
||||
template<class C, class R>
|
||||
struct callable_traits<R(C::*)>
|
||||
: public callable_traits<R(C &)> {};
|
||||
|
||||
// functor
|
||||
template<class F>
|
||||
struct callable_traits
|
||||
{
|
||||
private:
|
||||
using call_type = callable_traits<decltype(&F::operator())>;
|
||||
|
||||
public:
|
||||
using return_type = typename call_type::return_type;
|
||||
|
||||
static constexpr std::size_t Arity = call_type::Arity - 1;
|
||||
|
||||
template < std::size_t N, std::enable_if_t<N<Arity> * = nullptr>
|
||||
struct argument
|
||||
{
|
||||
using type = typename call_type::template argument<N + 1>::type;
|
||||
};
|
||||
|
||||
using argument_tuple = remove_first_from_tuple_t<typename call_type::argument_tuple>;
|
||||
};
|
||||
|
||||
template<class F>
|
||||
struct callable_traits<F &>
|
||||
: public callable_traits<F> {};
|
||||
|
||||
template<class F>
|
||||
struct callable_traits<F &&>
|
||||
: public callable_traits<F> {};
|
||||
|
||||
// Concepts of possible callbacks
|
||||
template<class F, class T>
|
||||
using sample_only_t = std::enable_if_t<callable_traits<std::decay_t<F>>::Arity == 1 &&
|
||||
std::is_same<typename callable_traits<std::decay_t<F>>::template argument<0>::type,
|
||||
const T &>::value &&
|
||||
std::is_same<typename callable_traits<std::decay_t<F>>::return_type, bool>::value
|
||||
>;
|
||||
|
||||
template<class F>
|
||||
using sample_info_only_t = std::enable_if_t<callable_traits<std::decay_t<F>>::Arity == 1 &&
|
||||
std::is_same<typename callable_traits<std::decay_t<F>>::template argument<0>::type,
|
||||
const dds::sub::SampleInfo &>::value &&
|
||||
std::is_same<typename callable_traits<std::decay_t<F>>::return_type, bool>::value
|
||||
>;
|
||||
|
||||
template<class F, class T>
|
||||
using sample_and_sample_info_t = std::enable_if_t<callable_traits<std::decay_t<F>>::Arity == 2 &&
|
||||
std::is_same<typename callable_traits<std::decay_t<F>>::template argument<0>::type,
|
||||
const T &>::value &&
|
||||
std::is_same<typename callable_traits<std::decay_t<F>>::template argument<1>::type,
|
||||
const dds::sub::SampleInfo &>::value &&
|
||||
std::is_same<typename callable_traits<std::decay_t<F>>::return_type, bool>::value
|
||||
>;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
namespace dds {
|
||||
namespace topic {
|
||||
namespace detail {
|
||||
|
||||
class FunctorHolderBase
|
||||
{
|
||||
public:
|
||||
FunctorHolderBase() = default;
|
||||
virtual ~FunctorHolderBase() = default;
|
||||
FunctorHolderBase(const FunctorHolderBase &) = default;
|
||||
FunctorHolderBase & operator=(const FunctorHolderBase &) = default;
|
||||
FunctorHolderBase(FunctorHolderBase &&) = default;
|
||||
FunctorHolderBase & operator=(FunctorHolderBase &&) = default;
|
||||
|
||||
virtual bool check_sample(const void * sample, const dds_sample_info_t * sample_info) = 0;
|
||||
|
||||
static bool c99_check_sample(const void *sample, void *arg)
|
||||
{
|
||||
auto funcHolder = static_cast<FunctorHolderBase *>(arg);
|
||||
return funcHolder->check_sample(sample, nullptr);
|
||||
}
|
||||
|
||||
static bool c99_check_sample_info(const dds_sample_info_t * sampleinfo, void * arg)
|
||||
{
|
||||
auto funcHolder = static_cast<FunctorHolderBase *>(arg);
|
||||
return funcHolder->check_sample(nullptr, sampleinfo);
|
||||
}
|
||||
|
||||
static bool c99_check_sample_and_sample_info(
|
||||
const void * sample,
|
||||
const dds_sample_info_t * sampleinfo, void * arg)
|
||||
{
|
||||
auto funcHolder = static_cast<FunctorHolderBase *>(arg);
|
||||
return funcHolder->check_sample(sample, sampleinfo);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename FUN, typename T, class = void>
|
||||
class FunctorHolder;
|
||||
|
||||
template <typename FUN, typename T>
|
||||
class FunctorHolder<FUN, T, ::detail::sample_only_t<FUN, T>>: public FunctorHolderBase
|
||||
{
|
||||
public:
|
||||
/* Remove const to be able to call non-const functors. */
|
||||
FunctorHolder(FUN functor)
|
||||
: myFunctor(std::move(functor)) {}
|
||||
|
||||
bool check_sample(const void * sample, const dds_sample_info_t *) override
|
||||
{
|
||||
return myFunctor(*(reinterpret_cast<const T*>(sample)));
|
||||
}
|
||||
|
||||
private:
|
||||
FUN myFunctor;
|
||||
};
|
||||
|
||||
template<typename FUN, typename T>
|
||||
class FunctorHolder<FUN, T, ::detail::sample_info_only_t<FUN>>: public FunctorHolderBase
|
||||
{
|
||||
public:
|
||||
/* Remove const to be able to call non-const functors. */
|
||||
FunctorHolder(FUN functor)
|
||||
: myFunctor(std::move(functor)) {}
|
||||
|
||||
bool check_sample(const void *, const dds_sample_info_t * sampleinfo) override
|
||||
{
|
||||
dds::sub::SampleInfo cxxSampleInfo;
|
||||
org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::copy_sample_infos(
|
||||
*sampleinfo,
|
||||
cxxSampleInfo);
|
||||
return myFunctor(cxxSampleInfo);
|
||||
}
|
||||
|
||||
private:
|
||||
FUN myFunctor;
|
||||
};
|
||||
|
||||
template<typename FUN, typename T>
|
||||
class FunctorHolder<FUN, T, ::detail::sample_and_sample_info_t<FUN, T>>: public FunctorHolderBase
|
||||
{
|
||||
public:
|
||||
/* Remove const to be able to call non-const functors. */
|
||||
FunctorHolder(FUN functor)
|
||||
: myFunctor(std::move(functor)) {}
|
||||
|
||||
bool check_sample(const void * sample, const dds_sample_info_t * sampleinfo) override
|
||||
{
|
||||
dds::sub::SampleInfo cxxSampleInfo;
|
||||
org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::copy_sample_infos(*sampleinfo,
|
||||
cxxSampleInfo);
|
||||
return myFunctor(*(reinterpret_cast<const T*>(sample)), cxxSampleInfo);
|
||||
}
|
||||
|
||||
private:
|
||||
FUN myFunctor;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class ContentFilteredTopic :
|
||||
public virtual org::eclipse::cyclonedds::topic::TopicDescriptionDelegate,
|
||||
public virtual org::eclipse::cyclonedds::core::DDScObjectDelegate
|
||||
{
|
||||
public:
|
||||
ContentFilteredTopic(
|
||||
const dds::topic::Topic<T>& topic,
|
||||
const std::string& name,
|
||||
const dds::topic::Filter& filter)
|
||||
: org::eclipse::cyclonedds::core::DDScObjectDelegate(),
|
||||
org::eclipse::cyclonedds::topic::TopicDescriptionDelegate(topic.domain_participant(), name, topic.type_name()),
|
||||
myTopic(topic),
|
||||
myFilter(filter),
|
||||
myFunctor(nullptr)
|
||||
{
|
||||
topic.delegate()->incrNrDependents();
|
||||
this->myParticipant.delegate()->add_cfTopic(*this);
|
||||
this->ser_type_ = topic->get_ser_type();
|
||||
}
|
||||
|
||||
virtual ~ContentFilteredTopic()
|
||||
{
|
||||
if (!this->closed) {
|
||||
try {
|
||||
this->close();
|
||||
} catch (...) {
|
||||
/* Empty: the exception throw should have already traced an error. */
|
||||
}
|
||||
}
|
||||
// delete the functor
|
||||
delete myFunctor;
|
||||
myFunctor = nullptr;
|
||||
}
|
||||
|
||||
virtual void close()
|
||||
{
|
||||
org::eclipse::cyclonedds::core::ScopedObjectLock scopedLock(*this);
|
||||
|
||||
myTopic.delegate()->decrNrDependents();
|
||||
|
||||
// Remove the ContentFilteredTopic from the list of topics in its participant.
|
||||
this->myParticipant.delegate()->remove_cfTopic(*this);
|
||||
|
||||
org::eclipse::cyclonedds::core::ObjectDelegate::close();
|
||||
}
|
||||
|
||||
void
|
||||
init(org::eclipse::cyclonedds::core::ObjectDelegate::weak_ref_type weak_ref)
|
||||
{
|
||||
/* Set weak_ref before passing ourselves to other isocpp objects. */
|
||||
this->set_weak_ref(weak_ref);
|
||||
/* Register topic at participant. */
|
||||
this->myParticipant.delegate()->add_cfTopic(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
#if 0
|
||||
void validate_filter()
|
||||
{
|
||||
q_expr expr = NULL;
|
||||
uint32_t length;
|
||||
c_value *params;
|
||||
|
||||
length = myFilter.parameters_length();
|
||||
if (length < 100) {
|
||||
expr = q_parse(myFilter.expression().c_str());
|
||||
if (!expr ) {
|
||||
ISOCPP_THROW_EXCEPTION(ISOCPP_INVALID_ARGUMENT_ERROR,
|
||||
"filter_expression '%s' is invalid", myFilter.expression().c_str());
|
||||
}
|
||||
} else {
|
||||
ISOCPP_THROW_EXCEPTION(ISOCPP_INVALID_ARGUMENT_ERROR,
|
||||
"Invalid number of filter_parameters '%d', maximum is 99", length);
|
||||
}
|
||||
|
||||
u_topic uTopic = (u_topic)(myTopic.delegate()->get_user_handle());
|
||||
|
||||
params = reader_parameters();
|
||||
if (!u_topicContentFilterValidate2(uTopic, expr, params)) {
|
||||
ISOCPP_THROW_EXCEPTION(ISOCPP_INVALID_ARGUMENT_ERROR,
|
||||
"filter_expression '%s' is invalid.", myFilter.expression().c_str());
|
||||
}
|
||||
q_dispose(expr);
|
||||
os_free(params);
|
||||
}
|
||||
#endif
|
||||
public:
|
||||
std::string reader_expression() const
|
||||
{
|
||||
std::string rExpr;
|
||||
|
||||
rExpr += "select * from ";
|
||||
rExpr += myTopic.name();
|
||||
rExpr += " where ";
|
||||
rExpr += myFilter.expression();
|
||||
return rExpr;
|
||||
}
|
||||
#if 0
|
||||
c_value *reader_parameters() const
|
||||
{
|
||||
c_value *params = NULL;
|
||||
uint32_t n, length;
|
||||
org::eclipse::cyclonedds::topic::FilterDelegate::const_iterator paramIterator;
|
||||
|
||||
length = myFilter.parameters_length();
|
||||
params = (c_value *)os_malloc(length * sizeof(struct c_value));
|
||||
for (n = 0, paramIterator = myFilter.begin(); n < length; n++, paramIterator++) {
|
||||
params[n] = c_stringValue(const_cast<char *>(paramIterator->c_str()));
|
||||
}
|
||||
return params;
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* @internal Accessor to return the topic filter.
|
||||
* @return The dds::topic::Filter in effect on this topic.
|
||||
*/
|
||||
const dds::topic::Filter& filter() const
|
||||
{
|
||||
return myFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Sets the filter parameters for this content filtered topic.
|
||||
* @param begin The iterator holding the first string param
|
||||
* @param end The last item in the string iteration
|
||||
*/
|
||||
template <typename FWIterator>
|
||||
void filter_parameters(const FWIterator& begin, const FWIterator& end)
|
||||
{
|
||||
ISOCPP_THROW_EXCEPTION(ISOCPP_UNSUPPORTED_ERROR, "Changing of Filter parameters is currently not supported.");
|
||||
myFilter.parameters(begin, end);
|
||||
//@todo validate_filter();
|
||||
}
|
||||
|
||||
const dds::topic::Topic<T>& topic() const
|
||||
{
|
||||
return myTopic;
|
||||
}
|
||||
|
||||
const std::string& filter_expression() const
|
||||
{
|
||||
return myFilter.expression();
|
||||
}
|
||||
|
||||
const dds::core::StringSeq filter_parameters() const
|
||||
{
|
||||
return dds::core::StringSeq(myFilter.begin(), myFilter.end());
|
||||
}
|
||||
#if 0
|
||||
dds::topic::TTopicDescription<TopicDescriptionDelegate> clone()
|
||||
{
|
||||
org::eclipse::cyclonedds::core::ScopedObjectLock scopedLock(*this);
|
||||
|
||||
typename dds::topic::ContentFilteredTopic<T, ContentFilteredTopic>::DELEGATE_REF_T ref(
|
||||
new ContentFilteredTopic<T>(this->myTopic, this->myTopicName, this->myFilter));
|
||||
ref->init(ref);
|
||||
|
||||
return dds::topic::ContentFilteredTopic<T, ContentFilteredTopic>(ref);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class Functor, ::detail::sample_only_t<Functor, T> * = nullptr>
|
||||
void filter_function(Functor && func)
|
||||
{
|
||||
dds_topic_filter flt;
|
||||
flt.mode = DDS_TOPIC_FILTER_SAMPLE_ARG;
|
||||
flt.f.sample_arg = &FunctorHolderBase::c99_check_sample;
|
||||
filter_function_internal(std::forward<Functor>(func), &flt);
|
||||
}
|
||||
|
||||
template<class Functor, ::detail::sample_info_only_t<Functor> * = nullptr>
|
||||
void filter_function(Functor && func)
|
||||
{
|
||||
dds_topic_filter flt;
|
||||
flt.mode = DDS_TOPIC_FILTER_SAMPLEINFO_ARG;
|
||||
flt.f.sampleinfo_arg = &FunctorHolderBase::c99_check_sample_info;
|
||||
filter_function_internal(std::forward<Functor>(func), &flt);
|
||||
}
|
||||
|
||||
template<class Functor, ::detail::sample_and_sample_info_t<Functor, T> * = nullptr>
|
||||
void filter_function(Functor && func)
|
||||
{
|
||||
dds_topic_filter flt;
|
||||
flt.mode = DDS_TOPIC_FILTER_SAMPLE_SAMPLEINFO_ARG;
|
||||
flt.f.sample_sampleinfo_arg = &FunctorHolderBase::c99_check_sample_and_sample_info;
|
||||
filter_function_internal(std::forward<Functor>(func), &flt);
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Functor>
|
||||
void filter_function_internal(Functor && func, dds_topic_filter * flt)
|
||||
{
|
||||
/* Make a private copy of the topic so my filter doesn't bother the original topic. */
|
||||
dds_qos_t* ddsc_qos = myTopic.qos()->ddsc_qos();
|
||||
ddsi_sertype *st = org::eclipse::cyclonedds::topic::TopicTraits<T>::getSerType();
|
||||
dds_entity_t cfTopic = dds_create_topic_sertype(
|
||||
myTopic.domain_participant().delegate()->get_ddsc_entity(), myTopic.name().c_str(), &st, ddsc_qos, NULL, NULL);
|
||||
dds_delete_qos(ddsc_qos);
|
||||
this->set_ddsc_entity(cfTopic);
|
||||
|
||||
org::eclipse::cyclonedds::core::ScopedObjectLock scopedLock(*this);
|
||||
if (this->myFunctor)
|
||||
{
|
||||
delete this->myFunctor;
|
||||
}
|
||||
myFunctor = new FunctorHolder<Functor, T>(std::forward<Functor>(func));
|
||||
flt->arg = myFunctor;
|
||||
dds_set_topic_filter_extended(cfTopic, flt);
|
||||
}
|
||||
|
||||
dds::topic::Topic<T> myTopic;
|
||||
dds::topic::Filter myFilter;
|
||||
FunctorHolderBase *myFunctor;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* OMG_DDS_CONTENT_SUBSCRIPTION_SUPPORT */
|
||||
|
||||
#endif /* OMG_DDS_TOPIC_DETAIL_CONTENTFILTEREDTOPIC_HPP_ */
|
||||
25
unitree_SDK/include/ddscxx/dds/topic/detail/Filter.hpp
Normal file
25
unitree_SDK/include/ddscxx/dds/topic/detail/Filter.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef DDS_TOPIC_DETAIL_QUERY_HPP_
|
||||
#define DDS_TOPIC_DETAIL_QUERY_HPP_
|
||||
|
||||
#include <dds/topic/detail/TFilterImpl.hpp>
|
||||
#include <org/eclipse/cyclonedds/topic/FilterDelegate.hpp>
|
||||
|
||||
namespace dds {
|
||||
namespace topic {
|
||||
namespace detail {
|
||||
typedef ::dds::topic::TFilter< ::org::eclipse::cyclonedds::topic::FilterDelegate > Filter;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* DDS_TOPIC_DETAIL_QUERY_HPP_ */
|
||||
135
unitree_SDK/include/ddscxx/dds/topic/detail/MultiTopic.hpp
Normal file
135
unitree_SDK/include/ddscxx/dds/topic/detail/MultiTopic.hpp
Normal file
@@ -0,0 +1,135 @@
|
||||
#ifndef OMG_DDS_TOPIC_DETAIL_MULTI_TOPIC_HPP_
|
||||
#define OMG_DDS_TOPIC_DETAIL_MULTI_TOPIC_HPP_
|
||||
|
||||
/* Copyright 2010, Object Management Group, Inc.
|
||||
* Copyright 2010, PrismTech, Inc.
|
||||
* Copyright 2010, Real-Time Innovations, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 <string>
|
||||
#include <vector>
|
||||
|
||||
#include <dds/core/types.hpp>
|
||||
#include <dds/domain/DomainParticipant.hpp>
|
||||
#include <dds/topic/detail/TopicDescription.hpp>
|
||||
#include <dds/core/Query.hpp>
|
||||
|
||||
#ifdef OMG_DDS_MULTI_TOPIC_SUPPORT
|
||||
|
||||
namespace dds { namespace topic { namespace detail {
|
||||
|
||||
|
||||
template <typename T>
|
||||
class MultiTopic : public org::eclipse::cyclonedds::topic::TopicDescriptionDelegate
|
||||
{
|
||||
public:
|
||||
MultiTopic(
|
||||
const dds::domain::DomainParticipant& dp,
|
||||
const std::string& name,
|
||||
const std::string expression,
|
||||
const FWDIterator& params_begin,
|
||||
const FWDIterator& params_end)
|
||||
: ::dds::core::Reference< DELEGATE<T> >(
|
||||
new dds::topic::detail::MultiTopic<T>(dp, name, expression, params_begin, params_end))
|
||||
{
|
||||
// Set the correct (IDL) type_name in the TopicDescription.
|
||||
dds::topic::detail::TopicDescription<T>::myTypeName = org::eclipse::cyclonedds::topic::TopicTraits<T>::getTypeName();
|
||||
|
||||
//@todo validate_filter();
|
||||
}
|
||||
|
||||
virtual ~MultiTopic()
|
||||
{
|
||||
// Assume destructor of Filter attribute cleans up itself.
|
||||
}
|
||||
|
||||
private:
|
||||
#if 0
|
||||
void validate_filter()
|
||||
{
|
||||
q_expr expr = NULL;
|
||||
uint32_t length;
|
||||
c_value *params;
|
||||
|
||||
length = myFilter.parameters_length();
|
||||
if (length < 100) {
|
||||
expr = q_parse(myFilter.expression().c_str());
|
||||
if (!expr ) {
|
||||
ISOCPP_THROW_EXCEPTION(ISOCPP_INVALID_ARGUMENT_ERROR,
|
||||
"filter_expression '%s' is invalid", myFilter.expression().c_str());
|
||||
}
|
||||
} else {
|
||||
ISOCPP_THROW_EXCEPTION(ISOCPP_INVALID_ARGUMENT_ERROR,
|
||||
"Invalid number of filter_parameters '%d', maximum is 99", length);
|
||||
}
|
||||
|
||||
params = reader_parameters();
|
||||
/* The function below does not exist yet, but probably a function like it will need to be developed. */
|
||||
if (!u_topicMultiExprValidate(dp.delegate()->get_user_handle(), myFilter.expression().c_str(), params)) {
|
||||
ISOCPP_THROW_EXCEPTION(ISOCPP_INVALID_ARGUMENT_ERROR,
|
||||
"filter_expression '%s' is invalid.", myFilter.expression().c_str());
|
||||
}
|
||||
q_dispose(expr);
|
||||
os_free(params);
|
||||
}
|
||||
#endif
|
||||
public:
|
||||
std::string reader_expression() const
|
||||
{
|
||||
return myFilter.expression();
|
||||
}
|
||||
#if 0
|
||||
c_value *reader_parameters() const
|
||||
{
|
||||
c_value *params = NULL;
|
||||
uint32_t n, length;
|
||||
org::eclipse::cyclonedds::topic::FilterDelegate::const_iterator paramIterator;
|
||||
|
||||
length = myFilter.parameters_length();
|
||||
params = (c_value *)os_malloc(length * sizeof(struct c_value));
|
||||
for (n = 0, paramIterator = myFilter.begin(); n < length; n++, paramIterator++) {
|
||||
params[n] = c_stringValue(const_cast<char *>(paramIterator->c_str()));
|
||||
}
|
||||
return params;
|
||||
}
|
||||
#endif
|
||||
const std::string expression() const
|
||||
{
|
||||
return myFilter.expression();
|
||||
}
|
||||
|
||||
template <typename FWIterator>
|
||||
void expression_parameters(const FWIterator& params_begin, const FWIterator& params_end)
|
||||
{
|
||||
myFilter.parameters(begin, end);
|
||||
validate_filter();
|
||||
}
|
||||
|
||||
const dds::core::StringSeq expression_parameters() const
|
||||
{
|
||||
return dds::core::StringSeq(myFilter.begin(), myFilter.end());
|
||||
}
|
||||
|
||||
private:
|
||||
dds::topic::Filter myFilter;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* OMG_DDS_MULTI_TOPIC_SUPPORT */
|
||||
|
||||
#endif /* OMG_DDS_TOPIC_DETAIL_MULTI_TOPIC_HPP_ */
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright(c) 2006 to 2021 ZettaScale Technology and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef CYCLONEDDS_DDS_TOPIC_TANYTOPIC_IMPL_HPP_
|
||||
#define CYCLONEDDS_DDS_TOPIC_TANYTOPIC_IMPL_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
#include <dds/topic/TAnyTopic.hpp>
|
||||
|
||||
// Implementation
|
||||
namespace dds
|
||||
{
|
||||
namespace topic
|
||||
{
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::topic::qos::TopicQos
|
||||
TAnyTopic<DELEGATE>::qos() const
|
||||
{
|
||||
return this->delegate()->qos();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
void
|
||||
TAnyTopic<DELEGATE>::qos(const dds::topic::qos::TopicQos& qos)
|
||||
{
|
||||
this->delegate()->qos(qos);
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
TAnyTopic<DELEGATE>&
|
||||
TAnyTopic<DELEGATE>::operator << (const dds::topic::qos::TopicQos& qos)
|
||||
{
|
||||
this->delegate()->qos(qos);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
const TAnyTopic<DELEGATE>&
|
||||
TAnyTopic<DELEGATE>::operator >> (dds::topic::qos::TopicQos& qos) const
|
||||
{
|
||||
qos = this->delegate()->qos();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::core::status::InconsistentTopicStatus
|
||||
TAnyTopic<DELEGATE>::inconsistent_topic_status() const
|
||||
{
|
||||
return this->delegate()->inconsistent_topic_status();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_TOPIC_TANYTOPIC_IMPL_HPP_ */
|
||||
@@ -0,0 +1,580 @@
|
||||
/*
|
||||
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef CYCLONEDDS_DDS_TOPIC_TBUILTINTOPIC_IMPL_HPP_
|
||||
#define CYCLONEDDS_DDS_TOPIC_TBUILTINTOPIC_IMPL_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
#include <dds/topic/TBuiltinTopic.hpp>
|
||||
|
||||
// Implementation
|
||||
namespace dds
|
||||
{
|
||||
namespace topic
|
||||
{
|
||||
|
||||
//TParticipantBuiltinTopicData
|
||||
template <typename D>
|
||||
const dds::topic::BuiltinTopicKey& TParticipantBuiltinTopicData<D>::key() const
|
||||
{
|
||||
return this->delegate().key();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::UserData& TParticipantBuiltinTopicData<D>::user_data() const
|
||||
{
|
||||
return this->delegate().user_data();
|
||||
}
|
||||
|
||||
//TTopicBuiltinTopicData
|
||||
template <typename D>
|
||||
const dds::topic::BuiltinTopicKey& TTopicBuiltinTopicData<D>::key() const
|
||||
{
|
||||
return this->delegate().key();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const std::string& TTopicBuiltinTopicData<D>::name() const
|
||||
{
|
||||
return this->delegate().name();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const std::string& TTopicBuiltinTopicData<D>::type_name() const
|
||||
{
|
||||
return this->delegate().type_name();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Durability& TTopicBuiltinTopicData<D>::durability() const
|
||||
{
|
||||
return this->delegate().durability();
|
||||
}
|
||||
|
||||
#ifdef OMG_DDS_PERSISTENCE_SUPPORT
|
||||
template <typename D>
|
||||
const ::dds::core::policy::DurabilityService& TTopicBuiltinTopicData<D>::durability_service() const
|
||||
{
|
||||
return this->delegate().durability_service();
|
||||
}
|
||||
|
||||
#endif // OMG_DDS_PERSISTENCE_SUPPORT
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Deadline& TTopicBuiltinTopicData<D>::deadline() const
|
||||
{
|
||||
return this->delegate().deadline();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::LatencyBudget& TTopicBuiltinTopicData<D>::latency_budget() const
|
||||
{
|
||||
return this->delegate().latency_budget();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Liveliness& TTopicBuiltinTopicData<D>::liveliness() const
|
||||
{
|
||||
return this->delegate().liveliness();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Reliability& TTopicBuiltinTopicData<D>::reliability() const
|
||||
{
|
||||
return this->delegate().reliability();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::TransportPriority& TTopicBuiltinTopicData<D>::transport_priority() const
|
||||
{
|
||||
return this->delegate().transport_priority();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Lifespan& TTopicBuiltinTopicData<D>::lifespan() const
|
||||
{
|
||||
return this->delegate().lifespan();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::DestinationOrder& TTopicBuiltinTopicData<D>::destination_order() const
|
||||
{
|
||||
return this->delegate().destination_order();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::History& TTopicBuiltinTopicData<D>::history() const
|
||||
{
|
||||
return this->delegate().history();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::ResourceLimits& TTopicBuiltinTopicData<D>::resource_limits() const
|
||||
{
|
||||
return this->delegate().resource_limits();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Ownership& TTopicBuiltinTopicData<D>::ownership() const
|
||||
{
|
||||
return this->delegate().ownership();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::TopicData& TTopicBuiltinTopicData<D>::topic_data() const
|
||||
{
|
||||
return this->delegate().topic_data();
|
||||
}
|
||||
|
||||
//TPublicationBuiltinTopicData
|
||||
|
||||
template <typename D>
|
||||
const dds::topic::BuiltinTopicKey& TPublicationBuiltinTopicData<D>::key() const
|
||||
{
|
||||
return this->delegate().key();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const dds::topic::BuiltinTopicKey& TPublicationBuiltinTopicData<D>::participant_key() const
|
||||
{
|
||||
return this->delegate().key();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const std::string& TPublicationBuiltinTopicData<D>::topic_name() const
|
||||
{
|
||||
return this->delegate().topic_name();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const std::string& TPublicationBuiltinTopicData<D>::type_name() const
|
||||
{
|
||||
return this->delegate().type_name();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Durability& TPublicationBuiltinTopicData<D>::durability() const
|
||||
{
|
||||
return this->delegate().durability();
|
||||
}
|
||||
|
||||
#ifdef OMG_DDS_PERSISTENCE_SUPPORT
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::DurabilityService& TPublicationBuiltinTopicData<D>::durability_service() const
|
||||
{
|
||||
return this->delegate().durability_service();
|
||||
}
|
||||
#endif // OMG_DDS_PERSISTENCE_SUPPORT
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Deadline& TPublicationBuiltinTopicData<D>::deadline() const
|
||||
{
|
||||
return this->delegate().deadline();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::LatencyBudget& TPublicationBuiltinTopicData<D>::latency_budget() const
|
||||
{
|
||||
return this->delegate().latency_budget();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Liveliness& TPublicationBuiltinTopicData<D>::liveliness() const
|
||||
{
|
||||
return this->delegate().liveliness();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Reliability& TPublicationBuiltinTopicData<D>::reliability() const
|
||||
{
|
||||
return this->delegate().reliability();
|
||||
}
|
||||
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Lifespan& TPublicationBuiltinTopicData<D>::lifespan() const
|
||||
{
|
||||
return this->delegate().lifespan();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::UserData& TPublicationBuiltinTopicData<D>::user_data() const
|
||||
{
|
||||
return this->delegate().user_data();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Ownership& TPublicationBuiltinTopicData<D>::ownership() const
|
||||
{
|
||||
return this->delegate().ownership();
|
||||
}
|
||||
|
||||
#ifdef OMG_DDS_OWNERSHIP_SUPPORT
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::OwnershipStrength& TPublicationBuiltinTopicData<D>::ownership_strength() const
|
||||
{
|
||||
return this->delegate().ownership_strength();
|
||||
}
|
||||
#endif // OMG_DDS_OWNERSHIP_SUPPORT
|
||||
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::DestinationOrder& TPublicationBuiltinTopicData<D>::destination_order() const
|
||||
{
|
||||
return this->delegate().destination_order();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Presentation& TPublicationBuiltinTopicData<D>::presentation() const
|
||||
{
|
||||
return this->delegate().presentation();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Partition& TPublicationBuiltinTopicData<D>::partition() const
|
||||
{
|
||||
return this->delegate().partition();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::TopicData& TPublicationBuiltinTopicData<D>::topic_data() const
|
||||
{
|
||||
return this->delegate().topic_data();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::GroupData& TPublicationBuiltinTopicData<D>::group_data() const
|
||||
{
|
||||
return this->delegate().group_data();
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename D>
|
||||
const dds::topic::BuiltinTopicKey& TSubscriptionBuiltinTopicData<D>::key() const
|
||||
{
|
||||
return this->delegate().key();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const dds::topic::BuiltinTopicKey& TSubscriptionBuiltinTopicData<D>::participant_key() const
|
||||
{
|
||||
return this->delegate().key();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const std::string& TSubscriptionBuiltinTopicData<D>::topic_name() const
|
||||
{
|
||||
return this->delegate().topic_name();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const std::string& TSubscriptionBuiltinTopicData<D>::type_name() const
|
||||
{
|
||||
return this->delegate().type_name();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Durability& TSubscriptionBuiltinTopicData<D>::durability() const
|
||||
{
|
||||
return this->delegate().durability();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Deadline& TSubscriptionBuiltinTopicData<D>::deadline() const
|
||||
{
|
||||
return this->delegate().deadline();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::LatencyBudget& TSubscriptionBuiltinTopicData<D>::latency_budget() const
|
||||
{
|
||||
return this->delegate().latency_budget();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Liveliness& TSubscriptionBuiltinTopicData<D>::liveliness() const
|
||||
{
|
||||
return this->delegate().liveliness();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Reliability& TSubscriptionBuiltinTopicData<D>::reliability() const
|
||||
{
|
||||
return this->delegate().reliability();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Ownership& TSubscriptionBuiltinTopicData<D>::ownership() const
|
||||
{
|
||||
return this->delegate().ownership();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::DestinationOrder& TSubscriptionBuiltinTopicData<D>::destination_order() const
|
||||
{
|
||||
return this->delegate().destination_order();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::UserData& TSubscriptionBuiltinTopicData<D>::user_data() const
|
||||
{
|
||||
return this->delegate().user_data();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::TimeBasedFilter& TSubscriptionBuiltinTopicData<D>::time_based_filter() const
|
||||
{
|
||||
return this->delegate().time_based_filter();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Presentation& TSubscriptionBuiltinTopicData<D>::presentation() const
|
||||
{
|
||||
return this->delegate().presentation();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Partition& TSubscriptionBuiltinTopicData<D>::partition() const
|
||||
{
|
||||
return this->delegate().partition();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::TopicData& TSubscriptionBuiltinTopicData<D>::topic_data() const
|
||||
{
|
||||
return this->delegate().topic_data();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::GroupData& TSubscriptionBuiltinTopicData<D>::group_data() const
|
||||
{
|
||||
return this->delegate().group_data();
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
//TCMParticipantBuiltinTopicData
|
||||
|
||||
template <typename D>
|
||||
const dds::topic::BuiltinTopicKey& TCMParticipantBuiltinTopicData<D>::key() const
|
||||
{
|
||||
return ((D)this->delegate()).key();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::org::eclipse::cyclonedds::core::policy::ProductData& TCMParticipantBuiltinTopicData<D>::product() const
|
||||
{
|
||||
return ((D)this->delegate()).product();
|
||||
}
|
||||
|
||||
//TCMPublisherBuiltinTopicData
|
||||
|
||||
template <typename D>
|
||||
const dds::topic::BuiltinTopicKey& TCMPublisherBuiltinTopicData<D>::key() const
|
||||
{
|
||||
return ((D)this->delegate()).key();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::org::eclipse::cyclonedds::core::policy::ProductData& TCMPublisherBuiltinTopicData<D>::product() const
|
||||
{
|
||||
return ((D)this->delegate()).product();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const dds::topic::BuiltinTopicKey& TCMPublisherBuiltinTopicData<D>::participant_key() const
|
||||
{
|
||||
return ((D)this->delegate()).participant_key();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const std::string& TCMPublisherBuiltinTopicData<D>::name() const
|
||||
{
|
||||
return ((D)this->delegate()).name();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::EntityFactory& TCMPublisherBuiltinTopicData<D>::entity_factory() const
|
||||
{
|
||||
return ((D)this->delegate()).entity_factory();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Partition& TCMPublisherBuiltinTopicData<D>::partition() const
|
||||
{
|
||||
return ((D)this->delegate()).partition();
|
||||
}
|
||||
|
||||
//TCMSubscriberBuiltinTopicData
|
||||
|
||||
template <typename D>
|
||||
const dds::topic::BuiltinTopicKey& TCMSubscriberBuiltinTopicData<D>::key() const
|
||||
{
|
||||
return ((D)this->delegate()).key();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::org::eclipse::cyclonedds::core::policy::ProductData& TCMSubscriberBuiltinTopicData<D>::product() const
|
||||
{
|
||||
return ((D)this->delegate()).product();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const dds::topic::BuiltinTopicKey& TCMSubscriberBuiltinTopicData<D>::participant_key() const
|
||||
{
|
||||
return ((D)this->delegate()).participant_key();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const std::string& TCMSubscriberBuiltinTopicData<D>::name() const
|
||||
{
|
||||
return ((D)this->delegate()).name();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::EntityFactory& TCMSubscriberBuiltinTopicData<D>::entity_factory() const
|
||||
{
|
||||
return ((D)this->delegate()).entity_factory();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::Partition& TCMSubscriberBuiltinTopicData<D>::partition() const
|
||||
{
|
||||
return ((D)this->delegate()).partition();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::org::eclipse::cyclonedds::core::policy::Share& TCMSubscriberBuiltinTopicData<D>::share() const
|
||||
{
|
||||
return ((D)this->delegate()).share();
|
||||
}
|
||||
|
||||
//TCMDataWriterBuiltinTopicData
|
||||
|
||||
template <typename D>
|
||||
const dds::topic::BuiltinTopicKey& TCMDataWriterBuiltinTopicData<D>::key() const
|
||||
{
|
||||
return ((D)this->delegate()).key();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::org::eclipse::cyclonedds::core::policy::ProductData& TCMDataWriterBuiltinTopicData<D>::product() const
|
||||
{
|
||||
return ((D)this->delegate()).product();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const dds::topic::BuiltinTopicKey& TCMDataWriterBuiltinTopicData<D>::publisher_key() const
|
||||
{
|
||||
return ((D)this->delegate()).publisher_key();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const std::string& TCMDataWriterBuiltinTopicData<D>::name() const
|
||||
{
|
||||
return ((D)this->delegate()).name();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::History& TCMDataWriterBuiltinTopicData<D>::history() const
|
||||
{
|
||||
return ((D)this->delegate()).history();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::ResourceLimits& TCMDataWriterBuiltinTopicData<D>::resource_limits() const
|
||||
{
|
||||
return ((D)this->delegate()).resource_limits();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::WriterDataLifecycle& TCMDataWriterBuiltinTopicData<D>::writer_data_lifecycle() const
|
||||
{
|
||||
return ((D)this->delegate()).writer_data_lifecycle();
|
||||
}
|
||||
|
||||
//TCMDataReaderBuiltinTopicData
|
||||
|
||||
template <typename D>
|
||||
const dds::topic::BuiltinTopicKey& TCMDataReaderBuiltinTopicData<D>::key() const
|
||||
{
|
||||
return ((D)this->delegate()).key();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::org::eclipse::cyclonedds::core::policy::ProductData& TCMDataReaderBuiltinTopicData<D>::product() const
|
||||
{
|
||||
return ((D)this->delegate()).product();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const dds::topic::BuiltinTopicKey& TCMDataReaderBuiltinTopicData<D>::subscriber_key() const
|
||||
{
|
||||
return ((D)this->delegate()).subscriber_key();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const std::string& TCMDataReaderBuiltinTopicData<D>::name() const
|
||||
{
|
||||
return ((D)this->delegate()).name();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::History& TCMDataReaderBuiltinTopicData<D>::history() const
|
||||
{
|
||||
return ((D)this->delegate()).history();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::ResourceLimits& TCMDataReaderBuiltinTopicData<D>::resource_limits() const
|
||||
{
|
||||
return ((D)this->delegate()).resource_limits();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::dds::core::policy::ReaderDataLifecycle& TCMDataReaderBuiltinTopicData<D>::reader_data_lifecycle() const
|
||||
{
|
||||
return ((D)this->delegate()).reader_data_lifecycle();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::org::eclipse::cyclonedds::core::policy::SubscriptionKey& TCMDataReaderBuiltinTopicData<D>::subscription_keys() const
|
||||
{
|
||||
return ((D)this->delegate()).subscription_keys();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::org::eclipse::cyclonedds::core::policy::ReaderLifespan& TCMDataReaderBuiltinTopicData<D>::reader_lifespan() const
|
||||
{
|
||||
return ((D)this->delegate()).reader_lifespan();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
const ::org::eclipse::cyclonedds::core::policy::Share& TCMDataReaderBuiltinTopicData<D>::share() const
|
||||
{
|
||||
return ((D)this->delegate()).share();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_TOPIC_TBUILTINTOPIC_IMPL_HPP_ */
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef CYCLONEDDS_DDS_TOPIC_DETAIL_TBUILTINTOPICKEY_IMPL_HPP_
|
||||
#define CYCLONEDDS_DDS_TOPIC_DETAIL_TBUILTINTOPICKEY_IMPL_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
#include <dds/topic/TBuiltinTopicKey.hpp>
|
||||
|
||||
// Implementation
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace topic
|
||||
{
|
||||
|
||||
template <typename D>
|
||||
const int32_t* TBuiltinTopicKey<D>::value() const
|
||||
{
|
||||
return this->delegate().value();
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
void TBuiltinTopicKey<D>::value(int32_t v[])
|
||||
{
|
||||
return this->delegate().value(v);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_TOPIC_DETAIL_TBUILTINTOPICKEY_IMPL_HPP_ */
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef CYCLONEDDS_DDS_TOPIC_TCONTENTFILTEREDTOPIC_HPP_
|
||||
#define CYCLONEDDS_DDS_TOPIC_TCONTENTFILTEREDTOPIC_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
#include <dds/topic/TContentFilteredTopic.hpp>
|
||||
|
||||
// Implementation
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace topic
|
||||
{
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
ContentFilteredTopic<T, DELEGATE>::ContentFilteredTopic(const Topic<T>& topic,
|
||||
const std::string& name,
|
||||
const dds::topic::Filter& filter) :
|
||||
::dds::core::Reference< DELEGATE<T> >(
|
||||
new dds::topic::detail::ContentFilteredTopic<T>(topic, name, filter))
|
||||
{
|
||||
this->delegate()->init(::dds::core::Reference< DELEGATE<T> >::impl_);
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
ContentFilteredTopic<T, DELEGATE>::~ContentFilteredTopic()
|
||||
{
|
||||
// Nothing to be done yet....
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
const std::string& ContentFilteredTopic<T, DELEGATE>::filter_expression() const
|
||||
{
|
||||
return this->delegate()->filter_expression();
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
const dds::core::StringSeq ContentFilteredTopic<T, DELEGATE>::filter_parameters() const
|
||||
{
|
||||
return this->delegate()->filter_parameters();
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
template <typename FWDIterator>
|
||||
void ContentFilteredTopic<T, DELEGATE>::filter_parameters(const FWDIterator& begin, const FWDIterator& end)
|
||||
{
|
||||
this->delegate()->filter_parameters(begin, end);
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
const dds::topic::Topic<T>& ContentFilteredTopic<T, DELEGATE>::topic() const
|
||||
{
|
||||
return this->delegate()->topic();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_TOPIC_TCONTENTFILTEREDTOPIC_HPP_ */
|
||||
105
unitree_SDK/include/ddscxx/dds/topic/detail/TFilterImpl.hpp
Normal file
105
unitree_SDK/include/ddscxx/dds/topic/detail/TFilterImpl.hpp
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef CYCLONEDDS_DDS_TOPIC_TFILTER_HPP_
|
||||
#define CYCLONEDDS_DDS_TOPIC_TFILTER_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
#include <dds/topic/TFilter.hpp>
|
||||
|
||||
// Implementation
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace topic
|
||||
{
|
||||
|
||||
template<typename D>
|
||||
TFilter<D>::TFilter(const std::string& query_expression) :
|
||||
dds::core::Value<D>(query_expression)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename D>
|
||||
template<typename FWIterator>
|
||||
TFilter<D>::TFilter(const std::string& query_expression, const FWIterator& params_begin,
|
||||
const FWIterator& params_end)
|
||||
: dds::core::Value<D>(query_expression, params_begin, params_end)
|
||||
{ }
|
||||
|
||||
template<typename D>
|
||||
TFilter<D>::TFilter(const std::string& query_expression,
|
||||
const std::vector<std::string>& params) :
|
||||
dds::core::Value<D>(query_expression, params.begin(), params.end())
|
||||
{
|
||||
}
|
||||
|
||||
template<typename D>
|
||||
const std::string& TFilter<D>::expression() const
|
||||
{
|
||||
return this->delegate().expression();
|
||||
}
|
||||
|
||||
template<typename D>
|
||||
typename TFilter<D>::const_iterator TFilter<D>::begin() const
|
||||
{
|
||||
return this->delegate().begin();
|
||||
}
|
||||
|
||||
template<typename D>
|
||||
typename TFilter<D>::const_iterator TFilter<D>::end() const
|
||||
{
|
||||
return this->delegate().end();
|
||||
}
|
||||
|
||||
template<typename D>
|
||||
typename TFilter<D>::iterator TFilter<D>::begin()
|
||||
{
|
||||
return this->delegate().begin();
|
||||
}
|
||||
|
||||
template<typename D>
|
||||
typename TFilter<D>::iterator TFilter<D>::end()
|
||||
{
|
||||
return this->delegate().end();
|
||||
}
|
||||
|
||||
template<typename D>
|
||||
template<typename FWIterator>
|
||||
void TFilter<D>::parameters(const FWIterator& begin, const FWIterator end)
|
||||
{
|
||||
this->delegate().parameters(begin, end);
|
||||
}
|
||||
|
||||
template<typename D>
|
||||
void TFilter<D>::add_parameter(const std::string& param)
|
||||
{
|
||||
this->delegate().add_parameter(param);
|
||||
}
|
||||
|
||||
template<typename D>
|
||||
uint32_t TFilter<D>::parameters_length() const
|
||||
{
|
||||
return this->delegate().parameters_length();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_TOPIC_TFILTER_HPP_ */
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright(c) 2006 to 2021 ZettaScale Technology and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef CYCLONEDDS_DDS_TOPIC_TTOPICDESCRIPTION_HPP_
|
||||
#define CYCLONEDDS_DDS_TOPIC_TTOPICDESCRIPTION_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
#include <dds/topic/TTopicDescription.hpp>
|
||||
|
||||
// Implementation
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace topic
|
||||
{
|
||||
|
||||
template <typename DELEGATE>
|
||||
const std::string& TTopicDescription<DELEGATE>::name() const
|
||||
{
|
||||
return this->delegate()->name();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
const std::string& TTopicDescription<DELEGATE>::type_name() const
|
||||
{
|
||||
return this->delegate()->type_name();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
const dds::domain::DomainParticipant& TTopicDescription<DELEGATE>::domain_participant() const
|
||||
{
|
||||
return this->delegate()->domain_participant();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_TOPIC_TTOPICDESCRIPTION_HPP_ */
|
||||
395
unitree_SDK/include/ddscxx/dds/topic/detail/TTopicImpl.hpp
Normal file
395
unitree_SDK/include/ddscxx/dds/topic/detail/TTopicImpl.hpp
Normal file
@@ -0,0 +1,395 @@
|
||||
/*
|
||||
* Copyright(c) 2006 to 2021 ZettaScale Technology and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef CYCLONEDDS_DDS_TOPIC_TTOPIC_HPP_
|
||||
#define CYCLONEDDS_DDS_TOPIC_TTOPIC_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
#include <dds/topic/TTopic.hpp>
|
||||
#include "org/eclipse/cyclonedds/topic/TopicTraits.hpp"
|
||||
#include "org/eclipse/cyclonedds/topic/TopicListener.hpp"
|
||||
|
||||
#include <dds/dds.h>
|
||||
#include <functional>
|
||||
|
||||
#define MAX_TOPIC_NAME_LEN 1024
|
||||
|
||||
// Implementation
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace topic
|
||||
{
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* dds/topic/Topic<> WRAPPER implementation.
|
||||
* Declaration can be found in dds/topic/TTopic.hpp
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
Topic<T, DELEGATE>::Topic(const dds::domain::DomainParticipant& dp,
|
||||
const std::string& topic_name) :
|
||||
::dds::core::Reference< DELEGATE<T> >(new DELEGATE<T>(
|
||||
dp,
|
||||
topic_name,
|
||||
"",
|
||||
dp.default_topic_qos(),
|
||||
NULL,
|
||||
dds::core::status::StatusMask::none()))
|
||||
{
|
||||
this->delegate()->init(this->impl_);
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
Topic<T, DELEGATE>::Topic(const dds::domain::DomainParticipant& dp,
|
||||
const std::string& topic_name,
|
||||
const std::string& type_name) :
|
||||
::dds::core::Reference< DELEGATE<T> >(new DELEGATE<T>(
|
||||
dp,
|
||||
topic_name,
|
||||
type_name,
|
||||
dp.default_topic_qos(),
|
||||
NULL,
|
||||
dds::core::status::StatusMask::none())),
|
||||
::dds::topic::TAnyTopic< DELEGATE<T> >(::dds::core::Reference< DELEGATE<T> >::delegate())
|
||||
{
|
||||
throw dds::core::UnsupportedError(std::string("Only Topics with default type_names are supported"));
|
||||
/* this->delegate()->init(this->impl_); */
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
Topic<T, DELEGATE>::Topic(const dds::domain::DomainParticipant& dp,
|
||||
const std::string& topic_name,
|
||||
const dds::topic::qos::TopicQos& qos,
|
||||
dds::topic::TopicListener<T>* listener,
|
||||
const dds::core::status::StatusMask& mask) :
|
||||
::dds::core::Reference< DELEGATE<T> >(new DELEGATE<T>(
|
||||
dp,
|
||||
topic_name,
|
||||
"",
|
||||
qos,
|
||||
listener,
|
||||
mask)),
|
||||
::dds::topic::TAnyTopic< DELEGATE<T> >(::dds::core::Reference< DELEGATE<T> >::delegate())
|
||||
{
|
||||
this->delegate()->init(this->impl_);
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
Topic<T, DELEGATE>::Topic(const dds::domain::DomainParticipant& dp,
|
||||
const std::string& topic_name,
|
||||
const std::string& type_name,
|
||||
const dds::topic::qos::TopicQos& qos,
|
||||
dds::topic::TopicListener<T>* listener,
|
||||
const dds::core::status::StatusMask& mask) :
|
||||
::dds::core::Reference< DELEGATE<T> >(new DELEGATE<T>(
|
||||
dp,
|
||||
topic_name,
|
||||
type_name,
|
||||
qos,
|
||||
listener,
|
||||
mask)),
|
||||
::dds::topic::TAnyTopic< DELEGATE<T> >(::dds::core::Reference< DELEGATE<T> >::delegate())
|
||||
{
|
||||
throw dds::core::UnsupportedError(std::string("Only Topics with default type_names are supported"));
|
||||
/* this->delegate()->init(this->impl_); */
|
||||
}
|
||||
|
||||
/** @internal @todo Relates to OMG_DDS_X_TYPE_DYNAMIC_TYPE_SUPPORT OSPL-1736 no implementation */
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
void Topic<T, DELEGATE>::listener(Listener* listener,
|
||||
const ::dds::core::status::StatusMask& event_mask)
|
||||
{
|
||||
this->delegate()->listener(listener, event_mask);
|
||||
}
|
||||
|
||||
/** @internal @todo Relates to OMG_DDS_X_TYPE_DYNAMIC_TYPE_SUPPORT OSPL-1736 no implementation */
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
typename Topic<T, DELEGATE>::Listener* Topic<T, DELEGATE>::listener() const
|
||||
{
|
||||
return this->delegate()->listener();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* dds/topic/detail/Topic<> DELEGATE implementation.
|
||||
* Declaration can be found in dds/topic/detail/Topic.hpp
|
||||
*
|
||||
* Implementation and declaration have been separated because some circular
|
||||
* dependencies, like with TopicListener and AnyTopic.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include <dds/topic/detail/Topic.hpp>
|
||||
#include <dds/topic/AnyTopic.hpp>
|
||||
#include <dds/topic/TopicListener.hpp>
|
||||
//#include <dds/domain/DomainParticipantListener.hpp>
|
||||
#include <org/eclipse/cyclonedds/core/ScopedLock.hpp>
|
||||
#include <org/eclipse/cyclonedds/core/ListenerDispatcher.hpp>
|
||||
|
||||
#include "dds/ddsi/ddsi_sertype.h"
|
||||
|
||||
template <typename T>
|
||||
dds::topic::detail::Topic<T>::Topic(const dds::domain::DomainParticipant& dp,
|
||||
const std::string& name,
|
||||
const std::string& type_name,
|
||||
const dds::topic::qos::TopicQos& qos,
|
||||
dds::topic::TopicListener<T>* listener,
|
||||
const dds::core::status::StatusMask& mask)
|
||||
: org::eclipse::cyclonedds::topic::TopicDescriptionDelegate(dp, name, type_name),
|
||||
org::eclipse::cyclonedds::topic::AnyTopicDelegate(qos, dp, name, type_name)
|
||||
{
|
||||
// Set the correct (IDL) type_name in the TopicDescription.
|
||||
org::eclipse::cyclonedds::topic::TopicDescriptionDelegate::myTypeName = org::eclipse::cyclonedds::topic::TopicTraits<T>::getTypeName();
|
||||
|
||||
// get and validate the ddsc qos
|
||||
org::eclipse::cyclonedds::topic::qos::TopicQosDelegate tQos = qos.delegate();
|
||||
tQos.check();
|
||||
dds_qos_t* ddsc_qos = tQos.ddsc_qos();
|
||||
dds_entity_t ddsc_par = dp.delegate()->get_ddsc_entity();
|
||||
|
||||
ser_type_ = org::eclipse::cyclonedds::topic::TopicTraits<T>::getSerType();
|
||||
|
||||
dds_entity_t ddsc_topic = dds_create_topic_sertype(
|
||||
ddsc_par, name.c_str(), &ser_type_, ddsc_qos, NULL, NULL);
|
||||
|
||||
dds_delete_qos(ddsc_qos);
|
||||
|
||||
if (ddsc_topic < 0) {
|
||||
ddsi_sertype_unref(ser_type_);
|
||||
ISOCPP_DDSC_RESULT_CHECK_AND_THROW(ddsc_topic, "Could not create topic.");
|
||||
}
|
||||
|
||||
this->set_ddsc_entity(ddsc_topic);
|
||||
|
||||
this->listener(listener, mask);
|
||||
|
||||
this->AnyTopicDelegate::set_sample(&this->sample_);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
dds::topic::detail::Topic<T>::Topic(const dds::domain::DomainParticipant& dp,
|
||||
const std::string& name,
|
||||
const std::string& type_name,
|
||||
const dds::topic::qos::TopicQos& qos,
|
||||
dds_entity_t ddsc_topic)
|
||||
: org::eclipse::cyclonedds::topic::TopicDescriptionDelegate(dp, name, type_name),
|
||||
org::eclipse::cyclonedds::topic::AnyTopicDelegate(qos, dp, name, type_name)
|
||||
{
|
||||
this->set_ddsc_entity(ddsc_topic);
|
||||
this->listener(NULL, dds::core::status::StatusMask::none());
|
||||
|
||||
this->AnyTopicDelegate::set_sample(&this->sample_);
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
dds::topic::detail::Topic<T>::~Topic<T>()
|
||||
{
|
||||
if (!closed) {
|
||||
try {
|
||||
close();
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
dds::topic::detail::Topic<T>::close()
|
||||
{
|
||||
org::eclipse::cyclonedds::core::ScopedObjectLock scopedLock(*this);
|
||||
|
||||
if (this->hasDependents()) {
|
||||
ISOCPP_THROW_EXCEPTION(ISOCPP_PRECONDITION_NOT_MET_ERROR, "Topic still has unclosed dependencies (e.g. Readers/Writers/ContentFilteredTopics)");
|
||||
}
|
||||
|
||||
this->listener_set(NULL, dds::core::status::StatusMask::none());
|
||||
|
||||
this->myParticipant.delegate()->remove_topic(*this);
|
||||
|
||||
org::eclipse::cyclonedds::core::EntityDelegate::close();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
dds::topic::detail::Topic<T>::init(ObjectDelegate::weak_ref_type weak_ref)
|
||||
{
|
||||
/* Set weak_ref before passing ourselves to other isocpp objects. */
|
||||
this->set_weak_ref(weak_ref);
|
||||
/* Add weak_ref to the map of entities */
|
||||
this->add_to_entity_map(weak_ref);
|
||||
/* Register topic at participant. */
|
||||
this->myParticipant.delegate()->add_topic(*this);
|
||||
|
||||
/* Enable when needed. */
|
||||
if (this->myParticipant.delegate()->is_auto_enable()) {
|
||||
this->enable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
dds::topic::detail::Topic<T>::listener(TopicListener<T>* listener,
|
||||
const ::dds::core::status::StatusMask& mask)
|
||||
{
|
||||
org::eclipse::cyclonedds::core::ScopedObjectLock scopedLock(*this);
|
||||
this->listener_set(listener, mask);
|
||||
scopedLock.unlock();
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
dds::topic::TopicListener<T>*
|
||||
dds::topic::detail::Topic<T>::listener()
|
||||
{
|
||||
this->check();
|
||||
return reinterpret_cast<dds::topic::TopicListener<T>*>(this->listener_get());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
dds::topic::Topic<T, dds::topic::detail::Topic>
|
||||
dds::topic::detail::Topic<T>::wrapper()
|
||||
{
|
||||
|
||||
typename Topic::ref_type ref =
|
||||
::std::dynamic_pointer_cast<Topic<T> >(this->get_strong_ref());
|
||||
dds::topic::Topic<T, dds::topic::detail::Topic> topic(ref);
|
||||
|
||||
return topic;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
dds::topic::detail::Topic<T>::listener_notify(
|
||||
ObjectDelegate::ref_type source,
|
||||
uint32_t triggerMask,
|
||||
void *eventData,
|
||||
void *l)
|
||||
{
|
||||
(void)source;
|
||||
(void)triggerMask;
|
||||
(void)eventData;
|
||||
(void)l;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
dds::topic::Topic<T, dds::topic::detail::Topic>
|
||||
dds::topic::detail::Topic<T>::discover_topic(
|
||||
const dds::domain::DomainParticipant& dp,
|
||||
const std::string& name,
|
||||
const dds::core::Duration& timeout)
|
||||
{
|
||||
dds::topic::Topic<T> found = dds::core::null;
|
||||
std::unique_ptr<dds_typeinfo_t, std::function<void(dds_typeinfo_t *)> >
|
||||
type_info(org::eclipse::cyclonedds::topic::TopicTraits<T>::getTypeInfo(nullptr),
|
||||
[](dds_typeinfo_t *ti) { static_cast<void>(dds_free_typeinfo(ti)); });
|
||||
dds_entity_t ddsc_topic = dp.delegate()->lookup_topic(name, type_info.get(), timeout);
|
||||
|
||||
if (ddsc_topic <= 0) {
|
||||
return dds::core::null;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Add type_name here when non-default ones are supported. */
|
||||
size_t slen = MAX_TOPIC_NAME_LEN;
|
||||
char *ddsc_type_name;
|
||||
ddsc_type_name = (char *)dds_alloc(slen);
|
||||
dds_get_type_name(ddsc_topic, ddsc_type_name, slen);
|
||||
std::string type_name = ddsc_type_name;
|
||||
dds_free(ddsc_type_name);
|
||||
#endif
|
||||
|
||||
dds_return_t ret;
|
||||
dds_qos_t* ddsc_qos = dds_create_qos();
|
||||
ret = dds_get_qos(ddsc_topic, ddsc_qos);
|
||||
dds::topic::qos::TopicQos qos;
|
||||
if (ret == DDS_RETCODE_OK) {
|
||||
qos.delegate().ddsc_qos(ddsc_qos);
|
||||
}
|
||||
dds_delete_qos(ddsc_qos);
|
||||
ISOCPP_DDSC_RESULT_CHECK_AND_THROW(ret, "Failed to get the qos from discovered topic");
|
||||
|
||||
/*
|
||||
* The found topic could be of the wrong type. This will be indicated
|
||||
* with a PreconditionNotMetError when we try to create it.
|
||||
*/
|
||||
try {
|
||||
found = dds::topic::Topic<T>(dp, name, qos);
|
||||
} catch (dds::core::PreconditionNotMetError&) {
|
||||
/* Ignore; just return dds::core::null */
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
dds::topic::detail::Topic<T>::discover_topics(
|
||||
const dds::domain::DomainParticipant& dp,
|
||||
std::vector<dds::topic::Topic<T, dds::topic::detail::Topic> >& topics,
|
||||
uint32_t max_size)
|
||||
{
|
||||
(void)dp;
|
||||
(void)topics;
|
||||
std::vector<dds_entity_t> ddsc_topics;
|
||||
topics.clear();
|
||||
/*
|
||||
* Unfortunately, DomainParticipantDelegate::lookup_topics() is not
|
||||
* supported yet and will throw an exception.
|
||||
*/
|
||||
dp.delegate()->lookup_topics(topic_type_name<T>::value(), ddsc_topics, max_size);
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void dds::topic::detail::Topic<T>::on_inconsistent_topic(
|
||||
dds_entity_t topic,
|
||||
org::eclipse::cyclonedds::core::InconsistentTopicStatusDelegate &sd )
|
||||
{
|
||||
dds::core::status::InconsistentTopicStatus s ;
|
||||
s.delegate() = sd ;
|
||||
(void)topic;
|
||||
dds::topic::Topic<T, dds::topic::detail::Topic> t = wrapper() ;
|
||||
|
||||
dds::topic::TopicListener<T> *l =
|
||||
reinterpret_cast<dds::topic::TopicListener<T> *>(this->listener_get());
|
||||
if( (l != NULL) &&
|
||||
(this->get_listener_mask().to_ulong() &
|
||||
dds::core::status::StatusMask::inconsistent_topic().to_ulong()) )
|
||||
{
|
||||
l->on_inconsistent_topic( t, s ) ;
|
||||
}
|
||||
}
|
||||
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_TOPIC_TTOPIC_HPP_ */
|
||||
131
unitree_SDK/include/ddscxx/dds/topic/detail/Topic.hpp
Normal file
131
unitree_SDK/include/ddscxx/dds/topic/detail/Topic.hpp
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright(c) 2006 to 2021 ZettaScale Technology and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef CYCLONEDDS_DDS_TOPIC_DETAIL_TOPIC_HPP_
|
||||
#define CYCLONEDDS_DDS_TOPIC_DETAIL_TOPIC_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
// Implementation
|
||||
|
||||
#include <dds/core/ref_traits.hpp>
|
||||
#include <dds/topic/TopicTraits.hpp>
|
||||
#include <dds/core/status/Status.hpp>
|
||||
#include <dds/core/status/State.hpp>
|
||||
#include <dds/domain/DomainParticipant.hpp>
|
||||
#include <dds/topic/qos/TopicQos.hpp>
|
||||
#include <dds/topic/AnyTopic.hpp>
|
||||
|
||||
#include <org/eclipse/cyclonedds/core/config.hpp>
|
||||
#include <org/eclipse/cyclonedds/topic/TopicTraits.hpp>
|
||||
#include <org/eclipse/cyclonedds/topic/AnyTopicDelegate.hpp>
|
||||
#include <org/eclipse/cyclonedds/topic/TopicDescriptionDelegate.hpp>
|
||||
|
||||
#include <dds/dds.h>
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace topic
|
||||
{
|
||||
template <typename T>
|
||||
class TopicListener;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace topic
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
class Topic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* dds/topic/detail/Topic<> DELEGATE declaration.
|
||||
* Implementation can be found in dds/topic/detail/TTopicImpl.hpp
|
||||
*
|
||||
***************************************************************************/
|
||||
template <typename T>
|
||||
class dds::topic::detail::Topic : public org::eclipse::cyclonedds::topic::AnyTopicDelegate
|
||||
{
|
||||
public:
|
||||
typedef typename ::dds::core::smart_ptr_traits< Topic<T> >::ref_type ref_type;
|
||||
typedef typename ::dds::core::smart_ptr_traits< Topic<T> >::weak_ref_type weak_ref_type;
|
||||
|
||||
Topic(const dds::domain::DomainParticipant& dp,
|
||||
const std::string& name,
|
||||
const std::string& type_name,
|
||||
const dds::topic::qos::TopicQos& qos,
|
||||
dds::topic::TopicListener<T>* listener,
|
||||
const dds::core::status::StatusMask& mask);
|
||||
|
||||
Topic(const dds::domain::DomainParticipant& dp,
|
||||
const std::string& name,
|
||||
const std::string& type_name,
|
||||
const dds::topic::qos::TopicQos& qos,
|
||||
dds_entity_t ddsc_topic);
|
||||
|
||||
virtual ~Topic();
|
||||
|
||||
virtual void close();
|
||||
|
||||
void init(ObjectDelegate::weak_ref_type weak_ref);
|
||||
|
||||
dds::topic::Topic<T, dds::topic::detail::Topic> wrapper();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
void listener(dds::topic::TopicListener<T>* listener,
|
||||
const ::dds::core::status::StatusMask& mask);
|
||||
|
||||
dds::topic::TopicListener<T>* listener();
|
||||
|
||||
virtual void listener_notify(ObjectDelegate::ref_type source,
|
||||
uint32_t triggerMask,
|
||||
void *eventData,
|
||||
void *listener);
|
||||
|
||||
dds::topic::TTopicDescription<TopicDescriptionDelegate> clone();
|
||||
|
||||
static dds::topic::Topic<T, dds::topic::detail::Topic>
|
||||
discover_topic(const dds::domain::DomainParticipant& dp,
|
||||
const std::string& name,
|
||||
const dds::core::Duration& timeout);
|
||||
|
||||
static void
|
||||
discover_topics(const dds::domain::DomainParticipant& dp,
|
||||
std::vector<dds::topic::Topic<T, dds::topic::detail::Topic> >& topics,
|
||||
uint32_t max_size);
|
||||
|
||||
//using ::org::eclipse::cyclonedds::topic::AnyTopicDelegate<T>::on_inconsistent_topic;
|
||||
|
||||
void on_inconsistent_topic(
|
||||
dds_entity_t topic,
|
||||
org::eclipse::cyclonedds::core::InconsistentTopicStatusDelegate &s ) ; // !!!
|
||||
|
||||
private:
|
||||
T sample_;
|
||||
};
|
||||
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_TOPIC_DETAIL_TOPIC_HPP_ */
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef CYCLONEDDS_DDS_TOPIC_DETAIL_TOPICDESCRIPTION_HPP_
|
||||
#define CYCLONEDDS_DDS_TOPIC_DETAIL_TOPICDESCRIPTION_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
// Implementation
|
||||
|
||||
#include <dds/topic/detail/TTopicDescriptionImpl.hpp>
|
||||
#include <org/eclipse/cyclonedds/topic/TopicDescriptionDelegate.hpp>
|
||||
|
||||
namespace dds { namespace topic { namespace detail {
|
||||
typedef dds::topic::TTopicDescription<org::eclipse::cyclonedds::topic::TopicDescriptionDelegate> TopicDescription;
|
||||
} } }
|
||||
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_TOPIC_DETAIL_TOPICDESCRIPTION_HPP_ */
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef CYCLONEDDS_DDS_TOPIC_TOPICINSTANCE_HPP_
|
||||
#define CYCLONEDDS_DDS_TOPIC_TOPICINSTANCE_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
#include <dds/topic/TopicInstance.hpp>
|
||||
|
||||
// Implementation
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace topic
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
TopicInstance<T>::TopicInstance() : h_(dds::core::null) {}
|
||||
|
||||
template <typename T>
|
||||
TopicInstance<T>::TopicInstance(const ::dds::core::InstanceHandle& h)
|
||||
: h_(h), sample_() {}
|
||||
|
||||
template <typename T>
|
||||
TopicInstance<T>::TopicInstance(const ::dds::core::InstanceHandle& h, const T& sample)
|
||||
: h_(h), sample_(sample) { }
|
||||
|
||||
template <typename T>
|
||||
TopicInstance<T>::operator const ::dds::core::InstanceHandle() const
|
||||
{
|
||||
return h_;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const ::dds::core::InstanceHandle TopicInstance<T>::handle() const
|
||||
{
|
||||
return h_;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TopicInstance<T>::handle(const ::dds::core::InstanceHandle& h)
|
||||
{
|
||||
h_ = h;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T& TopicInstance<T>::sample() const
|
||||
{
|
||||
return sample_;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T& TopicInstance<T>::sample()
|
||||
{
|
||||
return sample_;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TopicInstance<T>::sample(const T& sample)
|
||||
{
|
||||
sample_ = sample;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_TOPIC_TOPICINSTANCE_HPP_ */
|
||||
20
unitree_SDK/include/ddscxx/dds/topic/detail/ddstopic.hpp
Normal file
20
unitree_SDK/include/ddscxx/dds/topic/detail/ddstopic.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef OMG_DDS_TOPIC_PACKAGE_DETAIL_INCLUDE_HPP_
|
||||
#define OMG_DDS_TOPIC_PACKAGE_DETAIL_INCLUDE_HPP_
|
||||
|
||||
#include "dds/topic/detail/TTopicDescriptionImpl.hpp"
|
||||
#include "dds/topic/detail/TTopicImpl.hpp"
|
||||
#include "dds/topic/detail/TopicInstanceImpl.hpp"
|
||||
#include "dds/topic/detail/TContentFilteredTopicImpl.hpp"
|
||||
|
||||
#endif /* OMG_DDS_TOPIC_PACKAGE_DETAIL_INCLUDE_HPP_ */
|
||||
100
unitree_SDK/include/ddscxx/dds/topic/detail/discovery.hpp
Normal file
100
unitree_SDK/include/ddscxx/dds/topic/detail/discovery.hpp
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#ifndef CYCLONEDDS_DDS_TOPIC_DETAIL_DISCOVER_HPP_
|
||||
#define CYCLONEDDS_DDS_TOPIC_DETAIL_DISCOVER_HPP_
|
||||
|
||||
#include <dds/topic/AnyTopic.hpp>
|
||||
#include <dds/topic/Topic.hpp>
|
||||
#include <org/eclipse/cyclonedds/topic/discovery.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace topic
|
||||
{
|
||||
|
||||
template <typename TOPIC>
|
||||
TOPIC
|
||||
discover(
|
||||
const dds::domain::DomainParticipant& dp,
|
||||
const std::string& topic_name,
|
||||
const dds::core::Duration& timeout)
|
||||
{
|
||||
TOPIC t = org::eclipse::cyclonedds::topic::lookup_topic<TOPIC, typename TOPIC::DELEGATE_T>::discover(dp, topic_name, timeout);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
template <typename ANYTOPIC, typename FwdIterator>
|
||||
uint32_t
|
||||
discover(
|
||||
const dds::domain::DomainParticipant& dp,
|
||||
FwdIterator begin,
|
||||
uint32_t max_size)
|
||||
{
|
||||
std::vector<ANYTOPIC> list;
|
||||
|
||||
org::eclipse::cyclonedds::topic::lookup_topic<ANYTOPIC, typename ANYTOPIC::DELEGATE_T>::discover(dp, list, max_size);
|
||||
|
||||
FwdIterator fit = begin;
|
||||
for (typename std::vector<ANYTOPIC>::const_iterator it = list.begin(); it != list.end(); ++it) {
|
||||
*fit++ = *it;
|
||||
}
|
||||
|
||||
return static_cast<uint32_t>(list.size());
|
||||
}
|
||||
|
||||
template <typename ANYTOPIC, typename BinIterator>
|
||||
uint32_t
|
||||
discover_all(
|
||||
const dds::domain::DomainParticipant& dp,
|
||||
BinIterator begin)
|
||||
{
|
||||
std::vector<ANYTOPIC> list;
|
||||
|
||||
org::eclipse::cyclonedds::topic::lookup_topic<ANYTOPIC, typename ANYTOPIC::DELEGATE_T>::discover(dp, list, static_cast<uint32_t>(dds::core::LENGTH_UNLIMITED));
|
||||
|
||||
BinIterator bit = begin;
|
||||
for (typename std::vector<ANYTOPIC>::const_iterator it = list.begin(); it != list.end(); ++it) {
|
||||
*bit++ = *it;
|
||||
}
|
||||
|
||||
return list.size();
|
||||
}
|
||||
|
||||
|
||||
template <typename FwdIterator>
|
||||
void
|
||||
ignore(
|
||||
const dds::domain::DomainParticipant& dp,
|
||||
FwdIterator begin, FwdIterator end)
|
||||
{
|
||||
(void)dp;
|
||||
(void)begin;
|
||||
(void)end;
|
||||
ISOCPP_THROW_EXCEPTION(ISOCPP_UNSUPPORTED_ERROR, "Function not currently supported");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_TOPIC_DETAIL_DISCOVER_HPP_ */
|
||||
46
unitree_SDK/include/ddscxx/dds/topic/detail/find.hpp
Normal file
46
unitree_SDK/include/ddscxx/dds/topic/detail/find.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#ifndef CYCLONEDDS_DDS_TOPIC_DETAIL_FIND_HPP_
|
||||
#define CYCLONEDDS_DDS_TOPIC_DETAIL_FIND_HPP_
|
||||
|
||||
|
||||
#include <org/eclipse/cyclonedds/topic/find.hpp>
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace topic
|
||||
{
|
||||
|
||||
template <typename TOPIC>
|
||||
TOPIC
|
||||
find(const dds::domain::DomainParticipant& dp, const std::string& topic_name)
|
||||
{
|
||||
TOPIC t = org::eclipse::cyclonedds::topic::finder<TOPIC, typename TOPIC::DELEGATE_T>::find(dp, topic_name);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_TOPIC_DETAIL_FIND_HPP_ */
|
||||
Reference in New Issue
Block a user