init
This commit is contained in:
22
unitree_SDK/include/ddscxx/dds/sub/detail/AnyDataReader.hpp
Normal file
22
unitree_SDK/include/ddscxx/dds/sub/detail/AnyDataReader.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_ANYDATAREADER_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_DETAIL_ANYDATAREADER_HPP_
|
||||
|
||||
#include <dds/sub/detail/TAnyDataReaderImpl.hpp>
|
||||
#include <org/eclipse/cyclonedds/sub/AnyDataReaderDelegate.hpp>
|
||||
|
||||
namespace dds { namespace sub { namespace detail {
|
||||
typedef dds::sub::TAnyDataReader<org::eclipse::cyclonedds::sub::AnyDataReaderDelegate> AnyDataReader;
|
||||
} } }
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_ANYDATAREADER_HPP_ */
|
22
unitree_SDK/include/ddscxx/dds/sub/detail/CoherentAccess.hpp
Normal file
22
unitree_SDK/include/ddscxx/dds/sub/detail/CoherentAccess.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_COHERENT_ACCESS_HPP_
|
||||
#define OMG_DDS_SUB_DETAIL_COHERENT_ACCESS_HPP_
|
||||
|
||||
#include <dds/sub/detail/TCoherentAccessImpl.hpp>
|
||||
#include <org/eclipse/cyclonedds/sub/CoherentAccessDelegate.hpp>
|
||||
|
||||
namespace dds { namespace sub { namespace detail {
|
||||
typedef ::dds::sub::TCoherentAccess<org::eclipse::cyclonedds::sub::CoherentAccessDelegate> CoherentAccess;
|
||||
} } }
|
||||
|
||||
#endif /* OMG_DDS_SUB_DETAIL_COHERENT_ACCESS_HPP_ */
|
234
unitree_SDK/include/ddscxx/dds/sub/detail/DataReader.hpp
Normal file
234
unitree_SDK/include/ddscxx/dds/sub/detail/DataReader.hpp
Normal file
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_DATA_READER_HPP_
|
||||
#define OMG_DDS_SUB_DETAIL_DATA_READER_HPP_
|
||||
|
||||
#include <dds/topic/Topic.hpp>
|
||||
#include <dds/topic/TopicInstance.hpp>
|
||||
|
||||
#include <dds/core/status/Status.hpp>
|
||||
#include <dds/sub/status/detail/DataStateImpl.hpp>
|
||||
#include <dds/sub/detail/Manipulators.hpp>
|
||||
#include <dds/sub/LoanedSamples.hpp>
|
||||
#include <dds/sub/Subscriber.hpp>
|
||||
#include <dds/sub/Query.hpp>
|
||||
|
||||
#include <org/eclipse/cyclonedds/core/EntityDelegate.hpp>
|
||||
#include <org/eclipse/cyclonedds/sub/AnyDataReaderDelegate.hpp>
|
||||
|
||||
#include <org/eclipse/cyclonedds/core/ScopedLock.hpp>
|
||||
#include <org/eclipse/cyclonedds/ForwardDeclarations.hpp>
|
||||
|
||||
#include <dds/dds.h>
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* dds/sub/detail/DataReader<> DELEGATE declaration.
|
||||
* Implementation can be found in dds/sub/detail/TDataReaderImpl.hpp
|
||||
*
|
||||
***************************************************************************/
|
||||
template <typename T>
|
||||
class dds::sub::detail::DataReader : public ::org::eclipse::cyclonedds::sub::AnyDataReaderDelegate
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename ::dds::core::smart_ptr_traits< DataReader<T> >::ref_type ref_type;
|
||||
typedef typename ::dds::core::smart_ptr_traits< DataReader<T> >::weak_ref_type weak_ref_type;
|
||||
|
||||
DataReader(const dds::sub::Subscriber& sub,
|
||||
const dds::topic::Topic<T>& topic,
|
||||
const dds::sub::qos::DataReaderQos& qos,
|
||||
dds::sub::DataReaderListener<T>* listener = NULL,
|
||||
const dds::core::status::StatusMask& mask = ::dds::core::status::StatusMask::none());
|
||||
|
||||
DataReader(const dds::sub::Subscriber& sub,
|
||||
const dds::topic::ContentFilteredTopic<T, dds::topic::detail::ContentFilteredTopic>& topic,
|
||||
const dds::sub::qos::DataReaderQos& qos,
|
||||
dds::sub::DataReaderListener<T>* listener = NULL,
|
||||
const dds::core::status::StatusMask& mask = ::dds::core::status::StatusMask::none());
|
||||
|
||||
void common_constructor(dds::sub::DataReaderListener<T>* listener,
|
||||
const dds::core::status::StatusMask& mask);
|
||||
|
||||
virtual ~DataReader();
|
||||
|
||||
void copy_samples(
|
||||
dds::sub::detail::SamplesHolder& samples,
|
||||
void**& c_sample_pointers,
|
||||
dds_sample_info_t*& c_sample_infos,
|
||||
int num_read);
|
||||
|
||||
void init(ObjectDelegate::weak_ref_type weak_ref);
|
||||
|
||||
dds::sub::status::DataState default_filter_state();
|
||||
void default_filter_state(const dds::sub::status::DataState& state);
|
||||
|
||||
bool is_loan_supported();
|
||||
|
||||
dds::sub::LoanedSamples<org::eclipse::cyclonedds::topic::CDRBlob> read_cdr();
|
||||
dds::sub::LoanedSamples<org::eclipse::cyclonedds::topic::CDRBlob> take_cdr();
|
||||
|
||||
dds::sub::LoanedSamples<T> read();
|
||||
dds::sub::LoanedSamples<T> take();
|
||||
|
||||
template<typename SamplesFWIterator>
|
||||
uint32_t read(SamplesFWIterator samples, uint32_t max_samples);
|
||||
template<typename SamplesFWIterator>
|
||||
uint32_t take(SamplesFWIterator samples, uint32_t max_samples);
|
||||
|
||||
template<typename SamplesBIIterator>
|
||||
uint32_t read(SamplesBIIterator samples);
|
||||
template<typename SamplesBIIterator>
|
||||
uint32_t take(SamplesBIIterator samples);
|
||||
|
||||
dds::topic::TopicInstance<T> key_value(const dds::core::InstanceHandle& h);
|
||||
T& key_value(T& key, const dds::core::InstanceHandle& h);
|
||||
|
||||
const dds::core::InstanceHandle lookup_instance(const T& key) const;
|
||||
|
||||
virtual const dds::sub::Subscriber& subscriber() const;
|
||||
|
||||
void close();
|
||||
|
||||
dds::sub::DataReaderListener<T>* listener();
|
||||
void listener(dds::sub::DataReaderListener<T>* l,
|
||||
const dds::core::status::StatusMask& event_mask);
|
||||
|
||||
dds::sub::DataReader<T, dds::sub::detail::DataReader> wrapper();
|
||||
|
||||
void on_requested_deadline_missed(dds_entity_t,
|
||||
org::eclipse::cyclonedds::core::RequestedDeadlineMissedStatusDelegate &);
|
||||
|
||||
void on_requested_incompatible_qos(dds_entity_t,
|
||||
org::eclipse::cyclonedds::core::RequestedIncompatibleQosStatusDelegate &);
|
||||
|
||||
void on_sample_rejected(dds_entity_t,
|
||||
org::eclipse::cyclonedds::core::SampleRejectedStatusDelegate &);
|
||||
|
||||
void on_liveliness_changed(dds_entity_t,
|
||||
org::eclipse::cyclonedds::core::LivelinessChangedStatusDelegate &);
|
||||
|
||||
void on_data_available(dds_entity_t);
|
||||
|
||||
void on_subscription_matched(dds_entity_t,
|
||||
org::eclipse::cyclonedds::core::SubscriptionMatchedStatusDelegate &);
|
||||
|
||||
void on_sample_lost(dds_entity_t,
|
||||
org::eclipse::cyclonedds::core::SampleLostStatusDelegate &);
|
||||
|
||||
private:
|
||||
dds::sub::Subscriber sub_;
|
||||
dds::sub::status::DataState status_filter_;
|
||||
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
private:
|
||||
enum SelectMode {
|
||||
SELECT_MODE_READ,
|
||||
SELECT_MODE_READ_INSTANCE,
|
||||
SELECT_MODE_READ_NEXT_INSTANCE,
|
||||
SELECT_MODE_READ_WITH_CONDITION,
|
||||
SELECT_MODE_READ_INSTANCE_WITH_CONDITION,
|
||||
SELECT_MODE_READ_NEXT_INSTANCE_WITH_CONDITION
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
|
||||
class Selector
|
||||
{
|
||||
public:
|
||||
Selector(typename DataReader<T>::ref_type dr);
|
||||
|
||||
Selector& instance(const dds::core::InstanceHandle& h);
|
||||
Selector& next_instance(const dds::core::InstanceHandle& h);
|
||||
Selector& filter_state(const dds::sub::status::DataState& s);
|
||||
Selector& max_samples(uint32_t n);
|
||||
Selector& filter_content(const dds::sub::Query& query);
|
||||
|
||||
dds::sub::LoanedSamples<T> read();
|
||||
dds::sub::LoanedSamples<T> take();
|
||||
|
||||
// --- Forward Iterators: --- //
|
||||
template<typename SamplesFWIterator>
|
||||
uint32_t read(SamplesFWIterator sfit, uint32_t max_samples);
|
||||
template<typename SamplesFWIterator>
|
||||
uint32_t take(SamplesFWIterator sfit, uint32_t max_samples);
|
||||
|
||||
// --- Back-Inserting Iterators: --- //
|
||||
template<typename SamplesBIIterator>
|
||||
uint32_t read(SamplesBIIterator sbit);
|
||||
template<typename SamplesBIIterator>
|
||||
uint32_t take(SamplesBIIterator sbit);
|
||||
|
||||
SelectMode get_mode() const;
|
||||
|
||||
private:
|
||||
friend class DataReader;
|
||||
SelectMode mode;
|
||||
typename DataReader<T>::ref_type reader;
|
||||
dds::sub::status::DataState state_filter_;
|
||||
bool state_filter_is_set_;
|
||||
dds::core::InstanceHandle handle;
|
||||
uint32_t max_samples_;
|
||||
dds::sub::Query query_;
|
||||
};
|
||||
|
||||
|
||||
class ManipulatorSelector: public Selector
|
||||
{
|
||||
public:
|
||||
//ManipulatorSelector(DataReader<T>* dr);
|
||||
ManipulatorSelector(typename DataReader<T>::ref_type dr);
|
||||
|
||||
bool read_mode();
|
||||
void read_mode(bool b);
|
||||
|
||||
ManipulatorSelector&
|
||||
operator >>(dds::sub::LoanedSamples<T>& samples);
|
||||
|
||||
private:
|
||||
bool read_mode_;
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
// ==============================================================
|
||||
// == Selector Read/Take API
|
||||
|
||||
dds::sub::LoanedSamples<T> read(const Selector& selector);
|
||||
|
||||
dds::sub::LoanedSamples<T> take(const Selector& selector);
|
||||
|
||||
// --- Forward Iterators: --- //
|
||||
template<typename SamplesFWIterator>
|
||||
uint32_t read(SamplesFWIterator samples,
|
||||
uint32_t max_samples, const Selector& selector);
|
||||
|
||||
template<typename SamplesFWIterator>
|
||||
uint32_t take(SamplesFWIterator samples,
|
||||
uint32_t max_samples, const Selector& selector);
|
||||
|
||||
// --- Back-Inserting Iterators: --- //
|
||||
template<typename SamplesBIIterator>
|
||||
uint32_t read(SamplesBIIterator samples, const Selector& selector);
|
||||
|
||||
template<typename SamplesBIIterator>
|
||||
uint32_t take(SamplesBIIterator samples, const Selector& selector);
|
||||
|
||||
private:
|
||||
T typed_sample_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* OMG_TDDS_SUB_DETAIL_DATA_READER_HPP_ */
|
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_GENERATION_COUNT_HPP_
|
||||
#define OMG_DDS_SUB_DETAIL_GENERATION_COUNT_HPP_
|
||||
|
||||
#include <dds/sub/detail/TGenerationCountImpl.hpp>
|
||||
#include <org/eclipse/cyclonedds/sub/GenerationCountImpl.hpp>
|
||||
|
||||
namespace dds {
|
||||
namespace sub {
|
||||
namespace detail {
|
||||
typedef dds::sub::TGenerationCount< org::eclipse::cyclonedds::sub::GenerationCountImpl > GenerationCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* OMG_DDS_SUB_DETAIL_GENERATION_COUNT_HPP_ */
|
152
unitree_SDK/include/ddscxx/dds/sub/detail/LoanedSamples.hpp
Normal file
152
unitree_SDK/include/ddscxx/dds/sub/detail/LoanedSamples.hpp
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* 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 OMG_SUB_DETAIL_LOANED_SAMPLES_IMPL_HPP_
|
||||
#define OMG_SUB_DETAIL_LOANED_SAMPLES_IMPL_HPP_
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
class LoanedSamples
|
||||
{
|
||||
public:
|
||||
|
||||
typedef std::vector< dds::sub::SampleRef<T, dds::sub::detail::SampleRef> > LoanedSamplesContainer;
|
||||
typedef typename std::vector< dds::sub::SampleRef<T, dds::sub::detail::SampleRef> >::iterator iterator;
|
||||
typedef typename std::vector< dds::sub::SampleRef<T, dds::sub::detail::SampleRef> >::const_iterator const_iterator;
|
||||
|
||||
public:
|
||||
LoanedSamples() { }
|
||||
|
||||
~LoanedSamples()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
iterator mbegin()
|
||||
{
|
||||
return samples_.begin();
|
||||
}
|
||||
|
||||
const_iterator begin() const
|
||||
{
|
||||
return samples_.begin();
|
||||
}
|
||||
|
||||
const_iterator end() const
|
||||
{
|
||||
return samples_.end();
|
||||
}
|
||||
|
||||
uint32_t length() const
|
||||
{
|
||||
return static_cast<uint32_t>(samples_.size());
|
||||
}
|
||||
|
||||
void reserve(uint32_t s)
|
||||
{
|
||||
samples_.reserve(s);
|
||||
}
|
||||
|
||||
void resize(uint32_t s)
|
||||
{
|
||||
samples_.resize(s);
|
||||
}
|
||||
|
||||
dds::sub::SampleRef<T, dds::sub::detail::SampleRef>& operator[] (uint32_t i)
|
||||
{
|
||||
return this->samples_[i];
|
||||
}
|
||||
|
||||
dds::sub::SampleRef<T, dds::sub::detail::SampleRef> * get_buffer() {
|
||||
return this->samples_.data();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
LoanedSamplesContainer samples_;
|
||||
};
|
||||
|
||||
template <>
|
||||
class LoanedSamples<org::eclipse::cyclonedds::topic::CDRBlob>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef std::vector< dds::sub::Sample<org::eclipse::cyclonedds::topic::CDRBlob, dds::sub::detail::Sample> > LoanedSamplesContainer;
|
||||
typedef typename std::vector< dds::sub::Sample<org::eclipse::cyclonedds::topic::CDRBlob, dds::sub::detail::Sample> >::iterator iterator;
|
||||
typedef typename std::vector< dds::sub::Sample<org::eclipse::cyclonedds::topic::CDRBlob, dds::sub::detail::Sample> >::const_iterator const_iterator;
|
||||
|
||||
public:
|
||||
LoanedSamples() { }
|
||||
|
||||
~LoanedSamples()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
iterator mbegin()
|
||||
{
|
||||
return samples_.begin();
|
||||
}
|
||||
|
||||
const_iterator begin() const
|
||||
{
|
||||
return samples_.begin();
|
||||
}
|
||||
|
||||
const_iterator end() const
|
||||
{
|
||||
return samples_.end();
|
||||
}
|
||||
|
||||
uint32_t length() const
|
||||
{
|
||||
return static_cast<uint32_t>(samples_.size());
|
||||
}
|
||||
|
||||
void reserve(uint32_t s)
|
||||
{
|
||||
samples_.reserve(s);
|
||||
}
|
||||
|
||||
void resize(uint32_t s)
|
||||
{
|
||||
samples_.resize(s);
|
||||
}
|
||||
|
||||
dds::sub::Sample<org::eclipse::cyclonedds::topic::CDRBlob, dds::sub::detail::Sample>& operator[] (uint32_t i)
|
||||
{
|
||||
return this->samples_[i];
|
||||
}
|
||||
|
||||
dds::sub::Sample<org::eclipse::cyclonedds::topic::CDRBlob, dds::sub::detail::Sample> * get_buffer() {
|
||||
return this->samples_.data();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
LoanedSamplesContainer samples_;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* OMG_SUB_DETAIL_LOANED_SAMPLES_IMPL_HPP_ */
|
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_LOANED_SAMPLES_IMPL_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_DETAIL_LOANED_SAMPLES_IMPL_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
|
||||
// Implementation
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
LoanedSamples<T, DELEGATE>::LoanedSamples() : delegate_(new DELEGATE<T>()) { }
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
LoanedSamples<T, DELEGATE>::~LoanedSamples() { }
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
LoanedSamples<T, DELEGATE>::LoanedSamples(const LoanedSamples& other): delegate_(other.delegate_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
LoanedSamples<T, DELEGATE>::LoanedSamples(LoanedSamples&& other): delegate_(other.delegate_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
typename LoanedSamples<T, DELEGATE>::const_iterator LoanedSamples<T, DELEGATE>::begin() const
|
||||
{
|
||||
return delegate()->begin();
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
typename LoanedSamples<T, DELEGATE>::const_iterator LoanedSamples<T, DELEGATE>::end() const
|
||||
{
|
||||
return delegate()->end();
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
const typename LoanedSamples<T, DELEGATE>::DELEGATE_REF_T& LoanedSamples<T, DELEGATE>::delegate() const
|
||||
{
|
||||
return delegate_;
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
typename LoanedSamples<T, DELEGATE>::DELEGATE_REF_T& LoanedSamples<T, DELEGATE>::delegate()
|
||||
{
|
||||
return delegate_;
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
uint32_t LoanedSamples<T, DELEGATE>::length() const
|
||||
{
|
||||
return delegate_->length();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_LOANED_SAMPLES_IMPL_HPP_ */
|
125
unitree_SDK/include/ddscxx/dds/sub/detail/Manipulators.hpp
Normal file
125
unitree_SDK/include/ddscxx/dds/sub/detail/Manipulators.hpp
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_MANIPULATOR_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_DETAIL_MANIPULATOR_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <dds/sub/Query.hpp>
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
namespace functors
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class MaxSamplesManipulatorFunctor
|
||||
{
|
||||
public:
|
||||
MaxSamplesManipulatorFunctor(uint32_t n) :
|
||||
n_(n)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
void operator()(S& s)
|
||||
{
|
||||
s.max_samples(n_);
|
||||
}
|
||||
private:
|
||||
uint32_t n_;
|
||||
};
|
||||
|
||||
class ContentFilterManipulatorFunctor
|
||||
{
|
||||
public:
|
||||
ContentFilterManipulatorFunctor(const dds::sub::Query& q) :
|
||||
query_(q)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
void operator()(S& s)
|
||||
{
|
||||
s.content(query_);
|
||||
}
|
||||
private:
|
||||
const dds::sub::Query query_;
|
||||
};
|
||||
|
||||
class StateFilterManipulatorFunctor
|
||||
{
|
||||
public:
|
||||
StateFilterManipulatorFunctor(
|
||||
const dds::sub::status::DataState& s) :
|
||||
state_(s)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
void operator()(S& s)
|
||||
{
|
||||
s.state(state_);
|
||||
}
|
||||
private:
|
||||
dds::sub::status::DataState state_;
|
||||
};
|
||||
|
||||
class InstanceManipulatorFunctor
|
||||
{
|
||||
public:
|
||||
InstanceManipulatorFunctor(const dds::core::InstanceHandle& h) :
|
||||
handle_(h)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
void operator()(S& s)
|
||||
{
|
||||
s.instance(handle_);
|
||||
}
|
||||
private:
|
||||
dds::core::InstanceHandle handle_;
|
||||
};
|
||||
|
||||
class NextInstanceManipulatorFunctor
|
||||
{
|
||||
public:
|
||||
NextInstanceManipulatorFunctor(
|
||||
const dds::core::InstanceHandle& h) :
|
||||
handle_(h)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
void operator()(S& s)
|
||||
{
|
||||
s.next_instance(handle_);
|
||||
}
|
||||
private:
|
||||
dds::core::InstanceHandle handle_;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_MANIPULATOR_HPP_ */
|
32
unitree_SDK/include/ddscxx/dds/sub/detail/Query.hpp
Normal file
32
unitree_SDK/include/ddscxx/dds/sub/detail/Query.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_QUERY_HPP_
|
||||
#define DDS_SUB_DETAIL_QUERY_HPP_
|
||||
|
||||
#include <dds/sub/TQuery.hpp>
|
||||
#include <org/eclipse/cyclonedds/sub/QueryDelegate.hpp>
|
||||
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
typedef dds::sub::TQuery<org::eclipse::cyclonedds::sub::QueryDelegate> Query;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* DDS_SUB_DETAIL_QUERY_HPP_ */
|
22
unitree_SDK/include/ddscxx/dds/sub/detail/Rank.hpp
Normal file
22
unitree_SDK/include/ddscxx/dds/sub/detail/Rank.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_RANK_HPP
|
||||
#define OMG_DDS_SUB_DETAIL_RANK_HPP
|
||||
|
||||
#include <dds/sub/detail/TRankImpl.hpp>
|
||||
#include <org/eclipse/cyclonedds/sub/RankImpl.hpp>
|
||||
|
||||
namespace dds { namespace sub { namespace detail {
|
||||
typedef dds::sub::TRank< org::eclipse::cyclonedds::sub::RankImpl > Rank;
|
||||
} } }
|
||||
|
||||
#endif /* OMG_DDS_SUB_DETAIL_RANK_HPP */
|
123
unitree_SDK/include/ddscxx/dds/sub/detail/Sample.hpp
Normal file
123
unitree_SDK/include/ddscxx/dds/sub/detail/Sample.hpp
Normal file
@@ -0,0 +1,123 @@
|
||||
#ifndef OMG_DDS_PUB_DETAIL_SAMPLE_HPP_
|
||||
#define OMG_DDS_PUB_DETAIL_SAMPLE_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.
|
||||
*/
|
||||
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
class Sample;
|
||||
}}}
|
||||
|
||||
#include <dds/sub/SampleInfo.hpp>
|
||||
//#include <dds/sub/detail/TSampleImpl.hpp>
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
class Sample
|
||||
{
|
||||
public:
|
||||
Sample() { }
|
||||
|
||||
Sample(const T& d, const dds::sub::SampleInfo& i)
|
||||
{
|
||||
this->data_ = d;
|
||||
this->info_ = i;
|
||||
}
|
||||
|
||||
Sample(const Sample& other)
|
||||
{
|
||||
copy(other);
|
||||
}
|
||||
|
||||
Sample& operator=(const Sample& other)
|
||||
{
|
||||
return copy(other);
|
||||
}
|
||||
|
||||
Sample& copy(const Sample& other)
|
||||
{
|
||||
this->data_ = other.data_;
|
||||
this->info_ = other.info_;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
const T& data() const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
T& data()
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
void data(const T& d)
|
||||
{
|
||||
data_ = d;
|
||||
}
|
||||
|
||||
const dds::sub::SampleInfo& info() const
|
||||
{
|
||||
return info_;
|
||||
}
|
||||
|
||||
dds::sub::SampleInfo& info()
|
||||
{
|
||||
return info_;
|
||||
}
|
||||
|
||||
void info(const dds::sub::SampleInfo& i)
|
||||
{
|
||||
info_ = i;
|
||||
}
|
||||
|
||||
bool operator ==(const Sample& other) const
|
||||
{
|
||||
(void)other;
|
||||
return false;
|
||||
}
|
||||
|
||||
T* data_ptr()
|
||||
{
|
||||
return &this->data_;
|
||||
}
|
||||
|
||||
private:
|
||||
T data_;
|
||||
dds::sub::SampleInfo info_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* OMG_DDS_PUB_DETAIL_SAMPLE_HPP_ */
|
22
unitree_SDK/include/ddscxx/dds/sub/detail/SampleInfo.hpp
Normal file
22
unitree_SDK/include/ddscxx/dds/sub/detail/SampleInfo.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_SAMPLE_INFO_HPP_
|
||||
#define OMG_DDS_SUB_DETAIL_SAMPLE_INFO_HPP_
|
||||
|
||||
#include <dds/sub/detail/TSampleInfoImpl.hpp>
|
||||
#include <org/eclipse/cyclonedds/sub/SampleInfoImpl.hpp>
|
||||
|
||||
namespace dds { namespace sub { namespace detail {
|
||||
typedef dds::sub::TSampleInfo<org::eclipse::cyclonedds::sub::SampleInfoImpl> SampleInfo;
|
||||
} } }
|
||||
|
||||
#endif /* OMG_DDS_SUB_DETAIL_SAMPLE_INFO_HPP_ */
|
130
unitree_SDK/include/ddscxx/dds/sub/detail/SampleRef.hpp
Normal file
130
unitree_SDK/include/ddscxx/dds/sub/detail/SampleRef.hpp
Normal file
@@ -0,0 +1,130 @@
|
||||
#ifndef OMG_DDS_PUB_DETAIL_SAMPLEREF_HPP_
|
||||
#define OMG_DDS_PUB_DETAIL_SAMPLEREF_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.
|
||||
*/
|
||||
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
class SampleRef;
|
||||
}}}
|
||||
|
||||
#include <dds/sub/SampleInfo.hpp>
|
||||
#include <org/eclipse/cyclonedds/topic/datatopic.hpp>
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
class SampleRef
|
||||
{
|
||||
public:
|
||||
SampleRef()
|
||||
{
|
||||
this->data_ = nullptr;
|
||||
}
|
||||
|
||||
SampleRef(ddscxx_serdata<T>* d, const dds::sub::SampleInfo& i)
|
||||
{
|
||||
this->data_ = d;
|
||||
this->info_ = i;
|
||||
}
|
||||
|
||||
SampleRef(const SampleRef& other)
|
||||
{
|
||||
copy(other);
|
||||
}
|
||||
|
||||
virtual ~SampleRef()
|
||||
{
|
||||
if (data_ != nullptr) {
|
||||
ddsi_serdata_unref(reinterpret_cast<ddsi_serdata *>(data_));
|
||||
}
|
||||
}
|
||||
|
||||
SampleRef& operator=(const SampleRef& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
copy(other);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
const T& data() const
|
||||
{
|
||||
if (data_ == nullptr)
|
||||
{
|
||||
throw dds::core::Error("Data is Null");
|
||||
}
|
||||
return *data_->getT();
|
||||
}
|
||||
|
||||
const dds::sub::SampleInfo& info() const
|
||||
{
|
||||
return info_;
|
||||
}
|
||||
|
||||
dds::sub::SampleInfo& info()
|
||||
{
|
||||
return info_;
|
||||
}
|
||||
|
||||
bool operator ==(const SampleRef& other) const
|
||||
{
|
||||
(void)other;
|
||||
return false;
|
||||
}
|
||||
|
||||
ddscxx_serdata<T>* &data_ptr()
|
||||
{
|
||||
return this->data_;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
void copy(const SampleRef& other)
|
||||
{
|
||||
if (other.data_ == nullptr)
|
||||
{
|
||||
throw dds::core::Error("Other data is Null");
|
||||
}
|
||||
static_cast<void>(ddsi_serdata_ref(reinterpret_cast<ddsi_serdata* const>(other.data_)));
|
||||
this->data_ = other.data_;
|
||||
this->info_ = other.info_;
|
||||
}
|
||||
|
||||
ddscxx_serdata<T>* data_;
|
||||
dds::sub::SampleInfo info_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* OMG_DDS_PUB_DETAIL_SAMPLEREF_HPP_ */
|
373
unitree_SDK/include/ddscxx/dds/sub/detail/SamplesHolder.hpp
Normal file
373
unitree_SDK/include/ddscxx/dds/sub/detail/SamplesHolder.hpp
Normal file
@@ -0,0 +1,373 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_SAMPLES_HOLDER_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_DETAIL_SAMPLES_HOLDER_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <dds/sub/LoanedSamples.hpp>
|
||||
#include "org/eclipse/cyclonedds/sub/AnyDataReaderDelegate.hpp"
|
||||
#include "org/eclipse/cyclonedds/topic/datatopic.hpp"
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
class LoanedSamplesHolder : public SamplesHolder
|
||||
{
|
||||
public:
|
||||
LoanedSamplesHolder(dds::sub::LoanedSamples<T>& samples) : samples_(samples), index_(0)
|
||||
{
|
||||
}
|
||||
|
||||
void set_length(uint32_t len) {
|
||||
this->samples_.delegate()->resize(len);
|
||||
}
|
||||
|
||||
uint32_t get_length() const {
|
||||
return this->index_;
|
||||
}
|
||||
|
||||
SamplesHolder& operator++(int)
|
||||
{
|
||||
this->index_++;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void *data()
|
||||
{
|
||||
return (*this->samples_.delegate())[this->index_].delegate().data_ptr();
|
||||
}
|
||||
|
||||
detail::SampleInfo& info()
|
||||
{
|
||||
return (*this->samples_.delegate())[this->index_].delegate().info();
|
||||
}
|
||||
|
||||
void **cpp_sample_pointers(size_t length)
|
||||
{
|
||||
|
||||
return new void * [length];
|
||||
}
|
||||
|
||||
dds_sample_info_t *cpp_info_pointers(size_t length)
|
||||
{
|
||||
return new dds_sample_info_t[length];
|
||||
}
|
||||
|
||||
void set_sample_contents(void** c_sample_pointers, dds_sample_info_t *info)
|
||||
{
|
||||
uint32_t cpp_sample_size = this->samples_.delegate()->length();
|
||||
auto tmp_iterator = samples_.delegate()->mbegin();
|
||||
for (uint32_t i = 0; i < cpp_sample_size; ++i, ++tmp_iterator) {
|
||||
/* Transfer ownership for ddscxx_serdata from c_sample_pointers to SampleRef objects. */
|
||||
tmp_iterator->delegate().data_ptr() = static_cast<ddscxx_serdata<T>*>(c_sample_pointers[i]);
|
||||
org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::copy_sample_infos(info[i], tmp_iterator->delegate().info());
|
||||
}
|
||||
}
|
||||
|
||||
void fini_samples_buffers(void**& c_sample_pointers, dds_sample_info_t*& c_sample_infos)
|
||||
{
|
||||
delete [] c_sample_pointers;
|
||||
delete [] c_sample_infos;
|
||||
}
|
||||
|
||||
private:
|
||||
dds::sub::LoanedSamples<T>& samples_;
|
||||
uint32_t index_;
|
||||
};
|
||||
|
||||
class CDRSamplesHolder : public SamplesHolder
|
||||
{
|
||||
public:
|
||||
CDRSamplesHolder(dds::sub::LoanedSamples<org::eclipse::cyclonedds::topic::CDRBlob>& samples) : samples_(samples), index_(0)
|
||||
{
|
||||
}
|
||||
|
||||
void set_length(uint32_t len) {
|
||||
this->samples_.delegate()->resize(len);
|
||||
}
|
||||
|
||||
uint32_t get_length() const {
|
||||
return this->index_;
|
||||
}
|
||||
|
||||
SamplesHolder& operator++(int)
|
||||
{
|
||||
this->index_++;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void *data()
|
||||
{
|
||||
return (*this->samples_.delegate())[this->index_].delegate().data_ptr();
|
||||
}
|
||||
|
||||
detail::SampleInfo& info()
|
||||
{
|
||||
return (*this->samples_.delegate())[this->index_].delegate().info();
|
||||
}
|
||||
|
||||
void **cpp_sample_pointers(size_t length)
|
||||
{
|
||||
return new void * [length];
|
||||
}
|
||||
|
||||
dds_sample_info_t *cpp_info_pointers(size_t length)
|
||||
{
|
||||
return new dds_sample_info_t[length];
|
||||
}
|
||||
|
||||
void set_sample_contents(void** c_sample_pointers, dds_sample_info_t *info)
|
||||
{
|
||||
struct ddsi_serdata **cdr_blobs = reinterpret_cast<struct ddsi_serdata **>(c_sample_pointers);
|
||||
const uint32_t cpp_sample_size = this->samples_.delegate()->length();
|
||||
for (uint32_t i = 0; i < cpp_sample_size; ++i)
|
||||
{
|
||||
struct ddsi_serdata * current_blob = cdr_blobs[i];
|
||||
org::eclipse::cyclonedds::topic::CDRBlob &sample_data = (*this->samples_.delegate())[i].delegate().data();
|
||||
// update the data kind
|
||||
sample_data.kind(static_cast<org::eclipse::cyclonedds::topic::BlobKind>(current_blob->kind));
|
||||
|
||||
// if data is transferred using SHM, update the CDRBlob with iox_chunk
|
||||
if(!update_cdrblob_from_iox_chunk(*current_blob, sample_data)) {
|
||||
ddsrt_iovec_t blob_content;
|
||||
ddsi_serdata_to_ser_ref(current_blob, 0, ddsi_serdata_size(current_blob), &blob_content);
|
||||
copy_buffer_to_cdr_blob(reinterpret_cast<uint8_t *>(blob_content.iov_base),
|
||||
blob_content.iov_len, sample_data.kind(), sample_data);
|
||||
ddsi_serdata_to_ser_unref(current_blob, &blob_content);
|
||||
ddsi_serdata_unref(current_blob);
|
||||
}
|
||||
// copy sample infos
|
||||
org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::copy_sample_infos(info[i], (*samples_.delegate())[i].delegate().info());
|
||||
}
|
||||
}
|
||||
|
||||
void fini_samples_buffers(void**& c_sample_pointers, dds_sample_info_t*& c_sample_infos)
|
||||
{
|
||||
delete [] c_sample_pointers;
|
||||
delete [] c_sample_infos;
|
||||
}
|
||||
|
||||
private:
|
||||
dds::sub::LoanedSamples<org::eclipse::cyclonedds::topic::CDRBlob>& samples_;
|
||||
uint32_t index_;
|
||||
|
||||
void copy_buffer_to_cdr_blob(const uint8_t * buffer, const size_t size,
|
||||
const org::eclipse::cyclonedds::topic::BlobKind data_kind,
|
||||
org::eclipse::cyclonedds::topic::CDRBlob & cdr_blob) const
|
||||
{
|
||||
// update the CDR header
|
||||
memcpy(cdr_blob.encoding().data(), buffer, CDR_HEADER_SIZE);
|
||||
// if the data kind is not empty
|
||||
if (data_kind != org::eclipse::cyclonedds::topic::BlobKind::Empty) {
|
||||
// get the actual data from the buffer
|
||||
cdr_blob.payload().assign(buffer + CDR_HEADER_SIZE, buffer + size);
|
||||
}
|
||||
}
|
||||
|
||||
bool update_cdrblob_from_iox_chunk (ddsi_serdata & current_blob,
|
||||
org::eclipse::cyclonedds::topic::CDRBlob &sample_data) {
|
||||
#ifdef DDSCXX_HAS_SHM
|
||||
// if the data is available on SHM
|
||||
if (current_blob.iox_chunk && current_blob.iox_subscriber) {
|
||||
// get the user iox header
|
||||
auto iox_header = iceoryx_header_from_chunk(current_blob.iox_chunk);
|
||||
// if the iox chunk has the data in serialized form
|
||||
if (iox_header->shm_data_state == IOX_CHUNK_CONTAINS_SERIALIZED_DATA) {
|
||||
copy_buffer_to_cdr_blob(reinterpret_cast<uint8_t *>(current_blob.iox_chunk),
|
||||
iox_header->data_size, sample_data.kind(), sample_data);
|
||||
} else if (iox_header->shm_data_state == IOX_CHUNK_CONTAINS_RAW_DATA) {
|
||||
// serialize the data
|
||||
auto serialized_size = ddsi_sertype_get_serialized_size(current_blob.type,
|
||||
current_blob.iox_chunk);
|
||||
// create a buffer to serialize
|
||||
std::vector<uint8_t> buffer(serialized_size);
|
||||
// serialize into the buffer
|
||||
ddsi_sertype_serialize_into(current_blob.type, current_blob.iox_chunk, buffer.data(),
|
||||
serialized_size);
|
||||
// update the CDR blob with the serialized data
|
||||
copy_buffer_to_cdr_blob(buffer.data(), serialized_size, sample_data.kind(), sample_data);
|
||||
} else {
|
||||
// this shouldn't never happen
|
||||
ISOCPP_THROW_EXCEPTION(ISOCPP_PRECONDITION_NOT_MET_ERROR,
|
||||
"The received sample over SHM is not initialized");
|
||||
}
|
||||
// release the chunk
|
||||
free_iox_chunk(static_cast<iox_sub_t *>(current_blob.iox_subscriber), ¤t_blob.iox_chunk);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
(void) current_blob;
|
||||
(void) sample_data;
|
||||
return false;
|
||||
#endif // DDSCXX_HAS_SHM
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename SamplesFWIterator>
|
||||
class SamplesFWInteratorHolder : public SamplesHolder
|
||||
{
|
||||
public:
|
||||
SamplesFWInteratorHolder(SamplesFWIterator& it) : iterator(it), size(0)
|
||||
{
|
||||
}
|
||||
|
||||
void set_length(uint32_t len) {
|
||||
this->size = len;
|
||||
|
||||
}
|
||||
|
||||
uint32_t get_length() const {
|
||||
return this->size;
|
||||
}
|
||||
|
||||
SamplesHolder& operator++(int)
|
||||
{
|
||||
++this->iterator;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void *data()
|
||||
{
|
||||
return (*iterator).delegate().data_ptr();
|
||||
}
|
||||
|
||||
detail::SampleInfo& info()
|
||||
{
|
||||
return (*iterator).delegate().info();
|
||||
}
|
||||
|
||||
void **cpp_sample_pointers(size_t length)
|
||||
{
|
||||
void **c_sample_pointers = new void * [length];
|
||||
SamplesFWIterator tmp_iterator = iterator;
|
||||
for (uint32_t i = 0; i < length; ++i, ++tmp_iterator) {
|
||||
c_sample_pointers[i] = (*tmp_iterator).delegate().data_ptr();
|
||||
}
|
||||
return c_sample_pointers;
|
||||
}
|
||||
|
||||
dds_sample_info_t *cpp_info_pointers(size_t length)
|
||||
{
|
||||
return new dds_sample_info_t[length];
|
||||
}
|
||||
|
||||
void set_sample_contents(void**, dds_sample_info_t *info)
|
||||
{
|
||||
/* Samples have already been deserialized in their containers during the read/take call. */
|
||||
SamplesFWIterator tmp_iterator = iterator;
|
||||
for (uint32_t i = 0; i < size; ++i, ++tmp_iterator) {
|
||||
org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::copy_sample_infos(info[i], tmp_iterator->delegate().info());
|
||||
}
|
||||
}
|
||||
|
||||
void fini_samples_buffers(void**& c_sample_pointers, dds_sample_info_t*& c_sample_infos)
|
||||
{
|
||||
delete [] c_sample_infos;
|
||||
delete [] c_sample_pointers;
|
||||
}
|
||||
|
||||
private:
|
||||
SamplesFWIterator& iterator;
|
||||
uint32_t size;
|
||||
|
||||
};
|
||||
|
||||
template <typename T, typename SamplesBIIterator>
|
||||
class SamplesBIIteratorHolder : public SamplesHolder
|
||||
{
|
||||
public:
|
||||
SamplesBIIteratorHolder(SamplesBIIterator& it) : iterator(it), size(0)
|
||||
{
|
||||
}
|
||||
|
||||
void set_length(uint32_t len) {
|
||||
this->size = len;
|
||||
samples.resize(len);
|
||||
}
|
||||
|
||||
uint32_t get_length() const {
|
||||
return this->size;
|
||||
}
|
||||
|
||||
SamplesHolder& operator++(int)
|
||||
{
|
||||
++this->iterator;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void *data()
|
||||
{
|
||||
return this->samples[0].delegate().data_ptr();
|
||||
}
|
||||
|
||||
detail::SampleInfo& info()
|
||||
{
|
||||
return this->samples[0].delegate().info();
|
||||
}
|
||||
|
||||
void **cpp_sample_pointers(size_t length)
|
||||
{
|
||||
set_length(static_cast<uint32_t>(length));
|
||||
void **c_sample_pointers = new void*[length];
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
c_sample_pointers[i] = samples[i].delegate().data_ptr();
|
||||
}
|
||||
return c_sample_pointers;
|
||||
}
|
||||
|
||||
dds_sample_info_t *cpp_info_pointers(size_t length)
|
||||
{
|
||||
dds_sample_info_t *c_info_pointers = new dds_sample_info_t[length];
|
||||
return c_info_pointers;
|
||||
}
|
||||
|
||||
void set_sample_contents(void**, dds_sample_info_t *info)
|
||||
{
|
||||
/* Samples have already been deserialized in their containers during the read/take call. */
|
||||
for (uint32_t i = 0; i < size; ++i) {
|
||||
org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::copy_sample_infos(info[i], samples[i].delegate().info());
|
||||
this->iterator = std::move(samples[i]);
|
||||
this->iterator++;
|
||||
}
|
||||
}
|
||||
|
||||
void fini_samples_buffers(void**& c_sample_pointers, dds_sample_info_t*& c_sample_infos)
|
||||
{
|
||||
delete [] c_sample_infos;
|
||||
delete [] c_sample_pointers;
|
||||
}
|
||||
|
||||
private:
|
||||
SamplesBIIterator& iterator;
|
||||
std::vector< dds::sub::Sample<T, dds::sub::detail::Sample> > samples;
|
||||
uint32_t size;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_SAMPLES_HOLDER_HPP_ */
|
86
unitree_SDK/include/ddscxx/dds/sub/detail/SharedSamples.hpp
Normal file
86
unitree_SDK/include/ddscxx/dds/sub/detail/SharedSamples.hpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_SHARED_SAMPLES_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_DETAIL_SHARED_SAMPLES_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <dds/sub/LoanedSamples.hpp>
|
||||
|
||||
// Implementation
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
class SharedSamples
|
||||
{
|
||||
public:
|
||||
typedef typename std::vector< dds::sub::Sample<T, Sample> >::iterator iterator;
|
||||
typedef typename std::vector< dds::sub::Sample<T, Sample> >::const_iterator const_iterator;
|
||||
|
||||
public:
|
||||
SharedSamples() { }
|
||||
|
||||
SharedSamples(dds::sub::LoanedSamples<T> ls) : samples_(ls) { }
|
||||
|
||||
~SharedSamples()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
iterator mbegin()
|
||||
{
|
||||
return samples_->begin();
|
||||
}
|
||||
|
||||
const_iterator begin() const
|
||||
{
|
||||
return samples_.begin();
|
||||
}
|
||||
|
||||
const_iterator end() const
|
||||
{
|
||||
return samples_.end();
|
||||
}
|
||||
|
||||
uint32_t length() const
|
||||
{
|
||||
/** @internal @todo Possible RTF size issue ? */
|
||||
return static_cast<uint32_t>(samples_.length());
|
||||
}
|
||||
|
||||
void resize(uint32_t s)
|
||||
{
|
||||
samples_.resize(s);
|
||||
}
|
||||
|
||||
private:
|
||||
dds::sub::LoanedSamples<T> samples_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_SHARED_SAMPLES_HPP_ */
|
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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_SUB_SHARED_SAMPLES_IMPL_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_SHARED_SAMPLES_IMPL_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
|
||||
// Implementation
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
SharedSamples<T, DELEGATE>::SharedSamples() : delegate_(new DELEGATE<T>()) { }
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
SharedSamples<T, DELEGATE>::SharedSamples(dds::sub::LoanedSamples<T> ls) : delegate_(new DELEGATE<T>(ls)) { }
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
SharedSamples<T, DELEGATE>::~SharedSamples() { }
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
SharedSamples<T, DELEGATE>::SharedSamples(const SharedSamples& other)
|
||||
{
|
||||
delegate_ = other.delegate_;
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
typename SharedSamples<T, DELEGATE>::const_iterator SharedSamples<T, DELEGATE>::begin() const
|
||||
{
|
||||
return delegate()->begin();
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
typename SharedSamples<T, DELEGATE>::const_iterator SharedSamples<T, DELEGATE>::end() const
|
||||
{
|
||||
return delegate()->end();
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
const typename SharedSamples<T, DELEGATE>::DELEGATE_REF_T& SharedSamples<T, DELEGATE>::delegate() const
|
||||
{
|
||||
return delegate_;
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
typename SharedSamples<T, DELEGATE>::DELEGATE_REF_T& SharedSamples<T, DELEGATE>::delegate()
|
||||
{
|
||||
return delegate_;
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
uint32_t SharedSamples<T, DELEGATE>::length() const
|
||||
{
|
||||
return delegate_->length();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_SUB_SHARED_SAMPLES_IMPL_HPP_ */
|
29
unitree_SDK/include/ddscxx/dds/sub/detail/Subscriber.hpp
Normal file
29
unitree_SDK/include/ddscxx/dds/sub/detail/Subscriber.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef OMG_DDS_SUB_DETAIL_SUBSCRIBER_HPP_
|
||||
#define OMG_DDS_SUB_DETAIL_SUBSCRIBER_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/sub/detail/TSubscriberImpl.hpp>
|
||||
#include <org/eclipse/cyclonedds/sub/SubscriberDelegate.hpp>
|
||||
|
||||
namespace dds { namespace sub { namespace detail {
|
||||
typedef dds::sub::TSubscriber<org::eclipse::cyclonedds::sub::SubscriberDelegate> Subscriber;
|
||||
} } }
|
||||
|
||||
#endif /* OMG_DDS_SUB_DETAIL_SUBSCRIBER_HPP_ */
|
132
unitree_SDK/include/ddscxx/dds/sub/detail/TAnyDataReaderImpl.hpp
Normal file
132
unitree_SDK/include/ddscxx/dds/sub/detail/TAnyDataReaderImpl.hpp
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* 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 OMG_DDS_SUB_DETAIL_TANYDATAREADER_HPP_
|
||||
#define OMG_DDS_SUB_DETAIL_TANYDATAREADER_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
|
||||
#include <dds/sub/TAnyDataReader.hpp>
|
||||
#include <dds/topic/TopicDescription.hpp>
|
||||
|
||||
// Implementation
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
|
||||
template <typename DELEGATE>
|
||||
const dds::sub::Subscriber&
|
||||
TAnyDataReader<DELEGATE>::subscriber() const
|
||||
{
|
||||
return this->delegate()->subscriber();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
const dds::topic::TopicDescription&
|
||||
TAnyDataReader<DELEGATE>::topic_description() const
|
||||
{
|
||||
return this->delegate()->topic_description();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
void
|
||||
TAnyDataReader<DELEGATE>::wait_for_historical_data(const dds::core::Duration& timeout)
|
||||
{
|
||||
this->delegate()->wait_for_historical_data(timeout);
|
||||
}
|
||||
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::sub::qos::DataReaderQos
|
||||
TAnyDataReader<DELEGATE>::qos() const
|
||||
{
|
||||
return this->delegate()->qos();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
void
|
||||
TAnyDataReader<DELEGATE>::qos(const dds::sub::qos::DataReaderQos& qos)
|
||||
{
|
||||
this->delegate()->qos(qos);
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
TAnyDataReader<DELEGATE>&
|
||||
TAnyDataReader<DELEGATE>::operator << (const dds::sub::qos::DataReaderQos& qos)
|
||||
{
|
||||
this->delegate()->qos(qos);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
const TAnyDataReader<DELEGATE>&
|
||||
TAnyDataReader<DELEGATE>::operator >> (dds::sub::qos::DataReaderQos& qos) const
|
||||
{
|
||||
qos = this->delegate()->qos();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::core::status::LivelinessChangedStatus
|
||||
TAnyDataReader<DELEGATE>::liveliness_changed_status()
|
||||
{
|
||||
return this->delegate()->liveliness_changed_status();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::core::status::SampleRejectedStatus
|
||||
TAnyDataReader<DELEGATE>::sample_rejected_status()
|
||||
{
|
||||
return this->delegate()->sample_rejected_status();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::core::status::SampleLostStatus
|
||||
TAnyDataReader<DELEGATE>::sample_lost_status()
|
||||
{
|
||||
return this->delegate()->sample_lost_status();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::core::status::RequestedDeadlineMissedStatus
|
||||
TAnyDataReader<DELEGATE>::requested_deadline_missed_status()
|
||||
{
|
||||
return this->delegate()->requested_deadline_missed_status();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::core::status::RequestedIncompatibleQosStatus
|
||||
TAnyDataReader<DELEGATE>::requested_incompatible_qos_status()
|
||||
{
|
||||
return this->delegate()->requested_incompatible_qos_status();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::core::status::SubscriptionMatchedStatus
|
||||
TAnyDataReader<DELEGATE>::subscription_matched_status()
|
||||
{
|
||||
return this->delegate()->subscription_matched_status();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// End of implementation
|
||||
|
||||
#endif /* OMG_DDS_SUB_DETAIL_TANYDATAREADER_HPP_ */
|
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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_SUB_TCOHERENTACCESS_IMPL_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_TCOHERENTACCESS_IMPL_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
#include <dds/sub/TCoherentAccess.hpp>
|
||||
|
||||
// Implementation
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
|
||||
template <typename DELEGATE>
|
||||
TCoherentAccess<DELEGATE>::TCoherentAccess(const dds::sub::Subscriber& sub) : dds::core::Value<DELEGATE>(sub) { }
|
||||
|
||||
template <typename DELEGATE>
|
||||
void TCoherentAccess<DELEGATE>::end()
|
||||
{
|
||||
this->delegate().end();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
TCoherentAccess<DELEGATE>::~TCoherentAccess()
|
||||
{
|
||||
this->delegate().end();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_SUB_TCOHERENTACCESS_IMPL_HPP_ */
|
1444
unitree_SDK/include/ddscxx/dds/sub/detail/TDataReaderImpl.hpp
Normal file
1444
unitree_SDK/include/ddscxx/dds/sub/detail/TDataReaderImpl.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_TGENERATIONCOUNT_IMPL_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_DETAIL_TGENERATIONCOUNT_IMPL_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
#include <dds/sub/TGenerationCount.hpp>
|
||||
|
||||
// Implementation
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
|
||||
template <typename DELEGATE>
|
||||
TGenerationCount<DELEGATE>::TGenerationCount() { }
|
||||
|
||||
template <typename DELEGATE>
|
||||
TGenerationCount<DELEGATE>::TGenerationCount(int32_t dgc, int32_t nwgc)
|
||||
: dds::core::Value<DELEGATE>(dgc, nwgc) { }
|
||||
|
||||
template <typename DELEGATE>
|
||||
int32_t TGenerationCount<DELEGATE>::disposed() const
|
||||
{
|
||||
return this->delegate().disposed();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
inline int32_t TGenerationCount<DELEGATE>::no_writers() const
|
||||
{
|
||||
return this->delegate().no_writers();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_TGENERATIONCOUNT_IMPL_HPP_ */
|
136
unitree_SDK/include/ddscxx/dds/sub/detail/TQueryImpl.hpp
Normal file
136
unitree_SDK/include/ddscxx/dds/sub/detail/TQueryImpl.hpp
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_QUERY_IMPL_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_DETAIL_QUERY_IMPL_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
// Implementation
|
||||
#include <dds/sub/TQuery.hpp>
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::sub::TQuery<DELEGATE>::TQuery(
|
||||
const dds::sub::AnyDataReader& dr,
|
||||
const std::string& expression) :
|
||||
dds::core::Reference<DELEGATE>(new DELEGATE(AnyDataReader(dr), expression))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
template<typename FWIterator>
|
||||
dds::sub::TQuery<DELEGATE>::TQuery(
|
||||
const dds::sub::AnyDataReader& dr,
|
||||
const std::string& expression,
|
||||
const FWIterator& params_begin,
|
||||
const FWIterator& params_end) :
|
||||
dds::core::Reference<DELEGATE>(new DELEGATE(AnyDataReader(dr), expression))
|
||||
{
|
||||
for (FWIterator it = params_begin; it != params_end; ++it) {
|
||||
add_parameter(*it);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::sub::TQuery<DELEGATE>::TQuery(
|
||||
const dds::sub::AnyDataReader& dr,
|
||||
const std::string& expression,
|
||||
const std::vector<std::string>& params) :
|
||||
dds::core::Reference<DELEGATE>(new DELEGATE(AnyDataReader(dr), expression, params))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
const std::string& dds::sub::TQuery<DELEGATE>::expression() const
|
||||
{
|
||||
return this->delegate()->expression();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
void dds::sub::TQuery<DELEGATE>::expression(const std::string& expr)
|
||||
{
|
||||
this->delegate()->expression(expr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the begin iterator to the parameter list.
|
||||
*/
|
||||
template <typename DELEGATE>
|
||||
typename dds::sub::TQuery<DELEGATE>::const_iterator dds::sub::TQuery<DELEGATE>::begin() const
|
||||
{
|
||||
return this->delegate()->begin();
|
||||
}
|
||||
|
||||
/**
|
||||
* The end iterator to the parameter list.
|
||||
*/
|
||||
template <typename DELEGATE>
|
||||
typename dds::sub::TQuery<DELEGATE>::const_iterator dds::sub::TQuery<DELEGATE>::end() const
|
||||
{
|
||||
return this->delegate()->end();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the begin iterator to the parameter list.
|
||||
*/
|
||||
template <typename DELEGATE>
|
||||
typename dds::sub::TQuery<DELEGATE>::iterator dds::sub::TQuery<DELEGATE>::begin()
|
||||
{
|
||||
return this->delegate()->begin();
|
||||
}
|
||||
|
||||
/**
|
||||
* The end iterator to the parameter list.
|
||||
*/
|
||||
template <typename DELEGATE>
|
||||
typename dds::sub::TQuery<DELEGATE>::iterator dds::sub::TQuery<DELEGATE>::end()
|
||||
{
|
||||
return this->delegate()->end();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
template<typename FWIterator>
|
||||
void dds::sub::TQuery<DELEGATE>::parameters(
|
||||
const FWIterator& begin,
|
||||
const FWIterator end)
|
||||
{
|
||||
for (FWIterator it = begin; it != end; ++it) {
|
||||
add_parameter(*it);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
void dds::sub::TQuery<DELEGATE>::add_parameter(
|
||||
const std::string& param)
|
||||
{
|
||||
this->delegate()->add_parameter(param);
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
uint32_t dds::sub::TQuery<DELEGATE>::parameters_length() const
|
||||
{
|
||||
return this->delegate()->parameters_length();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
const dds::sub::AnyDataReader&
|
||||
dds::sub::TQuery<DELEGATE>::data_reader() const
|
||||
{
|
||||
return this->delegate()->data_reader();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_QUERY_IMPL_HPP_ */
|
59
unitree_SDK/include/ddscxx/dds/sub/detail/TRankImpl.hpp
Normal file
59
unitree_SDK/include/ddscxx/dds/sub/detail/TRankImpl.hpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_TRANK_IMPL_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_DETAIL_TRANK_IMPL_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
#include <dds/sub/TRank.hpp>
|
||||
|
||||
// Implementation
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
|
||||
template <typename DELEGATE>
|
||||
TRank<DELEGATE>::TRank() { }
|
||||
|
||||
template <typename DELEGATE>
|
||||
TRank<DELEGATE>::TRank(int32_t s, int32_t a, int32_t ag)
|
||||
: dds::core::Value<DELEGATE>(s, a, ag) { }
|
||||
|
||||
template <typename DELEGATE>
|
||||
int32_t TRank<DELEGATE>::absolute_generation() const
|
||||
{
|
||||
return this->delegate().absolute_generation();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
inline int32_t TRank<DELEGATE>::generation() const
|
||||
{
|
||||
return this->delegate().generation();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
inline int32_t TRank<DELEGATE>::sample() const
|
||||
{
|
||||
return this->delegate().sample();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_TRANK_IMPL_HPP_ */
|
66
unitree_SDK/include/ddscxx/dds/sub/detail/TSampleImpl.hpp
Normal file
66
unitree_SDK/include/ddscxx/dds/sub/detail/TSampleImpl.hpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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_SUB_TSAMPLE_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_TSAMPLE_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
#include <dds/sub/TSample.hpp>
|
||||
|
||||
// Implementation
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
Sample<T, DELEGATE>::Sample() : dds::core::Value< DELEGATE<T> >() {}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
Sample<T, DELEGATE>::Sample(const T& data, const SampleInfo& info) : dds::core::Value< DELEGATE<T> >(data, info) { }
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
Sample<T, DELEGATE>::Sample(const Sample& other) : dds::core::Value< DELEGATE<T> >(other.delegate()) { }
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
const typename Sample<T, DELEGATE>::DataType& Sample<T, DELEGATE>::data() const
|
||||
{
|
||||
return this->delegate().data();
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
void Sample<T, DELEGATE>::data(const DataType& d)
|
||||
{
|
||||
this->delegate().data(d);
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
const SampleInfo& Sample<T, DELEGATE>::info() const
|
||||
{
|
||||
return this->delegate().info();
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
void Sample<T, DELEGATE>::info(const SampleInfo& i)
|
||||
{
|
||||
this->delegate().info(i);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// End of implementation
|
||||
#endif /* CYCLONEDDS_DDS_SUB_TSAMPLE_HPP_ */
|
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_TSAMPLEINFO_IMPL_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_DETAIL_TSAMPLEINFO_IMPL_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
#include <dds/sub/TSampleInfo.hpp>
|
||||
|
||||
// Implementation
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
|
||||
template <typename DELEGATE>
|
||||
TSampleInfo<DELEGATE>::TSampleInfo() { }
|
||||
|
||||
template <typename DELEGATE>
|
||||
const dds::core::Time TSampleInfo<DELEGATE>::timestamp() const
|
||||
{
|
||||
return this->delegate().timestamp();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
const dds::sub::status::DataState TSampleInfo<DELEGATE>::state() const
|
||||
{
|
||||
return this->delegate().state();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::sub::GenerationCount TSampleInfo<DELEGATE>::generation_count() const
|
||||
{
|
||||
return this->delegate().generation_count();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::sub::Rank TSampleInfo<DELEGATE>::rank() const
|
||||
{
|
||||
return this->delegate().rank();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
bool TSampleInfo<DELEGATE>::valid() const
|
||||
{
|
||||
return this->delegate().valid();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::core::InstanceHandle TSampleInfo<DELEGATE>::instance_handle() const
|
||||
{
|
||||
return this->delegate().instance_handle();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::core::InstanceHandle TSampleInfo<DELEGATE>::publication_handle() const
|
||||
{
|
||||
return this->delegate().publication_handle();
|
||||
}
|
||||
}
|
||||
}
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_TSAMPLEINFO_IMPL_HPP_ */
|
54
unitree_SDK/include/ddscxx/dds/sub/detail/TSampleRefImpl.hpp
Normal file
54
unitree_SDK/include/ddscxx/dds/sub/detail/TSampleRefImpl.hpp
Normal file
@@ -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_SUB_TSAMPLEREF_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_TSAMPLEREF_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
#include <dds/sub/TSampleRef.hpp>
|
||||
|
||||
// Implementation
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
SampleRef<T, DELEGATE>::SampleRef() : dds::core::Value< DELEGATE<T> >() {}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
SampleRef<T, DELEGATE>::SampleRef(const T& data, const SampleInfo& info) : dds::core::Value< DELEGATE<T> >(data, info) { }
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
SampleRef<T, DELEGATE>::SampleRef(const SampleRef& other) : dds::core::Value< DELEGATE<T> >(other.delegate()) { }
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
const typename SampleRef<T, DELEGATE>::DataType& SampleRef<T, DELEGATE>::data() const
|
||||
{
|
||||
return this->delegate().data();
|
||||
}
|
||||
|
||||
template <typename T, template <typename Q> class DELEGATE>
|
||||
const SampleInfo& SampleRef<T, DELEGATE>::info() const
|
||||
{
|
||||
return this->delegate().info();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// End of implementation
|
||||
#endif /* CYCLONEDDS_DDS_SUB_TSAMPLEREF_HPP_ */
|
121
unitree_SDK/include/ddscxx/dds/sub/detail/TSubscriberImpl.hpp
Normal file
121
unitree_SDK/include/ddscxx/dds/sub/detail/TSubscriberImpl.hpp
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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_SUB_TSUBSCRIBER_IMPL_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_TSUBSCRIBER_IMPL_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
* OMG PSM class declaration
|
||||
*/
|
||||
#include <dds/sub/TSubscriber.hpp>
|
||||
|
||||
// Implementation
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
|
||||
template <typename DELEGATE>
|
||||
TSubscriber<DELEGATE>::TSubscriber(const ::dds::domain::DomainParticipant& dp)
|
||||
: ::dds::core::Reference<DELEGATE>(new DELEGATE(dp,
|
||||
dp.default_subscriber_qos(),
|
||||
NULL,
|
||||
dds::core::status::StatusMask::none()))
|
||||
{
|
||||
this->delegate()->init(this->impl_);
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
TSubscriber<DELEGATE>::TSubscriber(const ::dds::domain::DomainParticipant& dp,
|
||||
const dds::sub::qos::SubscriberQos& qos,
|
||||
dds::sub::SubscriberListener* listener,
|
||||
const dds::core::status::StatusMask& mask)
|
||||
: ::dds::core::Reference<DELEGATE>(new DELEGATE(dp, qos, listener, mask))
|
||||
{
|
||||
this->delegate()->init(this->impl_);
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
void TSubscriber<DELEGATE>::notify_datareaders()
|
||||
{
|
||||
this->delegate()->notify_datareaders();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
void TSubscriber<DELEGATE>::listener(Listener* listener,
|
||||
const dds::core::status::StatusMask& event_mask)
|
||||
{
|
||||
return this->delegate()->listener(listener, event_mask);
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
typename TSubscriber<DELEGATE>::Listener* TSubscriber<DELEGATE>::listener() const
|
||||
{
|
||||
return this->delegate()->listener();
|
||||
}
|
||||
|
||||
|
||||
template <typename DELEGATE>
|
||||
const dds::sub::qos::SubscriberQos& TSubscriber<DELEGATE>::qos() const
|
||||
{
|
||||
return this->delegate()->qos();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
void TSubscriber<DELEGATE>::qos(const dds::sub::qos::SubscriberQos& sqos)
|
||||
{
|
||||
this->delegate()->qos(sqos);
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
dds::sub::qos::DataReaderQos TSubscriber<DELEGATE>::default_datareader_qos() const
|
||||
{
|
||||
return this->delegate()->default_datareader_qos();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
TSubscriber<DELEGATE>& TSubscriber<DELEGATE>::default_datareader_qos(
|
||||
const dds::sub::qos::DataReaderQos& qos)
|
||||
{
|
||||
this->delegate()->default_datareader_qos(qos);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
const dds::domain::DomainParticipant& TSubscriber<DELEGATE>::participant() const
|
||||
{
|
||||
return this->delegate()->participant();
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
TSubscriber<DELEGATE>& TSubscriber<DELEGATE>::operator << (const dds::sub::qos::SubscriberQos& qos)
|
||||
{
|
||||
this->qos(qos);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename DELEGATE>
|
||||
const TSubscriber<DELEGATE>& TSubscriber<DELEGATE>::operator >> (dds::sub::qos::SubscriberQos& qos) const
|
||||
{
|
||||
qos = this->qos();
|
||||
return *this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// End of implementation
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_SUB_TSUBSCRIBER_IMPL_HPP_ */
|
21
unitree_SDK/include/ddscxx/dds/sub/detail/ddssub.hpp
Normal file
21
unitree_SDK/include/ddscxx/dds/sub/detail/ddssub.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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 OMG_DDS_SUB_PACKAGE_DETAIL_INCLUDE_HPP_
|
||||
#define OMG_DDS_SUB_PACKAGE_DETAIL_INCLUDE_HPP_
|
||||
|
||||
#include "dds/sub/detail/TDataReaderImpl.hpp"
|
||||
#include "dds/sub/detail/TQueryImpl.hpp"
|
||||
#include "dds/sub/detail/TSampleImpl.hpp"
|
||||
#include "dds/sub/detail/TSampleRefImpl.hpp"
|
||||
#include "dds/sub/cond/detail/TQueryConditionImpl.hpp"
|
||||
|
||||
#endif /* OMG_DDS_SUB_PACKAGE_DETAIL_INCLUDE_HPP_ */
|
62
unitree_SDK/include/ddscxx/dds/sub/detail/discovery.hpp
Normal file
62
unitree_SDK/include/ddscxx/dds/sub/detail/discovery.hpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_DISCOVERY_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_DETAIL_DISCOVERY_HPP_
|
||||
|
||||
#include <dds/sub/DataReader.hpp>
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
::dds::core::InstanceHandleSeq
|
||||
matched_publications(const dds::sub::DataReader<T>& dr)
|
||||
{
|
||||
return dr.delegate()->matched_publications();
|
||||
}
|
||||
|
||||
template <typename T, typename FwdIterator>
|
||||
uint32_t
|
||||
matched_publications(const dds::sub::DataReader<T>& dr,
|
||||
FwdIterator begin, uint32_t max_size)
|
||||
{
|
||||
return dr.delegate()->matched_publications(begin, max_size);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const dds::topic::PublicationBuiltinTopicData
|
||||
matched_publication_data(const dds::sub::DataReader<T>& dr,
|
||||
const ::dds::core::InstanceHandle& h)
|
||||
{
|
||||
return dr.delegate()->matched_publication_data(h);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_DISCOVERY_HPP_ */
|
218
unitree_SDK/include/ddscxx/dds/sub/detail/find.hpp
Normal file
218
unitree_SDK/include/ddscxx/dds/sub/detail/find.hpp
Normal file
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* 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_SUB_DETAIL_FIND_HPP_
|
||||
#define CYCLONEDDS_DDS_SUB_DETAIL_FIND_HPP_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
// Implementation
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <dds/sub/DataReader.hpp>
|
||||
#include <dds/sub/Subscriber.hpp>
|
||||
#include <dds/sub/status/DataState.hpp>
|
||||
#include <dds/topic/TopicDescription.hpp>
|
||||
|
||||
#include <org/eclipse/cyclonedds/sub/SubscriberDelegate.hpp>
|
||||
#include <org/eclipse/cyclonedds/sub/BuiltinSubscriberDelegate.hpp>
|
||||
#include <org/eclipse/cyclonedds/sub/AnyDataReaderDelegate.hpp>
|
||||
|
||||
namespace dds
|
||||
{
|
||||
namespace sub
|
||||
{
|
||||
|
||||
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* To be able to properly copy found readers into the given iterators
|
||||
* (which are related to typed DataReaders or AnyDataReaders), we have
|
||||
* to specialize the find() template functions.
|
||||
* But template functions specialization is not supported by C++. So,
|
||||
* we have to use these helper classes to get the specialization.
|
||||
*********************************************************************/
|
||||
|
||||
typedef std::vector<org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::ref_type> base_readers_vector;
|
||||
typedef std::vector<org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::ref_type>::iterator base_readers_iterator;
|
||||
|
||||
/*
|
||||
* Copy helper class for typed readers.
|
||||
*/
|
||||
template <typename READER, typename ITERATOR>
|
||||
class ReadersCopySpecialization
|
||||
{
|
||||
public:
|
||||
static
|
||||
bool copy(base_readers_iterator base_iter, ITERATOR typed_iter) {
|
||||
bool copied = false;
|
||||
try {
|
||||
/* Cast base reader to typed delegate: */
|
||||
typename READER::DELEGATE_REF_T reader_typed =
|
||||
::std::dynamic_pointer_cast<typename READER::DELEGATE_T>(*base_iter);
|
||||
READER dr(reader_typed);
|
||||
if(dr != dds::core::null)
|
||||
{
|
||||
*typed_iter = dr;
|
||||
copied = true;
|
||||
}
|
||||
} catch (...) {
|
||||
/* Ignore, because subscriber can have returned readers that are of
|
||||
* different types. */
|
||||
}
|
||||
return copied;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Copy helper class for any readers.
|
||||
*/
|
||||
template <typename ITERATOR>
|
||||
class ReadersCopySpecialization<dds::sub::AnyDataReader, ITERATOR>
|
||||
{
|
||||
public:
|
||||
static
|
||||
bool copy(base_readers_iterator base_iter, ITERATOR any_iter) {
|
||||
*any_iter = (*base_iter)->wrapper_to_any();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Copy helper class for list of readers.
|
||||
*/
|
||||
template <typename READER, typename ITERATOR>
|
||||
class ReadersCopy
|
||||
{
|
||||
public:
|
||||
static
|
||||
uint32_t copy(base_readers_vector base_readers,
|
||||
ITERATOR begin,
|
||||
uint32_t max_size)
|
||||
{
|
||||
uint32_t size = 0;
|
||||
base_readers_iterator iter;
|
||||
for (iter = base_readers.begin(); (size < max_size) && (iter != base_readers.end()); ++iter) {
|
||||
if (ReadersCopySpecialization<READER, ITERATOR>::copy(iter, begin)) {
|
||||
begin++;
|
||||
size++;
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
static
|
||||
uint32_t copy(base_readers_vector base_readers,
|
||||
ITERATOR begin)
|
||||
{
|
||||
uint32_t size = 0;
|
||||
base_readers_iterator iter;
|
||||
for (iter = base_readers.begin(); iter != base_readers.end(); ++iter) {
|
||||
if (ReadersCopySpecialization<READER, ITERATOR>::copy(iter, begin)) {
|
||||
begin++;
|
||||
size++;
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace detail */
|
||||
|
||||
|
||||
|
||||
template <typename READER, typename FwdIterator>
|
||||
uint32_t
|
||||
find(const dds::sub::Subscriber& sub,
|
||||
const std::string &topic_name,
|
||||
FwdIterator begin, uint32_t max_size)
|
||||
{
|
||||
uint32_t size = 0;
|
||||
if (max_size > 0) {
|
||||
detail::base_readers_vector base_readers;
|
||||
base_readers = sub.delegate()->find_datareaders(topic_name);
|
||||
size = detail::ReadersCopy<READER, FwdIterator>::copy(base_readers, begin, max_size);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
template <typename READER, typename BinIterator>
|
||||
uint32_t
|
||||
find(const dds::sub::Subscriber& sub,
|
||||
const std::string &topic_name,
|
||||
BinIterator begin)
|
||||
{
|
||||
uint32_t size = 0;
|
||||
detail::base_readers_vector base_readers;
|
||||
base_readers = sub.delegate()->find_datareaders(topic_name);
|
||||
size = detail::ReadersCopy<READER, BinIterator>::copy(base_readers, begin);
|
||||
return size;
|
||||
}
|
||||
|
||||
template <typename READER, typename T, typename FwdIterator>
|
||||
uint32_t
|
||||
find(const dds::sub::Subscriber& sub,
|
||||
const dds::topic::TopicDescription& topic_description,
|
||||
FwdIterator begin, uint32_t max_size)
|
||||
{
|
||||
return find<READER, FwdIterator>(sub, topic_description.name(), begin, max_size);
|
||||
}
|
||||
|
||||
template <typename READER, typename T, typename BinIterator>
|
||||
uint32_t
|
||||
find(const dds::sub::Subscriber& sub,
|
||||
const dds::topic::TopicDescription& topic_description,
|
||||
BinIterator begin)
|
||||
{
|
||||
return find<READER, BinIterator>(sub, topic_description.name(), begin);
|
||||
}
|
||||
|
||||
template <typename READER, typename FwdIterator>
|
||||
uint32_t
|
||||
find(const dds::sub::Subscriber& sub,
|
||||
const dds::sub::status::DataState& rs,
|
||||
FwdIterator begin, uint32_t max_size)
|
||||
{
|
||||
uint32_t size = 0;
|
||||
if (max_size > 0) {
|
||||
detail::base_readers_vector base_readers;
|
||||
base_readers = sub.delegate()->get_datareaders(rs);
|
||||
size = detail::ReadersCopy<READER, FwdIterator>::copy(base_readers, begin, max_size);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
template <typename READER, typename BinIterator>
|
||||
uint32_t
|
||||
find(const dds::sub::Subscriber& sub,
|
||||
const dds::sub::status::DataState& rs,
|
||||
BinIterator begin)
|
||||
{
|
||||
uint32_t size = 0;
|
||||
detail::base_readers_vector base_readers;
|
||||
base_readers = sub.delegate()->get_datareaders(rs);
|
||||
size = detail::ReadersCopy<READER, BinIterator>::copy(base_readers, begin);
|
||||
return size;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_FIND_HPP_ */
|
||||
|
Reference in New Issue
Block a user