This commit is contained in:
2025-09-24 10:53:28 +08:00
commit f8e4df77fb
856 changed files with 140098 additions and 0 deletions

View File

@@ -0,0 +1,120 @@
/*
* 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 LITE_FORWARD_DECLARATIONS_HPP_
#define LITE_FORWARD_DECLARATIONS_HPP_
namespace dds
{
namespace domain
{
class DomainParticipantListener;
template <typename DELEGATE>
class TDomainParticipant;
}
namespace sub
{
template <typename T, template <typename Q> class DELEGATE>
class DataReader;
template <typename T>
class DataReaderListener;
class SubscriberListener;
template <typename DELEGATE>
class TSubscriber;
namespace detail
{
template <typename T>
class DataReader;
template <typename T>
class LoanedSamplesHolder;
template <typename T, typename SamplesFWIterator>
class SamplesFWInteratorHolder;
template <typename T, typename SamplesBIIterator>
class SamplesBIIteratorHolder;
}
}
namespace pub
{
class PublisherListener;
template <typename DELEGATE>
class TPublisher;
}
namespace topic
{
template <typename DELEGATE>
class TTopicDescription;
template <typename T>
class TopicListener;
template <typename T, template <typename Q> class DELEGATE>
class Topic;
template <typename T, template <typename Q> class DELEGATE>
class ContentFilteredTopic;
namespace detail
{
template <typename T>
class ContentFilteredTopic;
}
}
}
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace domain {
class DomainParticipantDelegate;
}
namespace sub {
class SubscriberDelegate;
}
namespace pub {
class PublisherDelegate;
}
namespace topic {
template <class TOPIC>
class TopicTraits;
class TopicDescriptionDelegate;
}
}
}
}
#endif /* LITE_FORWARD_DECLARATIONS_HPP_ */

View File

@@ -0,0 +1,74 @@
/*
* 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_CORE_USEROBJECT_DELEGATE_HPP_
#define CYCLONEDDS_CORE_USEROBJECT_DELEGATE_HPP_
#include "dds/core/macros.hpp"
#include "dds/core/refmacros.hpp"
#include "org/eclipse/cyclonedds/core/Mutex.hpp"
#include "org/eclipse/cyclonedds/core/ObjectDelegate.hpp"
#include <unordered_map>
#include "dds/dds.h"
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
DDSCXX_WARNING_MSVC_OFF(4251)
class OMG_DDS_API DDScObjectDelegate : public virtual org::eclipse::cyclonedds::core::ObjectDelegate
{
public:
typedef std::unordered_map<dds_entity_t,org::eclipse::cyclonedds::core::ObjectDelegate::weak_ref_type> entity_map_type;
DDScObjectDelegate ();
virtual ~DDScObjectDelegate ();
void close ();
dds_entity_t get_ddsc_entity ();
void set_ddsc_entity (dds_entity_t e);
void add_to_entity_map (org::eclipse::cyclonedds::core::ObjectDelegate::weak_ref_type weak_ref);
public:
static ObjectDelegate::ref_type extract_strong_ref(dds_entity_t e);
protected:
dds_entity_t ddsc_entity;
private:
void delete_from_entity_map();
static org::eclipse::cyclonedds::core::DDScObjectDelegate::entity_map_type entity_map;
static Mutex entity_map_mutex;
};
DDSCXX_WARNING_MSVC_ON(4251)
}
}
}
}
#endif /* CYCLONEDDS_CORE_USEROBJECT_DELEGATE_HPP_ */

View File

@@ -0,0 +1,140 @@
/*
* 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_CORE_ENTITY_DELEGATE_HPP_
#define CYCLONEDDS_CORE_ENTITY_DELEGATE_HPP_
#include <dds/core/status/State.hpp>
#include <dds/core/InstanceHandle.hpp>
#include <dds/core/policy/CorePolicy.hpp>
#include <org/eclipse/cyclonedds/core/DDScObjectDelegate.hpp>
#include <org/eclipse/cyclonedds/ForwardDeclarations.hpp>
#include <org/eclipse/cyclonedds/core/status/StatusDelegate.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
class OMG_DDS_API EntityDelegate :
public virtual ::org::eclipse::cyclonedds::core::DDScObjectDelegate
{
public:
typedef ::dds::core::smart_ptr_traits< EntityDelegate >::ref_type ref_type;
typedef ::dds::core::smart_ptr_traits< EntityDelegate >::weak_ref_type weak_ref_type;
EntityDelegate();
virtual ~EntityDelegate();
/**
* @internal Enables this entity.
*/
void enable();
::dds::core::status::StatusMask status_changes() const;
::dds::core::InstanceHandle instance_handle() const;
bool contains_entity(const ::dds::core::InstanceHandle& handle);
ObjectDelegate::ref_type get_statusCondition();
virtual void close();
virtual void retain();
void *listener_get() const;
protected:
void listener_set(void *listener,
const dds::core::status::StatusMask& mask);
public:
const dds::core::status::StatusMask get_listener_mask() const ;
bool obtain_callback_lock() ;
void release_callback_lock() ;
// Topic callback
virtual void on_inconsistent_topic(dds_entity_t topic,
org::eclipse::cyclonedds::core::InconsistentTopicStatusDelegate &) ;
// Writer callbacks
virtual void on_offered_deadline_missed(dds_entity_t writer,
org::eclipse::cyclonedds::core::OfferedDeadlineMissedStatusDelegate &) ;
virtual void on_offered_incompatible_qos(dds_entity_t writer,
org::eclipse::cyclonedds::core::OfferedIncompatibleQosStatusDelegate &) ;
virtual void on_liveliness_lost(dds_entity_t writer,
org::eclipse::cyclonedds::core::LivelinessLostStatusDelegate &) ;
virtual void on_publication_matched(dds_entity_t writer,
org::eclipse::cyclonedds::core::PublicationMatchedStatusDelegate &) ;
// Reader callbacks
virtual void on_requested_deadline_missed(dds_entity_t reader,
org::eclipse::cyclonedds::core::RequestedDeadlineMissedStatusDelegate &);
virtual void on_requested_incompatible_qos(dds_entity_t reader,
org::eclipse::cyclonedds::core::RequestedIncompatibleQosStatusDelegate &);
virtual void on_sample_rejected(dds_entity_t reader,
org::eclipse::cyclonedds::core::SampleRejectedStatusDelegate &);
virtual void on_liveliness_changed(dds_entity_t reader,
org::eclipse::cyclonedds::core::LivelinessChangedStatusDelegate &);
virtual void on_data_available(dds_entity_t reader);
virtual void on_subscription_matched(dds_entity_t reader,
org::eclipse::cyclonedds::core::SubscriptionMatchedStatusDelegate &);
virtual void on_sample_lost(dds_entity_t reader,
org::eclipse::cyclonedds::core::SampleLostStatusDelegate &);
// Subscriber callback
virtual void on_data_readers(dds_entity_t subscriber);
protected:
static volatile unsigned int entityID_;
bool enabled_;
dds::core::status::StatusMask listener_mask;
void prevent_callbacks();
long callback_count;
dds_listener_t *listener_callbacks;
private:
void *listener;
ObjectDelegate::weak_ref_type myStatusCondition;
void *callback_mutex;
void *callback_cond;
};
}
}
}
}
#endif /* CYCLONEDDS_CORE_ENTITY_DELEGATE_HPP_ */

View File

@@ -0,0 +1,95 @@
/*
* 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_CORE_ENTITY_REGISTRY_HPP_
#define CYCLONEDDS_CORE_ENTITY_REGISTRY_HPP_
#include <dds/core/detail/WeakReferenceImpl.hpp>
#include <org/eclipse/cyclonedds/core/Mutex.hpp>
#include <map>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
template <typename T, typename U>
class EntityRegistry
{
public:
/**
* @internal Inserts a EntityDelegate key, dds::core::Entity value pair into the registry.
* @param key The org::eclipse::cyclonedds::core::Entity to use as a key
* @param val The dds::core::Entity that encapsulates the key
*/
void insert(T key, U& val)
{
mutex.lock();
registry[key] = dds::core::WeakReference<U>(val);
mutex.unlock();
}
/**
* @internal Removes a DDS::Entity from the registry
* @param key Entity to remove
*/
void remove(T key)
{
mutex.lock();
registry.erase(key);
mutex.unlock();
}
/**
* @internal Checks the registry for a dds::core::Entity that wraps the supplied DDS::Entity
* and returns it. If no match is found dds::core::null is returned.
* @param key DDS::Entity to find an encapsulating dds::core:Entity for.
* @return dds::core::Entity if a match is found, dds::core::null if not.
*/
U get(T key)
{
typename std::map<T, dds::core::WeakReference<U> >::iterator it;
mutex.lock();
it = registry.find(key);
U entity(dds::core::null);
if(it != registry.end())
{
entity = it->second.lock();
}
mutex.unlock();
return entity;
}
private:
std::map<T, dds::core::WeakReference<U> > registry;
org::eclipse::cyclonedds::core::Mutex mutex;
};
}
}
}
}
#endif /* CYCLONEDDS_CORE_ENTITY_REGISTRY_HPP_ */

View File

@@ -0,0 +1,94 @@
/*
* 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_CORE_ENTITY_SET_HPP_
#define CYCLONEDDS_CORE_ENTITY_SET_HPP_
#include <dds/core/InstanceHandle.hpp>
#include <org/eclipse/cyclonedds/core/EntityDelegate.hpp>
#include <org/eclipse/cyclonedds/core/Mutex.hpp>
#include <org/eclipse/cyclonedds/core/WeakReferenceSet.hpp>
#include <vector>
#include <memory>
#include <set>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
class EntitySet
{
public:
typedef std::vector<org::eclipse::cyclonedds::core::ObjectDelegate::weak_ref_type>::iterator vectorIterator;
typedef std::vector<org::eclipse::cyclonedds::core::ObjectDelegate::weak_ref_type> vector;
/**
* @internal Inserts a EntityDelegate into the set.
* @param entity The org::eclipse::cyclonedds::core::EntityDelegate to store
*/
void insert(org::eclipse::cyclonedds::core::EntityDelegate& entity);
/**
* @internal Erases a EntityDelegate from the set.
* @param entity The org::eclipse::cyclonedds::core::EntityDelegate to delete
*/
void erase(org::eclipse::cyclonedds::core::EntityDelegate& entity);
/**
* @internal Check if Entity with specific handle is part of the set.
* @param handle The dds::core::InstanceHandle to search for
*/
bool contains(const dds::core::InstanceHandle& handle);
/**
* @internal Call close() of all the Entities within the set (outside lock).
*/
void all_close();
/**
* @internal Call retain() of all the Entities within the set (outside lock).
*/
void all_retain();
/**
* @internal Call enable() of all the Entities within the set (outside lock).
*/
void all_enable();
/**
* @internal Copy internal set into a vector.
*/
vector copy();
private:
WeakReferenceSet<ObjectDelegate::weak_ref_type>::wset entities;
Mutex mutex;
};
}
}
}
}
#endif /* CYCLONEDDS_CORE_ENTITY_SET_HPP_ */

View File

@@ -0,0 +1,71 @@
/*
* 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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_CORE_INSTANCE_HANDLE_HPP_
#define CYCLONEDDS_CORE_INSTANCE_HANDLE_HPP_
#include <dds/core/types.hpp>
#include <org/eclipse/cyclonedds/core/config.hpp>
#include <dds/dds.h>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
class InstanceHandleDelegate;
}
}
}
}
class OMG_DDS_API org::eclipse::cyclonedds::core::InstanceHandleDelegate
{
public:
InstanceHandleDelegate();
InstanceHandleDelegate(dds_instance_handle_t h);
public:
InstanceHandleDelegate(const dds::core::null_type& src);
public:
bool operator==(const InstanceHandleDelegate& that) const;
bool operator<(const InstanceHandleDelegate& that) const;
bool operator>(const InstanceHandleDelegate& that) const;
InstanceHandleDelegate& operator=(const dds::core::null_type& src);
bool is_nil() const;
public:
dds_instance_handle_t handle() const;
private:
dds_instance_handle_t handle_;
};
inline std::ostream&
operator << (std::ostream& os,
const org::eclipse::cyclonedds::core::InstanceHandleDelegate& h)
{
os << h.handle();
return os;
}
#endif /* CYCLONEDDS_CORE_INSTANCE_HANDLE_HPP_ */

View File

@@ -0,0 +1,57 @@
/*
* 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_CORE_LISTENERDISPATCHER_H_
#define CYCLONEDDS_CORE_LISTENERDISPATCHER_H_
#include "dds/dds.h"
extern "C"
{
extern OMG_DDS_API void callback_on_inconsistent_topic
(dds_entity_t topic, dds_inconsistent_topic_status_t status, void* arg);
extern OMG_DDS_API void callback_on_offered_deadline_missed
(dds_entity_t writer, dds_offered_deadline_missed_status_t status, void* arg);
extern OMG_DDS_API void callback_on_offered_incompatible_qos
(dds_entity_t writer, dds_offered_incompatible_qos_status_t status, void* arg);
extern OMG_DDS_API void callback_on_liveliness_lost
(dds_entity_t writer, dds_liveliness_lost_status_t status, void* arg);
extern OMG_DDS_API void callback_on_publication_matched
(dds_entity_t writer, dds_publication_matched_status_t status, void* arg);
extern OMG_DDS_API void callback_on_requested_deadline_missed
(dds_entity_t reader, dds_requested_deadline_missed_status_t status, void* arg);
extern OMG_DDS_API void callback_on_requested_incompatible_qos
(dds_entity_t reader, dds_requested_incompatible_qos_status_t status, void* arg);
extern OMG_DDS_API void callback_on_sample_rejected
(dds_entity_t reader, dds_sample_rejected_status_t status, void* arg);
extern OMG_DDS_API void callback_on_liveliness_changed
(dds_entity_t reader, dds_liveliness_changed_status_t status, void* arg);
extern OMG_DDS_API void callback_on_data_available (dds_entity_t reader, void* arg);
extern OMG_DDS_API void callback_on_subscription_matched
(dds_entity_t reader, dds_subscription_matched_status_t status, void* arg);
extern OMG_DDS_API void callback_on_sample_lost
(dds_entity_t reader, dds_sample_lost_status_t status, void* arg);
extern OMG_DDS_API void callback_on_data_readers (dds_entity_t subscriber, void* arg);
}
#endif /* CYCLONEDDS_CORE_LISTENERDISPATCHER_H_ */

View File

@@ -0,0 +1,90 @@
/*
* 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_CORE_MISC_UTILS_HPP_
#define CYCLONEDDS_CORE_MISC_UTILS_HPP_
#include <dds/core/ddscore.hpp>
#include <org/eclipse/cyclonedds/core/Mutex.hpp>
#include "dds/dds.h"
#define STATUS_MASK_CONTAINS(mask,check) ((mask & check) == check)
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
void
convertByteSeq(
const dds::core::ByteSeq &from,
void*& to,
int32_t size);
void
convertByteSeq(
const void* from,
const int32_t size,
dds::core::ByteSeq &to);
void
convertStringSeq(
const dds::core::StringSeq &from,
char **&to);
void
convertStringSeq(
char **from,
uint32_t size,
dds::core::StringSeq &to);
dds::core::Duration
convertDuration(
const dds_duration_t &from);
dds_duration_t
convertDuration(
const dds::core::Duration &from);
dds::core::Time
convertTime(
const dds_time_t &from);
dds_time_t
convertTime(
const dds::core::Time &from);
dds::core::status::StatusMask
convertStatusMask(
const uint32_t from);
uint32_t
convertStatusMask(
const dds::core::status::StatusMask &from);
static Mutex gpb_mutex;
}
}
}
}
#endif //CYCLONEDDS_CORE_MISC_UTILS_HPP_

View File

@@ -0,0 +1,36 @@
/*
* Copyright(c) 2006 to 2022 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_CORE_MISSING_HPP_
#define CYCLONEDDS_CORE_MISSING_HPP_
//since these helpers are only introduced from c++14 onwards
#if __cplusplus < 201402L
namespace std {
template< bool B, class T, class F >
using conditional_t = typename std::conditional<B, T, F>::type;
template<bool cond, class T = void>
using enable_if_t = typename std::enable_if<cond, T>::type;
template<class T = void>
using decay_t = typename std::decay<T>::type;
}
#endif /* _cplusplus */
#endif /* CYCLONEDDS_CORE_MISSING_HPP_ */

View File

@@ -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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_CORE_MUTEX_HPP_
#define CYCLONEDDS_CORE_MUTEX_HPP_
#include <dds/core/macros.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
class OMG_DDS_API Mutex
{
public:
Mutex();
virtual ~Mutex();
void lock() const;
bool try_lock() const;
void unlock() const;
private:
void* mtx;
};
}
}
}
}
#endif /* CYCLONEDDS_CORE_MUTEX_HPP_ */

View File

@@ -0,0 +1,71 @@
/*
* 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_CORE_OBJECT_DELEGATE_HPP_
#define CYCLONEDDS_CORE_OBJECT_DELEGATE_HPP_
#include "dds/core/macros.hpp"
#include "dds/core/refmacros.hpp"
#include "org/eclipse/cyclonedds/core/Mutex.hpp"
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
DDSCXX_WARNING_MSVC_OFF(4251)
class OMG_DDS_API ObjectDelegate
{
public:
typedef ::dds::core::smart_ptr_traits< ObjectDelegate >::ref_type ref_type;
typedef ::dds::core::smart_ptr_traits< ObjectDelegate >::weak_ref_type weak_ref_type;
ObjectDelegate ();
virtual ~ObjectDelegate ();
virtual void close ();
void lock() const;
void unlock() const;
virtual void init (ObjectDelegate::weak_ref_type weak_ref) = 0;
ObjectDelegate::weak_ref_type get_weak_ref () const;
ObjectDelegate::ref_type get_strong_ref () const;
protected:
void check () const;
void set_weak_ref (ObjectDelegate::weak_ref_type weak_ref);
Mutex mutex;
bool closed;
ObjectDelegate::weak_ref_type myself;
};
DDSCXX_WARNING_MSVC_ON(4251)
}
}
}
}
#endif /* CYCLONEDDS_CORE_OBJECT_DELEGATE_HPP_ */

View File

@@ -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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_CORE_OBJECT_SET_HPP_
#define CYCLONEDDS_CORE_OBJECT_SET_HPP_
#include <dds/core/InstanceHandle.hpp>
#include <org/eclipse/cyclonedds/core/ObjectDelegate.hpp>
#include <org/eclipse/cyclonedds/core/Mutex.hpp>
#include <org/eclipse/cyclonedds/core/WeakReferenceSet.hpp>
#include <vector>
#include <memory>
#include <set>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
class ObjectSet
{
public:
typedef std::set<org::eclipse::cyclonedds::core::ObjectDelegate::weak_ref_type>::iterator setIterator;
typedef std::vector<org::eclipse::cyclonedds::core::ObjectDelegate::weak_ref_type>::iterator vectorIterator;
typedef std::vector<org::eclipse::cyclonedds::core::ObjectDelegate::weak_ref_type> vector;
/**
* @internal Inserts a EntityDelegate into the set.
* @param obj The org::eclipse::cyclonedds::core::ObjectDelegate to store
*/
void insert(org::eclipse::cyclonedds::core::ObjectDelegate& obj);
/**
* @internal Erases a EntityDelegate from the set.
* @param obj The org::eclipse::cyclonedds::core::ObjectDelegate to delete
*/
void erase(org::eclipse::cyclonedds::core::ObjectDelegate& obj);
/**
* @internal Call close() of all the Objects within the set (outside lock).
*/
void all_close();
/**
* @internal Copy internal set into a vector.
*/
vector copy();
private:
WeakReferenceSet<ObjectDelegate::weak_ref_type>::wset objects;
Mutex mutex;
};
}
}
}
}
#endif /* CYCLONEDDS_CORE_OBJECT_SET_HPP_ */

View File

@@ -0,0 +1,81 @@
/*
* 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_CORE_QOSPROVIDERDELEGATE_HPP_
#define CYCLONEDDS_CORE_QOSPROVIDERDELEGATE_HPP_
#include <dds/domain/qos/DomainParticipantQos.hpp>
#include <dds/topic/qos/TopicQos.hpp>
#include <dds/sub/qos/SubscriberQos.hpp>
#include <dds/sub/qos/DataReaderQos.hpp>
#include <dds/pub/qos/PublisherQos.hpp>
#include <dds/pub/qos/DataWriterQos.hpp>
#if 0
C_CLASS(cmn_qosProvider);
C_CLASS(cmn_qosProviderInputAttr);
#endif
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
class QosProviderDelegate;
}
}
}
}
class OMG_DDS_API org::eclipse::cyclonedds::core::QosProviderDelegate
{
public:
QosProviderDelegate(const std::string& uri, const std::string& id = "");
~QosProviderDelegate();
dds::domain::qos::DomainParticipantQos
participant_qos(const char* id);
dds::topic::qos::TopicQos
topic_qos(const char* id);
dds::sub::qos::SubscriberQos
subscriber_qos(const char* id);
dds::sub::qos::DataReaderQos
datareader_qos(const char* id);
dds::pub::qos::PublisherQos
publisher_qos(const char* id);
dds::pub::qos::DataWriterQos
datawriter_qos(const char* id);
private:
template <typename FROM, typename TO>
static void named_qos__copyOut(void *from, void *to);
#if 0
cmn_qosProvider qosProvider;
static const C_STRUCT(cmn_qosProviderInputAttr) qosProviderAttr;
#endif
};
#endif /* CYCLONEDDS_CORE_QOSPROVIDERDELEGATE_HPP_ */

View File

@@ -0,0 +1,191 @@
/*
* 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_CORE_REPORT_UTILS_HPP_
#define CYCLONEDDS_CORE_REPORT_UTILS_HPP_
#include <string>
#include <sstream>
#include <org/eclipse/cyclonedds/core/config.hpp>
#include <dds/core/Exception.hpp>
#include <dds/dds.h>
#include <ios>
#include <stdarg.h>
//#define _OS_WARNING 2
//#define _OS_ERROR 4
#define ISOCPP_ERROR org::eclipse::cyclonedds::core::utils::error_code
#define ISOCPP_UNSUPPORTED_ERROR org::eclipse::cyclonedds::core::utils::unsupported_error_code
#define ISOCPP_INVALID_ARGUMENT_ERROR org::eclipse::cyclonedds::core::utils::invalid_argument_code
#define ISOCPP_PRECONDITION_NOT_MET_ERROR org::eclipse::cyclonedds::core::utils::precondition_not_met_error_code
#define ISOCPP_OUT_OF_RESOURCES_ERROR org::eclipse::cyclonedds::core::utils::out_of_resources_error_code
#define ISOCPP_NOT_ENABLED_ERROR org::eclipse::cyclonedds::core::utils::not_enabled_error_code
#define ISOCPP_IMMUTABLE_POLICY_ERROR org::eclipse::cyclonedds::core::utils::immutable_policy_error_code
#define ISOCPP_INCONSISTENT_POLICY_ERROR org::eclipse::cyclonedds::core::utils::inconsistent_policy_error_code
#define ISOCPP_ALREADY_CLOSED_ERROR org::eclipse::cyclonedds::core::utils::already_closed_error_code
#define ISOCPP_TIMEOUT_ERROR org::eclipse::cyclonedds::core::utils::timeout_error_code
#define ISOCPP_NO_DATA_ERROR org::eclipse::cyclonedds::core::utils::no_data_error_code
#define ISOCPP_ILLEGAL_OPERATION_ERROR org::eclipse::cyclonedds::core::utils::illegal_operation_error_code
#define ISOCPP_NULL_REFERENCE_ERROR org::eclipse::cyclonedds::core::utils::null_reference_error_code
/* \brief OS_FUNCTION provides undecorated function name of current function
*
* Behavior of OS_FUNCTION outside a function is undefined. Note that
* implementations differ across compilers and compiler versions. It might be
* implemented as either a string literal or a constant variable.
*/
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
# define OS_FUNCTION __func__
#elif defined(__cplusplus) && (__cplusplus >= 201103)
# define OS_FUNCTION __func__
#elif defined(__GNUC__)
# define OS_FUNCTION __FUNCTION__
#elif defined(__clang__)
# define OS_FUNCTION __FUNCTION__
#elif defined(__ghs__)
# define OS_FUNCTION __FUNCTION__
#elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC))
/* Solaris Studio had support for __func__ before it supported __FUNCTION__.
Compiler flag -features=extensions is required on older versions. */
# define OS_FUNCTION __func__
#elif defined(__FUNCTION__)
/* Visual Studio */
# define OS_FUNCTION __FUNCTION__
#elif defined(__vxworks)
/* At least versions 2.9.6 and 3.3.4 of the GNU C Preprocessor only define
__GNUC__ if the entire GNU C compiler is in use. VxWorks 5.5 targets invoke
the preprocessor separately resulting in __GNUC__ not being defined. */
# define OS_FUNCTION __FUNCTION__
#else
# warning "OS_FUNCTION is not supported"
#endif
/* \brief OS_PRETTY_FUNCTION provides function signature of current function
*
* See comments on OS_FUNCTION for details.
*/
#if defined(__GNUC__)
# define OS_PRETTY_FUNCTION __PRETTY_FUNCTION__
#elif defined(__clang__)
# define OS_PRETTY_FUNCTION __PRETTY_FUNCTION__
#elif defined(__ghs__)
# define OS_PRETTY_FUNCTION __PRETTY_FUNCTION__
#elif (defined(__SUNPRO_C) && __SUNPRO_C >= 0x5100)
/* Solaris Studio supports __PRETTY_FUNCTION__ in C since version 12.1 */
# define OS_PRETTY_FUNCTION __PRETTY_FUNCTION__
#elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x5120)
/* Solaris Studio supports __PRETTY_FUNCTION__ in C++ since version 12.3 */
# define OS_PRETTY_FUNCTION __PRETTY_FUNCTION__
#elif defined(__FUNCSIG__)
/* Visual Studio */
# define OS_PRETTY_FUNCTION __FUNCSIG__
#elif defined(__vxworks)
/* See comments on __vxworks macro above. */
# define OS_PRETTY_FUNCTION __PRETTY_FUNCTION__
#else
/* Do not warn user about OS_PRETTY_FUNCTION falling back to OS_FUNCTION.
# warning "OS_PRETTY_FUNCTION is not supported, using OS_FUNCTION"
*/
# define OS_PRETTY_FUNCTION OS_FUNCTION
#endif
#define ISOCPP_DDSC_RESULT_CHECK_AND_THROW(code, ...) \
org::eclipse::cyclonedds::core::utils::check_ddsc_result_and_throw_exception( \
static_cast<dds_return_t>(code), \
__FILE__, \
__LINE__, \
OS_PRETTY_FUNCTION, \
__VA_ARGS__) \
#define ISOCPP_THROW_EXCEPTION(code, ...) \
org::eclipse::cyclonedds::core::utils::throw_exception( \
(code), \
__FILE__, \
__LINE__, \
OS_PRETTY_FUNCTION, \
__VA_ARGS__) \
#define ISOCPP_BOOL_CHECK_AND_THROW(test, code, ...) \
if (!(test)) { \
ISOCPP_THROW_EXCEPTION(code, __VA_ARGS__); \
}
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
namespace utils
{
const int32_t error_code = 1;
const int32_t unsupported_error_code = 2;
const int32_t invalid_argument_code = 3;
const int32_t precondition_not_met_error_code = 4;
const int32_t out_of_resources_error_code = 5;
const int32_t not_enabled_error_code = 6;
const int32_t immutable_policy_error_code = 7;
const int32_t inconsistent_policy_error_code = 8;
const int32_t already_closed_error_code = 9;
const int32_t timeout_error_code = 10;
const int32_t no_data_error_code = 11;
const int32_t illegal_operation_error_code = 12;
const int32_t null_reference_error_code = 13;
OMG_DDS_API void
report(
int32_t code,
int32_t reportType,
const char *file,
int32_t line,
const char *signature,
const char *format,
...);
OMG_DDS_API void
throw_exception(
int32_t code,
const char *file,
int32_t line,
const char *signature,
const char *format,
...);
OMG_DDS_API void
check_ddsc_result_and_throw_exception(
dds_return_t code,
const char *file,
int32_t line,
const char *signature,
const char *format,
...);
}
}
}
}
}
#endif /* CYCLONEDDS_CORE_REPORT_UTILS_HPP_ */

View File

@@ -0,0 +1,103 @@
/*
* 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_CORE_SCOPEDLOCK_HPP_
#define CYCLONEDDS_CORE_SCOPEDLOCK_HPP_
#include <org/eclipse/cyclonedds/core/Mutex.hpp>
#include <org/eclipse/cyclonedds/core/ObjectDelegate.hpp>
#include <cassert>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
template <typename LOCKABLE>
class OMG_DDS_API ScopedLock
{
public:
ScopedLock(const LOCKABLE& obj, bool lock = true)
: lockable(obj),
owner(lock)
{
if (lock) {
lockable.lock();
}
}
virtual ~ScopedLock()
{
if (owner) {
try {
lockable.unlock();
} catch (...) {
/* Don't know what to do anymore (it should have never failed)... */
assert(false);
}
}
}
void lock()
{
assert(!owner);
lockable.lock();
owner = true;
}
bool try_lock()
{
bool locked;
locked = lockable.try_lock();
if (locked) {
owner = true;
}
return locked;
}
void unlock()
{
assert(owner);
owner = false;
lockable.unlock();
}
bool own() const
{
return owner;
}
private:
const LOCKABLE& lockable;
bool owner;
};
typedef ScopedLock<Mutex> ScopedMutexLock;
typedef ScopedLock<ObjectDelegate> ScopedObjectLock;
}
}
}
}
#endif /* CYCLONEDDS_CORE_SCOPEDLOCK_HPP_ */

View File

@@ -0,0 +1,91 @@
/*
* 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
*
* Unfortunately, we need this because we can not change the Duration.hpp and Time.hpp
* and we don't want this piece of code repeated in every function within their
* implementation files.
*/
#ifndef CYCLONEDDS_CORE_TIME_HELPER_HPP_
#define CYCLONEDDS_CORE_TIME_HELPER_HPP_
#include <sstream>
#include <dds/dds.h>
#include <org/eclipse/cyclonedds/core/ReportUtils.hpp>
#define MS 1000
#define MiS 1000000
#define NS 1000000000
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
namespace timehelper
{
/**
* Check if the TIMEISH value supplied is at all suitable for arithmetic jiggery
* pokery. Invalidity encompasses (but is not restricted to) a -1 seconds part
* an 'infinity' Duration, an 'invalid' Time (or Duration).
* @param t the TIMEISH thing to check
* @return true if the argument is not suitable for doing sums with.
*/
template <typename TIMEISH>
bool is_valid_for_arithmetic(const TIMEISH& t)
{
return (t.sec() != -1 // Invalid
&& t.sec() != 0x7FFFFFFF // Infinity
&& t.nanosec() < 1000000000); // Invalid & infinity are > 10^9
}
/**
* Check a TIMEISH is valid for doing sums with.
* @param t the TIMEISH thing to check
* @param context Some sort of clue to the receiver about what was
* called or what you were trying to do. Must be a literal or c_str.
* Defaults to "".
* @param function String to be concateneated onto context.
* Must be a literal or c_str. Defaults to "".
* @throws a dds::core::InvalidDataError if not valid.
* @see OSPL_CONTEXT_LITERAL
* @see is_valid_for_arithmetic
*/
template <typename TIMEISH>
void validate(const TIMEISH& t, const char* context = "timehelper", const char* function = "validate")
{
if(! is_valid_for_arithmetic<TIMEISH>(t))
{
std::stringstream message("dds::core::InvalidDataError");
message << "Value invalid for arithmetic operations" << context << function
<< " seconds=" << t.sec() << " (" << std::hex << t.sec()
<< ") nanoseconds=" << t.nanosec() << " (" << std::hex << t.nanosec() << ")";
ISOCPP_THROW_EXCEPTION(ISOCPP_ILLEGAL_OPERATION_ERROR, message.str().c_str());
}
}
}
}
}
}
}
#endif /* CYCLONEDDS_CORE_TIME_HELPER_HPP_ */

View File

@@ -0,0 +1,47 @@
/*
* 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_CORE_WEAK_REFERENCE_SET_HPP_
#define CYCLONEDDS_CORE_WEAK_REFERENCE_SET_HPP_
#include <dds/core/macros.hpp>
#include <memory>
#include <set>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
template <typename T>
struct WeakReferenceSet
{
typedef typename std::set<T, std::owner_less<T> > wset;
typedef typename std::set<T, std::owner_less<T> >::iterator iterator;
};
}
}
}
}
#endif /* CYCLONEDDS_CORE_WEAK_REFERENCE_SET_HPP_ */

View File

@@ -0,0 +1,122 @@
/*
* Copyright(c) 2021 to 2022 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 BASIC_CDR_SERIALIZATION_HPP_
#define BASIC_CDR_SERIALIZATION_HPP_
#include "cdr_stream.hpp"
namespace org {
namespace eclipse {
namespace cyclonedds {
namespace core {
namespace cdr {
/**
* @brief
* Implementation of the basic cdr stream.
*
* This type of cdr stream has a maximum alignment of 8 bytes.
*/
class OMG_DDS_API basic_cdr_stream : public cdr_stream {
public:
/**
* @brief
* Constructor.
*
* Basically a pass through for the cdr_stream base class.
*
* @param[in] end The endianness to set for the data stream, default to the local system endianness.
* @param[in] ignore_faults Bitmask for ignoring faults, can be composed of bit fields from the serialization_status enumerator.
*/
basic_cdr_stream(endianness end = native_endianness(), uint64_t ignore_faults = 0x0) : cdr_stream(end, 8, ignore_faults) { ; }
/**
* @brief
* Start a new struct.
*
* This function is called by the generated streaming functions, and will start a parameter list, if that is relevant for it.
*
* @param[in, out] props The entity whose members might be represented by a parameter list.
*
* @return Whether the operation was completed succesfully.
*/
bool start_struct(entity_properties_t &props);
};
/**
* @brief
* Enumerated type stream manipulation functions.
* Since enumerated types are represented by a uint32_t in basic CDR streams
* they just loop through to writing uint32_t versions of the enum.
*
* These are "endpoints" for write functions, since compound
* (sequence/array/constructed type) functions will decay to these
* calls.
*/
/**
* @brief
* Reads the value of the enum from the stream.
*
* @param[in, out] str The stream which is read from.
* @param[out] toread The variable to read into.
* @param[in] N The number of entities to read.
*/
template<typename T, std::enable_if_t<std::is_enum<T>::value && !std::is_arithmetic<T>::value, bool> = true >
bool read(basic_cdr_stream& str, T& toread, size_t N = 1) {
return read_enum_impl<basic_cdr_stream,T,uint32_t>(str, toread, N);
}
/**
* @brief
* Writes the value of the enum to the stream.
*
* @param[in, out] str The stream which is written to.
* @param[in] towrite The variable to write.
* @param[in] N The number of entities to write.
*/
template<typename T, std::enable_if_t<std::is_enum<T>::value && !std::is_arithmetic<T>::value, bool> = true >
bool write(basic_cdr_stream& str, const T& towrite, size_t N = 1) {
return write_enum_impl<basic_cdr_stream,T,uint32_t>(str, towrite, N);
}
/**
* @brief
* Moves the cursor of the stream by the size the enum would take up.
*
* @param[in, out] str The stream whose cursor is moved.
* @param[in] N The number of entities to move.
*/
template<typename T, std::enable_if_t<std::is_enum<T>::value && !std::is_arithmetic<T>::value, bool> = true >
bool move(basic_cdr_stream& str, const T&, size_t N = 1) {
return move(str, uint32_t(0), N);
}
/**
* @brief
* Moves the cursor of the stream by the size the enum would take up (maximum size version).
*
* @param[in, out] str The stream whose cursor is moved.
* @param[in] N The number of entities at most to move.
*/
template<typename T, std::enable_if_t<std::is_enum<T>::value && !std::is_arithmetic<T>::value, bool> = true >
bool max(basic_cdr_stream& str, const T&, size_t N = 1) {
return max(str, uint32_t(0), N);
}
}
}
}
}
} /* namespace org / eclipse / cyclonedds / core / cdr */
#endif

View File

@@ -0,0 +1,64 @@
/*
* Copyright(c) 2021 to 2022 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 CDR_ENUMS_HPP_
#define CDR_ENUMS_HPP_
namespace org {
namespace eclipse {
namespace cyclonedds {
namespace core {
namespace cdr {
/**
* @brief
* Entity extensibility descriptors.
*
* @enum extensibility Describes the extensibility of entities.
*
* This value is set for entities and their parents.
*
* @var extensibility::ext_final The entity representation is complete, no fields can be added or removed.
* @var extensibility::ext_appendable The entity representation can be extended, no fields can be removed.
* @var extensibility::ext_mutable The entity representation can be modified, fields can be removed or added.
*/
enum class extensibility {
ext_final,
ext_appendable,
ext_mutable
};
/**
* @brief
* Encoding version descriptors.
*
* @enum encoding_version Describes the CDR encoding version of entities.
*
* @var encoding_version::basic_cdr Basic CDR encoding, does not support any xtypes functionality.
* @xml encoding_version::xml XML encoding.
* @var encoding_version::xcdr_v1 Version 1 Xtypes CDR encoding (deprecated).
* @var encoding_version::xcdr_v2 Version 2 XTypes CDR encoding.
*/
enum class encoding_version {
basic_cdr,
xml,
xcdr_v1,
xcdr_v2
};
typedef uint32_t allowable_encodings_t;
}
}
}
}
} /* namespace org / eclipse / cyclonedds / core / cdr */
#endif

View File

@@ -0,0 +1,935 @@
/*
* Copyright(c) 2021 to 2022 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 CDR_STREAM_HPP_
#define CDR_STREAM_HPP_
#include "dds/ddsrt/endian.h"
#include <org/eclipse/cyclonedds/core/type_helpers.hpp>
#include <org/eclipse/cyclonedds/core/cdr/entity_properties.hpp>
#include <stdint.h>
#include <string>
#include <stdexcept>
#include <stack>
#include <cassert>
#include <dds/core/macros.hpp>
namespace org {
namespace eclipse {
namespace cyclonedds {
namespace core {
namespace cdr {
/**
* @brief
* Custom stack implementation.
*/
template<typename T, size_t N>
class custom_stack {
static_assert(N > 0, "Stack capacity must be larger than 0");
T data[N];
size_t sz = 0;
public:
custom_stack() = default;
custom_stack(const T &in) {data[0] = in; sz = 1;}
T &top() {return data[sz-1];}
const T& top() const {return data[sz-1];}
void pop() {sz--;}
void push(const T &in) {data[sz++] = in;}
void reset() {sz = 0;}
size_t size() const {return sz;}
};
/**
* @brief
* Enum conversion and validation function template forward declaration.
*
* This function is generated for each enumerated class encountered in the parsed .idl files.
* Converts an integer value to the corresponding enum class value, or its default value
* if there is no enum equivalent to the int.
*
* @param[in] in The integer to convert to the enumerated class.
*
* @return The enumerator representation of in.
*/
template<typename E>
E enum_conversion(uint32_t in);
/**
* @brief
* Byte swapping function, is only enabled for arithmetic (base) types.
*
* Determines the number of bytes to swap by the size of the template parameter.
*
* @param[in, out] toswap The entity whose bytes will be swapped.
*/
template<typename T, typename = std::enable_if_t<std::is_arithmetic<T>::value> >
void byte_swap(T& toswap) {
union { T a; uint16_t u2; uint32_t u4; uint64_t u8; } u;
u.a = toswap;
DDSCXX_WARNING_MSVC_OFF(6326)
switch (sizeof(T)) {
case 1:
break;
case 2:
u.u2 = static_cast<uint16_t>((u.u2 & 0xFF00) >> 8)
| static_cast<uint16_t>((u.u2 & 0x00FF) << 8);
break;
case 4:
u.u4 = static_cast<uint32_t>((u.u4 & 0xFFFF0000) >> 16)
| static_cast<uint32_t>((u.u4 & 0x0000FFFF) << 16);
u.u4 = static_cast<uint32_t>((u.u4 & 0xFF00FF00) >> 8)
| static_cast<uint32_t>((u.u4 & 0x00FF00FF) << 8);
break;
case 8:
u.u8 = static_cast<uint64_t>((u.u8 & 0xFFFFFFFF00000000) >> 32)
| static_cast<uint64_t>((u.u8 & 0x00000000FFFFFFFF) << 32);
u.u8 = static_cast<uint64_t>((u.u8 & 0xFFFF0000FFFF0000) >> 16)
| static_cast<uint64_t>((u.u8 & 0x0000FFFF0000FFFF) << 16);
u.u8 = static_cast<uint64_t>((u.u8 & 0xFF00FF00FF00FF00) >> 8)
| static_cast<uint64_t>((u.u8 & 0x00FF00FF00FF00FF) << 8);
break;
default:
throw std::invalid_argument(std::string("attempted byteswap on variable of invalid size: ") + std::to_string(sizeof(T)));
}
DDSCXX_WARNING_MSVC_ON(6326)
toswap = u.a;
}
/**
* @brief
* Endianness types.
*
* @enum endianness C++ implementation of cyclonedds's DDSRT_ENDIAN endianness defines
*
* @var endianness::little_endian Little endianness.
* @var endianness::big_endian Big endianness.
*/
enum class endianness {
little_endian = DDSRT_LITTLE_ENDIAN,
big_endian = DDSRT_BIG_ENDIAN
};
/**
* @brief
* Returns the endianness of the local system.
*
* Takes the value from the DDSRT_ENDIAN definition and converts it to the c++ enum class value.
*
* @retval little_endian If the system is little endian.
* @retval big_endian If the system is big endian.
*/
constexpr endianness native_endianness() { return endianness(DDSRT_ENDIAN); }
/**
* @brief
* Serialization status bitmasks.
*
* @enum serialization_status Describes the serialization status of a cdr stream.
*
* These are stored as an bitfields in an int in cdr streams, since more than one serialization fault can be encountered.
*
* @var serialization_status::move_bound_exceeded The serialization has encountered a field which has exceeded the bounds set for it.
* @var serialization_status::write_bound_exceeded The serialization has encountered a field which has exceeded the bounds set for it.
* @var serialization_status::read_bound_exceeded The serialization has encountered a field which has exceeded the bounds set for it.
* @var serialization_status::illegal_field_value The serialization has encountered a field with a value which should never occur in a valid CDR stream.
* @var serialization_status::invalid_pl_entry The serialization has encountered a parameter list id which is illegal (not extended id in reserved for OMG space).
* @var serialization_status::unsupported_xtypes A streamer has attempted to stream a struct requiring xtypes but not supporting it itself.
* @var serialization_status::must_understand_fail A struct being read contains a field that must be understood but does not recognize or have.
*/
enum serialization_status : uint64_t {
move_bound_exceeded = 0x1 << 0,
write_bound_exceeded = 0x1 << 1,
read_bound_exceeded = 0x1 << 2,
invalid_pl_entry = 0x1 << 3,
illegal_field_value = 0x1 << 4,
unsupported_xtypes = 0x1 << 5,
must_understand_fail = 0x1 << 6
};
/**
* @brief
* Base cdr_stream class.
*
* This class implements the base functions which all "real" cdr stream implementations will use.
*/
class OMG_DDS_API cdr_stream {
public:
/**
* @brief
* Constructor.
*
* Sets the stream endianness to end, and maximum alignment to max_align.
*
* @param[in] end The endianness to set for the data stream, default to the local system endianness.
* @param[in] max_align The maximum size that the stream will align CDR primitives to.
* @param[in] ignore_faults Bitmask for ignoring faults, can be composed of bit fields from the serialization_status enumerator.
*/
cdr_stream(endianness end, size_t max_align, uint64_t ignore_faults = 0x0) : m_stream_endianness(end), m_max_alignment(max_align), m_fault_mask(~ignore_faults), m_swap(native_endianness() != m_stream_endianness) { ; }
/**
* @brief
* Returns the current stream alignment.
*
* @return The current stream alignment.
*/
size_t alignment() const { return m_current_alignment; }
/**
* @brief
* Sets the new stream alignment.
*
* Also returns the value the alignment has been set to.
*
* @param[in] newalignment The new alignment to set.
*
* @return The value the alignment has been set to.
*/
size_t alignment(size_t newalignment) { return m_current_alignment = newalignment; }
/**
* @brief
* Checks whether a delimited cdr stream is not being read out of bounds.
*
* This function will return true if N bytes can be read from the stream.
*
* @param[in] N The number of bytes requested.
* @param[in] peek Whether this is true access, or just a "peek".
*
* @return Whether enough bytes are available for another header.
*/
bool bytes_available(size_t N = 1, bool peek = false);
/**
* @brief
* Returns the current cursor offset.
*
* @retval SIZE_MAX In this case, a maximum size calculation was being done, and the maximum size was determined to be unbounded.
* @return The current cursor offset.
*/
inline size_t position() const { return m_position; }
/**
* @brief
* Sets the new cursor offset.
*
* Also returs the value the offset has been set to.
*
* @param[in] newposition The new offset to set.
*
* @return The value the offset has been set to.
*/
size_t position(size_t newposition) { return m_position = newposition; }
/**
* @brief
* Cursor move function.
*
* Moves the current position offset by incr_by if it is not at SIZE_MAX.
* Returns the position value after this operation.
*
* @param[in] incr_by The amount to move the cursor position by.
*
* @return The cursor position after this operation.
*/
size_t incr_position(size_t incr_by) { if (m_position != SIZE_MAX) m_position += incr_by; return m_position; }
/**
* @brief
* Resets the state of the stream as before streaming began.
*
* Will set the current offset, alignment to 0, clear the stack and fault status.
* Will retain the buffer pointer and size.
*/
virtual void reset();
/**
* @brief
* Buffer set function.
*
* Sets the buffer pointer to toset.
* As a side effect, the current position and alignment are reset, since these are not associated with the new buffer.
*
* @param[in] toset The new pointer of the buffer to set.
* @param[in] buffer_size The size of the buffer being set.
*/
void set_buffer(void* toset, size_t buffer_size = SIZE_MAX);
/**
* @brief
* Gets the current cursor pointer.
*
* If the current position is SIZE_MAX or the buffer pointer is not set, it returns nullptr.
*
* @retval nullptr If the current buffer is not set, or if the cursor offset is not valid.
* @return The current cursor pointer.
*/
inline char* get_cursor() const { return m_buffer + m_position; }
/**
* @brief
* Const stream endianness getter (const).
*
* This is used to determine whether the data read or written from the stream needs to have their bytes swapped.
*
* @return The stream endianness.
*/
const endianness& stream_endianness() const { return m_stream_endianness; }
/**
* @brief
* Determines whether the local and stream endianness are the same.
*
* This is used to determine whether the data read or written from the stream needs to have their bytes swapped.
*
* @retval false If the stream endianness DOES match the local endianness.
* @retval true If the stream endianness DOES NOT match the local endianness.
*/
bool swap_endianness() const { return m_swap; }
/**
* @brief
* Aligns the current stream to a new alignment.
*
* Aligns the current stream to newalignment, moves the cursor be at newalignment.
* Aligns to maximum m_max_alignment (which is stream-type specific).
* Zeroes the bytes the cursor is moved if add_zeroes is true.
* Nothing happens if the stream is already aligned to newalignment.
*
* @param[in] newalignment The new alignment to align the stream to.
* @param[in] add_zeroes Whether the bytes that the cursor moves need to be zeroed.
*
* @return Whether the cursor could be moved by the required amount.
*/
bool align(size_t newalignment, bool add_zeroes);
/**
* @brief
* Returns the current status of serialization.
*
* Can be a composition of multiple bit fields from serialization_status.
*
* @return The current status of serialization.
*/
uint64_t status() const { return m_status; }
/**
* @brief
* Serialization status update function.
*
* Adds to the current status of serialization and returns whether abort status has been reached.
*
* @param[in] toadd The serialization status error to add.
*
* @retval false If the serialization status of the stream HAS NOT YET reached one of the serialization errors which it is not set to ignore.
* @retval true If the serialization status of the stream HAS reached one of the serialization errors which it is not set to ignore.
*/
bool status(serialization_status toadd) { m_status |= static_cast<uint64_t>(toadd); return abort_status(); }
/**
* @brief
* Returns true when the stream has encountered an error which it is not set to ignore.
*
* All streaming functions should become NOOPs after this status is encountered.
*
* @retval false If the serialization status of the stream HAS NOT YET reached one of the serialization errors which it is not set to ignore.
* @retval true If the serialization status of the stream HAS reached one of the serialization errors which it is not set to ignore.
*/
inline bool abort_status() const { return m_status & m_fault_mask; }
/**
* @brief
* Type of streaming operation to be done.
*
* @var stream_mode::unset The stream mode is not set.
* @var stream_mode::read Reads from the stream into an instance.
* @var stream_mode::write Writes from the instance to the stream.
* @var stream_mode::move Moves the cursor by the same amount as would has been done through stream_mode::write, without copying any data to the stream.
* @var stream_mode::max Same as stream_mode::move, but by the maximum amount possible for an entity of that type.
*/
enum class stream_mode {
unset,
read,
write,
move,
max
};
/**
* @brief
* Returns whether the streaming is done only over the key values.
*
* @return Whether the streaming is done only over the key values.
*/
inline bool is_key() const {return m_key;}
/**
* @brief
* Function which sets the current streaming mode.
*
* This will impact which entities will be retrieved from the entity properties list.
* This will also reset the current cursor position.
*
* @param[in] mode The streaming mode to set for the stream.
* @param[in] key The key mode to set for the stream.
*/
void set_mode(stream_mode mode, bool key) {m_mode = mode; m_key = key; reset();}
/**
* @brief
* Function declaration for starting a new member.
*
* This function is called by next_entity for each entity which is iterated over.
* Depending on the implementation and mode headers may be read from/written to the stream.
* This function can be overridden in cdr streaming implementations.
*
* @param[in] prop Properties of the entity to start.
* @param[in] is_set Whether the entity represented by prop is present, if it is an optional entity.
*
* @return Whether the operation was completed succesfully.
*/
virtual bool start_member(entity_properties_t &prop, bool is_set = true) { prop.is_present = is_set; return true;}
/**
* @brief
* Function declaration for finishing an existing member.
*
* This function is called by next_entity for each entity which is iterated over.
* Depending on the implementation and mode header length fields may be completed.
* This function can be overridden in cdr streaming implementations.
*
* @param[in] is_set Whether the entity represented by prop is present, if it is an optional entity.
*
* @return Whether the operation was completed succesfully.
*/
virtual bool finish_member(entity_properties_t &, bool is_set = true) { (void) is_set; return true;}
/**
* @brief
* Function declaration for retrieving the next entity to be operated on by the streamer.
*
* This function is called by the instance implementation switchbox and will return the next entity to operate on by calling next_prop.
* This will also call the implementation specific push/pop entity functions to write/finish headers where necessary.
*
* @param[in, out] prop The property tree to get the next entity from.
*
* @return The next entity to be processed, or the final entity if the current tree level does not hold more entities.
*/
virtual entity_properties_t* next_entity(entity_properties_t *prop);
/**
* @brief
* Returns the first entity to be processed at this level.
*
* Depending on the data structure and the streaming mode, either a header is read from the stream, or a
* properties entry is pulled from the tree.
*
* @param[in, out] prop The property tree to get the next entity from.
*
* @return The first entity to be processed, or a nullptr if the current tree level does not hold any entities that match this tree.
*/
virtual entity_properties_t* first_entity(entity_properties_t *prop);
/**
* @brief
* Function declaration for starting a parameter list.
*
* This function is called by the generated functions for the entity, and will trigger the necessary actions on starting a new struct.
* I.E. starting a new parameter list, writing headers.
*
* @param[in,out] props The entity whose members might be represented by a parameter list.
*
* @return Whether the operation was completed succesfully.
*/
virtual bool start_struct(entity_properties_t &props);
/**
* @brief
* Function declaration for finishing a parameter list.
*
* This function is called by the generated functions for the entity, and will trigger the necessary actions on finishing the current struct.
* I.E. finishing headers, writing length fields.
*
* @param[in,out] props The entity whose members might be represented by a parameter list.
*
* @return Whether the struct is complete and correct.
*/
virtual bool finish_struct(entity_properties_t &props);
/**
* @brief
* Function declaration for starting an array or sequence of non-primitive types.
*
* This function is used to keep track of whether delimiters need to be and have been written to the stream.
* This function is an effective no-op for all streamers except xcdr_v2.
*
* @param[in] is_array True when the consecutive entries is an array, false when it is a sequence.
* @param[in] primitive Whether the consecutive entities are primitives (base types, not enums, strings, typedefs and arrays are resolved though)
*
* @return Always true.
*/
virtual bool start_consecutive(bool is_array, bool primitive) { (void) is_array; (void) primitive; return true;}
/**
* @brief
* Function declaration for finishing an array or sequence of non-primitive types.
*
* This function is an effective no-op for all streamers except xcdr_v2.
*
* @return Always true.
*/
virtual bool finish_consecutive() {return true;}
protected:
/**
* @brief Implementation for starting the recording the size and starting offset of a member.
*/
inline void push_member_start() { m_e_sz.push(0); m_e_off.push(static_cast<uint32_t>(position())); }
/**
* @brief Implementation for finishing the recording the size and starting offset of a member.
*/
inline void pop_member_start() { m_e_sz.pop(); m_e_off.pop(); }
/**
* @brief
* Checks the struct for completeness.
*
* Checks whether all fields which must be understood are present.
*
* @param[in,out] props The struct whose start is recorded.
*/
void check_struct_completeness(entity_properties_t &props);
/**
* @brief
* Returns the previous entity at the current level (if any).
*
* @param[in] prop Entity to the current entity.
*
* @return Pointer to the previous entity, or nullptr if there is any.
*/
entity_properties_t* previous_entity(entity_properties_t *prop);
static const size_t m_maximum_depth = 32; /**< the maximum depth of structures in the streamer*/
endianness m_stream_endianness; /**< the endianness of the stream*/
size_t m_position = 0, /**< the current offset position in the stream*/
m_max_alignment, /**< the maximum bytes that can be aligned to*/
m_current_alignment = 1, /**< the current alignment*/
m_buffer_size = 0; /**< the size of the current buffer*/
char* m_buffer = nullptr; /**< the current buffer in use*/
uint64_t m_status = 0, /**< the current status of streaming*/
m_fault_mask; /**< the mask for statuses that will cause streaming
to be aborted*/
stream_mode m_mode = stream_mode::unset; /**< the current streaming mode*/
bool m_key = false; /**< the current key mode*/
bool m_swap = false; /**< whether to swap endianness*/
DDSCXX_WARNING_MSVC_OFF(4251)
custom_stack<size_t, m_maximum_depth> m_buffer_end; /**< the end of reading at the current level*/
custom_stack<uint32_t, m_maximum_depth> m_e_off, /**< the offset of the entity at the current level*/
m_e_sz; /**< the size of the entity at the current level*/
DDSCXX_WARNING_MSVC_ON(4251)
};
/**
* @brief
* Primitive type stream manipulation functions.
*
* These are "endpoints" for write functions, since composit
* (sequence/array/constructed type) functions will decay to these
* calls.
*/
/**
* @brief
* Primitive type read function.
*
* Aligns the stream to the alignment of type T.
* Reads the value from the current position of the stream str into
* toread, will swap bytes if necessary.
* Moves the cursor of the stream by the size of T.
* This function is only enabled for arithmetic types and enums.
*
* @param[in, out] str The stream which is read from.
* @param[out] toread The variable to read into.
* @param[in] N The number of entities to read.
*
* @return Whether the operation was completed succesfully.
*/
template<typename S, typename T, std::enable_if_t<std::is_arithmetic<T>::value
&& !std::is_enum<T>::value
&& std::is_base_of<cdr_stream, S>::value, bool> = true >
bool read(S &str, T& toread, size_t N = 1)
{
if (str.position() == SIZE_MAX
|| !str.align(sizeof(T), false)
|| !str.bytes_available(sizeof(T)*N))
return false;
auto from = reinterpret_cast<const T*>(str.get_cursor());
T *to = &toread;
assert(from);
if (N == 1) {
toread = *from;
if (str.swap_endianness())
byte_swap(toread);
} else {
memcpy(to,from,sizeof(T)*N);
if (str.swap_endianness()) {
for (size_t i = 0; i < N; i++, to++)
byte_swap(*to);
}
}
str.incr_position(sizeof(T)*N);
return true;
}
/**
* @brief
* Enum type read function implementation.
*
* Uses the template parameter I to determine the stream-end read type,
* this type is determined by the stream implementation.
* Reads the enums as type I from the stream.
* Each read entity is verified by the enum's conversion version.
* This function is only enabled for enum types.
*
* @param[in, out] str The stream which is read from.
* @param[out] toread The variable to read.
* @param[in] N The number of entities to read.
*
* @return Whether the operation was completed succesfully.
*/
template<typename S, typename T, typename I, std::enable_if_t<std::is_integral<I>::value
&& std::is_enum<T>::value
&& std::is_base_of<cdr_stream, S>::value, bool> = true>
bool read_enum_impl(S& str, T& toread, size_t N)
{
T *ptr = &toread;
I holder = 0;
for (size_t i = 0; i < N; i++, ptr++)
{
if (!read(str, holder))
return false;
*ptr = enum_conversion<T>(holder);
}
return true;
}
/**
* @brief
* Primitive type write function.
*
* Aligns str to the type to be written.
* Writes towrite to str.
* Swaps bytes written to str if the endiannesses do not match up.
* Moves the cursor of str by the size of towrite.
* This function is only enabled for arithmetic types.
*
* @param[in, out] str The stream which is written to.
* @param[in] towrite The variable to write.
* @param[in] N The number of entities to write.
*
* @return Whether the operation was completed succesfully.
*/
template<typename S, typename T, std::enable_if_t<std::is_arithmetic<T>::value
&& !std::is_enum<T>::value
&& std::is_base_of<cdr_stream, S>::value, bool> = true >
bool write(S& str, const T& towrite, size_t N = 1)
{
if (str.position() == SIZE_MAX
|| !str.align(sizeof(T), true)
|| !str.bytes_available(sizeof(T)*N))
return false;
auto to = reinterpret_cast<T*>(str.get_cursor());
assert(to);
if (N == 1) {
*to = towrite;
if (str.swap_endianness())
byte_swap(*to);
} else {
const T *from = &towrite;
memcpy(to,from,sizeof(T)*N);
if (str.swap_endianness()) {
for (size_t i = 0; i < N; i++, to++)
byte_swap(*to);
}
}
str.incr_position(sizeof(T)*N);
return true;
}
/**
* @brief
* Enum type write function implementation.
*
* Uses the template parameter I to determine the stream-end write type,
* this type is determined by the stream implementation.
* Writes the enums as type I to the stream.
* If the enums have the same size as the integer stream type, they are written
* as a block, otherwise they are copied one by one.
* This function is only enabled for enum types.
*
* @param[in, out] str The stream which is written to.
* @param[in] towrite The variable to write.
* @param[in] N The number of entities to write.
*
* @return Whether the operation was completed succesfully.
*/
template<typename S, typename T, typename I, std::enable_if_t<std::is_integral<I>::value
&& std::is_enum<T>::value
&& std::is_base_of<cdr_stream, S>::value, bool> = true>
bool write_enum_impl(S& str, const T& towrite, size_t N)
{
const T *ptr = &towrite;
if (sizeof(T) == sizeof(I)) {
if (!write(str, *reinterpret_cast<const I*>(ptr), N))
return false;
} else {
for (size_t i = 0; i < N; i++, ptr++)
if (!write(str, *reinterpret_cast<const I*>(ptr)))
return false;
}
return true;
}
/**
* @brief
* Primitive type cursor move function.
*
* Used in determining the size of a type when written to the stream.
* Aligns str to the size of toincr.
* Moves the cursor of str by the size of toincr.
* This function is only enabled for arithmetic types.
*
* @param[in, out] str The stream whose cursor is moved.
* @param[in] N The number of entities to move.
*
* @return Whether the operation was completed succesfully.
*/
template<typename S, typename T, std::enable_if_t<std::is_arithmetic<T>::value
&& !std::is_enum<T>::value
&& std::is_base_of<cdr_stream, S>::value, bool> = true >
bool move(S& str, const T&, size_t N = 1)
{
if (str.position() == SIZE_MAX)
return true;
if (!str.align(sizeof(T), false))
return false;
str.incr_position(sizeof(T)*N);
return true;
}
/**
* @brief
* Primitive type max stream move function.
*
* Used in determining the maximum stream size of a constructed type.
* Moves the cursor to the maximum position it could occupy after
* writing max_sz to the stream.
* Is in essence the same as the primitive type cursor move function,
* but additionally checks for whether the cursor it at the "end",
* which may happen if unbounded members (strings/sequences/...)
* are part of the constructed type.
* This function is only enabled for arithmetic types.
*
* @param[in, out] str The stream whose cursor is moved.
* @param[in] max_sz The variable to move the cursor by, no contents of this variable are used, it is just used to determine the template.
* @param[in] N The number of entities at most to move.
*
* @return Whether the operation was completed succesfully.
*/
template<typename S, typename T, std::enable_if_t<std::is_arithmetic<T>::value
&& !std::is_enum<T>::value
&& std::is_base_of<cdr_stream, S>::value, bool> = true >
bool max(S& str, const T& max_sz, size_t N = 1)
{
return move(str, max_sz, N);
}
/**
* @brief
* String type stream manipulation functions
*
* These are "endpoints" for write functions, since compound
* (sequence/array/constructed type) functions will decay to these
* calls.
*/
/**
* @brief
* Bounded string read function.
*
* Reads the length from str, but then initializes toread with at most N characters from it.
* It does move the cursor by length read, since that is the number of characters in the stream.
* If N is 0, then the string is taken to be unbounded.
*
* @param[in, out] str The stream to read from.
* @param[out] toread The string to read to.
* @param[in] N The maximum number of characters to read from the stream.
*
* @return Whether the operation was completed succesfully.
*/
template<typename S, typename T, std::enable_if_t<std::is_base_of<cdr_stream, S>::value, bool> = true >
bool read_string(S& str, T& toread, size_t N)
{
if (str.position() == SIZE_MAX)
return false;
uint32_t string_length = 0;
if (!read(str, string_length)
|| !str.bytes_available(string_length))
return false;
if (string_length == 0
&& str.status(serialization_status::illegal_field_value))
return false;
if (N && string_length > N + 1)
return false;
auto cursor = str.get_cursor();
toread.assign(cursor, cursor + std::min<size_t>(string_length - 1, N ? N : SIZE_MAX)); //remove 1 for terminating NULL
str.incr_position(string_length);
//aligned to chars
str.alignment(1);
return true;
}
/**
* @brief
* Bounded string write function.
*
* Attempts to write the length of towrite to str, where the bound is checked.
* Then writes the contents of towrite to str.
* If N is 0, then the string is taken to be unbounded.
*
* @param[in, out] str The stream to write to.
* @param[in] towrite The string to write.
* @param[in] N The maximum number of characters to write to the stream.
*
* @return Whether the operation was completed succesfully.
*/
template<typename S, typename T, std::enable_if_t<std::is_base_of<cdr_stream, S>::value, bool> = true >
bool write_string(S& str, const T& towrite, size_t N)
{
if (str.position() == SIZE_MAX)
return false;
size_t string_length = towrite.length() + 1; //add 1 extra for terminating NULL
if (N
&& string_length > N + 1
&& str.status(serialization_status::write_bound_exceeded))
return false;
if (!write(str, uint32_t(string_length))
|| !str.bytes_available(string_length))
return false;
memcpy(str.get_cursor(), towrite.c_str(), string_length);
str.incr_position(string_length);
//aligned to chars
str.alignment(1);
return true;
}
/**
* @brief
* Bounded string cursor move function.
*
* Attempts to move the cursor for the length field, where the bound is checked.
* Then moves the cursor for the length of the string.
* If N is 0, then the string is taken to be unbounded.
*
* @param[in, out] str The stream whose cursor is moved.
* @param[in] toincr The string used to move the cursor.
* @param[in] N The maximum number of characters in the string which the stream is moved by.
*
* @return Whether the operation was completed succesfully.
*/
template<typename S, typename T, std::enable_if_t<std::is_base_of<cdr_stream, S>::value, bool> = true >
bool move_string(S& str, const T& toincr, size_t N)
{
if (str.position() == SIZE_MAX)
return true;
size_t string_length = toincr.length() + 1; //add 1 extra for terminating NULL
if (N
&& string_length > N + 1
&& str.status(serialization_status::move_bound_exceeded))
return false;
if (!move(str, uint32_t()))
return false;
str.incr_position(string_length);
//aligned to chars
str.alignment(1);
return true;
}
/**
* @brief
* Bounded string cursor max move function.
*
* Similar to the string move function, with the additional checks that no move
* is done if the cursor is already at its maximum position, and that the cursor
* is set to its maximum position if the bound is equal to 0 (unbounded).
*
* @param[in, out] str The stream whose cursor is moved.
* @param[in] max_sz The string used to move the cursor.
* @param[in] N The maximum number of characters in the string which the stream is at most moved by.
*
* @return Whether the operation was completed succesfully.
*/
template<typename S, typename T, std::enable_if_t<std::is_base_of<cdr_stream, S>::value, bool> = true >
bool max_string(S& str, const T& max_sz, size_t N)
{
if (N == 0)
str.position(SIZE_MAX); //unbounded string, theoretical length unlimited
else
return move_string(str, max_sz, N);
return true;
}
}
}
}
}
} /* namespace org / eclipse / cyclonedds / core / cdr */
#endif

View File

@@ -0,0 +1,265 @@
/*
* Copyright(c) 2021 to 2022 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 ENTITY_PROPERTIES_HPP_
#define ENTITY_PROPERTIES_HPP_
#include <dds/core/macros.hpp>
#include <cstdint>
#include <list>
#include <vector>
#include <map>
#include <atomic>
#include <mutex>
#if DDSCXX_USE_BOOST
#include <boost/type_traits.hpp>
#define DDSCXX_STD_IMPL boost
#else
#include <type_traits>
#define DDSCXX_STD_IMPL std
#endif
#include "cdr_enums.hpp"
namespace org {
namespace eclipse {
namespace cyclonedds {
namespace core {
namespace cdr {
#define decl_ref_type(x) DDSCXX_STD_IMPL::remove_cv_t<DDSCXX_STD_IMPL::remove_reference_t<decltype(x)>>
/**
* @brief
* Bit bound descriptors.
*
* @enum bit_bound Describes the minimal bit width for enum and bitmask types.
*
* This value is unset for anything other than enums and bitmasks.
* It describes the smallest piece of memory which is able to represent the entire range of values.
*
* @var bit_bound::bb_unset The bit width of the entity is unset.
* @var bit_bound::bb_8_bits The bit width of the entity is at most 8 bits (1 byte).
* @var bit_bound::bb_16_bits The bit width of the entity is at most 16 bits (2 bytes).
* @var bit_bound::bb_32_bits The bit width of the entity is at most 32 bits (4 bytes).
* @var bit_bound::bb_64_bits The bit width of the entity is at most 64 bits (8 bytes).
*/
enum bit_bound {
bb_unset = 0,
bb_8_bits = 1,
bb_16_bits = 2,
bb_32_bits = 4,
bb_64_bits = 8
};
/**
* @brief
* Helper struct to keep track of key endpoints of the a struct
*/
DDSCXX_WARNING_MSVC_OFF(4251)
class OMG_DDS_API key_endpoint: public std::map<uint32_t, key_endpoint> {
DDSCXX_WARNING_MSVC_ON(4251)
public:
void add_key_endpoint(const std::list<uint32_t> &key_indices);
operator bool() const {return !empty();}
};
/**
* @brief
* Primitive type/enum get_bit_bound function.
*
* Returns a bb_unset for all primitive types and enums.
* This function will be implemented for all enums with a manually defined bit_bound.
*
* @return The bit bound for the primitive type.
*/
template<typename T, DDSCXX_STD_IMPL::enable_if_t<std::is_arithmetic<T>::value || std::is_enum<T>::value, bool> = true >
bit_bound get_bit_bound() {
switch (sizeof(T)) {
case 1:
return bb_8_bits;
break;
case 2:
return bb_16_bits;
break;
case 4:
return bb_32_bits;
break;
case 8:
return bb_64_bits;
break;
default:
return bb_unset;
}
}
/**
* @brief
* Generic get_bit_bound fallback function.
*
* Returns a bb_unset for all non-primitive, non-enum types.
*
* @return bb_unset always.
*/
template<typename T, DDSCXX_STD_IMPL::enable_if_t<!std::is_enum<T>::value && !std::is_arithmetic<T>::value, bool> = true >
constexpr bit_bound get_bit_bound() { return bb_unset;}
typedef struct entity_properties entity_properties_t;
typedef std::vector<entity_properties_t> propvec;
/**
* @brief
* Entity properties struct.
*
* This is a container for data fields inside message classes, both as a representation passed for writing
* as well as headers taken from streams when reading in the appropriate manner.
* Normally these are not used by the end-user, and the streaming functions all interact with these objects
* through the get_type_props function, which is generated for all user supplied message types.
*/
struct OMG_DDS_API entity_properties
{
entity_properties(
uint32_t _depth = 0,
uint32_t _m_id = 0,
bool _is_optional = false,
bit_bound _bb = bb_unset,
extensibility _ext = extensibility::ext_final,
bool _must_understand = true):
e_ext(_ext),
m_id(_m_id),
depth(_depth),
must_understand(_must_understand),
xtypes_necessary(_ext != extensibility::ext_final || _is_optional),
is_optional(_is_optional),
e_bb(_bb) {;}
extensibility e_ext = extensibility::ext_final; /**< The extensibility of the entity itself. */
extensibility p_ext = extensibility::ext_final; /**< The extensibility of the entity's parent. */
uint32_t m_id = 0; /**< The member id of the entity, it is the global field by which the entity is identified. */
uint32_t depth = 0; /**< The depth of this entity.*/
bool must_understand = false; /**< If the reading end cannot parse a field with this header, it must discard the entire object.*/
bool xtypes_necessary = false; /**< Is set if any of the members of this entity require xtypes support.*/
bool implementation_extension = false; /**< Can be set in XCDR_v1 stream parameter list headers.*/
bool ignore = false; /**< Indicates that this field must be ignored.*/
bool is_optional = false; /**< Indicates that this field can be empty (length 0) for reading/writing purposes.*/
bool is_key = false; /**< Indicates that this field is a key field.*/
bool is_present = false; /**< Indicates that this entity is present in the read stream.*/
bit_bound e_bb = bb_unset; /**< The minimum number of bytes necessary to represent this entity/bitmask.*/
entity_properties_t *next_on_level = nullptr, /**< Pointer to the next entity on the same level.*/
*prev_on_level = nullptr, /**< Pointer to the previous entity on the same level.*/
*parent = nullptr, /**< Pointer to the parent of this entity.*/
*first_member = nullptr; /**< Pointer to the first entity which is a member of this entity.*/
/**
* @brief
* Reset function.
*
* This function will reset the fields that may have been set through streaming (is_present).
*/
void reset();
/**
* @brief
* Print function.
*
* This function write the contents (id, is_key, is_optional, must_understand, xtypes_necessary) of this entity to std::cout.
*/
void print() const;
/**
* @brief
* Checks whether this entity is not keyless.
*
* This function will check all members (if any) and if any of them has the is_key flag set, this will return true.
* If none have this flag set, it will return false.
* Used in the finish function to finish the entire entity_properties_t tree.
*
* @return true if any of the members have a key, false otherwise.
*/
bool has_keys() const;
/**
* @brief
* Sets is_key flags on members.
*
* This function will set is_key flags on all members if the entity is keyless
* and will recursively call this on all members with the is_key flag set.
* Used in the finish function to finish the entire entity_properties_t tree.
*/
void set_key_values();
/**
* @brief
* Removes all is_key flags from members.
*
* This function will set all is_key flags of members of this entity to false.
* Used in the finish function to finish the entire entity_properties_t tree.
*/
void erase_key_values();
/**
* @brief
* Finishes a tree representing an entire datamodel.
*
* This function will set the next_on_level and prev_on_level pointers to create a sub linked list
* of the members of the entity at that level. Also it will set the parent pointer of member entities
* and the first_member pointer of entities which have sub entities (members).
* When all this is done, it will take the key information in the key_endpoint map to (un)set the is_key
* flags on all members.
*
* @param[in, out] props The list of entities representing the datamodel.
* @param[in] keys The map of key indices.
*/
static void finish(propvec &props, const key_endpoint &keys);
/**
* @brief
* Appends a sub tree to the current tree as a member.
*
* This function will take the contents of toappend, insert them at the end of appendto and increase the
* depth of all entities added. It is used to add a constructed type as a member of another constructed type.
*
* @param[in, out] appendto The tree to append to.
* @param[in] toappend The sub tree to append.
*/
static void append_struct_contents(propvec &appendto, const propvec &toappend);
/**
* @brief
* Prints the contents of a tree representing a datatype to the screen.
*
* @param[in] in The tree to print.
*/
static void print(const propvec &in);
};
/**
* @brief
* Forward declaration for type properties getter function.
*
* This template function is replaced/implemented by the types implemented through IDL generation.
* It generates a static container which is initialized the first time the function is called,
* this is then returned.
*
* @return propvec "Tree" representing the type.
*/
template<typename T>
propvec& get_type_props();
}
}
}
}
} /* namespace org / eclipse / cyclonedds / core / cdr */
#endif

View File

@@ -0,0 +1,344 @@
/*
* Copyright(c) 2021 to 2022 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 EXTENDED_CDR_SERIALIZATION_V1_HPP_
#define EXTENDED_CDR_SERIALIZATION_V1_HPP_
#include "cdr_stream.hpp"
namespace org {
namespace eclipse {
namespace cyclonedds {
namespace core {
namespace cdr {
/**
* @brief
* Implementation of the extended cdr version1 stream.
*
* This type of cdr stream has a maximum alignment of 8 bytes.
*/
class OMG_DDS_API xcdr_v1_stream : public cdr_stream {
public:
/**
* @brief
* Constructor.
*
* Basically a pass through for the cdr_stream base class.
*
* @param[in] end The endianness to set for the data stream, default to the local system endianness.
* @param[in] ignore_faults Bitmask for ignoring faults, can be composed of bit fields from the serialization_status enumerator.
*/
xcdr_v1_stream(endianness end = native_endianness(), uint64_t ignore_faults = 0x0) : cdr_stream(end, 8, ignore_faults) { ; }
/**
* @brief
* Starts a new member.
*
* Determines whether a header is necessary for this entity through header_necessary, and if it is, handles the header.
*
* @param[in, out] prop Properties of the member to start.
* @param[in] is_set Whether the entity represented by prop is present, if it is an optional entity.
*
* @return Whether the operation was completed succesfully.
*/
bool start_member(entity_properties_t &prop, bool is_set = true);
/**
* @brief
* Finishes a member.
*
* Determines whether a header is necessary for this entity through header_necessary, and if it is, completes the previous header.
*
* @param[in, out] prop Properties of the member to finish.
* @param[in] is_set Whether the entity represented by prop is present, if it is an optional entity.
*
* @return Whether the operation was completed succesfully.
*/
bool finish_member(entity_properties_t &prop, bool is_set = true);
/**
* @brief
* Returns the next entity to be processed at this level.
*
* Depending on the data structure and the streaming mode, either a header is read from the stream, or a
* properties entry is pulled from the tree.
*
* @param[in, out] prop The property tree to get the next entity from.
*
* @return The next entity to be processed, or a nullptr if the current tree level does not hold more entities that match this tree.
*/
entity_properties_t* next_entity(entity_properties_t *prop);
/**
* @brief
* Returns the first entity to be processed at this level.
*
* Depending on the data structure and the streaming mode, either a header is read from the stream, or a
* properties entry is pulled from the tree.
*
* @param[in, out] prop The property tree to get the next entity from.
*
* @return The first entity to be processed, or a nullptr if the current tree level does not hold any entities that match this tree.
*/
entity_properties_t *first_entity(entity_properties_t *prop);
/**
* @brief
* Finishes the current struct.
*
* Adds the final parameter list entry if necessary when writing to the stream.
*
* @param[in, out] props The property tree to get the next entity from.
*
* @return Whether the struct is complete and correct.
*/
bool finish_struct(entity_properties_t &props);
private:
static const uint16_t pid_mask; /**< the mask for non-extended parameter list ids*/
static const uint16_t pid_extended; /**< indicating an extended entry*/
static const uint16_t pid_list_end; /**< guardian entry indicating end of parameter list*/
static const uint16_t pid_ignore; /**< ignore this entry*/
static const uint16_t pid_flag_impl_extension; /**< bit flag indicating implementation specific extension*/
static const uint16_t pid_flag_must_understand; /**< bit flag indicating that this entry must be parsed successfully or the entire sample must be discarded*/
static const uint32_t pl_extended_mask; /**< mask for extended parameter list ids*/
static const uint32_t pl_extended_flag_impl_extension; /**< bit flag indicating implementation specific extension*/
static const uint32_t pl_extended_flag_must_understand; /**< bit flag indicating that this entry must be parsed successfully or the entire sample must be discarded*/
/**
* @brief
* Returns the next entity to be processed.
*
* For optional members and members of mutable structures, a parameter list header field is necessary preceding
* the field contents itself.
*
* @param[in] props The properties of the entity.
*
* @return Whether a header is necessary for the entity.
*/
bool header_necessary(const entity_properties_t &props);
/**
* @brief
* Determines whether a parameter list is necessary.
*
* @param[in] props The entity whose members might be represented by a parameter list.
*
* @return Whether a parameter list is necessary for the entity.
*/
bool list_necessary(const entity_properties_t &props);
/**
* @brief
* Reads a header field from the stream.
*
* If header_necessary returns true for a field, then this function needs to be called first to read the
* header from stream and to allow the streamer to determine what to do with the field.
*
* @param[out] out The header to read into.
* @param[out] is_final Whether the final field has been read.
*
* @return Whether the header was read succesfully.
*/
bool read_header(entity_properties_t &out, bool &is_final);
/**
* @brief
* Writes a header field to the stream.
*
* If header_necessary returns true for a field, then this function needs to be called first to write the
* header to the stream before the contents of the field are written.
*
* @param[in, out] props The properties of the entity.
*
* @return Whether the header was read succesfully.
*/
bool write_header(entity_properties_t &props);
/**
* @brief
* Finishes a header field in the stream.
*
* Goes back to the offset of the length field that was unfinished in
*
* @param[in, out] props The properties of the entity.
*
* @return Whether the header was read succesfully.
*/
bool finish_write_header(entity_properties_t &props);
/**
* @brief
* Writes the terminating entry in a parameter list.
*
* @return Whether the header was read succesfully.
*/
bool write_final_list_entry();
/**
* @brief
* Moves the cursor as if writing the terminating entry in a parameter list.
*
* @return Whether the header was read succesfully.
*/
bool move_final_list_entry();
/**
* @brief
* Moves the stream offset by the amount that would have been written by write_header.
*
* This function needs to be called first to move the stream by the same amount the header would
* have taken up, if it would have been written.
*
* @param[in] props The entity to move the cursor by.
*
* @return Whether the header was read succesfully.
*/
bool move_header(const entity_properties_t &props);
/**
* @brief
* Determines whether to use extended format header.
*
* An extended header is necessary for entities with a size larger than 65535 bytes or entities with
* a member id larger than 16128.
*
* @param[in] props The entity to check.
*
* @return Whether an extended format header is necessary.
*/
static bool extended_header(const entity_properties_t &props);
};
/**
* @brief
* Enumerated type stream manipulation functions.
* Depending on the number coverage of the enum, it will be written
* to the stream as an uint8_t, an uint16_t or a uint32_t.
*
* These are "endpoints" for write functions, since compound
* (sequence/array/constructed type) functions will decay to these
* calls.
*/
/**
* @brief
* Reads the value of the enum from the stream.
*
* @param[in, out] str The stream which is read from.
* @param[out] toread The variable to read into.
* @param[in] N The number of entities to read.
*
* @return Whether the operation was completed succesfully.
*/
template<typename T, std::enable_if_t<std::is_enum<T>::value && !std::is_arithmetic<T>::value, bool> = true >
bool read(xcdr_v1_stream& str, T& toread, size_t N = 1)
{
switch (str.is_key() ? bb_32_bits : get_bit_bound<T>())
{
case bb_8_bits:
return read_enum_impl<xcdr_v1_stream,T,uint8_t>(str, toread, N);
break;
case bb_16_bits:
return read_enum_impl<xcdr_v1_stream,T,uint16_t>(str, toread, N);
break;
case bb_32_bits:
return read_enum_impl<xcdr_v1_stream,T,uint32_t>(str, toread, N);
break;
default:
assert(false);
}
return true;
}
/**
* @brief
* Writes the value of the enum to the stream.
*
* @param[in, out] str The stream which is written to.
* @param[in] towrite The variable to write.
* @param[in] N The number of entities to write.
*
* @return Whether the operation was completed succesfully.
*/
template<typename T, std::enable_if_t<std::is_enum<T>::value && !std::is_arithmetic<T>::value, bool> = true >
bool write(xcdr_v1_stream& str, const T& towrite, size_t N = 1)
{
switch (str.is_key() ? bb_32_bits : get_bit_bound<T>())
{
case bb_8_bits:
return write_enum_impl<xcdr_v1_stream,T,uint8_t>(str, towrite, N);
break;
case bb_16_bits:
return write_enum_impl<xcdr_v1_stream,T,uint16_t>(str, towrite, N);
break;
case bb_32_bits:
return write_enum_impl<xcdr_v1_stream,T,uint32_t>(str, towrite, N);
break;
default:
assert(false);
}
return true;
}
/**
* @brief
* Moves the cursor of the stream by the size the enum would take up.
*
* @param[in, out] str The stream whose cursor is moved.
* @param[in] N The number of entities to move.
*
* @return Whether the operation was completed succesfully.
*/
template<typename T, std::enable_if_t<std::is_enum<T>::value && !std::is_arithmetic<T>::value, bool> = true >
bool move(xcdr_v1_stream& str, const T&, size_t N = 1)
{
switch (str.is_key() ? bb_32_bits : get_bit_bound<T>())
{
case bb_8_bits:
return move(str, int8_t(0), N);
break;
case bb_16_bits:
return move(str, int16_t(0), N);
break;
case bb_32_bits:
return move(str, int32_t(0), N);
break;
default:
assert(false);
}
return true;
}
/**
* @brief
* Moves the cursor of the stream by the size the enum would take up (maximum size version).
*
* @param[in, out] str The stream whose cursor is moved.
* @param[in] max_sz The variable to move the cursor by, no contents of this variable are used, it is just used to determine the template.
* @param[in] N The number of entities at most to move.
*
* @return Whether the operation was completed succesfully.
*/
template<typename T, std::enable_if_t<std::is_enum<T>::value && !std::is_arithmetic<T>::value, bool> = true >
bool max(xcdr_v1_stream& str, const T& max_sz, size_t N = 1)
{
return move(str, max_sz, N);
}
}
}
}
}
} /* namespace org / eclipse / cyclonedds / core / cdr */
#endif

View File

@@ -0,0 +1,409 @@
/*
* Copyright(c) 2021 to 2022 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 EXTENDED_CDR_SERIALIZATION_V2_HPP_
#define EXTENDED_CDR_SERIALIZATION_V2_HPP_
#include "cdr_stream.hpp"
namespace org {
namespace eclipse {
namespace cyclonedds {
namespace core {
namespace cdr {
/**
* @brief
* Implementation of the extended cdr version1 stream.
*
* This type of cdr stream has a maximum alignment of 8 bytes.
*/
class OMG_DDS_API xcdr_v2_stream : public cdr_stream {
public:
/**
* @brief
* Constructor.
*
* Basically a pass through for the cdr_stream base class.
*
* @param[in] end The endianness to set for the data stream, default to the local system endianness.
* @param[in] ignore_faults Bitmask for ignoring faults, can be composed of bit fields from the serialization_status enumerator.
*/
xcdr_v2_stream(endianness end = native_endianness(), uint64_t ignore_faults = 0x0) : cdr_stream(end, 4, ignore_faults) { ; }
/**
* @brief
* Resets the state of the stream as before streaming began.
*
* Will reset the stack of delimiters in addition to what is reset by cdr_stream::reset.
*/
void reset();
/**
* @brief
* Starts a new member.
*
* Determines whether a header is necessary for this entity through em_header_necessary, and if it is, handles the header.
*
* @param[in, out] prop Properties of the member to start.
* @param[in] is_set Whether the entity represented by prop is present, if it is an optional entity.
*/
bool start_member(entity_properties_t &prop, bool is_set = true);
/**
* @brief
* Finishes a member.
*
* Determines whether a header is necessary for this entity through em_header_necessary, and if it is, completes the previous header.
*
* @param[in, out] prop Properties of the member to finish.
* @param[in] is_set Whether the entity represented by prop is present, if it is an optional entity.
*
* @return Whether the operation was completed succesfully.
*/
bool finish_member(entity_properties_t &prop, bool is_set = true);
/**
* @brief
* Returns the next entity to be processed at this level.
*
* Depending on the data structure and the streaming mode, either a header is read from the stream, or a
* properties entry is pulled from the tree.
*
* @param[in, out] prop The property tree to get the next entity from.
*
* @return The next entity to be processed, or a nullptr if the current tree level does not hold more entities that match this tree.
*/
entity_properties_t* next_entity(entity_properties_t *prop);
/**
* @brief
* Returns the first entity to be processed at this level.
*
* Depending on the data structure and the streaming mode, either a header is read from the stream, or a
* properties entry is pulled from the tree.
*
* @param[in, out] prop The property tree to get the next entity from.
*
* @return The first entity to be processed, or a nullptr if the current tree level does not hold any entities that match this tree.
*/
entity_properties_t *first_entity(entity_properties_t *prop);
/**
* @brief
* Start a new struct.
*
* This function is called by the generated streaming functions, and will start a parameter list, if that is relevant for it.
*
* @param[in, out] props The entity whose members might be represented by a parameter list.
*
* @return Whether the operation was completed succesfully.
*/
bool start_struct(entity_properties_t &props);
/**
* @brief
* Finish the current struct.
*
* This function is called by the generated streaming functions, and will finish the current parameter list, if that is relevant for it.
*
* @param[in, out] props The entity whose members might be represented by a parameter list.
*
* @return Whether the struct is complete and correct.
*/
bool finish_struct(entity_properties_t &props);
/**
* @brief
* Function declaration for starting an array or sequence of non-primitive types.
*
* This function inserts a d-header placeholder before the start of the consecutive objects.
*
*@param[in] is_array True when the consecutive entries is an array, false when it is a sequence.
*@param[in] primitive Whether the consecutive entities are primitives (base types, not enums, strings, typedefs and arrays are resolved though)
*
* @return Whether the d-header was inserted correctly.
*/
bool start_consecutive(bool is_array, bool primitive);
/**
* @brief
* Function declaration for finishing an array or sequence of non-primitive types.
*
* This function finishes the d-header placeholder.
*
* @return Whether the d-header was finished correctly.
*/
bool finish_consecutive();
private:
typedef struct consecutives {
consecutives(bool is_array = false, bool d_header_present = false) : is_array(is_array), d_header_present(d_header_present) {}
bool is_array;
bool d_header_present;
} consecutives_t;
static const uint32_t bytes_1; /**< length field code indicating length is 1 byte*/
static const uint32_t bytes_2; /**< length field code indicating length is 2 bytes*/
static const uint32_t bytes_4; /**< length field code indicating length is 4 bytes*/
static const uint32_t bytes_8; /**< length field code indicating length is 8 bytes*/
static const uint32_t nextint; /**< length field code indicating length is the next integer field*/
static const uint32_t nextint_times_1; /**< same as nextint*/
static const uint32_t nextint_times_4; /**< length field code indicating length is the next integer field times 4*/
static const uint32_t nextint_times_8; /**< length field code indicating length is the next integer field times 8*/
static const uint32_t lc_mask; /**< mask for length field codes*/
static const uint32_t id_mask; /**< mask for member ids*/
static const uint32_t must_understand; /**< must understand member field flag*/
DDSCXX_WARNING_MSVC_OFF(4251)
custom_stack<consecutives_t, m_maximum_depth> m_consecutives; /**< stack of consecutive entries, uses to determine whether or not to finish a d_header*/
custom_stack<size_t, m_maximum_depth> m_delimiters; /**< locations of sequence delimiters */
DDSCXX_WARNING_MSVC_ON(4251)
/**
* @brief
* Reads a D-header from the stream.
*
* Will put the entity size into the streams m_buffer_end stack
*
* @return Whether the read was succesful.
*/
bool read_d_header();
/**
* @brief
* Reads an EM-header from the stream.
*
* @param[out] props The entity to read the EM-header into.
*
* @return Whether the read was succesful.
*/
bool read_em_header(entity_properties_t &props);
/**
* @brief
* Writes a D-header placeholder to the stream.
*
* This will be filled with the value through the function finish_d_header when the struct is completed.
*
* @return Whether the write was succesful.
*/
bool write_d_header();
/**
* @brief
* Adds an optional flag to the stream.
*
* In the case of an optional field, but not a parameter list, the xcdrv2 spec states that this field should
* preceded by a single boolean, indicating its presence or absence.
*
* @param[in] is_set Whether the entity represented by prop is present.
*
* @return Whether the read was succesful.
*/
bool write_optional_tag(bool is_set);
/**
* @brief
* Moves the stream cursor by the amount of an optional flag.
*
* In the case of an optional field, but not a parameter list, the xcdrv2 spec states that this field should
* preceded by a single boolean, indicating its presence or absence.
*
* @return Whether the read was succesful.
*/
bool move_optional_tag();
/**
* @brief
* Writes an EM-header to the stream.
*
* @param[in, out] prop The entity to write the EM-header for.
*
* @return Whether the header was read succesfully.
*/
bool write_em_header(entity_properties_t &prop);
/**
* @brief
* Moves the stream's position by the amount that it would after writing the D-header.
*
* Moves the cursor by a 4 byte int.
*
* @return Whether the operation was completed succesfully.
*/
bool move_d_header() {return move(*this, uint32_t(0));}
/**
* @brief
* Moves the stream's position by the amount that it would after writing the EM-header.
*
* @return Whether the header was read succesfully.
*/
bool move_em_header();
/**
* @brief
* Finishes the write operation of the D-header.
*
* @return Whether the header was read succesfully.
*/
bool finish_d_header();
/**
* @brief
* Finishes the write operation of the EM-header.
*
* @return Whether the header was read succesfully.
*/
bool finish_em_header();
/**
* @brief
* Checks whether a D-header is necessary for the indicated entity.
*
* @param[in] props The entity whose properties to check.
*
* @return Whether the entity props needs a D-header
*/
bool d_header_necessary(const entity_properties_t &props);
/**
* @brief
* Checks whether a EM-header is necessary for the indicated entity.
*
* @param[in] props The entity whose properties to check.
*
* @return Whether the entity props needs a EM-header
*/
bool em_header_necessary(const entity_properties_t &props);
/**
* @brief
* Determines whether a parameter list is necessary.
*
* This function is called by the next_entity function, to determine whether or not
* to read em headers from the stream.
*
* @param[in] props The entity whose members might be represented by a parameter list.
*
* @return Whether a list is necessary for this entity.
*/
bool list_necessary(const entity_properties_t &props);
};
/**
* @brief
* Reads the value of the enum from the stream.
*
* @param[in, out] str The stream which is read from.
* @param[out] toread The variable to read into.
* @param[in] N The number of entities to read.
*
* @return Whether the operation was completed succesfully.
*/
template<typename T, std::enable_if_t<std::is_enum<T>::value && !std::is_arithmetic<T>::value, bool> = true >
bool read(xcdr_v2_stream& str, T& toread, size_t N = 1) {
switch (str.is_key() ? bb_32_bits : get_bit_bound<T>())
{
case bb_8_bits:
return read_enum_impl<xcdr_v2_stream,T,uint8_t>(str, toread, N);
break;
case bb_16_bits:
return read_enum_impl<xcdr_v2_stream,T,uint16_t>(str, toread, N);
break;
case bb_32_bits:
return read_enum_impl<xcdr_v2_stream,T,uint32_t>(str, toread, N);
break;
default:
assert(false);
}
return true;
}
/**
* @brief
* Writes the value of the enum to the stream.
*
* @param [in, out] str The stream which is written to.
* @param [in] towrite The variable to write.
* @param[in] N The number of entities to write.
*
* @return Whether the operation was completed succesfully.
*/
template<typename T, std::enable_if_t<std::is_enum<T>::value && !std::is_arithmetic<T>::value, bool> = true >
bool write(xcdr_v2_stream& str, const T& towrite, size_t N = 1) {
switch (str.is_key() ? bb_32_bits : get_bit_bound<T>())
{
case bb_8_bits:
return write_enum_impl<xcdr_v2_stream,T,uint8_t>(str, towrite, N);
break;
case bb_16_bits:
return write_enum_impl<xcdr_v2_stream,T,uint16_t>(str, towrite, N);
break;
case bb_32_bits:
return write_enum_impl<xcdr_v2_stream,T,uint32_t>(str, towrite, N);
break;
default:
assert(false);
}
return true;
}
/**
* @brief
* Moves the cursor of the stream by the size the enum would take up.
*
* @param[in, out] str The stream whose cursor is moved.
* @param[in] N The number of entities to move.
*
* @return Whether the operation was completed succesfully.
*/
template<typename T, std::enable_if_t<std::is_enum<T>::value && !std::is_arithmetic<T>::value, bool> = true >
bool move(xcdr_v2_stream& str, const T&, size_t N = 1) {
switch (str.is_key() ? bb_32_bits : get_bit_bound<T>())
{
case bb_8_bits:
return move(str, int8_t(0), N);
break;
case bb_16_bits:
return move(str, int16_t(0), N);
break;
case bb_32_bits:
return move(str, int32_t(0), N);
break;
default:
assert(false);
}
return true;
}
/**
* @brief
* Moves the cursor of the stream by the size the enum would take up (maximum size version).
*
* @param[in, out] str The stream whose cursor is moved.
* @param[in] max_sz The variable to move the cursor by, no contents of this variable are used, it is just used to determine the template.
* @param[in] N The number of entities at most to move.
*
* @return Whether the operation was completed succesfully.
*/
template<typename T, std::enable_if_t<std::is_enum<T>::value && !std::is_arithmetic<T>::value, bool> = true >
bool max(xcdr_v2_stream& str, const T& max_sz, size_t N = 1) {
return move(str, max_sz, N);
}
}
}
}
}
} /* namespace org / eclipse / cyclonedds / core / cdr */
#endif

View File

@@ -0,0 +1,27 @@
/*
* Copyright(c) 2022 ZettaScale Technology
*
* 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 CDR_SERIALIZATION_FRAGCHAIN_HPP_
#define CDR_SERIALIZATION_FRAGCHAIN_HPP_
#include <cstddef> //size_t
#include <dds/core/macros.hpp>
// unfortunate namespace pollution from C
struct nn_rdata;
namespace org { namespace eclipse { namespace cyclone { namespace core { namespace cdr {
OMG_DDS_API void serdata_from_ser_copyin_fragchain (unsigned char * __restrict cursor, const struct nn_rdata* fragchain, size_t size);
} } } } }
#endif

View File

@@ -0,0 +1,117 @@
/*
* 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_CORE_COND_CONDITION_DELEGATE_HPP_
#define CYCLONEDDS_CORE_COND_CONDITION_DELEGATE_HPP_
#include <org/eclipse/cyclonedds/core/DDScObjectDelegate.hpp>
#include <org/eclipse/cyclonedds/core/cond/FunctorHolder.hpp>
#include <org/eclipse/cyclonedds/core/Mutex.hpp>
#include <org/eclipse/cyclonedds/core/ScopedLock.hpp>
#include <org/eclipse/cyclonedds/core/ReportUtils.hpp>
#include <set>
namespace dds
{
namespace core
{
namespace cond
{
template <typename DELEGATE> class TCondition;
}
}
}
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
namespace cond
{
DDSCXX_WARNING_MSVC_OFF(4251)
class WaitSetDelegate;
class OMG_DDS_API ConditionDelegate :
public virtual org::eclipse::cyclonedds::core::DDScObjectDelegate
{
public:
typedef ::dds::core::smart_ptr_traits< ConditionDelegate >::ref_type
ref_type;
typedef ::dds::core::smart_ptr_traits< ConditionDelegate >::weak_ref_type
weak_ref_type;
ConditionDelegate();
~ConditionDelegate();
void init(ObjectDelegate::weak_ref_type weak_ref);
void close();
virtual bool trigger_value() const = 0;
template <typename FUN>
void set_handler(FUN functor)
{
org::eclipse::cyclonedds::core::ScopedObjectLock scopedLock(*this);
if (this->myFunctor)
{
delete this->myFunctor;
}
myFunctor =
new org::eclipse::cyclonedds::core::cond::FunctorHolder<FUN>(functor);
}
void reset_handler();
virtual void dispatch();
virtual void add_waitset(
const dds::core::cond::TCondition<ConditionDelegate> & cond,
org::eclipse::cyclonedds::core::cond::WaitSetDelegate *waitset);
virtual bool remove_waitset(
org::eclipse::cyclonedds::core::cond::WaitSetDelegate *waitset);
virtual void detach_from_waitset(const dds_entity_t entity_handle);
virtual void detach_and_close(const dds_entity_t entity_handle);
dds::core::cond::TCondition<ConditionDelegate> wrapper();
private:
std::set<WaitSetDelegate *> waitSetList;
org::eclipse::cyclonedds::core::Mutex waitSetListUpdateMutex;
org::eclipse::cyclonedds::core::cond::FunctorHolderBase *myFunctor;
};
DDSCXX_WARNING_MSVC_ON(4251)
}
}
}
}
}
#endif /* CYCLONEDDS_CORE_COND_CONDITION_DELEGATE_HPP_ */

View File

@@ -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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_CORE_COND_FUNCTOR_HOLDER_HPP_
#define CYCLONEDDS_CORE_COND_FUNCTOR_HOLDER_HPP_
namespace dds
{
namespace core
{
namespace cond
{
template <typename DELEGATE> class TCondition;
}
}
}
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
namespace cond
{
class ConditionDelegate;
class FunctorHolderBase
{
public:
FunctorHolderBase() { };
virtual ~FunctorHolderBase() { };
virtual void dispatch(dds::core::cond::TCondition<org::eclipse::cyclonedds::core::cond::ConditionDelegate> &condition) = 0;
};
template <typename FUN>
class FunctorHolder : public FunctorHolderBase
{
public:
FunctorHolder(FUN functor) : myFunctor(functor)
{
}
virtual ~FunctorHolder() { };
void dispatch(dds::core::cond::TCondition<org::eclipse::cyclonedds::core::cond::ConditionDelegate> &condition)
{
myFunctor(condition);
}
private:
FUN myFunctor;
};
}
}
}
}
}
#endif /* CYCLONEDDS_CORE_COND_FUNCTOR_HOLDER_HPP_ */

View File

@@ -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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_CORE_GUARD_CONDITION_DELEGATE_HPP_
#define CYCLONEDDS_CORE_GUARD_CONDITION_DELEGATE_HPP_
#include <org/eclipse/cyclonedds/core/cond/ConditionDelegate.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
namespace cond
{
class OMG_DDS_API GuardConditionDelegate :
public org::eclipse::cyclonedds::core::cond::ConditionDelegate
{
public:
GuardConditionDelegate();
~GuardConditionDelegate();
void close();
virtual bool trigger_value() const;
void trigger_value(bool value);
};
}
}
}
}
}
#endif /* CYCLONEDDS_CORE_GUARD_CONDITION_DELEGATE_HPP_ */

View File

@@ -0,0 +1,81 @@
/*
* 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_CORE_COND_SHADOW_PARTICIPANT_HPP_
#define CYCLONEDDS_CORE_COND_SHADOW_PARTICIPANT_HPP_
#include "dds/dds.h"
#include <dds/domain/DomainParticipant.hpp>
#include <org/eclipse/cyclonedds/core/config.hpp>
#include <org/eclipse/cyclonedds/core/Mutex.hpp>
#include <org/eclipse/cyclonedds/core/ScopedLock.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
namespace cond
{
class ShadowParticipant {
public:
static ShadowParticipant& getInstance()
{
org::eclipse::cyclonedds::core::ScopedMutexLock scopedLock(mutex_);
if (!instance_) {
// Create shadow participant that is used as parent entity for all waitsets
dds_entity_t ddsc_part = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
instance_ = new ShadowParticipant(ddsc_part);
}
return *instance_;
}
dds_entity_t get_participant()
{
return ddsc_participant_;
}
private:
ShadowParticipant(dds_entity_t ddsc_participant)
{
this->ddsc_participant_ = ddsc_participant;
}
~ShadowParticipant()
{
dds_delete(this->ddsc_participant_);
}
ShadowParticipant(const ShadowParticipant&);
ShadowParticipant& operator=(const ShadowParticipant&);
static ShadowParticipant* instance_;
static org::eclipse::cyclonedds::core::Mutex mutex_;
dds_entity_t ddsc_participant_;
};
}
}
}
}
}
#endif /* CYCLONEDDS_CORE_COND_SHADOW_PARTICIPANT_HPP_ */

View File

@@ -0,0 +1,87 @@
/*
* 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_CORE_STATUS_CONDITION_DELEGATE_HPP_
#define CYCLONEDDS_CORE_STATUS_CONDITION_DELEGATE_HPP_
#include <dds/core/Entity.hpp>
#include <dds/core/status/Status.hpp>
#include <org/eclipse/cyclonedds/core/cond/ConditionDelegate.hpp>
namespace dds
{
namespace core
{
namespace cond
{
template <typename T> class TStatusCondition;
}
}
}
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
namespace cond
{
class OMG_DDS_API StatusConditionDelegate :
public org::eclipse::cyclonedds::core::cond::ConditionDelegate
{
public:
typedef ::dds::core::smart_ptr_traits<StatusConditionDelegate>::ref_type
ref_type;
typedef
::dds::core::smart_ptr_traits<StatusConditionDelegate>::weak_ref_type
weak_ref_type;
StatusConditionDelegate(
const org::eclipse::cyclonedds::core::EntityDelegate *entity,
dds_entity_t uEntity);
~StatusConditionDelegate();
virtual void close();
void init(org::eclipse::cyclonedds::core::ObjectDelegate::weak_ref_type weak_ref);
void enabled_statuses(const dds::core::status::StatusMask& status);
dds::core::status::StatusMask enabled_statuses() const;
dds::core::Entity& entity();
virtual bool trigger_value() const;
dds::core::cond::TStatusCondition<StatusConditionDelegate> wrapper();
private:
dds::core::Entity myEntity;
};
}
}
}
}
}
#endif /* CYCLONEDDS_CORE_STATUS_CONDITION_DELEGATE_HPP_ */

View File

@@ -0,0 +1,102 @@
/*
* 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_CORE_COND_WAITSET_DELEGATE_HPP_
#define CYCLONEDDS_CORE_COND_WAITSET_DELEGATE_HPP_
#include <vector>
#include <map>
#include <dds/core/Duration.hpp>
#include <dds/core/cond/Condition.hpp>
#include <org/eclipse/cyclonedds/core/config.hpp>
#include <org/eclipse/cyclonedds/core/DDScObjectDelegate.hpp>
namespace dds
{
namespace core
{
namespace cond
{
template <typename DELEGATE> class TWaitSet;
}
}
}
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
namespace cond
{
DDSCXX_WARNING_MSVC_OFF(4251)
class OMG_DDS_API WaitSetDelegate :
public org::eclipse::cyclonedds::core::DDScObjectDelegate
{
public:
typedef ::dds::core::smart_ptr_traits< WaitSetDelegate >::ref_type ref_type;
typedef ::dds::core::smart_ptr_traits< WaitSetDelegate >::weak_ref_type weak_ref_type;
typedef std::vector<dds::core::cond::Condition> ConditionSeq;
typedef std::map<org::eclipse::cyclonedds::core::cond::ConditionDelegate *,
dds::core::cond::Condition> ConditionMap;
typedef std::map<org::eclipse::cyclonedds::core::cond::ConditionDelegate *,
dds::core::cond::Condition>::iterator ConditionIterator;
typedef std::map<org::eclipse::cyclonedds::core::cond::ConditionDelegate *,
dds::core::cond::Condition>::const_iterator ConstConditionIterator;
typedef std::pair<org::eclipse::cyclonedds::core::cond::ConditionDelegate *,
dds::core::cond::Condition> ConditionEntry;
WaitSetDelegate ();
virtual ~WaitSetDelegate ();
void init (ObjectDelegate::weak_ref_type weak_ref);
void close ();
ConditionSeq& wait (ConditionSeq& triggered, const dds::core::Duration& timeout);
void dispatch (const dds::core::Duration & timeout);
void attach_condition (const dds::core::cond::Condition & cond);
bool detach_condition (org::eclipse::cyclonedds::core::cond::ConditionDelegate * cond);
void add_condition_locked(const dds::core::cond::Condition& cond);
void remove_condition_locked(org::eclipse::cyclonedds::core::cond::ConditionDelegate *cond,
const dds_entity_t entity_handle = DDS_HANDLE_NIL);
ConditionSeq & conditions (ConditionSeq & conds) const;
private:
ConditionMap conditions_;
};
DDSCXX_WARNING_MSVC_ON(4251)
}
}
}
}
}
#endif /* CYCLONEDDS_CORE_COND_WAITSET_DELEGATE_HPP_ */

View File

@@ -0,0 +1,24 @@
/*
* 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_CORE_CONFIG_HPP_
#define CYCLONEDDS_CORE_CONFIG_HPP_
#include <dds/core/macros.hpp>
#include <dds/core/types.hpp>
#endif /* CYCLONEDDS_CORE_CONFIG_HPP_ */

View 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_CORE_POLICY_POLICY_HPP_
#define CYCLONEDDS_CORE_POLICY_POLICY_HPP_
/******************************************************************************
*
* PROPRIETARY POLICIES
*
******************************************************************************/
#include <org/eclipse/cyclonedds/core/policy/PolicyDelegate.hpp>
#include <org/eclipse/cyclonedds/core/policy/TPolicy.hpp>
/* Use same macro as in dds/core/policy/CorePolicy.hpp, called OMG_DDS_POLICY_TRAITS */
#define LITE_POLICY_TRAITS(POLICY, ID) \
template <> \
class policy_id<POLICY> { \
public: \
static const dds::core::policy::QosPolicyId value = ID; \
};\
template <> \
class policy_name<POLICY> { \
public:\
static const std::string& name(); \
};
namespace dds
{
namespace core
{
namespace policy
{
template <typename Policy>
class policy_id;
template <typename Policy>
class policy_name;
}
}
}
#undef LITE_POLICY_TRAITS
#endif /* CYCLONEDDS_CORE_POLICY_POLICY_HPP_ */

View File

@@ -0,0 +1,983 @@
/*
* 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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_CORE_POLICY_POLICY_DELEGATE_HPP_
#define CYCLONEDDS_CORE_POLICY_POLICY_DELEGATE_HPP_
#ifdef _WIN32
#pragma warning( push )
#pragma warning( disable : 4251 )
#endif
#include <dds/core/types.hpp>
#include <dds/core/LengthUnlimited.hpp>
#include <dds/core/Duration.hpp>
#include <dds/core/policy/PolicyKind.hpp>
#include <org/eclipse/cyclonedds/core/policy/ProprietaryPolicyKind.hpp>
#include <dds/dds.h>
//==============================================================================
/*
* Unfortunately, there isn't an ddsc or builtin SubscriptionKey policy that
* is alligned the same as the idl representation. To be able to translate it
* as well, we have to seperately mention it...
*/
struct _DDS_SubscriptionKeyQosPolicy;
//==============================================================================
// DDS Policy Classes
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
namespace policy
{
//==============================================================================
class OMG_DDS_API TimeBasedFilterDelegate;
/**
* @internal This policy is useful for cases where a Topic is expected to have each
* instance updated periodically. On the publishing side this setting
* establishes a contract that the application must meet. On the subscribing
* side the setting establishes a minimum requirement for the remote publishers
* that are expected to supply the data values. When the Service <D4>matches<D5> a
* DataWriter and a DataReader it checks whether the settings are compatible
* (i.e., offered deadline period<= requested deadline period) if they are not,
* the two entities are informed (via the listener or condition mechanism)
* of the incompatibility of the QoS settings and communication will not occur.
* Assuming that the reader and writer ends have compatible settings, the
* fulfillment of this contract is monitored by the Service and the application
* is informed of any violations by means of the proper listener or condition.
* The value offered is considered compatible with the value requested if and
* only if the inequality <D2>offered deadline period <= requested deadline period<D3>
* evaluates to <D4>TRUE.<D5> The setting of the DEADLINE policy must be set
* consistently with that of the TIME_BASED_FILTER.
* For these two policies to be consistent the settings must be such that
* <D2>deadline period>= minimum_separation.<D3>
*/
class OMG_DDS_API DeadlineDelegate
{
public:
DeadlineDelegate(const DeadlineDelegate& other);
explicit DeadlineDelegate(const dds::core::Duration& d);
DeadlineDelegate& operator=(const DeadlineDelegate& other) = default;
void period(const dds::core::Duration& d);
dds::core::Duration period() const;
bool operator ==(const DeadlineDelegate& other) const;
void check() const;
void check_against(const org::eclipse::cyclonedds::core::policy::TimeBasedFilterDelegate& filter) const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::Duration period_;
};
//==============================================================================
class OMG_DDS_API DestinationOrderDelegate
{
public:
DestinationOrderDelegate(const DestinationOrderDelegate& other);
explicit DestinationOrderDelegate(dds::core::policy::DestinationOrderKind::Type kind);
DestinationOrderDelegate& operator=(const DestinationOrderDelegate& other) = default;
void kind(dds::core::policy::DestinationOrderKind::Type kind);
dds::core::policy::DestinationOrderKind::Type kind() const;
bool operator ==(const DestinationOrderDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::policy::DestinationOrderKind::Type kind_;
};
//==============================================================================
class OMG_DDS_API DurabilityDelegate
{
public:
DurabilityDelegate(const DurabilityDelegate& other);
explicit DurabilityDelegate(dds::core::policy::DurabilityKind::Type kind);
DurabilityDelegate& operator=(const DurabilityDelegate& other) = default;
void kind(dds::core::policy::DurabilityKind::Type kind);
dds::core::policy::DurabilityKind::Type kind() const;
bool operator ==(const DurabilityDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
public:
dds::core::policy::DurabilityKind::Type kind_;
};
//==============================================================================
#ifdef OMG_DDS_PERSISTENCE_SUPPORT
class OMG_DDS_API DurabilityServiceDelegate
{
public:
DurabilityServiceDelegate(const DurabilityServiceDelegate& other);
DurabilityServiceDelegate(const dds::core::Duration& service_cleanup_delay,
dds::core::policy::HistoryKind::Type history_kind,
int32_t history_depth,
int32_t max_samples,
int32_t max_instances,
int32_t max_samples_per_instance);
DurabilityServiceDelegate& operator=(const DurabilityServiceDelegate& other) = default;
void service_cleanup_delay(const dds::core::Duration& d);
const dds::core::Duration service_cleanup_delay() const;
void history_kind(dds::core::policy::HistoryKind::Type kind);
dds::core::policy::HistoryKind::Type history_kind() const;
void history_depth(int32_t depth);
int32_t history_depth() const;
void max_samples(int32_t max_samples);
int32_t max_samples() const;
void max_instances(int32_t max_instances);
int32_t max_instances() const;
void max_samples_per_instance(int32_t max_samples_per_instance);
int32_t max_samples_per_instance() const;
bool operator ==(const DurabilityServiceDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::Duration cleanup_delay_;
dds::core::policy::HistoryKind::Type history_kind_;
int32_t history_depth_;
int32_t max_samples_;
int32_t max_instances_;
int32_t max_samples_per_instance_;
};
#endif // OMG_DDS_PERSISTENCE_SUPPORT
//==============================================================================
/**
* @internal This policy controls the behavior of the Entity as a factory for other
* entities. This policy concerns only DomainParticipant (as factory for
* Publisher, Subscriber, and Topic), Publisher (as factory for DataWriter),
* and Subscriber (as factory for DataReader). This policy is mutable.
* A change in the policy affects only the entities created after the change;
* not the previously created entities.
* The setting of autoenable_created_entities to TRUE indicates that the
* newly created object will be enabled by default.
* A setting of FALSE indicates that the Entity will not be automatically
* enabled. The application will need to enable it explicitly by means of the
* enable operation (see Section 7.1.2.1.1.7, <D2>enable<D3>). The default setting
* of autoenable_created_entities = TRUE means that, by default, it is not
* necessary to explicitly call enable on newly created entities.
*/
class OMG_DDS_API EntityFactoryDelegate
{
public:
EntityFactoryDelegate(const EntityFactoryDelegate& other);
explicit EntityFactoryDelegate(bool auto_enable);
void auto_enable(bool on);
bool auto_enable() const;
bool operator ==(const EntityFactoryDelegate& other) const;
EntityFactoryDelegate& operator =(const EntityFactoryDelegate& other) = default;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
bool auto_enable_;
};
//==============================================================================
/**
* @internal The purpose of this QoS is to allow the application to attach additional
* information to the created Publisher or Subscriber.
* The value of the GROUP_DATA is available to the application on the
* DataReader and DataWriter entities and is propagated by means of the
* built-in topics. This QoS can be used by an application combination with
* the DataReaderListener and DataWriterListener to implement matching policies
* similar to those of the PARTITION QoS except the decision can be made based
* on an application-defined policy.
*/
class OMG_DDS_API GroupDataDelegate
{
public:
/**
* @internal Create a <code>GroupData</code> instance.
*/
GroupDataDelegate();
/**
* @internal Create a <code>GroupData</code> instance.
*
* @param other the group data to copy
*/
GroupDataDelegate(const GroupDataDelegate& other);
/**
* @internal Copies a <code>GroupData</code> instance.
*
* @param other the group data to copy
*
* @return reference to the instance which was copied to
*/
GroupDataDelegate& operator=(const GroupDataDelegate& other) = default;
/**
* @internal Create a <code>GroupData</code> instance.
*
* @param seq the group data value
*/
explicit GroupDataDelegate(const dds::core::ByteSeq& seq);
/**
* @internal Set the value for this <code>GroupData</code>
*
* @param seq the group data value
*/
void value(const dds::core::ByteSeq& seq);
/**
* @internal Get the value for this <code>GroupData</code>
*
* @return the group data value
*/
const dds::core::ByteSeq& value() const;
bool operator ==(const GroupDataDelegate& other) const;
/**
* @internal Check if policy is consistent.
*/
void check() const;
/**
* @internal Set internals by the ddsc policy.
*
* @param qos the ddsc policy
*/
void set_iso_policy(const dds_qos_t* qos);
/**
* @internal Set internals by the ddsc policy.
*
* @param the ddsc policy
*/
//@todo void v_policy(const v_builtinGroupDataPolicy& policy);
/**
* @internal Get the ddsc policy representation.
*
* @param qos the ddsc policy
*/
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::ByteSeq value_;
};
//==============================================================================
class OMG_DDS_API ResourceLimitsDelegate;
class OMG_DDS_API HistoryDelegate
{
public:
HistoryDelegate(const HistoryDelegate& other);
HistoryDelegate(dds::core::policy::HistoryKind::Type kind, int32_t depth);
HistoryDelegate& operator=(const HistoryDelegate& other) = default;
dds::core::policy::HistoryKind::Type kind() const;
void kind(dds::core::policy::HistoryKind::Type kind);
int32_t depth() const;
void depth(int32_t depth);
bool operator ==(const HistoryDelegate& other) const;
void check() const;
void check_against(const org::eclipse::cyclonedds::core::policy::ResourceLimitsDelegate& limits) const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::policy::HistoryKind::Type kind_;
int32_t depth_;
};
//==============================================================================
class OMG_DDS_API LatencyBudgetDelegate
{
public:
LatencyBudgetDelegate(const LatencyBudgetDelegate& other);
explicit LatencyBudgetDelegate(const dds::core::Duration& d);
LatencyBudgetDelegate& operator=(const LatencyBudgetDelegate& other) = default;
void duration(const dds::core::Duration& d);
const dds::core::Duration duration() const;
bool operator ==(const LatencyBudgetDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::Duration duration_;
};
//==============================================================================
/**
* @internal The purpose of this QoS is to avoid delivering <D2>stale<D3> data to the
* application. Each data sample written by the DataWriter has an associated
* expiration time beyond which the data should not be delivered to any
* application. Once the sample expires, the data will be removed from the
* DataReader caches as well as from the transient and persistent
* information caches. The expiration time of each sample is computed by
* adding the duration specified by the LIFESPAN QoS to the source timestamp.
* As described in Section 7.1.2.4.2.11, <D2>write and Section 7.1.2.4.2.12,
* write_w_timestamp the source timestamp is either automatically computed by
* the Service each time the DataWriter write operation is called, or else
* supplied by the application by means of the write_w_timestamp operation.
*
* This QoS relies on the sender and receiving applications having their clocks
* sufficiently synchronized. If this is not the case and the Service can
* detect it, the DataReader is allowed to use the reception timestamp instead
* of the source timestamp in its computation of the expiration time.
*/
class OMG_DDS_API LifespanDelegate
{
public:
LifespanDelegate(const LifespanDelegate& other);
explicit LifespanDelegate(const dds::core::Duration& d);
LifespanDelegate& operator=(const LifespanDelegate& other) = default;
void duration(const dds::core::Duration& d);
const dds::core::Duration duration() const;
bool operator ==(const LifespanDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::Duration duration_;
};
//==============================================================================
class OMG_DDS_API LivelinessDelegate
{
public:
public:
LivelinessDelegate(const LivelinessDelegate& other);
LivelinessDelegate(dds::core::policy::LivelinessKind::Type kind,
dds::core::Duration lease_duration);
LivelinessDelegate& operator=(const LivelinessDelegate& other) = default;
void kind(dds::core::policy::LivelinessKind::Type kind);
dds::core::policy::LivelinessKind::Type kind() const;
void lease_duration(const dds::core::Duration& lease_duration);
const dds::core::Duration lease_duration() const;
bool operator ==(const LivelinessDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::policy::LivelinessKind::Type kind_;
dds::core::Duration lease_duration_;
};
//==============================================================================
class OMG_DDS_API OwnershipDelegate
{
public:
OwnershipDelegate(const OwnershipDelegate& other);
explicit OwnershipDelegate(dds::core::policy::OwnershipKind::Type kind);
OwnershipDelegate& operator=(const OwnershipDelegate& other) = default;
void kind(dds::core::policy::OwnershipKind::Type kind);
dds::core::policy::OwnershipKind::Type kind() const;
bool operator ==(const OwnershipDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::policy::OwnershipKind::Type kind_;
};
//==============================================================================
#ifdef OMG_DDS_OWNERSHIP_SUPPORT
class OMG_DDS_API OwnershipStrengthDelegate
{
public:
OwnershipStrengthDelegate(const OwnershipStrengthDelegate& other);
explicit OwnershipStrengthDelegate(int32_t s);
OwnershipStrengthDelegate& operator=(const OwnershipStrengthDelegate& other) = default;
int32_t strength() const;
void strength(int32_t s);
bool operator ==(const OwnershipStrengthDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
int32_t strength_;
};
#endif // OMG_DDS_OWNERSHIP_SUPPORT
//==============================================================================
class OMG_DDS_API PartitionDelegate
{
public:
PartitionDelegate(const PartitionDelegate& other);
explicit PartitionDelegate(const std::string& partition);
explicit PartitionDelegate(const dds::core::StringSeq& partitions);
PartitionDelegate& operator=(const PartitionDelegate& other) = default;
void name(const std::string& partition);
void name(const dds::core::StringSeq& partitions);
const dds::core::StringSeq& name() const;
bool operator ==(const PartitionDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
//@todo void v_policy(const v_builtinPartitionPolicy& policy);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::StringSeq name_;
};
//==============================================================================
class OMG_DDS_API PresentationDelegate
{
public:
PresentationDelegate(const PresentationDelegate& other);
PresentationDelegate(dds::core::policy::PresentationAccessScopeKind::Type access_scope,
bool coherent_access,
bool ordered_access);
PresentationDelegate& operator=(const PresentationDelegate& other) = default;
void access_scope(dds::core::policy::PresentationAccessScopeKind::Type as);
dds::core::policy::PresentationAccessScopeKind::Type access_scope() const;
void coherent_access(bool on);
bool coherent_access() const;
void ordered_access(bool on);
bool ordered_access() const;
bool operator ==(const PresentationDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::policy::PresentationAccessScopeKind::Type access_scope_;
bool coherent_access_;
bool ordered_access_;
};
//==============================================================================
class OMG_DDS_API ReaderDataLifecycleDelegate
{
public:
ReaderDataLifecycleDelegate(const ReaderDataLifecycleDelegate& other);
ReaderDataLifecycleDelegate(const dds::core::Duration& nowriter_delay,
const dds::core::Duration& disposed_samples_delay);
const dds::core::Duration autopurge_nowriter_samples_delay() const;
void autopurge_nowriter_samples_delay(const dds::core::Duration& d);
const dds::core::Duration autopurge_disposed_samples_delay() const;
void autopurge_disposed_samples_delay(const dds::core::Duration& d);
bool operator ==(const ReaderDataLifecycleDelegate& other) const;
ReaderDataLifecycleDelegate& operator =(const ReaderDataLifecycleDelegate& other) = default;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::Duration autopurge_nowriter_samples_delay_;
dds::core::Duration autopurge_disposed_samples_delay_;
};
//==============================================================================
class OMG_DDS_API ReaderLifespanDelegate
{
public:
ReaderLifespanDelegate(const ReaderLifespanDelegate& other);
explicit ReaderLifespanDelegate(bool used,
const dds::core::Duration& d);
void duration(const dds::core::Duration& d);
const dds::core::Duration duration() const;
void used(bool v);
bool used() const;
bool operator ==(const ReaderLifespanDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
bool used_;
dds::core::Duration duration_;
};
//==============================================================================
class OMG_DDS_API ReliabilityDelegate
{
public:
public:
ReliabilityDelegate(const ReliabilityDelegate& other);
ReliabilityDelegate(dds::core::policy::ReliabilityKind::Type kind,
const dds::core::Duration& max_blocking_time);
ReliabilityDelegate& operator=(const ReliabilityDelegate& other) = default;
void kind(dds::core::policy::ReliabilityKind::Type kind);
dds::core::policy::ReliabilityKind::Type kind() const;
void max_blocking_time(const dds::core::Duration& d);
const dds::core::Duration max_blocking_time() const;
bool operator ==(const ReliabilityDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::policy::ReliabilityKind::Type kind_;
dds::core::Duration max_blocking_time_;
};
//==============================================================================
class OMG_DDS_API ResourceLimitsDelegate
{
public:
ResourceLimitsDelegate(const ResourceLimitsDelegate& other);
ResourceLimitsDelegate(int32_t max_samples,
int32_t max_instances,
int32_t max_samples_per_instance);
ResourceLimitsDelegate& operator=(const ResourceLimitsDelegate& other) = default;
void max_samples(int32_t samples);
int32_t max_samples() const;
void max_instances(int32_t max_instances);
int32_t max_instances() const;
void max_samples_per_instance(int32_t max_samples_per_instance);
int32_t max_samples_per_instance() const;
bool operator ==(const ResourceLimitsDelegate& other) const;
void check() const;
void check_against(const org::eclipse::cyclonedds::core::policy::HistoryDelegate& history) const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
int32_t max_samples_;
int32_t max_instances_;
int32_t max_samples_per_instance_;
};
//==============================================================================
class OMG_DDS_API TimeBasedFilterDelegate
{
public:
TimeBasedFilterDelegate(const TimeBasedFilterDelegate& other);
explicit TimeBasedFilterDelegate(const dds::core::Duration& min_separation);
TimeBasedFilterDelegate& operator=(const TimeBasedFilterDelegate& other) = default;
void min_separation(const dds::core::Duration& ms);
const dds::core::Duration min_separation() const;
bool operator ==(const TimeBasedFilterDelegate& other) const;
void check() const;
void check_against(const org::eclipse::cyclonedds::core::policy::DeadlineDelegate& deadline) const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::Duration min_sep_;
};
//==============================================================================
/**
* @internal The purpose of this QoS is to allow the application to attach additional
* information to the created Topic such that when a remote application
* discovers their existence it can examine the information and use it in
* an application-defined way. In combination with the listeners on the
* DataReader and DataWriter as well as by means of operations such as
* ignore_topic, these QoS can assist an application to extend the provided QoS.
*/
class OMG_DDS_API TopicDataDelegate
{
public:
TopicDataDelegate();
TopicDataDelegate(const TopicDataDelegate& other);
explicit TopicDataDelegate(const dds::core::ByteSeq& seq);
TopicDataDelegate& operator=(const TopicDataDelegate& other) = default;
void value(const dds::core::ByteSeq& seq);
const dds::core::ByteSeq& value() const;
bool operator ==(const TopicDataDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
//@todo void v_policy(const v_builtinTopicDataPolicy& policy);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::ByteSeq value_;
};
//==============================================================================
/**
* @internal The purpose of this QoS is to allow the application to take advantage of
* transports capable of sending messages with different priorities.
* This policy is considered a hint. The policy depends on the ability of the
* underlying transports to set a priority on the messages they send.
* Any value within the range of a 32-bit signed integer may be chosen;
* higher values indicate higher priority. However, any further interpretation
* of this policy is specific to a particular transport and a particular
* implementation of the Service. For example, a particular transport is
* permitted to treat a range of priority values as equivalent to one another.
* It is expected that during transport configuration the application would
* provide a mapping between the values of the TRANSPORT_PRIORITY set on
* DataWriter and the values meaningful to each transport. This mapping would
* then be used by the infrastructure when propagating the data written by
* the DataWriter.
*/
class OMG_DDS_API TransportPriorityDelegate
{
public:
TransportPriorityDelegate(const TransportPriorityDelegate& other);
TransportPriorityDelegate& operator=(const TransportPriorityDelegate& other) = default;
explicit TransportPriorityDelegate(int32_t prio);
void value(int32_t prio);
int32_t value() const;
bool operator ==(const TransportPriorityDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
int32_t value_;
};
//==============================================================================
/**
* @internal The purpose of this QoS is to allow the application to attach additional
* information to the created Entity objects such that when a remote application
* discovers their existence it can access that information and use it for its
* own purposes. One possible use of this QoS is to attach security credentials
* or some other information that can be used by the remote application to
* authenticate the source. In combination with operations such as
* ignore_participant, ignore_publication, ignore_subscription,
* and ignore_topic these QoS can assist an application to define and enforce
* its own security policies. The use of this QoS is not limited to security,
* rather it offers a simple, yet flexible extensibility mechanism.
*/
class OMG_DDS_API UserDataDelegate
{
public:
/**
* @internal Create a <code>UserData</code> instance with an empty user data.
*/
UserDataDelegate();
/**
* @internal Create a <code>UserData</code> instance.
*
* @param other the user data to copy
*/
UserDataDelegate(const UserDataDelegate& other);
/**
* @internal Copies a <code>UserData</code> instance.
*
* @param other the user data to copy
*
* @return reference to the instance that was copied to
*/
UserDataDelegate& operator=(const UserDataDelegate& other) = default;
/**
* @internal Create a <code>UserData</code> instance.
*
* @param seq the sequence of octet representing the user data
*/
explicit UserDataDelegate(const dds::core::ByteSeq& seq);
/**
* @internal Set the value for the user data.
*
* @param seq a sequence of octet representing the user data.
*/
void value(const dds::core::ByteSeq& seq);
/**
* @internal Get the user data.
*
* @return the sequence of octet representing the user data
*/
const dds::core::ByteSeq value() const;
bool operator ==(const UserDataDelegate& other) const;
/**
* @internal Check if policy is consistent.
*/
void check() const;
/**
* @internal Set internals by the ddsc policy.
*
* @param qos the ddsc policy
*/
void set_iso_policy(const dds_qos_t* qos);
/**
* @internal Set internals by the ddsc policy.
*
* @param the ddsc policy
*/
//@todo void v_policy(const v_builtinUserDataPolicy& policy);
/**
* @internal Get the ddsc policy representation.
*/
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::ByteSeq value_;
};
//==============================================================================
class OMG_DDS_API WriterDataLifecycleDelegate
{
public:
WriterDataLifecycleDelegate(const WriterDataLifecycleDelegate& other);
explicit WriterDataLifecycleDelegate(bool autodispose);
bool autodispose() const;
void autodispose(bool b);
bool operator ==(const WriterDataLifecycleDelegate& other) const;
WriterDataLifecycleDelegate& operator =(const WriterDataLifecycleDelegate& other) = default;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
bool autodispose_;
};
#ifdef OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
class OMG_DDS_API DataRepresentationDelegate
{
public:
DataRepresentationDelegate(const DataRepresentationDelegate& other);
explicit DataRepresentationDelegate(const dds::core::policy::DataRepresentationIdSeq& value);
DataRepresentationDelegate& operator=(const DataRepresentationDelegate& other) = default;
void value(const dds::core::policy::DataRepresentationIdSeq &value);
const dds::core::policy::DataRepresentationIdSeq& value() const;
bool operator ==(const DataRepresentationDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::policy::DataRepresentationIdSeq value_;
};
#endif // OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
#ifdef OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
class OMG_DDS_API TypeConsistencyEnforcementDelegate {
public:
TypeConsistencyEnforcementDelegate(const TypeConsistencyEnforcementDelegate& other);
explicit TypeConsistencyEnforcementDelegate(dds::core::policy::TypeConsistencyKind kind,
bool ignore_sequence_bounds,
bool ignore_string_bounds,
bool ignore_member_names,
bool prevent_type_widening,
bool force_type_validation);
TypeConsistencyEnforcementDelegate& operator=(const TypeConsistencyEnforcementDelegate& other) = default;
void kind(dds::core::policy::TypeConsistencyKind kind);
dds::core::policy::TypeConsistencyKind kind() const;
void ignore_sequence_bounds(bool ignore_sequence_bounds);
bool ignore_sequence_bounds() const;
void ignore_string_bounds(bool ignore_string_bounds);
bool ignore_string_bounds() const;
void ignore_member_names(bool ignore_member_names);
bool ignore_member_names() const;
void prevent_type_widening(bool prevent_type_widening);
bool prevent_type_widening() const;
void force_type_validation(bool force_type_validation);
bool force_type_validation() const;
bool operator ==(const TypeConsistencyEnforcementDelegate& other) const;
void check() const;
void set_iso_policy(const dds_qos_t* qos);
void set_c_policy(dds_qos_t* qos) const;
private:
dds::core::policy::TypeConsistencyKind kind_;
bool ignore_sequence_bounds_;
bool ignore_string_bounds_;
bool ignore_member_names_;
bool prevent_type_widening_;
bool force_type_validation_;
};
#endif // OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
}
}
}
}
} // namespace org::eclipse::cyclonedds::core::policy
#endif /* CYCLONEDDS_CORE_POLICY_POLICY_DELEGATE_HPP_ */

View File

@@ -0,0 +1,76 @@
/*
* 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_CORE_POLICY_PROPRIETARYPOLICYKIND_HPP_
#define CYCLONEDDS_CORE_POLICY_PROPRIETARYPOLICYKIND_HPP_
#include <dds/core/SafeEnumeration.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
namespace policy
{
/*
* Proprietary policy values
*/
struct InvalidSampleVisibility_def
{
enum Type
{
NO_INVALID_SAMPLES,
MINIMUM_INVALID_SAMPLES,
ALL_INVALID_SAMPLES
};
};
typedef dds::core::safe_enum<InvalidSampleVisibility_def> InvalidSampleVisibility;
struct SchedulingKind_def
{
enum Type
{
SCHEDULE_DEFAULT,
SCHEDULE_TIMESHARING,
SCHEDULE_REALTIME
};
};
typedef dds::core::safe_enum<SchedulingKind_def> SchedulingKind;
struct SchedulingPriorityKind_def
{
enum Type
{
PRIORITY_RELATIVE,
PRIORITY_ABSOLUTE
};
};
typedef dds::core::safe_enum<SchedulingPriorityKind_def> SchedulingPriorityKind;
}
}
}
}
}
#endif /* CYCLONEDDS_CORE_POLICY_PROPRIETARYPOLICYKIND_HPP_ */

View 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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_CORE_POLICY_QOS_POLICY_COUNT_DELEGATE_HPP_
#define CYCLONEDDS_CORE_POLICY_QOS_POLICY_COUNT_DELEGATE_HPP_
#include <dds/core/types.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
namespace policy
{
class QosPolicyCountDelegate
{
public:
QosPolicyCountDelegate(dds::core::policy::QosPolicyId id, int32_t count)
: policy_id_(id),
count_(count)
{ }
QosPolicyCountDelegate(const QosPolicyCountDelegate& other)
: policy_id_(other.policy_id()),
count_(other.count())
{ }
QosPolicyCountDelegate& operator=(const QosPolicyCountDelegate& other) = default;
public:
dds::core::policy::QosPolicyId policy_id() const
{
return policy_id_;
}
void policy_id(dds::core::policy::QosPolicyId id)
{
policy_id_ = id;
}
int32_t count() const
{
return count_;
}
void count(int32_t c)
{
count_ = c;
}
bool operator ==(const QosPolicyCountDelegate& other) const
{
return other.policy_id_ == policy_id_ &&
other.count_ == count_;
}
private:
dds::core::policy::QosPolicyId policy_id_;
int32_t count_;
};
}
}
}
}
}
#endif /* CYCLONEDDS_CORE_POLICY_QOS_POLICY_COUNT_DELEGATE_HPP_ */

View File

@@ -0,0 +1,468 @@
/*
* 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_CORE_POLICY_TPOLICY_HPP_
#define CYCLONEDDS_CORE_POLICY_TPOLICY_HPP_
#include <org/eclipse/cyclonedds/core/policy/ProprietaryPolicyKind.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
namespace policy
{
/**
*/
template <typename D>
class TShare : public dds::core::Value<D>
{
public:
/**
* Creates a Share QoS instance
*/
TShare() { }
/**
* Creates a Share QoS instance
*
* @param name the name
* @param enable state
*/
TShare(const std::string& name, bool enable) : dds::core::Value<D>(name, enable) { }
/**
* Copies a Share QoS instance
*
* @param other the TShare QoS instance to copy
*/
TShare(const TShare& other) : dds::core::Value<D>(other.delegate()) { }
public:
/**
* Sets the name
*
* @param name the name
*/
TShare& name(const std::string& name)
{
this->delegate().name(name);
return *this;
}
/**
* Gets the name
*
* @return the name
*/
std::string name() const
{
return this->delegate().name();
}
/**
* Sets enable state
*
* @param enable state
*/
TShare& enable(bool enable)
{
this->delegate().enable(enable);
return *this;
}
/**
* Gets enable state
*
* @return enable state
*/
bool enable() const
{
return this->delegate().enable();
}
};
template <typename D>
class TProductData : public dds::core::Value<D>
{
public:
/**
* Creates a ProductData QoS instance
*/
TProductData() { }
/**
* Creates a ProductData QoS instance
*
* @param name the name
*/
TProductData(const std::string& name) : dds::core::Value<D>(name) { }
/**
* Copies a ProductData QoS instance
*
* @param other the TProductData QoS instance to copy
*/
TProductData(const TProductData& other) : dds::core::Value<D>(other.delegate()) { }
public:
/**
* Sets the name
*
* @param name the name to set
*/
TProductData& name(const std::string& name)
{
this->delegate().name(name);
return *this;
}
/**
* Gets the name
*
* @return the name
*/
std::string name() const
{
return this->delegate().name();
}
};
template <typename D>
class TSubscriptionKey : public dds::core::Value<D>
{
public:
/**
* Creates a SubscriptionKey QoS instance
*/
TSubscriptionKey() { }
/**
* Creates a SubscriptionKey QoS instance
*
* @param use_key_list use the key list or not
* @param key a single key
*/
explicit TSubscriptionKey(bool use_key_list, const std::string& key) :
dds::core::Value<D>(use_key_list, key) { }
/**
* Creates a SubscriptionKey QoS instance
*
* @param use_key_list use the key list or not
* @param keys a sequence containing multiple keys
*/
explicit TSubscriptionKey(bool use_key_list, const dds::core::StringSeq& keys) :
dds::core::Value<D>(use_key_list, keys) { }
/**
* Copies a SubscriptionKey QoS instance
*
* @param other the TSubscriptionKey QoS instance to copy
*/
TSubscriptionKey(const TSubscriptionKey& other) :
dds::core::Value<D>(other.delegate()) { }
public:
/**
* Sets the key
*
* @param key the key
*/
TSubscriptionKey& key(const std::string& key)
{
this->delegate().key(key);
return *this;
}
/**
* Sets multiple keys
*
* @param keys a sequence containing multiple keys
*/
TSubscriptionKey& key(const dds::core::StringSeq& keys)
{
this->delegate().key(keys);
return *this;
}
/**
* Gets the keys
*
* @return a sequence containing the keys
*/
const dds::core::StringSeq key() const
{
return this->delegate().key();
}
/**
* Sets use_key_list state
*
* @param use_key_list state
*/
TSubscriptionKey& use_key_list(bool use_key_list)
{
this->delegate().use_key_list(use_key_list);
return *this;
}
/**
* Gets use_key_list state
*
* @return use_key_list state
*/
bool use_key_list() const
{
return this->delegate().use_key_list();
}
};
template <typename D>
class TReaderLifespan : public dds::core::Value<D>
{
public:
/**
* Creates a ReaderLifespan QoS instance
*/
TReaderLifespan() { }
/**
* Creates a ReaderLifespan QoS instance
*
* @param used Indicates ReaderLifespan is used
* @param duration ReaderLifespan expiration duration
*/
explicit TReaderLifespan(bool used, const dds::core::Duration& duration) :
dds::core::Value<D>(used, duration) { }
/**
* Copies a Lifespan QoS instance
*
* @param other the Lifespan QoS instance to copy
*/
TReaderLifespan(const TReaderLifespan& other) :
dds::core::Value<D>(other.delegate()) { }
public:
/**
* Sets the used flag
*
* @param used the state of the flag to set
*/
TReaderLifespan& used(bool used)
{
this->delegate().used(used);
return *this;
}
/**
* Gets the used flag
*
* @return true if used
*/
bool used() const
{
return this->delegate().used();
}
/**
* Sets the expiration duration
*
* @param duration expiration duration
*/
TReaderLifespan& duration(const dds::core::Duration& duration)
{
this->delegate().duration(duration);
return *this;
}
/**
* Gets the expiration duration
*
* @return expiration duration
*/
const dds::core::Duration duration() const
{
return this->delegate().duration();
}
};
/**
* Base scheduling class
*/
template <typename D>
class TScheduling : public dds::core::Value<D>
{
public:
/**
* Creates a Scheduling QoS instance
*/
TScheduling() { }
/**
* Creates a Scheduling QoS instance
*
* @param scheduling_kind the scheduling kind
* @param scheduling_priority_kind the scheduling priority kind
* @param scheduling_priority the scheduling priority
*/
TScheduling(const org::eclipse::cyclonedds::core::policy::SchedulingKind::Type& scheduling_kind,
const org::eclipse::cyclonedds::core::policy::SchedulingPriorityKind::Type& scheduling_priority_kind,
int32_t scheduling_priority)
: dds::core::Value<D>(scheduling_kind, scheduling_priority_kind, scheduling_priority)
{
}
/**
* Copies a Scheduling QoS instance
*
* @param other the TProductData QoS instance to copy
*/
TScheduling(const TScheduling& other)
: dds::core::Value<D>(other.delegate())
{
}
public:
/**
* Sets the scheduling kind
*
* @param scheduling_kind the scheduling_kind
*/
TScheduling& scheduling_kind(const org::eclipse::cyclonedds::core::policy::SchedulingKind::Type& scheduling_kind)
{
this->delegate().scheduling_kind(scheduling_kind);
return *this;
}
/**
* Gets the scheduling kind
*
* @return the scheduling_kind
*/
org::eclipse::cyclonedds::core::policy::SchedulingKind::Type scheduling_kind() const
{
return this->delegate().scheduling_kind();
}
/**
* Sets the scheduling priority kind
*
* @param scheduling_priority_kind the scheduling_priority_kind
*/
TScheduling& scheduling_kind(const org::eclipse::cyclonedds::core::policy::SchedulingPriorityKind::Type& scheduling_priority_kind)
{
this->delegate().scheduling_priority_kind(scheduling_priority_kind);
return *this;
}
/**
* Gets the scheduling priority kind
*
* @return the scheduling_priority_kind
*/
org::eclipse::cyclonedds::core::policy::SchedulingPriorityKind::Type scheduling_priority_kind() const
{
return this->delegate().scheduling_priority_kind();
}
/**
* Sets the scheduling priority
*
* @param scheduling_priority the scheduling_priority
*/
TScheduling& scheduling_priority(int32_t scheduling_priority)
{
this->delegate().scheduling_priority(scheduling_priority);
return *this;
}
/**
* Gets the scheduling priority
*
* @return the scheduling_priority
*/
int32_t scheduling_priority() const
{
return this->delegate().scheduling_priority();
}
};
/**
* Listener specific scheduling class
*/
template <typename D>
class TListenerScheduling : public org::eclipse::cyclonedds::core::policy::TScheduling<D>
{
public:
/**
* Creates a ListenerScheduling QoS instance
*/
TListenerScheduling() { }
explicit TListenerScheduling(const org::eclipse::cyclonedds::core::policy::SchedulingKind::Type& scheduling_kind,
const org::eclipse::cyclonedds::core::policy::SchedulingPriorityKind::Type& scheduling_priority_kind,
int32_t scheduling_priority)
: org::eclipse::cyclonedds::core::policy::TScheduling<D>(scheduling_kind, scheduling_priority_kind, scheduling_priority)
{
}
};
/**
* Watchdog specific scheduling class
*/
template <typename D>
class TWatchdogScheduling : public org::eclipse::cyclonedds::core::policy::TScheduling<D>
{
public:
/**
* Creates a WatchdogScheduling QoS instance
*/
TWatchdogScheduling() { }
explicit TWatchdogScheduling(const org::eclipse::cyclonedds::core::policy::SchedulingKind::Type& scheduling_kind,
const org::eclipse::cyclonedds::core::policy::SchedulingPriorityKind::Type& scheduling_priority_kind,
int32_t scheduling_priority)
: org::eclipse::cyclonedds::core::policy::TScheduling<D>(scheduling_kind, scheduling_priority_kind, scheduling_priority)
{
}
};
}
}
}
}
}
#endif /* CYCLONEDDS_CORE_POLICY_TPOLICY_HPP_ */

View File

@@ -0,0 +1,813 @@
/*
* 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_CORE_STATUS_STATUS_DELEGATE_HPP_
#define CYCLONEDDS_CORE_STATUS_STATUS_DELEGATE_HPP_
#include <org/eclipse/cyclonedds/core/config.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
class InconsistentTopicStatusDelegate
{
public:
InconsistentTopicStatusDelegate() : total_count_(0), total_count_change_(0) { }
public:
int32_t total_count() const
{
return total_count_;
}
int32_t total_count_change() const
{
return total_count_change_;
}
void total_count(int32_t total_count)
{
total_count_ = total_count;
}
void total_count_change(int32_t total_count_change)
{
total_count_change_ = total_count_change;
}
bool operator ==(const InconsistentTopicStatusDelegate& other) const
{
return other.total_count() == total_count_ ;
}
public:
void ddsc_status(const dds_inconsistent_topic_status_t* from)
{
total_count_ = static_cast<int32_t>(from->total_count);
total_count_change_ = from->total_count_change;
}
protected:
int32_t total_count_;
int32_t total_count_change_;
};
class SampleLostStatusDelegate
{
public:
SampleLostStatusDelegate() : total_count_(0), total_count_change_(0) { }
public:
int32_t total_count() const
{
return total_count_;
}
int32_t total_count_change() const
{
return total_count_change_;
}
void total_count(int32_t total_count)
{
total_count_ = total_count;
}
void total_count_change(int32_t total_count_change)
{
total_count_change_ = total_count_change;
}
bool operator ==(const SampleLostStatusDelegate& other) const
{
return other.total_count() == total_count_;
}
public:
void ddsc_status(const dds_sample_lost_status_t* from)
{
total_count_ = static_cast<int32_t>(from->total_count);
total_count_change_ = from->total_count_change;
}
protected:
int32_t total_count_;
int32_t total_count_change_;
};
class SampleRejectedStatusDelegate
{
public:
SampleRejectedStatusDelegate()
: total_count_(0),
total_count_change_(0),
last_reason_(dds::core::status::SampleRejectedState::not_rejected()),
last_instance_handle_(dds::core::null) { }
public:
int32_t total_count() const
{
return total_count_;
}
int32_t total_count_change() const
{
return total_count_change_;
}
dds::core::status::SampleRejectedState last_reason() const
{
return last_reason_;
}
const dds::core::InstanceHandle last_instance_handle() const
{
return last_instance_handle_;
}
void total_count(int32_t total_count)
{
total_count_ = total_count;
}
void total_count_change(int32_t total_count_change)
{
total_count_change_ = total_count_change;
}
void last_reason(dds::core::status::SampleRejectedState last_reason)
{
last_reason_ = last_reason;
}
void last_instance_handle(dds::core::InstanceHandle last_instance_handle)
{
last_instance_handle_ = last_instance_handle;
}
bool operator ==(const SampleRejectedStatusDelegate& other) const
{
return other.total_count() == total_count_ &&
other.last_reason() == last_reason_ &&
other.last_instance_handle() == last_instance_handle_;
}
public:
void ddsc_status(const dds_sample_rejected_status_t* from)
{
total_count_ = static_cast<int32_t>(from->total_count);
total_count_change_ = from->total_count_change;
switch (from->last_reason) {
case DDS_NOT_REJECTED:
last_reason_ = dds::core::status::SampleRejectedState::not_rejected();
break;
case DDS_REJECTED_BY_INSTANCES_LIMIT:
last_reason_ = dds::core::status::SampleRejectedState::rejected_by_instances_limit();
break;
case DDS_REJECTED_BY_SAMPLES_LIMIT:
last_reason_ = dds::core::status::SampleRejectedState::rejected_by_samples_limit();
break;
case DDS_REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT:
last_reason_ = dds::core::status::SampleRejectedState::rejected_by_samples_per_instance_limit();
break;
default:
ISOCPP_THROW_EXCEPTION(ISOCPP_ERROR, "Invalid SampleRejectedStatus::last_reason from ddsc");
break;
}
last_instance_handle_ = dds::core::InstanceHandle(from->last_instance_handle);
}
protected:
int32_t total_count_;
int32_t total_count_change_;
dds::core::status::SampleRejectedState last_reason_;
dds::core::InstanceHandle last_instance_handle_;
};
class LivelinessLostStatusDelegate
{
public:
LivelinessLostStatusDelegate() : total_count_(0), total_count_change_(0) { }
public:
int32_t total_count() const
{
return total_count_;
}
int32_t total_count_change() const
{
return total_count_change_;
}
void total_count(int32_t total_count)
{
total_count_ = total_count;
}
void total_count_change(int32_t total_count_change)
{
total_count_change_ = total_count_change;
}
bool operator ==(const LivelinessLostStatusDelegate& other) const
{
return other.total_count() == total_count_;
}
public:
void ddsc_status(const dds_liveliness_lost_status_t* from)
{
total_count_ = static_cast<int32_t>(from->total_count);
total_count_change_ = from->total_count_change;
}
protected:
int32_t total_count_;
int32_t total_count_change_;
};
class LivelinessChangedStatusDelegate
{
public:
LivelinessChangedStatusDelegate() :
alive_count_(0),
not_alive_count_(0),
alive_count_change_(0),
not_alive_count_change_(0),
last_publication_handle_(dds::core::null) { }
public:
int32_t alive_count() const
{
return alive_count_;
}
int32_t not_alive_count() const
{
return not_alive_count_;
}
int32_t alive_count_change() const
{
return alive_count_change_;
}
int32_t not_alive_count_change() const
{
return not_alive_count_change_;
}
void alive_count(int32_t alive_count)
{
alive_count_ = alive_count;
}
void not_alive_count(int32_t not_alive_count)
{
not_alive_count_ = not_alive_count;
}
void alive_count_change(int32_t alive_count_change)
{
alive_count_change_ = alive_count_change;
}
void not_alive_count_change(int32_t not_alive_count_change)
{
not_alive_count_change_ = not_alive_count_change;
}
void last_publication_handle(dds::core::InstanceHandle last_publication_handle)
{
last_publication_handle_ = last_publication_handle;
}
dds::core::InstanceHandle last_publication_handle() const
{
return last_publication_handle_;
}
bool operator ==(const LivelinessChangedStatusDelegate& other) const
{
return other.alive_count() == alive_count_ &&
other.not_alive_count() == not_alive_count_;
}
public:
void ddsc_status(const dds_liveliness_changed_status_t* from)
{
alive_count_ = static_cast<int32_t>(from->alive_count);
not_alive_count_ = static_cast<int32_t>(from->not_alive_count);
alive_count_change_ = from->alive_count_change;
not_alive_count_change_ = from->not_alive_count_change;
last_publication_handle_ = dds::core::InstanceHandle(from->last_publication_handle);
}
protected:
int32_t alive_count_;
int32_t not_alive_count_;
int32_t alive_count_change_;
int32_t not_alive_count_change_;
dds::core::InstanceHandle last_publication_handle_;
};
class OfferedDeadlineMissedStatusDelegate
{
public:
OfferedDeadlineMissedStatusDelegate() :
total_count_(0),
total_count_change_(0),
last_instance_handle_(dds::core::null) { }
public:
int32_t total_count() const
{
return total_count_;
}
int32_t total_count_change() const
{
return total_count_change_;
}
const dds::core::InstanceHandle last_instance_handle() const
{
return last_instance_handle_;
}
void total_count(int32_t total_count)
{
total_count_ = total_count;
}
void total_count_change(int32_t total_count_change)
{
total_count_change_ = total_count_change;
}
void last_instance_handle(dds::core::InstanceHandle last_instance_handle)
{
last_instance_handle_ = last_instance_handle;
}
bool operator ==(const OfferedDeadlineMissedStatusDelegate& other) const
{
return other.total_count() == total_count_ &&
other.last_instance_handle() == last_instance_handle_;
}
public:
void ddsc_status(const dds_offered_deadline_missed_status* from)
{
total_count_ = static_cast<int32_t>(from->total_count);
total_count_change_ = from->total_count_change;
last_instance_handle_ = dds::core::InstanceHandle(from->last_instance_handle);
}
protected:
int32_t total_count_;
int32_t total_count_change_;
dds::core::InstanceHandle last_instance_handle_;
};
class RequestedDeadlineMissedStatusDelegate
{
public:
RequestedDeadlineMissedStatusDelegate() :
total_count_(0),
total_count_change_(0),
last_instance_handle_(dds::core::null) { }
public:
int32_t total_count() const
{
return total_count_;
}
int32_t total_count_change() const
{
return total_count_change_;
}
const dds::core::InstanceHandle last_instance_handle() const
{
return last_instance_handle_;
}
void total_count(int32_t total_count)
{
total_count_ = total_count;
}
void total_count_change(int32_t total_count_change)
{
total_count_change_ = total_count_change;
}
void last_instance_handle(dds::core::InstanceHandle last_instance_handle)
{
last_instance_handle_ = last_instance_handle;
}
bool operator ==(const RequestedDeadlineMissedStatusDelegate& other) const
{
return other.total_count() == total_count_ &&
other.last_instance_handle() == last_instance_handle_;
}
public:
void ddsc_status(const dds_requested_deadline_missed_status_t* from)
{
total_count_ = static_cast<int32_t>(from->total_count);
total_count_change_ = from->total_count_change;
last_instance_handle_ = dds::core::InstanceHandle(from->last_instance_handle);
}
protected:
int32_t total_count_;
int32_t total_count_change_;
dds::core::InstanceHandle last_instance_handle_;
};
class OfferedIncompatibleQosStatusDelegate
{
public:
OfferedIncompatibleQosStatusDelegate() :
total_count_(0),
total_count_change_(0),
last_policy_id_(0) { }
public :
int32_t total_count() const
{
return total_count_;
}
int32_t total_count_change() const
{
return total_count_change_;
}
dds::core::policy::QosPolicyId last_policy_id() const
{
return last_policy_id_;
}
const dds::core::policy::QosPolicyCountSeq policies() const
{
return policies_;
}
const dds::core::policy::QosPolicyCountSeq& policies(dds::core::policy::QosPolicyCountSeq& dst) const
{
dst = policies_;
return dst;
}
void total_count(int32_t total_count)
{
total_count_ = total_count;
}
void total_count_change(int32_t total_count_change)
{
total_count_change_ = total_count_change;
}
void last_policy_id(dds::core::policy::QosPolicyId last_policy_id)
{
last_policy_id_ = last_policy_id;
}
void set_policies(dds::core::policy::QosPolicyCountSeq policies)
{
policies_ = policies;
}
bool operator ==(const OfferedIncompatibleQosStatusDelegate& other) const
{
return other.total_count() == total_count_ &&
other.last_policy_id() == last_policy_id_ &&
other.policies() == policies_;
}
public:
void ddsc_status(const dds_offered_incompatible_qos_status_t* from)
{
total_count_ = static_cast<int32_t>(from->total_count);
total_count_change_ = from->total_count_change;
last_policy_id_ = from->last_policy_id;
policies_.clear();
#if 0 //@todo
for (c_long i = 0; (i < V_POLICY_ID_COUNT) && (i < from->totalCount); i++)
{
if (((c_long*)(from->policyCount))[i] != 0) {
dds::core::policy::QosPolicyCount policy(i, ((c_long*)(from->policyCount))[i]);
policies_->push_back(policy);
}
}
#endif
}
protected:
int32_t total_count_;
int32_t total_count_change_;
dds::core::policy::QosPolicyId last_policy_id_;
dds::core::policy::QosPolicyCountSeq policies_;
};
class RequestedIncompatibleQosStatusDelegate
{
public:
RequestedIncompatibleQosStatusDelegate() :
total_count_(0),
total_count_change_(0),
last_policy_id_(0) { }
public :
int32_t total_count() const
{
return total_count_;
}
int32_t total_count_change() const
{
return total_count_change_;
}
dds::core::policy::QosPolicyId last_policy_id() const
{
return last_policy_id_;
}
const dds::core::policy::QosPolicyCountSeq policies() const
{
return policies_;
}
const dds::core::policy::QosPolicyCountSeq& policies(dds::core::policy::QosPolicyCountSeq& dst) const
{
dst = policies_;
return dst;
}
void total_count(int32_t total_count)
{
total_count_ = total_count;
}
void total_count_change(int32_t total_count_change)
{
total_count_change_ = total_count_change;
}
void last_policy_id(dds::core::policy::QosPolicyId last_policy_id)
{
last_policy_id_ = last_policy_id;
}
void set_policies(dds::core::policy::QosPolicyCountSeq policies)
{
policies_ = policies;
}
bool operator ==(const RequestedIncompatibleQosStatusDelegate& other) const
{
return other.total_count() == total_count_ &&
other.last_policy_id() == last_policy_id_ &&
other.policies() == policies_;
}
public:
void ddsc_status(const dds_requested_incompatible_qos_status_t* from)
{
total_count_ = static_cast<int32_t>(from->total_count);
total_count_change_ = from->total_count_change;
last_policy_id_ = from->last_policy_id;
policies_.clear();
#if 0 //@todo
for (c_long i = 0; (i < V_POLICY_ID_COUNT) && (i < from->totalCount); i++)
{
if (((c_long*)(from->policyCount))[i] != 0) {
dds::core::policy::QosPolicyCount policy(i, ((c_long*)(from->policyCount))[i]);
policies_.push_back(policy);
}
}
#endif
}
protected:
int32_t total_count_;
int32_t total_count_change_;
dds::core::policy::QosPolicyId last_policy_id_;
dds::core::policy::QosPolicyCountSeq policies_;
};
class PublicationMatchedStatusDelegate
{
public:
PublicationMatchedStatusDelegate() :
total_count_(0),
total_count_change_(0),
current_count_(0),
current_count_change_(0),
last_subscription_handle_(dds::core::null) { }
public:
int32_t total_count() const
{
return total_count_;
}
int32_t total_count_change() const
{
return total_count_change_;
}
int32_t current_count() const
{
return current_count_;
}
int32_t current_count_change() const
{
return current_count_change_;
}
const dds::core::InstanceHandle last_subscription_handle() const
{
return last_subscription_handle_;
}
void total_count(int32_t total_count)
{
total_count_ = total_count;
}
void total_count_change(int32_t total_count_change)
{
total_count_change_ = total_count_change;
}
void current_count(int32_t current_count)
{
current_count_ = current_count;
}
void current_count_change(int32_t current_count_change)
{
current_count_change_ = current_count_change;
}
void last_subscription_handle(dds::core::InstanceHandle last_subscription_handle)
{
last_subscription_handle_ = last_subscription_handle;
}
bool operator ==(const PublicationMatchedStatusDelegate& other) const
{
return other.total_count() == total_count_ &&
other.current_count() == current_count_ &&
other.last_subscription_handle() == last_subscription_handle_;
}
public:
void ddsc_status(const dds_publication_matched_status_t* from)
{
total_count_ = static_cast<int32_t>(from->total_count);
total_count_change_ = from->total_count_change;
current_count_ = static_cast<int32_t>(from->current_count);
current_count_change_ = from->current_count_change;
last_subscription_handle_ = dds::core::InstanceHandle(from->last_subscription_handle);
}
protected:
int32_t total_count_;
int32_t total_count_change_;
int32_t current_count_;
int32_t current_count_change_;
dds::core::InstanceHandle last_subscription_handle_;
};
class SubscriptionMatchedStatusDelegate
{
public:
SubscriptionMatchedStatusDelegate() :
total_count_(0),
total_count_change_(0),
current_count_(0),
current_count_change_(0),
last_publication_handle_(dds::core::null) { }
public:
int32_t total_count() const
{
return total_count_;
}
int32_t total_count_change() const
{
return total_count_change_;
}
int32_t current_count() const
{
return current_count_;
}
int32_t current_count_change() const
{
return current_count_change_;
}
const dds::core::InstanceHandle last_publication_handle() const
{
return last_publication_handle_;
}
void total_count(int32_t total_count)
{
total_count_ = total_count;
}
void total_count_change(int32_t total_count_change)
{
total_count_change_ = total_count_change;
}
void current_count(int32_t current_count)
{
current_count_ = current_count;
}
void current_count_change(int32_t current_count_change)
{
current_count_change_ = current_count_change;
}
void last_publication_handle(dds::core::InstanceHandle last_publication_handle)
{
last_publication_handle_ = last_publication_handle;
}
bool operator ==(const SubscriptionMatchedStatusDelegate& other) const
{
return other.total_count() == total_count_ &&
other.current_count() == current_count_ &&
other.last_publication_handle() == last_publication_handle_;
}
public:
void ddsc_status(const dds_subscription_matched_status_t* from)
{
total_count_ = static_cast<int32_t>(from->total_count);
total_count_change_ = from->total_count_change;
current_count_ = static_cast<int32_t>(from->current_count);
current_count_change_ = from->current_count_change;
last_publication_handle_ = dds::core::InstanceHandle(from->last_publication_handle);
}
protected:
int32_t total_count_;
int32_t total_count_change_;
int32_t current_count_;
int32_t current_count_change_;
dds::core::InstanceHandle last_publication_handle_;
};
}
}
}
} /* namespace org::eclipse::cyclonedds::core */
#endif /* CYCLONEDDS_CORE_STATUS_STATUS_DELEGATE_HPP_ */

View File

@@ -0,0 +1,63 @@
/*
* 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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_CORE_TYPE_HELPERS_HPP_
#define CYCLONEDDS_CORE_TYPE_HELPERS_HPP_
#include <type_traits>
//for c++ < 14
#if __cplusplus == 201103L
#include <org/eclipse/cyclonedds/core/Missing.hpp>
#endif
//check template for whether a class is a template specification of another
template<typename Test, template<typename...> class Ref>
struct is_specialization : std::false_type {};
template<template<typename...> class Ref, typename... Args>
struct is_specialization<Ref<Args...>, Ref> : std::true_type {};
//check template for whether a class is an STL container
template<typename T, typename _ = void>
struct is_container : std::false_type {};
template<typename... Ts>
struct is_container_helper {};
template<typename T>
struct is_container<
T,
std::conditional_t<
false,
is_container_helper<
typename T::value_type,
typename T::size_type,
typename T::allocator_type,
typename T::iterator,
typename T::const_iterator,
decltype(std::declval<T>().size()),
decltype(std::declval<T>().begin()),
decltype(std::declval<T>().end()),
decltype(std::declval<T>().cbegin()),
decltype(std::declval<T>().cend())
>,
void
>
> : public std::true_type{};
#endif

View File

@@ -0,0 +1,39 @@
/*
* 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_DOMAIN_DOMAIN_HPP_
#define CYCLONEDDS_DOMAIN_DOMAIN_HPP_
#include "dds/core/types.hpp"
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace domain
{
OMG_DDS_API uint32_t any_id();
OMG_DDS_API uint32_t default_id();
}
}
}
}
#endif /* CYCLONEDDS_DOMAIN_DOMAIN_HPP_ */

View File

@@ -0,0 +1,187 @@
/*
* 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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_DOMAIN_PARTICIPANT_DELEGATE_HPP_
#define CYCLONEDDS_DOMAIN_PARTICIPANT_DELEGATE_HPP_
// DDS-PSM-Cxx Includes
#include <dds/core/ref_traits.hpp>
#include <dds/core/Time.hpp>
#include <dds/core/InstanceHandle.hpp>
#include <dds/core/status/State.hpp>
#include <dds/core/detail/WeakReferenceImpl.hpp>
#include <dds/core/Entity.hpp>
#include <dds/domain/qos/DomainParticipantQos.hpp>
#include <dds/topic/qos/TopicQos.hpp>
#include <dds/pub/qos/PublisherQos.hpp>
#include <dds/sub/qos/SubscriberQos.hpp>
// Delegate Includes
#include <org/eclipse/cyclonedds/ForwardDeclarations.hpp>
#include <org/eclipse/cyclonedds/core/Mutex.hpp>
#include <org/eclipse/cyclonedds/core/EntityDelegate.hpp>
#include <org/eclipse/cyclonedds/core/ObjectSet.hpp>
#include <org/eclipse/cyclonedds/core/EntitySet.hpp>
#include "org/eclipse/cyclonedds/domain/Domain.hpp"
#include "org/eclipse/cyclonedds/domain/DomainWrap.hpp"
class OMG_DDS_API org::eclipse::cyclonedds::domain::DomainParticipantDelegate :
public ::org::eclipse::cyclonedds::core::EntityDelegate
{
public:
typedef ::dds::core::smart_ptr_traits< DomainParticipantDelegate >::ref_type ref_type;
typedef ::dds::core::smart_ptr_traits< DomainParticipantDelegate >::weak_ref_type weak_ref_type;
DomainParticipantDelegate(uint32_t id,
const dds::domain::qos::DomainParticipantQos& qos,
dds::domain::DomainParticipantListener *listener,
const dds::core::status::StatusMask& mask,
const std::string& config);
DomainParticipantDelegate(uint32_t id,
const dds::domain::qos::DomainParticipantQos& qos,
dds::domain::DomainParticipantListener *listener,
const dds::core::status::StatusMask& mask,
const ddsi_config& config);
virtual ~DomainParticipantDelegate();
public:
void init(ObjectDelegate::weak_ref_type weak_ref);
void listener(dds::domain::DomainParticipantListener *listener,
const ::dds::core::status::StatusMask& mask);
dds::domain::DomainParticipantListener* listener() const;
const dds::domain::qos::DomainParticipantQos& qos() const;
void qos(const dds::domain::qos::DomainParticipantQos& qos);
uint32_t domain_id();
void assert_liveliness();
bool contains_entity(const ::dds::core::InstanceHandle& handle);
void close();
dds::core::Time current_time() const;
dds::topic::qos::TopicQos default_topic_qos() const;
void default_topic_qos(const dds::topic::qos::TopicQos& qos);
dds::pub::qos::PublisherQos default_publisher_qos() const;
void default_publisher_qos(const ::dds::pub::qos::PublisherQos& qos);
dds::sub::qos::SubscriberQos default_subscriber_qos() const;
void default_subscriber_qos(const ::dds::sub::qos::SubscriberQos& qos);
static dds::domain::qos::DomainParticipantQos default_participant_qos();
static void default_participant_qos(const ::dds::domain::qos::DomainParticipantQos& qos);
static void add_participant(org::eclipse::cyclonedds::core::EntityDelegate& participant);
static void remove_participant(org::eclipse::cyclonedds::core::EntityDelegate& participant);
void add_publisher(org::eclipse::cyclonedds::core::EntityDelegate& publisher);
void remove_publisher(org::eclipse::cyclonedds::core::EntityDelegate& publisher);
void add_subscriber(org::eclipse::cyclonedds::core::EntityDelegate& subscriber);
void remove_subscriber(org::eclipse::cyclonedds::core::EntityDelegate& subscriber);
void add_topic(org::eclipse::cyclonedds::core::EntityDelegate& topic);
void remove_topic(org::eclipse::cyclonedds::core::EntityDelegate& topic);
void add_cfTopic(org::eclipse::cyclonedds::core::ObjectDelegate& cfTopic);
void remove_cfTopic(org::eclipse::cyclonedds::core::ObjectDelegate& cfTopic);
org::eclipse::cyclonedds::core::EntityDelegate::ref_type
find_topic(const std::string& topic_name);
org::eclipse::cyclonedds::core::ObjectDelegate::ref_type
find_cfTopic(const std::string& topic_name);
dds_entity_t
lookup_topic(const std::string& topic_name,
const dds_typeinfo_t *type_info,
const dds::core::Duration& timeout);
void
lookup_topics(const std::string& type_name,
std::vector<dds_entity_t>& topics,
uint32_t max_size);
static org::eclipse::cyclonedds::domain::DomainParticipantDelegate::ref_type
lookup_participant(uint32_t domain_id);
dds::domain::TDomainParticipant<DomainParticipantDelegate>
wrapper();
bool is_auto_enable() const;
void ignore_participant(const ::dds::core::InstanceHandle& handle);
virtual void
listener_notify(ObjectDelegate::ref_type source,
uint32_t triggerMask,
void *eventData,
void *listener);
org::eclipse::cyclonedds::core::EntityDelegate::ref_type
builtin_subscriber();
void
builtin_subscriber(const org::eclipse::cyclonedds::core::EntityDelegate::ref_type subscriber);
// Subscriber events
virtual void on_data_readers(dds_entity_t subscriber);
// Reader events
void on_requested_deadline_missed(dds_entity_t reader,
org::eclipse::cyclonedds::core::RequestedDeadlineMissedStatusDelegate &sd);
void on_requested_incompatible_qos(dds_entity_t reader,
org::eclipse::cyclonedds::core::RequestedIncompatibleQosStatusDelegate &sd);
void on_sample_rejected(dds_entity_t reader,
org::eclipse::cyclonedds::core::SampleRejectedStatusDelegate &sd);
void on_liveliness_changed(dds_entity_t reader,
org::eclipse::cyclonedds::core::LivelinessChangedStatusDelegate &sd);
void on_data_available(dds_entity_t reader);
void on_subscription_matched(dds_entity_t reader,
org::eclipse::cyclonedds::core::SubscriptionMatchedStatusDelegate &sd);
void on_sample_lost(dds_entity_t reader,
org::eclipse::cyclonedds::core::SampleLostStatusDelegate &sd);
private:
static org::eclipse::cyclonedds::core::EntitySet participants;
static dds::domain::qos::DomainParticipantQos default_participant_qos_;
static org::eclipse::cyclonedds::core::Mutex global_participants_lock_;
static org::eclipse::cyclonedds::domain::DomainWrap::map_ref_type domain_registry_;
uint32_t domain_id_;
dds::domain::qos::DomainParticipantQos qos_;
dds::topic::qos::TopicQos default_topic_qos_;
dds::pub::qos::PublisherQos default_pub_qos_;
dds::sub::qos::SubscriberQos default_sub_qos_;
org::eclipse::cyclonedds::core::EntitySet publishers;
org::eclipse::cyclonedds::core::EntitySet subscribers;
org::eclipse::cyclonedds::core::EntitySet topics;
org::eclipse::cyclonedds::core::ObjectSet cfTopics;
org::eclipse::cyclonedds::core::EntityDelegate::weak_ref_type builtin_subscriber_;
org::eclipse::cyclonedds::domain::DomainWrap::ref_type domain_ref_;
};
#endif /* CYCLONEDDS_DOMAIN_PARTICIPANT_DELEGATE_HPP_ */

View File

@@ -0,0 +1,60 @@
/*
* 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_DOMAIN_DOMAINPARTICIPANT_LISTENER_HPP_
#define CYCLONEDDS_DOMAIN_DOMAINPARTICIPANT_LISTENER_HPP_
#include <dds/domain/DomainParticipantListener.hpp>
#include <org/eclipse/cyclonedds/topic/AnyTopicListener.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace domain
{
DDSCXX_WARNING_MSVC_OFF(4250)
class OMG_DDS_API DomainParticipantListener :
public virtual dds::domain::DomainParticipantListener,
public virtual org::eclipse::cyclonedds::topic::AnyTopicListener
{
public:
virtual ~DomainParticipantListener() { }
};
class OMG_DDS_API NoOpDomainParticipantListener :
public virtual dds::domain::NoOpDomainParticipantListener,
public virtual org::eclipse::cyclonedds::topic::NoOpAnyTopicListener
{
public:
virtual ~NoOpDomainParticipantListener() { }
};
DDSCXX_WARNING_MSVC_ON(4250)
}
}
}
}
#endif /* CYCLONEDDS_DOMAIN_DOMAINPARTICIPANT_LISTENER_HPP_ */

View File

@@ -0,0 +1,52 @@
/*
* 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_DOMAIN_PARTICIPANT_REGISTRY_HPP_
#define CYCLONEDDS_DOMAIN_PARTICIPANT_REGISTRY_HPP_
#include <org/eclipse/cyclonedds/core/EntityRegistry.hpp>
#include <org/eclipse/cyclonedds/domain/DomainParticipantDelegate.hpp>
#include <dds/domain/TDomainParticipant.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace domain
{
class OMG_DDS_API DomainParticipantRegistry {
public:
static void insert(dds::domain::TDomainParticipant<org::eclipse::cyclonedds::domain::DomainParticipantDelegate>& participant);
static void remove(org::eclipse::cyclonedds::domain::DomainParticipantDelegate *delegate);
private:
static org::eclipse::cyclonedds::core::EntityRegistry
<org::eclipse::cyclonedds::domain::DomainParticipantDelegate *,
dds::domain::TDomainParticipant<org::eclipse::cyclonedds::domain::DomainParticipantDelegate> > registry;
};
}
}
}
}
#endif /* CYCLONEDDS_DOMAIN_PARTICIPANT_REGISTRY_HPP_ */

View File

@@ -0,0 +1,70 @@
/*
* 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_DOMAIN_WRAP_HPP_
#define CYCLONEDDS_DOMAIN_WRAP_HPP_
#include <map>
#include <dds/dds.h>
#include <dds/core/ref_traits.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace domain
{
/*
* In cyclonedds, you can now create a domain explicitly. A participant will
* attach to that domain automatically if the ids match. If the participant
* can not find a domain, then it'll create one implicitly.
*
* The explicit creation is needed for the 'config by string' feature.
*
* To be able to use that feature in C++, this small 'domain' wrapper class
* is introduced.
*
* It should be created for every new domain (detected during participant
* creation) and should be deleted when the last participant is closed that
* uses the related domain.
*
* Either, this wrapper contains an explicitly created domain or not.
* When not, it's basically just a placeholder.
* When yes, it'll delete the explicitly created domain in its destructor.
*/
class DomainWrap
{
public:
typedef ::dds::core::smart_ptr_traits< DomainWrap >::ref_type ref_type;
typedef ::std::map<dds_domainid_t, ref_type> map_ref_type;
typedef map_ref_type::iterator map_ref_iter;
public:
DomainWrap(dds_domainid_t id, const std::string& config);
DomainWrap(dds_domainid_t id, const ddsi_config& config);
~DomainWrap();
private:
dds_entity_t ddsc_domain;
};
}}}} /* namespaced */
#endif /* CYCLONEDDS_DOMAIN_WRAP_HPP_ */

View File

@@ -0,0 +1,104 @@
/*
* 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_DOMAIN_QOS_DOMAIN_PARTICIPANT_QOS_DELEGATE_HPP_
#define CYCLONEDDS_DOMAIN_QOS_DOMAIN_PARTICIPANT_QOS_DELEGATE_HPP_
#include <dds/core/policy/CorePolicy.hpp>
struct _DDS_NamedDomainParticipantQos;
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace domain
{
namespace qos
{
class OMG_DDS_API DomainParticipantQosDelegate
{
public:
DomainParticipantQosDelegate();
DomainParticipantQosDelegate(const DomainParticipantQosDelegate& other);
~DomainParticipantQosDelegate();
void policy(const dds::core::policy::UserData& ud);
void policy(const dds::core::policy::EntityFactory& efp);
template <typename POLICY> const POLICY& policy() const;
template <typename POLICY> POLICY& policy();
/* The returned ddsc QoS has to be freed. */
dds_qos_t* ddsc_qos() const;
void ddsc_qos(const dds_qos_t* qos);
void named_qos(const struct _DDS_NamedDomainParticipantQos &qos);
void check() const;
bool operator ==(const DomainParticipantQosDelegate& other) const;
DomainParticipantQosDelegate& operator =(const DomainParticipantQosDelegate& other);
private:
dds::core::policy::UserData user_data_;
dds::core::policy::EntityFactory entity_factory_;
};
//==============================================================================
template<>
inline const dds::core::policy::UserData&
DomainParticipantQosDelegate::policy<dds::core::policy::UserData> () const
{
return user_data_;
}
template<>
inline dds::core::policy::UserData&
DomainParticipantQosDelegate::policy<dds::core::policy::UserData> ()
{
return user_data_;
}
template<>
inline const dds::core::policy::EntityFactory&
DomainParticipantQosDelegate::policy<dds::core::policy::EntityFactory> () const
{
return entity_factory_;
}
template<>
inline dds::core::policy::EntityFactory&
DomainParticipantQosDelegate::policy<dds::core::policy::EntityFactory> ()
{
return entity_factory_;
}
}
}
}
}
}
#endif /* CYCLONEDDS_DOMAIN_QOS_DOMAIN_PARTICIPANT_QOS_DELEGATE_HPP_ */

View File

@@ -0,0 +1,203 @@
/*
* 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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_PUB_ANYDATAWRITERDELEGATE_HPP_
#define CYCLONEDDS_PUB_ANYDATAWRITERDELEGATE_HPP_
#include <dds/core/types.hpp>
#include <dds/core/Time.hpp>
#include <dds/core/InstanceHandle.hpp>
#include <dds/core/status/Status.hpp>
#include <dds/pub/qos/DataWriterQos.hpp>
#include <org/eclipse/cyclonedds/topic/TopicTraits.hpp>
#include <org/eclipse/cyclonedds/core/EntityDelegate.hpp>
#include <dds/topic/TopicDescription.hpp>
#include <dds/topic/BuiltinTopic.hpp>
#include <org/eclipse/cyclonedds/topic/CDRBlob.hpp>
namespace dds { namespace pub {
template <typename DELEGATE>
class TAnyDataWriter;
} }
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace pub
{
class OMG_DDS_API AnyDataWriterDelegate : public org::eclipse::cyclonedds::core::EntityDelegate
{
public:
typedef ::dds::core::smart_ptr_traits< AnyDataWriterDelegate >::ref_type ref_type;
typedef ::dds::core::smart_ptr_traits< AnyDataWriterDelegate >::weak_ref_type weak_ref_type;
virtual ~AnyDataWriterDelegate();
void close();
public:
/* DDS API mirror. */
dds::pub::qos::DataWriterQos qos() const;
void qos(const dds::pub::qos::DataWriterQos& qos);
/* Let DataWriter<T> implement the publisher handling to circumvent circular dependencies. */
virtual const dds::pub::TPublisher<org::eclipse::cyclonedds::pub::PublisherDelegate>& publisher() const = 0;
const dds::topic::TopicDescription& topic_description() const;
void wait_for_acknowledgments(const dds::core::Duration& timeout);
const ::dds::core::status::LivelinessLostStatus liveliness_lost_status();
const ::dds::core::status::OfferedDeadlineMissedStatus offered_deadline_missed_status();
const ::dds::core::status::OfferedIncompatibleQosStatus offered_incompatible_qos_status();
const ::dds::core::status::PublicationMatchedStatus publication_matched_status();
::dds::core::InstanceHandleSeq
matched_subscriptions();
template <typename FwdIterator>
uint32_t
matched_subscriptions(FwdIterator begin, uint32_t max_size)
{
::dds::core::InstanceHandleSeq handleSeq = matched_subscriptions();
uint32_t seq_size = static_cast<uint32_t>(handleSeq.size());
uint32_t size = (seq_size < max_size ? seq_size : max_size);
for (uint32_t i = 0; i < size; i++, begin++) {
*begin = handleSeq[i];
}
return size;
}
const dds::topic::SubscriptionBuiltinTopicData
matched_subscription_data(const ::dds::core::InstanceHandle& h);
void assert_liveliness();
public:
dds::pub::TAnyDataWriter<AnyDataWriterDelegate> wrapper_to_any();
void write_flush();
void set_batch(bool);
private:
void
write_cdr(dds_entity_t writer,
const org::eclipse::cyclonedds::topic::CDRBlob *data,
const dds::core::InstanceHandle& handle,
const dds::core::Time& timestamp,
uint32_t statusinfo);
protected:
AnyDataWriterDelegate(const dds::pub::qos::DataWriterQos& qos,
const dds::topic::TopicDescription& td);
void
write_cdr(dds_entity_t writer,
const org::eclipse::cyclonedds::topic::CDRBlob *data,
const dds::core::InstanceHandle& handle,
const dds::core::Time& timestamp);
void
dispose_cdr(dds_entity_t writer,
const org::eclipse::cyclonedds::topic::CDRBlob *data,
const dds::core::InstanceHandle& handle,
const dds::core::Time& timestamp);
void
unregister_instance_cdr(dds_entity_t writer,
const org::eclipse::cyclonedds::topic::CDRBlob *data,
const dds::core::InstanceHandle& handle,
const dds::core::Time& timestamp);
bool
is_loan_supported(const dds_entity_t writer);
void
loan_sample(dds_entity_t writer,
void **sample);
void
return_loan(dds_entity_t writer,
void *sample);
void
write(dds_entity_t writer,
const void *data,
const dds::core::InstanceHandle& handle,
const dds::core::Time& timestamp);
void
writedispose(dds_entity_t writer,
const void *data,
const dds::core::InstanceHandle& handle,
const dds::core::Time& timestamp);
dds_instance_handle_t
register_instance(dds_entity_t writer,
const void *data,
const dds::core::Time& timestamp);
void
unregister_instance(dds_entity_t writer,
const dds::core::InstanceHandle& handle,
const dds::core::Time& timestamp);
void
unregister_instance(dds_entity_t writer,
const void *data,
const dds::core::Time& timestamp);
void
dispose_instance(dds_entity_t writer,
const dds::core::InstanceHandle& handle,
const dds::core::Time& timestamp);
void
dispose_instance(dds_entity_t writer,
const void *data,
const dds::core::Time& timestamp);
void
get_key_value(dds_entity_t writer,
void *data,
const dds::core::InstanceHandle& handle);
dds_instance_handle_t
lookup_instance(dds_entity_t writer,
const void *data);
private:
dds::pub::qos::DataWriterQos qos_;
dds::topic::TopicDescription td_;
//@todo static bool copy_data(c_type t, void *data, void *to);
};
}
}
}
}
#endif /* CYCLONEDDS_PUB_ANYDATAWRITERDELEGATE_HPP_ */

View File

@@ -0,0 +1,54 @@
/*
* 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_PUB_COHERENT_SET_DELEGATE_HPP_
#define CYCLONEDDS_PUB_COHERENT_SET_DELEGATE_HPP_
#include <dds/pub/Publisher.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace pub
{
class OMG_DDS_API CoherentSetDelegate
{
public:
CoherentSetDelegate(const dds::pub::Publisher& pub);
~CoherentSetDelegate();
void end();
bool operator ==(const CoherentSetDelegate& other) const;
private:
dds::pub::Publisher pub;
bool ended;
};
}
}
}
}
#endif /* CYCLONEDDS_PUB_COHERENT_SET_DELEGATE_HPP_ */

View File

@@ -0,0 +1,116 @@
/*
* 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 OMG_IDDS_PUB_PUBLISHER_DELEGATE_HPP_
#define OMG_IDDS_PUB_PUBLISHER_DELEGATE_HPP_
#include <dds/core/types.hpp>
#include <dds/core/Duration.hpp>
#include <dds/core/status/State.hpp>
#include <dds/pub/qos/PublisherQos.hpp>
#include <dds/pub/qos/DataWriterQos.hpp>
#include <dds/domain/DomainParticipant.hpp>
#include <org/eclipse/cyclonedds/ForwardDeclarations.hpp>
#include <org/eclipse/cyclonedds/core/EntityDelegate.hpp>
#include <org/eclipse/cyclonedds/core/EntitySet.hpp>
#include <org/eclipse/cyclonedds/pub/AnyDataWriterDelegate.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace pub
{
class OMG_DDS_API PublisherDelegate : public org::eclipse::cyclonedds::core::EntityDelegate
{
public:
typedef ::dds::core::smart_ptr_traits< PublisherDelegate >::ref_type ref_type;
typedef ::dds::core::smart_ptr_traits< PublisherDelegate >::weak_ref_type weak_ref_type;
PublisherDelegate(const dds::domain::DomainParticipant& dp,
const dds::pub::qos::PublisherQos& qos,
dds::pub::PublisherListener* listener,
const dds::core::status::StatusMask& event_mask);
virtual ~PublisherDelegate();
void init(ObjectDelegate::weak_ref_type weak_ref);
void close();
const dds::pub::qos::PublisherQos& qos() const;
void qos(const dds::pub::qos::PublisherQos& pqos);
void default_datawriter_qos(const dds::pub::qos::DataWriterQos& dwqos);
dds::pub::qos::DataWriterQos default_datawriter_qos() const;
void suspend_publications();
void resume_publications();
void begin_coherent_changes();
void end_coherent_changes();
void wait_for_acknowledgments(const dds::core::Duration& max_wait);
void listener(dds::pub::PublisherListener* listener,
const ::dds::core::status::StatusMask& mask);
dds::pub::PublisherListener* listener() const;
const dds::domain::DomainParticipant& participant() const;
bool contains_entity(const ::dds::core::InstanceHandle& handle);
void add_datawriter(org::eclipse::cyclonedds::core::EntityDelegate& datawriter);
void remove_datawriter(org::eclipse::cyclonedds::core::EntityDelegate& datawriter);
org::eclipse::cyclonedds::pub::AnyDataWriterDelegate::ref_type find_datawriter(const std::string& topic_name);
dds::pub::TPublisher<PublisherDelegate>
wrapper();
bool is_auto_enable() const;
void on_offered_deadline_missed(dds_entity_t writer,
org::eclipse::cyclonedds::core::OfferedDeadlineMissedStatusDelegate &sd);
void on_offered_incompatible_qos(dds_entity_t writer,
org::eclipse::cyclonedds::core::OfferedIncompatibleQosStatusDelegate &sd);
void on_liveliness_lost(dds_entity_t writer,
org::eclipse::cyclonedds::core::LivelinessLostStatusDelegate &sd);
void on_publication_matched(dds_entity_t writer,
org::eclipse::cyclonedds::core::PublicationMatchedStatusDelegate &sd);
private:
dds::domain::DomainParticipant dp_;
dds::pub::qos::PublisherQos qos_;
dds::pub::qos::DataWriterQos default_dwqos_;
org::eclipse::cyclonedds::core::EntitySet writers;
};
}
}
}
}
#endif /* OMG_IDDS_PUB_PUBLISHER_DELEGATE_HPP_ */

View File

@@ -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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_PUB_SUSPENDED_PUBBLICATIONS_DELEGATE_HPP_
#define CYCLONEDDS_PUB_SUSPENDED_PUBBLICATIONS_DELEGATE_HPP_
#include <dds/pub/Publisher.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace pub
{
//class OMG_DDS_API SuspendedPublicationDelegate
class SuspendedPublicationDelegate
{
public:
SuspendedPublicationDelegate(const dds::pub::Publisher& pub);
~SuspendedPublicationDelegate();
void resume();
bool operator ==(const SuspendedPublicationDelegate& other) const;
private:
dds::pub::Publisher pub;
bool resumed;
};
}
}
}
}
#endif /* CYCLONEDDS_PUB_SUSPENDED_PUBBLICATIONS_DELEGATE_HPP_ */

View File

@@ -0,0 +1,305 @@
/*
* 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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_PUB_QOS_DATA_WRITER_QOS_DELEGATE_HPP_
#define CYCLONEDDS_PUB_QOS_DATA_WRITER_QOS_DELEGATE_HPP_
#include <dds/core/detail/conformance.hpp>
#include <org/eclipse/cyclonedds/topic/qos/TopicQosDelegate.hpp>
struct _DDS_NamedDataWriterQos;
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace pub
{
namespace qos
{
class OMG_DDS_API DataWriterQosDelegate
{
public:
DataWriterQosDelegate();
DataWriterQosDelegate(const org::eclipse::cyclonedds::topic::qos::TopicQosDelegate& tqos);
void policy(const dds::core::policy::UserData& user_data);
void policy(const dds::core::policy::Durability& durability);
void policy(const dds::core::policy::Deadline& deadline);
void policy(const dds::core::policy::LatencyBudget& budget);
void policy(const dds::core::policy::Liveliness& liveliness);
void policy(const dds::core::policy::Reliability& reliability);
void policy(const dds::core::policy::DestinationOrder& order);
void policy(const dds::core::policy::History& history);
void policy(const dds::core::policy::ResourceLimits& resources);
void policy(const dds::core::policy::TransportPriority& priority);
void policy(const dds::core::policy::Lifespan& lifespan);
void policy(const dds::core::policy::Ownership& ownership);
#ifdef OMG_DDS_OWNERSHIP_SUPPORT
void policy(const dds::core::policy::OwnershipStrength& strength);
#endif // OMG_DDS_OWNERSHIP_SUPPORT
void policy(const dds::core::policy::WriterDataLifecycle& lifecycle);
#ifdef OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
void policy(const dds::core::policy::DataRepresentation& datarepresentation);
void policy(const dds::core::policy::TypeConsistencyEnforcement& typeconsistencyenforcement);
#endif // OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
template <typename POLICY> const POLICY& policy() const;
template <typename POLICY> POLICY& policy();
/* The returned ddsc QoS has to be freed. */
dds_qos_t* ddsc_qos() const;
void ddsc_qos(const dds_qos_t* qos);
void named_qos(const struct _DDS_NamedDataWriterQos &qos);
void check() const;
bool operator ==(const DataWriterQosDelegate& other) const;
DataWriterQosDelegate& operator =(const org::eclipse::cyclonedds::topic::qos::TopicQosDelegate& tqos);
private:
dds::core::policy::UserData user_data_;
dds::core::policy::Durability durability_;
dds::core::policy::Deadline deadline_;
dds::core::policy::LatencyBudget budget_;
dds::core::policy::Liveliness liveliness_;
dds::core::policy::Reliability reliability_;
dds::core::policy::DestinationOrder order_;
dds::core::policy::History history_;
dds::core::policy::ResourceLimits resources_;
dds::core::policy::TransportPriority priority_;
dds::core::policy::Lifespan lifespan_;
dds::core::policy::Ownership ownership_;
#ifdef OMG_DDS_OWNERSHIP_SUPPORT
dds::core::policy::OwnershipStrength strength_;
#endif // OMG_DDS_OWNERSHIP_SUPPORT
dds::core::policy::WriterDataLifecycle lifecycle_;
#ifdef OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
dds::core::policy::DataRepresentation datarepresentation_;
dds::core::policy::TypeConsistencyEnforcement typeconsistencyenforcement_;
#endif // OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
};
//==============================================================================
template<> inline const dds::core::policy::UserData&
DataWriterQosDelegate::policy<dds::core::policy::UserData>() const
{
return user_data_;
}
template<> inline dds::core::policy::UserData&
DataWriterQosDelegate::policy<dds::core::policy::UserData>()
{
return user_data_;
}
template<> inline const dds::core::policy::Durability&
DataWriterQosDelegate::policy<dds::core::policy::Durability>() const
{
return durability_;
}
template<> inline dds::core::policy::Durability&
DataWriterQosDelegate::policy<dds::core::policy::Durability>()
{
return durability_;
}
template<> inline const dds::core::policy::Deadline&
DataWriterQosDelegate::policy<dds::core::policy::Deadline>() const
{
return deadline_;
}
template<> inline dds::core::policy::Deadline&
DataWriterQosDelegate::policy<dds::core::policy::Deadline>()
{
return deadline_;
}
template<> inline const dds::core::policy::LatencyBudget&
DataWriterQosDelegate::policy<dds::core::policy::LatencyBudget>() const
{
return budget_;
}
template<> inline dds::core::policy::LatencyBudget&
DataWriterQosDelegate::policy<dds::core::policy::LatencyBudget>()
{
return budget_;
}
template<> inline const dds::core::policy::Liveliness&
DataWriterQosDelegate::policy<dds::core::policy::Liveliness>() const
{
return liveliness_;
}
template<> inline dds::core::policy::Liveliness&
DataWriterQosDelegate::policy<dds::core::policy::Liveliness>()
{
return liveliness_;
}
template<> inline const dds::core::policy::Reliability&
DataWriterQosDelegate::policy<dds::core::policy::Reliability>() const
{
return reliability_;
}
template<> inline dds::core::policy::Reliability&
DataWriterQosDelegate::policy<dds::core::policy::Reliability>()
{
return reliability_;
}
template<> inline const dds::core::policy::DestinationOrder&
DataWriterQosDelegate::policy<dds::core::policy::DestinationOrder>() const
{
return order_;
}
template<> inline dds::core::policy::DestinationOrder&
DataWriterQosDelegate::policy<dds::core::policy::DestinationOrder>()
{
return order_;
}
template<> inline const dds::core::policy::History&
DataWriterQosDelegate::policy<dds::core::policy::History>() const
{
return history_;
}
template<> inline dds::core::policy::History&
DataWriterQosDelegate::policy<dds::core::policy::History>()
{
return history_;
}
template<> inline const dds::core::policy::ResourceLimits&
DataWriterQosDelegate::policy<dds::core::policy::ResourceLimits>() const
{
return resources_;
}
template<> inline dds::core::policy::ResourceLimits&
DataWriterQosDelegate::policy<dds::core::policy::ResourceLimits>()
{
return resources_;
}
template<> inline const dds::core::policy::TransportPriority&
DataWriterQosDelegate::policy<dds::core::policy::TransportPriority>() const
{
return priority_;
}
template<> inline dds::core::policy::TransportPriority&
DataWriterQosDelegate::policy<dds::core::policy::TransportPriority>()
{
return priority_;
}
template<> inline const dds::core::policy::Lifespan&
DataWriterQosDelegate::policy<dds::core::policy::Lifespan>() const
{
return lifespan_;
}
template<> inline dds::core::policy::Lifespan&
DataWriterQosDelegate::policy<dds::core::policy::Lifespan>()
{
return lifespan_;
}
template<> inline const dds::core::policy::Ownership&
DataWriterQosDelegate::policy<dds::core::policy::Ownership>() const
{
return ownership_;
}
template<> inline dds::core::policy::Ownership&
DataWriterQosDelegate::policy<dds::core::policy::Ownership>()
{
return ownership_;
}
#ifdef OMG_DDS_OWNERSHIP_SUPPORT
template<> inline const dds::core::policy::OwnershipStrength&
DataWriterQosDelegate::policy<dds::core::policy::OwnershipStrength>() const
{
return strength_;
}
template<> inline dds::core::policy::OwnershipStrength&
DataWriterQosDelegate::policy<dds::core::policy::OwnershipStrength>()
{
return strength_;
}
#endif // OMG_DDS_OWNERSHIP_SUPPORT
template<> inline const dds::core::policy::WriterDataLifecycle&
DataWriterQosDelegate::policy<dds::core::policy::WriterDataLifecycle>() const
{
return lifecycle_;
}
template<> inline dds::core::policy::WriterDataLifecycle&
DataWriterQosDelegate::policy<dds::core::policy::WriterDataLifecycle>()
{
return lifecycle_;
}
#ifdef OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
template<> inline const dds::core::policy::DataRepresentation&
DataWriterQosDelegate::policy<dds::core::policy::DataRepresentation>() const
{
return datarepresentation_;
}
template<> inline dds::core::policy::DataRepresentation&
DataWriterQosDelegate::policy<dds::core::policy::DataRepresentation>()
{
return datarepresentation_;
}
template<> inline const dds::core::policy::TypeConsistencyEnforcement&
DataWriterQosDelegate::policy<dds::core::policy::TypeConsistencyEnforcement>() const
{
return typeconsistencyenforcement_;
}
template<> inline dds::core::policy::TypeConsistencyEnforcement&
DataWriterQosDelegate::policy<dds::core::policy::TypeConsistencyEnforcement>()
{
return typeconsistencyenforcement_;
}
#endif // OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
}
}
}
}
}
#endif /* CYCLONEDDS_PUB_QOS_DATA_WRITER_QOS_DELEGATE_HPP_ */

View 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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_PUB_QOS_PUBLISHER_QOS_DELEGATE_HPP_
#define CYCLONEDDS_PUB_QOS_PUBLISHER_QOS_DELEGATE_HPP_
#include <dds/core/policy/CorePolicy.hpp>
struct _DDS_NamedPublisherQos;
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace pub
{
namespace qos
{
class OMG_DDS_API PublisherQosDelegate
{
public:
PublisherQosDelegate();
PublisherQosDelegate(const PublisherQosDelegate& other);
~PublisherQosDelegate();
void policy(const dds::core::policy::Presentation& presentation);
void policy(const dds::core::policy::Partition& partition);
void policy(const dds::core::policy::GroupData& gdata);
void policy(const dds::core::policy::EntityFactory& factory_policy);
template <typename POLICY> const POLICY& policy() const;
template <typename POLICY> POLICY& policy();
/* The returned ddsc QoS has to be freed. */
dds_qos_t* ddsc_qos() const;
void ddsc_qos(const dds_qos_t* qos);
void named_qos(const struct _DDS_NamedPublisherQos &qos);
void check() const;
bool operator ==(const PublisherQosDelegate& other) const;
PublisherQosDelegate& operator =(const PublisherQosDelegate& other);
private:
dds::core::policy::Presentation presentation_;
dds::core::policy::Partition partition_;
dds::core::policy::GroupData gdata_;
dds::core::policy::EntityFactory factory_policy_;
};
//==============================================================================
template<>
inline const dds::core::policy::Presentation&
PublisherQosDelegate::policy<dds::core::policy::Presentation>() const
{
return presentation_;
}
template<>
inline dds::core::policy::Presentation&
PublisherQosDelegate::policy<dds::core::policy::Presentation>()
{
return presentation_;
}
template<>
inline const dds::core::policy::Partition&
PublisherQosDelegate::policy<dds::core::policy::Partition>() const
{
return partition_;
}
template<>
inline dds::core::policy::Partition&
PublisherQosDelegate::policy<dds::core::policy::Partition>()
{
return partition_;
}
template<>
inline const dds::core::policy::GroupData&
PublisherQosDelegate::policy<dds::core::policy::GroupData>() const
{
return gdata_;
}
template<>
inline dds::core::policy::GroupData&
PublisherQosDelegate::policy<dds::core::policy::GroupData>()
{
return gdata_;
}
template<>
inline const dds::core::policy::EntityFactory&
PublisherQosDelegate::policy<dds::core::policy::EntityFactory>() const
{
return factory_policy_;
}
template<>
inline dds::core::policy::EntityFactory&
PublisherQosDelegate::policy<dds::core::policy::EntityFactory>()
{
return factory_policy_;
}
}
}
}
}
}
#endif /* CYCLONEDDS_PUB_QOS_PUBLISHER_QOS_DELEGATE_HPP_ */

View File

@@ -0,0 +1,303 @@
/*
* 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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_SUB_ANY_DATA_READER_DELEGATE_HPP_
#define CYCLONEDDS_SUB_ANY_DATA_READER_DELEGATE_HPP_
#include <dds/core/types.hpp>
#include <dds/core/Time.hpp>
#include <dds/core/InstanceHandle.hpp>
#include <dds/core/status/Status.hpp>
#include <dds/sub/status/detail/DataStateImpl.hpp>
#include <dds/sub/qos/DataReaderQos.hpp>
#include <dds/sub/Sample.hpp>
#include <dds/sub/SampleInfo.hpp>
#include <org/eclipse/cyclonedds/core/EntityDelegate.hpp>
#include <org/eclipse/cyclonedds/topic/TopicTraits.hpp>
#include <org/eclipse/cyclonedds/core/ObjectSet.hpp>
#include <org/eclipse/cyclonedds/ForwardDeclarations.hpp>
#include <dds/topic/TopicDescription.hpp>
#include <org/eclipse/cyclonedds/topic/CDRBlob.hpp>
#include <dds/topic/BuiltinTopic.hpp>
namespace dds { namespace sub {
template <typename DELEGATE>
class TAnyDataReader;
} }
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace sub
{
class QueryContainer;
}
}
}
}
namespace dds
{
namespace sub
{
namespace detail
{
class SamplesHolder
{
public:
SamplesHolder() {}
virtual ~SamplesHolder() {}
virtual void set_length(uint32_t len) = 0;
virtual uint32_t get_length() const = 0;
virtual SamplesHolder& operator++(int) = 0;
virtual void *data() = 0;
virtual detail::SampleInfo& info() = 0;
virtual void **cpp_sample_pointers(size_t length) = 0;
virtual dds_sample_info_t *cpp_info_pointers(size_t length) = 0;
virtual void set_sample_contents(void** c_sample_pointers, dds_sample_info_t *info) = 0;
virtual void fini_samples_buffers(void**& c_sample_pointers, dds_sample_info_t*& c_sample_infos) = 0;
};
}
}
}
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace sub
{
class QueryDelegate;
class OMG_DDS_API AnyDataReaderDelegate : public org::eclipse::cyclonedds::core::EntityDelegate
{
public:
typedef ::dds::core::smart_ptr_traits< AnyDataReaderDelegate >::ref_type ref_type;
typedef ::dds::core::smart_ptr_traits< AnyDataReaderDelegate >::weak_ref_type weak_ref_type;
AnyDataReaderDelegate(const dds::sub::qos::DataReaderQos& qos,
const dds::topic::TopicDescription& td);
virtual ~AnyDataReaderDelegate();
static void copy_sample_infos(
const dds_sample_info_t &from,
dds::sub::SampleInfo &to);
public:
/* DDS API mirror. */
dds::sub::qos::DataReaderQos qos() const;
void qos(const dds::sub::qos::DataReaderQos& qos);
/* Let DataReader<T> implement the subscriber handling to circumvent circular dependencies. */
virtual const dds::sub::TSubscriber<org::eclipse::cyclonedds::sub::SubscriberDelegate>& subscriber() const = 0;
const dds::topic::TopicDescription& topic_description() const;
void wait_for_historical_data(const dds::core::Duration& timeout);
dds::core::status::LivelinessChangedStatus
liveliness_changed_status();
dds::core::status::SampleRejectedStatus
sample_rejected_status();
dds::core::status::SampleLostStatus
sample_lost_status();
dds::core::status::RequestedDeadlineMissedStatus
requested_deadline_missed_status();
dds::core::status::RequestedIncompatibleQosStatus
requested_incompatible_qos_status();
dds::core::status::SubscriptionMatchedStatus
subscription_matched_status();
::dds::core::InstanceHandleSeq
matched_publications();
template <typename FwdIterator>
uint32_t
matched_publications(FwdIterator begin, uint32_t max_size)
{
::dds::core::InstanceHandleSeq handleSeq = matched_publications();
uint32_t seq_size = static_cast<uint32_t>(handleSeq.size());
uint32_t size = (seq_size < max_size ? seq_size : max_size);
for (uint32_t i = 0; i < size; i++, begin++) {
*begin = handleSeq[i];
}
return size;
}
const dds::topic::PublicationBuiltinTopicData
matched_publication_data(const ::dds::core::InstanceHandle& h);
public:
/* Internal API. */
dds::sub::TAnyDataReader<AnyDataReaderDelegate> wrapper_to_any();
static uint32_t get_ddsc_state_mask(const dds::sub::status::DataState& state);
void reset_data_available();
void add_query(org::eclipse::cyclonedds::sub::QueryDelegate& query);
void remove_query(org::eclipse::cyclonedds::sub::QueryDelegate& query);
void setSample(void* sample);
void* getSample() const;
bool is_loan_supported(const dds_entity_t reader) const;
void read_cdr(
const dds_entity_t reader,
const dds::sub::status::DataState& mask,
dds::sub::detail::SamplesHolder& samples,
uint32_t max_samples);
void take_cdr(
const dds_entity_t reader,
const dds::sub::status::DataState& mask,
dds::sub::detail::SamplesHolder& samples,
uint32_t max_samples);
void loaned_read(
const dds_entity_t reader,
const dds::sub::status::DataState& mask,
dds::sub::detail::SamplesHolder& samples,
uint32_t max_samples);
void loaned_take(
const dds_entity_t reader,
const dds::sub::status::DataState& mask,
dds::sub::detail::SamplesHolder& samples,
uint32_t max_samples);
void loaned_read_instance(
const dds_entity_t reader,
const dds::core::InstanceHandle& handle,
const dds::sub::status::DataState& mask,
dds::sub::detail::SamplesHolder& samples,
uint32_t max_samples);
void loaned_take_instance(
const dds_entity_t reader,
const dds::core::InstanceHandle& handle,
const dds::sub::status::DataState& mask,
dds::sub::detail::SamplesHolder& samples,
uint32_t max_samples);
void loaned_read_next_instance(
const dds_entity_t reader,
const dds::core::InstanceHandle& handle,
const dds::sub::status::DataState& mask,
dds::sub::detail::SamplesHolder& samples,
uint32_t max_samples);
void loaned_take_next_instance(
const dds_entity_t reader,
const dds::core::InstanceHandle& handle,
const dds::sub::status::DataState& mask,
dds::sub::detail::SamplesHolder& samples,
uint32_t max_samples);
void read(
const dds_entity_t reader,
const dds::sub::status::DataState& mask,
dds::sub::detail::SamplesHolder& samples,
uint32_t max_samples);
void take(
const dds_entity_t reader,
const dds::sub::status::DataState& mask,
dds::sub::detail::SamplesHolder& samples,
uint32_t max_samples);
void read_instance(
const dds_entity_t reader,
const dds::core::InstanceHandle& handle,
const dds::sub::status::DataState& mask,
dds::sub::detail::SamplesHolder& samples,
uint32_t max_samples);
void take_instance(
const dds_entity_t reader,
const dds::core::InstanceHandle& handle,
const dds::sub::status::DataState& mask,
dds::sub::detail::SamplesHolder& samples,
uint32_t max_samples);
void read_next_instance(
const dds_entity_t reader,
const dds::core::InstanceHandle& handle,
const dds::sub::status::DataState& mask,
dds::sub::detail::SamplesHolder& samples,
uint32_t max_samples);
void take_next_instance(
const dds_entity_t reader,
const dds::core::InstanceHandle& handle,
const dds::sub::status::DataState& mask,
dds::sub::detail::SamplesHolder& samples,
uint32_t max_samples);
void get_key_value(
const dds_entity_t reader,
const dds::core::InstanceHandle& handle,
void *key);
dds_instance_handle_t lookup_instance(
const dds_entity_t reader,
const void *key) const;
void close();
private:
bool init_samples_buffers(
const uint32_t requested_max_samples,
uint32_t& samples_to_read_cnt,
size_t& c_sample_pointers_size,
dds::sub::detail::SamplesHolder& samples,
void**& c_sample_pointers,
dds_sample_info_t*& c_sample_infos);
void fini_samples_buffers(
void**& c_sample_pointers,
dds_sample_info_t*& c_sample_infos);
protected:
org::eclipse::cyclonedds::core::ObjectSet queries;
dds::sub::qos::DataReaderQos qos_;
dds::topic::TopicDescription td_;
void *sample_;
};
}
}
}
}
#endif /* CYCLONEDDS_SUB_ANY_DATA_READER_DELEGATE_HPP_ */

View File

@@ -0,0 +1,69 @@
/*
* 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_SUB_BUILTIN_SUBSCRIBER_DELEGATE_HPP_
#define CYCLONEDDS_SUB_BUILTIN_SUBSCRIBER_DELEGATE_HPP_
#include <dds/core/types.hpp>
#include <dds/domain/DomainParticipant.hpp>
#include <org/eclipse/cyclonedds/ForwardDeclarations.hpp>
#include <org/eclipse/cyclonedds/sub/SubscriberDelegate.hpp>
#include <org/eclipse/cyclonedds/sub/AnyDataReaderDelegate.hpp>
#include <org/eclipse/cyclonedds/core/Mutex.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace sub
{
class OMG_DDS_API BuiltinSubscriberDelegate : public org::eclipse::cyclonedds::sub::SubscriberDelegate
{
public:
BuiltinSubscriberDelegate(
const dds::domain::DomainParticipant& dp,
const dds::sub::qos::SubscriberQos& qos);
virtual ~BuiltinSubscriberDelegate() {};
std::vector<AnyDataReaderDelegate::ref_type>
find_datareaders(const std::string& topic_name);
public:
static SubscriberDelegate::ref_type
get_builtin_subscriber(const dds::domain::DomainParticipant& dp);
static AnyDataReaderDelegate::ref_type
get_builtin_reader(SubscriberDelegate& subscriber, const std::string& topic_name);
private:
static org::eclipse::cyclonedds::core::Mutex builtinLock;
};
}
}
}
}
#endif /* CYCLONEDDS_SUB_BUILTIN_SUBSCRIBER_DELEGATE_HPP_ */

View File

@@ -0,0 +1,52 @@
/*
* 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_SUB_COHERENT_ACCESS_DELEGATE_HPP_
#define CYCLONEDDS_SUB_COHERENT_ACCESS_DELEGATE_HPP_
#include <dds/sub/Subscriber.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace sub
{
class OMG_DDS_API CoherentAccessDelegate
{
public:
CoherentAccessDelegate(const dds::sub::Subscriber sub);
~CoherentAccessDelegate();
void end();
bool operator==(const CoherentAccessDelegate& other) const;
private:
dds::sub::Subscriber sub;
bool ended;
};
}
}
}
}
#endif /* CYCLONEDDS_SUB_COHERENT_ACCESS_DELEGATE_HPP_ */

View File

@@ -0,0 +1,72 @@
/*
* 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_SUB_GENERATION_COUNT_IMPL_HPP_
#define CYCLONEDDS_SUB_GENERATION_COUNT_IMPL_HPP_
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace sub
{
class GenerationCountImpl;
}
}
}
}
class org::eclipse::cyclonedds::sub::GenerationCountImpl
{
public:
GenerationCountImpl() : d_(0), nw_(0) { }
GenerationCountImpl(int32_t d, int32_t nw) : d_(d), nw_(nw) { }
public:
inline int32_t disposed() const
{
return d_;
}
inline void disposed(int32_t d)
{
this->d_ = d;
}
inline int32_t no_writers() const
{
return nw_;
}
inline void no_writers(int32_t nw)
{
this->nw_ = nw;
}
bool operator ==(const GenerationCountImpl& other) const
{
return other.d_ == d_ && other.nw_ == nw_;
}
private:
int32_t d_, nw_;
};
#endif /* CYCLONEDDS_SUB_GENERATION_COUNT_IMPL_HPP_ */

View File

@@ -0,0 +1,119 @@
/*
* 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_SUB_QUERY_DELEGATE_HPP_
#define CYCLONEDDS_SUB_QUERY_DELEGATE_HPP_
/**
* @file
*/
#include <dds/core/macros.hpp>
#include <dds/sub/Subscriber.hpp>
#include <dds/sub/AnyDataReader.hpp>
#include <org/eclipse/cyclonedds/core/DDScObjectDelegate.hpp>
#include <org/eclipse/cyclonedds/core/Mutex.hpp>
#include <vector>
#include <iterator>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace sub
{
class OMG_DDS_API QueryDelegate : public virtual org::eclipse::cyclonedds::core::DDScObjectDelegate
{
public:
typedef std::vector<std::string>::iterator iterator;
typedef std::vector<std::string>::const_iterator const_iterator;
typedef ::dds::core::smart_ptr_traits<QueryDelegate>::ref_type Ref;
typedef ::dds::core::smart_ptr_traits<QueryDelegate>::weak_ref_type WeakRef;
public:
QueryDelegate(const dds::sub::AnyDataReader& dr,
const dds::sub::status::DataState& state_filter = dds::sub::status::DataState::any());
QueryDelegate(const dds::sub::AnyDataReader& dr,
const std::string& query_expression,
const dds::sub::status::DataState& state_filter = dds::sub::status::DataState::any());
QueryDelegate(const dds::sub::AnyDataReader& dr,
const std::string& query_expression,
const std::vector<std::string>& params,
const dds::sub::status::DataState& state_filter = dds::sub::status::DataState::any());
virtual ~QueryDelegate();
void init(ObjectDelegate::weak_ref_type weak_ref);
void close();
const std::string& expression() const;
void expression(const std::string& expr);
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
void add_parameter(const std::string& param);
uint32_t parameters_length() const;
void parameters(const std::vector<std::string>& params);
std::vector<std::string> parameters();
void clear_parameters();
const dds::sub::AnyDataReader& data_reader() const;
virtual void state_filter(dds::sub::status::DataState& s);
virtual dds::sub::status::DataState state_filter();
virtual bool modify_state_filter(dds::sub::status::DataState& s);
bool state_filter_equal(dds::sub::status::DataState& s);
protected:
void deinit();
private:
dds::sub::AnyDataReader reader_;
std::string expression_;
std::vector<std::string> params_;
dds::sub::status::DataState state_filter_;
bool modified_;
};
}
}
}
}
#endif /* CYCLONEDDS_SUB_QUERY_DELEGATE_HPP_ */

View File

@@ -0,0 +1,68 @@
/*
* 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_SUB_RANK_IMPL_HPP_
#define CYCLONEDDS_SUB_RANK_IMPL_HPP_
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace sub
{
class RankImpl;
}
}
}
}
class org::eclipse::cyclonedds::sub::RankImpl
{
public:
RankImpl() : s_(0), g_(0), ag_(0) { }
RankImpl(int32_t s, int32_t g, int32_t ag) : s_(s), g_(g), ag_(ag) { }
public:
inline int32_t absolute_generation() const
{
return ag_;
}
inline int32_t generation() const
{
return g_;
}
inline int32_t sample() const
{
return s_;
}
bool operator ==(const RankImpl& other) const
{
return other.s_ == s_ && other.g_ == g_ && other.ag_;
}
private:
int32_t s_;
int32_t g_;
int32_t ag_;
};
#endif /* CYCLONEDDS_SUB_RANK_IMPL_HPP_ */

View File

@@ -0,0 +1,150 @@
/*
* 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_SUB_SAMPLE_INFO_IMPL_HPP_
#define CYCLONEDDS_SUB_SAMPLE_INFO_IMPL_HPP_
#include <org/eclipse/cyclonedds/core/config.hpp>
#include <dds/sub/Rank.hpp>
#include <dds/sub/GenerationCount.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace sub
{
class SampleInfoImpl;
}
}
}
}
class org::eclipse::cyclonedds::sub::SampleInfoImpl
{
public:
SampleInfoImpl() : valid_(false) { }
public:
inline const dds::core::Time timestamp() const
{
return this->source_timestamp_;
}
inline void timestamp(const dds::core::Time& t)
{
this->source_timestamp_ = t;
}
inline const dds::sub::status::DataState state() const
{
return this->state_;
}
inline void state(const dds::sub::status::DataState& s)
{
this->state_ = s;
}
inline dds::sub::GenerationCount generation_count() const
{
return this->generation_count_;
}
inline void generation_count(dds::sub::GenerationCount& c)
{
this->generation_count_ = c;
}
inline dds::sub::Rank rank() const
{
return this->rank_;
}
inline void rank(dds::sub::Rank& r)
{
this->rank_ = r;
}
inline bool valid() const
{
return this->valid_;
}
inline void valid(bool v)
{
this->valid_ = v;
}
inline dds::core::InstanceHandle instance_handle() const
{
return this->instance_handle_;
}
inline void instance_handle(dds::core::InstanceHandle& h)
{
this->instance_handle_ = h;
}
inline dds::core::InstanceHandle publication_handle() const
{
return this->publication_handle_;
}
inline void publication_handle(dds::core::InstanceHandle& h)
{
this->publication_handle_ = h;
}
bool operator==(const SampleInfoImpl& other) const
{
return this->source_timestamp_ == other.timestamp()
&& state_is_equal(this->state_, other.state())
&& this->generation_count_ == other.generation_count()
&& this->rank_ == other.rank()
&& this->valid_ == other.valid()
&& this->instance_handle_ == other.instance_handle()
&& this->publication_handle_ == other.publication_handle();
}
private:
static bool state_is_equal(
const dds::sub::status::DataState& s1,
const dds::sub::status::DataState& s2)
{
return s1.instance_state() == s1.instance_state()
&& s1.view_state() == s2.view_state()
&& s1.sample_state() == s2.sample_state();
}
private:
dds::core::Time source_timestamp_;
dds::sub::status::DataState state_;
dds::sub::GenerationCount generation_count_;
dds::sub::Rank rank_;
bool valid_;
dds::core::InstanceHandle instance_handle_;
dds::core::InstanceHandle publication_handle_;
};
#endif /* CYCLONEDDS_SUB_SAMPLE_INFO_IMPL_HPP_ */

View File

@@ -0,0 +1,149 @@
/*
* 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_SUB_SUBSCRIBER_DELEGATE_HPP_
#define CYCLONEDDS_SUB_SUBSCRIBER_DELEGATE_HPP_
#include <dds/core/types.hpp>
#include <dds/core/status/State.hpp>
#include <dds/sub/AnyDataReader.hpp>
#include <dds/sub/qos/SubscriberQos.hpp>
#include <dds/sub/qos/DataReaderQos.hpp>
#include <dds/domain/DomainParticipant.hpp>
#include <org/eclipse/cyclonedds/ForwardDeclarations.hpp>
#include <org/eclipse/cyclonedds/core/EntityDelegate.hpp>
#include <org/eclipse/cyclonedds/core/EntitySet.hpp>
#include <org/eclipse/cyclonedds/sub/AnyDataReaderDelegate.hpp>
#include <vector>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace sub
{
class OMG_DDS_API SubscriberDelegate : public org::eclipse::cyclonedds::core::EntityDelegate
{
public:
typedef ::dds::core::smart_ptr_traits< SubscriberDelegate >::ref_type ref_type;
typedef ::dds::core::smart_ptr_traits< SubscriberDelegate >::weak_ref_type weak_ref_type;
SubscriberDelegate(const dds::domain::DomainParticipant& dp,
const dds::sub::qos::SubscriberQos& qos,
dds::sub::SubscriberListener* listener,
const dds::core::status::StatusMask& event_mask);
virtual ~SubscriberDelegate();
void init(ObjectDelegate::weak_ref_type weak_ref);
void close();
const dds::sub::qos::SubscriberQos& qos() const;
void qos(const dds::sub::qos::SubscriberQos& sqos);
void default_datareader_qos(const dds::sub::qos::DataReaderQos& qos);
dds::sub::qos::DataReaderQos default_datareader_qos() const;
void begin_coherent_access();
void end_coherent_access();
/**
* @internal This function initialises the delegate as the built in subscriber
*/
//void init_builtin(DDS::Subscriber_ptr sub);
void listener(dds::sub::SubscriberListener* listener,
const ::dds::core::status::StatusMask& mask);
dds::sub::SubscriberListener* listener() const;
const dds::domain::DomainParticipant& participant() const;
/** @internal @todo OSPL-1944 Subscriber Listener should return list of affected DataReaders (on_data_on_readers) **/
//dds::sub::AnyDataReader get_datareaders(); /* TODO: OSPL-1944? */
bool contains_entity(
const ::dds::core::InstanceHandle& handle);
void add_datareader(
org::eclipse::cyclonedds::core::EntityDelegate& datareader);
void remove_datareader(
org::eclipse::cyclonedds::core::EntityDelegate& datareader);
virtual std::vector<org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::ref_type>
find_datareaders(
const std::string& topic_name);
std::vector<org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::ref_type>
get_datareaders(
const dds::sub::status::DataState& mask);
void notify_datareaders();
dds::sub::TSubscriber<SubscriberDelegate>
wrapper();
bool is_auto_enable() const;
void reset_data_on_readers();
// Subscriber events
void on_data_readers(
dds_entity_t);
// Reader events
void on_requested_deadline_missed(
dds_entity_t reader,
org::eclipse::cyclonedds::core::RequestedDeadlineMissedStatusDelegate &sd);
void on_requested_incompatible_qos(
dds_entity_t reader,
org::eclipse::cyclonedds::core::RequestedIncompatibleQosStatusDelegate &sd);
void on_sample_rejected(
dds_entity_t reader,
org::eclipse::cyclonedds::core::SampleRejectedStatusDelegate &sd);
void on_liveliness_changed(
dds_entity_t reader,
org::eclipse::cyclonedds::core::LivelinessChangedStatusDelegate &sd);
void on_data_available(
dds_entity_t reader);
void on_subscription_matched(
dds_entity_t reader,
org::eclipse::cyclonedds::core::SubscriptionMatchedStatusDelegate &sd);
void on_sample_lost(
dds_entity_t reader,
org::eclipse::cyclonedds::core::SampleLostStatusDelegate &sd);
private:
dds::domain::DomainParticipant dp_;
dds::sub::qos::SubscriberQos qos_;
dds::sub::qos::DataReaderQos default_dr_qos_;
org::eclipse::cyclonedds::core::EntitySet readers;
};
}
}
}
}
#endif /* CYCLONEDDS_SUB_SUBSCRIBER_DELEGATE_HPP_ */

View File

@@ -0,0 +1,79 @@
/*
* 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_SUB_COND_QUERYCONDITION_DELEGATE_HPP_
#define CYCLONEDDS_SUB_COND_QUERYCONDITION_DELEGATE_HPP_
#include <org/eclipse/cyclonedds/sub/cond/ReadConditionDelegate.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace sub
{
namespace cond
{
class OMG_DDS_API QueryConditionDelegate :
public org::eclipse::cyclonedds::sub::cond::ReadConditionDelegate
{
public:
typedef QueryDelegate::iterator iterator;
typedef QueryDelegate::const_iterator const_iterator;
public:
QueryConditionDelegate(
const dds::sub::AnyDataReader& dr,
const std::string& query_expression,
const dds::sub::status::DataState& state_filter);
QueryConditionDelegate(
const dds::sub::AnyDataReader& dr,
const std::string& expression,
const std::vector<std::string>& params,
const dds::sub::status::DataState& data_state);
QueryConditionDelegate(
const dds::sub::AnyDataReader& dr,
const dds::sub::status::DataState& data_state);
~QueryConditionDelegate();
typedef bool (*Filter_fn) (const void * sample);
void set_filter(Filter_fn filter);
Filter_fn get_filter();
void init(ObjectDelegate::weak_ref_type weak_ref);
protected:
Filter_fn cpp_filter;
static bool trans_filter(const void *csample, const void *ctx);
};
}
}
}
}
}
#endif /* CYCLONEDDS_SUB_COND_QUERYCONDITION_DELEGATE_HPP_ */

View File

@@ -0,0 +1,64 @@
/*
* 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_SUB_COND_READCONDITION_DELEGATE_HPP_
#define CYCLONEDDS_SUB_COND_READCONDITION_DELEGATE_HPP_
#include <dds/sub/AnyDataReader.hpp>
#include <org/eclipse/cyclonedds/core/cond/ConditionDelegate.hpp>
#include <org/eclipse/cyclonedds/sub/QueryDelegate.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace sub
{
namespace cond
{
class OMG_DDS_API ReadConditionDelegate :
public virtual org::eclipse::cyclonedds::core::cond::ConditionDelegate,
public virtual org::eclipse::cyclonedds::sub::QueryDelegate
{
public:
ReadConditionDelegate(
const dds::sub::AnyDataReader& dr,
const dds::sub::status::DataState& state_filter);
~ReadConditionDelegate();
void init(ObjectDelegate::weak_ref_type weak_ref);
void close();
virtual bool trigger_value() const;
};
}
}
}
}
}
#endif /* CYCLONEDDS_SUB_COND_READCONDITION_DELEGATE_HPP_ */

View File

@@ -0,0 +1,285 @@
/*
* 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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_SUB_QOS_DATA_READER_QOS_DELEGATE_HPP_
#define CYCLONEDDS_SUB_QOS_DATA_READER_QOS_DELEGATE_HPP_
#include <dds/core/detail/conformance.hpp>
#include <org/eclipse/cyclonedds/topic/qos/TopicQosDelegate.hpp>
struct _DDS_NamedDataReaderQos;
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace sub
{
namespace qos
{
class OMG_DDS_API DataReaderQosDelegate
{
public:
DataReaderQosDelegate();
DataReaderQosDelegate(const org::eclipse::cyclonedds::topic::qos::TopicQosDelegate& tqos);
void policy(const dds::core::policy::UserData& user_data);
void policy(const dds::core::policy::Durability& durability);
void policy(const dds::core::policy::Deadline& deadline);
void policy(const dds::core::policy::LatencyBudget& budget);
void policy(const dds::core::policy::Liveliness& liveliness);
void policy(const dds::core::policy::Reliability& reliability);
void policy(const dds::core::policy::DestinationOrder& order);
void policy(const dds::core::policy::History& history);
void policy(const dds::core::policy::ResourceLimits& resources);
void policy(const dds::core::policy::Ownership& ownership);
void policy(const dds::core::policy::TimeBasedFilter& tfilter);
void policy(const dds::core::policy::ReaderDataLifecycle& lifecycle);
#ifdef OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
void policy(const dds::core::policy::DataRepresentation& datarepresentation);
void policy(const dds::core::policy::TypeConsistencyEnforcement& typeconsistencyenforcement);
#endif // OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
template <typename POLICY> const POLICY& policy() const;
template <typename POLICY> POLICY& policy();
/* The returned ddsc QoS has to be freed. */
dds_qos_t* ddsc_qos() const;
void ddsc_qos(const dds_qos_t* qos);
void named_qos(const struct _DDS_NamedDataReaderQos &qos);
void check() const;
bool operator==(const DataReaderQosDelegate& other) const;
DataReaderQosDelegate& operator =(const org::eclipse::cyclonedds::topic::qos::TopicQosDelegate& tqos);
private:
dds::core::policy::UserData user_data_;
dds::core::policy::Durability durability_;
dds::core::policy::Deadline deadline_;
dds::core::policy::LatencyBudget budget_;
dds::core::policy::Liveliness liveliness_;
dds::core::policy::Reliability reliability_;
dds::core::policy::DestinationOrder order_;
dds::core::policy::History history_;
dds::core::policy::ResourceLimits resources_;
dds::core::policy::Ownership ownership_;
dds::core::policy::TimeBasedFilter tfilter_;
dds::core::policy::ReaderDataLifecycle lifecycle_;
#ifdef OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
dds::core::policy::DataRepresentation datarepresentation_;
dds::core::policy::TypeConsistencyEnforcement typeconsistencyenforcement_;
#endif // OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
};
//==============================================================================
template<>
inline const dds::core::policy::Durability&
DataReaderQosDelegate::policy<dds::core::policy::Durability>() const
{
return durability_;
}
template<>
inline dds::core::policy::Durability&
DataReaderQosDelegate::policy<dds::core::policy::Durability>()
{
return durability_;
}
template<>
inline const dds::core::policy::UserData&
DataReaderQosDelegate::policy<dds::core::policy::UserData>() const
{
return user_data_;
}
template<>
inline dds::core::policy::UserData&
DataReaderQosDelegate::policy<dds::core::policy::UserData>()
{
return user_data_;
}
template<> inline const dds::core::policy::Deadline&
DataReaderQosDelegate::policy<dds::core::policy::Deadline>() const
{
return deadline_;
}
template<>
inline dds::core::policy::Deadline&
DataReaderQosDelegate::policy<dds::core::policy::Deadline>()
{
return deadline_;
}
template<> inline const dds::core::policy::LatencyBudget&
DataReaderQosDelegate::policy<dds::core::policy::LatencyBudget>() const
{
return budget_;
}
template<>
inline dds::core::policy::LatencyBudget&
DataReaderQosDelegate::policy<dds::core::policy::LatencyBudget>()
{
return budget_;
}
template<> inline const dds::core::policy::Liveliness&
DataReaderQosDelegate::policy<dds::core::policy::Liveliness>() const
{
return liveliness_;
}
template<>
inline dds::core::policy::Liveliness&
DataReaderQosDelegate::policy<dds::core::policy::Liveliness>()
{
return liveliness_;
}
template<> inline const dds::core::policy::Reliability&
DataReaderQosDelegate::policy<dds::core::policy::Reliability>() const
{
return reliability_;
}
template<>
inline dds::core::policy::Reliability&
DataReaderQosDelegate::policy<dds::core::policy::Reliability>()
{
return reliability_;
}
template<> inline const dds::core::policy::DestinationOrder&
DataReaderQosDelegate::policy<dds::core::policy::DestinationOrder>() const
{
return order_;
}
template<>
inline dds::core::policy::DestinationOrder&
DataReaderQosDelegate::policy<dds::core::policy::DestinationOrder>()
{
return order_;
}
template<> inline const dds::core::policy::History&
DataReaderQosDelegate::policy<dds::core::policy::History>() const
{
return history_;
}
template<>
inline dds::core::policy::History&
DataReaderQosDelegate::policy<dds::core::policy::History>()
{
return history_;
}
template<> inline const dds::core::policy::ResourceLimits&
DataReaderQosDelegate::policy<dds::core::policy::ResourceLimits>() const
{
return resources_;
}
template<>
inline dds::core::policy::ResourceLimits&
DataReaderQosDelegate::policy<dds::core::policy::ResourceLimits>()
{
return resources_;
}
template<> inline const dds::core::policy::Ownership&
DataReaderQosDelegate::policy<dds::core::policy::Ownership>() const
{
return ownership_;
}
template<>
inline dds::core::policy::Ownership&
DataReaderQosDelegate::policy<dds::core::policy::Ownership>()
{
return ownership_;
}
template<> inline const dds::core::policy::TimeBasedFilter&
DataReaderQosDelegate::policy<dds::core::policy::TimeBasedFilter>() const
{
return tfilter_;
}
template<>
inline dds::core::policy::TimeBasedFilter&
DataReaderQosDelegate::policy<dds::core::policy::TimeBasedFilter>()
{
return tfilter_;
}
template<> inline const dds::core::policy::ReaderDataLifecycle&
DataReaderQosDelegate::policy<dds::core::policy::ReaderDataLifecycle>() const
{
return lifecycle_;
}
template<>
inline dds::core::policy::ReaderDataLifecycle&
DataReaderQosDelegate::policy<dds::core::policy::ReaderDataLifecycle>()
{
return lifecycle_;
}
#ifdef OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
template<> inline const dds::core::policy::DataRepresentation&
DataReaderQosDelegate::policy<dds::core::policy::DataRepresentation>() const
{
return datarepresentation_;
}
template<> inline dds::core::policy::DataRepresentation&
DataReaderQosDelegate::policy<dds::core::policy::DataRepresentation>()
{
return datarepresentation_;
}
template<> inline const dds::core::policy::TypeConsistencyEnforcement&
DataReaderQosDelegate::policy<dds::core::policy::TypeConsistencyEnforcement>() const
{
return typeconsistencyenforcement_;
}
template<> inline dds::core::policy::TypeConsistencyEnforcement&
DataReaderQosDelegate::policy<dds::core::policy::TypeConsistencyEnforcement>()
{
return typeconsistencyenforcement_;
}
#endif // OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
}
}
}
}
}
#endif /* CYCLONEDDS_SUB_QOS_DATA_READER_QOS_DELEGATE_HPP_ */

View 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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_SUB_QOS_SUBSCRIBER_QOS_DELEGATE_HPP_
#define CYCLONEDDS_SUB_QOS_SUBSCRIBER_QOS_DELEGATE_HPP_
#include <dds/core/policy/CorePolicy.hpp>
struct _DDS_NamedSubscriberQos;
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace sub
{
namespace qos
{
class OMG_DDS_API SubscriberQosDelegate
{
public:
SubscriberQosDelegate();
SubscriberQosDelegate(const SubscriberQosDelegate& other);
~SubscriberQosDelegate();
void policy(const dds::core::policy::Presentation& presentation);
void policy(const dds::core::policy::Partition& partition);
void policy(const dds::core::policy::GroupData& grout_data);
void policy(const dds::core::policy::EntityFactory& entity_factory);
template <typename POLICY> const POLICY& policy() const;
template <typename POLICY> POLICY& policy();
/* The returned ddsc QoS has to be freed. */
dds_qos_t* ddsc_qos() const;
void ddsc_qos(const dds_qos_t* qos);
void named_qos(const struct _DDS_NamedSubscriberQos &qos);
void check() const;
bool operator ==(const SubscriberQosDelegate& other) const;
SubscriberQosDelegate& operator =(const SubscriberQosDelegate& other);
private:
dds::core::policy::Presentation presentation_;
dds::core::policy::Partition partition_;
dds::core::policy::GroupData group_data_;
dds::core::policy::EntityFactory entity_factory_;
};
//==============================================================================
template<>
inline const dds::core::policy::Presentation&
SubscriberQosDelegate::policy<dds::core::policy::Presentation>() const
{
return presentation_;
}
template<>
inline dds::core::policy::Presentation&
SubscriberQosDelegate::policy<dds::core::policy::Presentation>()
{
return presentation_;
}
template<>
inline const dds::core::policy::Partition&
SubscriberQosDelegate::policy<dds::core::policy::Partition>() const
{
return partition_;
}
template<>
inline dds::core::policy::Partition&
SubscriberQosDelegate::policy<dds::core::policy::Partition>()
{
return partition_;
}
template<>
inline const dds::core::policy::GroupData&
SubscriberQosDelegate::policy<dds::core::policy::GroupData>() const
{
return group_data_;
}
template<>
inline dds::core::policy::GroupData&
SubscriberQosDelegate::policy<dds::core::policy::GroupData>()
{
return group_data_;
}
template<>
inline const dds::core::policy::EntityFactory&
SubscriberQosDelegate::policy<dds::core::policy::EntityFactory>() const
{
return entity_factory_;
}
template<>
inline dds::core::policy::EntityFactory&
SubscriberQosDelegate::policy<dds::core::policy::EntityFactory>()
{
return entity_factory_;
}
}
}
}
}
}
#endif /* CYCLONEDDS_SUB_QOS_SUBSCRIBER_QOS_DELEGATE_HPP_ */

View File

@@ -0,0 +1,113 @@
/*
* 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_TOPIC_ANYTOPICDELEGATE_HPP_
#define CYCLONEDDS_TOPIC_ANYTOPICDELEGATE_HPP_
#include <dds/core/types.hpp>
#include <org/eclipse/cyclonedds/topic/TopicTraits.hpp>
#include <org/eclipse/cyclonedds/core/EntityDelegate.hpp>
#include <org/eclipse/cyclonedds/topic/TopicDescriptionDelegate.hpp>
namespace dds { namespace topic {
template <typename DELEGATE>
class TAnyTopic;
} }
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace topic
{
DDSCXX_WARNING_MSVC_OFF(4250)
class OMG_DDS_API AnyTopicDelegate :
public virtual org::eclipse::cyclonedds::core::EntityDelegate,
public virtual org::eclipse::cyclonedds::topic::TopicDescriptionDelegate
{
public:
typedef ::dds::core::smart_ptr_traits< AnyTopicDelegate >::ref_type ref_type;
typedef ::dds::core::smart_ptr_traits< AnyTopicDelegate >::weak_ref_type weak_ref_type;
AnyTopicDelegate(const dds::topic::qos::TopicQos& qos,
const dds::domain::DomainParticipant& dp,
const std::string& name,
const std::string& type_name,
dds_entity_t ddsc_topic);
virtual ~AnyTopicDelegate();
public:
/* DDS API mirror. */
dds::topic::qos::TopicQos qos() const;
void qos(const dds::topic::qos::TopicQos& qos);
::dds::core::status::InconsistentTopicStatus inconsistent_topic_status() const;
std::string reader_expression() const;
TEMP_TYPE reader_parameters() const;
//@todo c_value *reader_parameters() const;
public:
dds::topic::TAnyTopic<AnyTopicDelegate> wrapper_to_any();
void init(ObjectDelegate::weak_ref_type weak_ref);
void listener_notify(ObjectDelegate::ref_type,
uint32_t,
void *,
void *) {}
static dds::topic::TAnyTopic<AnyTopicDelegate>
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::TAnyTopic<AnyTopicDelegate> >& topics,
uint32_t max_size);
void set_sample(void* sample);
void* get_sample();
protected:
AnyTopicDelegate(const dds::topic::qos::TopicQos& qos,
const dds::domain::DomainParticipant& dp,
const std::string& name,
const std::string& type_name);
dds::topic::qos::TopicQos qos_;
void* sample_;
};
DDSCXX_WARNING_MSVC_ON(4250)
}
}
}
}
#endif /* CYCLONEDDS_TOPIC_ANYTOPICDELEGATE_HPP_ */

View File

@@ -0,0 +1,47 @@
/*
* 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_TOPIC_ANY_TOPIC_LISTENER_HPP_
#define CYCLONEDDS_TOPIC_ANY_TOPIC_LISTENER_HPP_
#include <dds/topic/AnyTopicListener.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace topic
{
class OMG_DDS_API AnyTopicListener
{
public:
virtual ~AnyTopicListener() { }
};
class OMG_DDS_API NoOpAnyTopicListener : public virtual AnyTopicListener
{
public:
virtual ~NoOpAnyTopicListener() { }
};
}
}
}
}
#endif /* CYCLONEDDS_TOPIC_ANY_TOPIC_LISTENER_HPP_ */

View File

@@ -0,0 +1,50 @@
/*
* 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_TOPIC_BUILTIN_TOPIC_HPP_
#define CYCLONEDDS_TOPIC_BUILTIN_TOPIC_HPP_
#include <org/eclipse/cyclonedds/topic/TBuiltinTopic.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace topic
{
typedef TCMParticipantBuiltinTopicData<CMParticipantBuiltinTopicDataDelegate>
CMParticipantBuiltinTopicData;
typedef TCMPublisherBuiltinTopicData<CMPublisherBuiltinTopicDataDelegate>
CMPublisherBuiltinTopicData;
typedef TCMSubscriberBuiltinTopicData<CMSubscriberBuiltinTopicDataDelegate>
CMSubscriberBuiltinTopicData;
typedef TCMDataWriterBuiltinTopicData<CMDataWriterBuiltinTopicDataDelegate>
CMDataWriterBuiltinTopicData;
typedef TCMDataReaderBuiltinTopicData<CMDataReaderBuiltinTopicDataDelegate>
CMDataReaderBuiltinTopicData;
}
}
}
}
#endif /* CYCLONEDDS_TOPIC_BUILTIN_TOPIC_HPP_ */

View File

@@ -0,0 +1,19 @@
/*
* 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_TOPIC_BUILTIN_TOPIC_COPY_HPP_
#define CYCLONEDDS_TOPIC_BUILTIN_TOPIC_COPY_HPP_
/* TODO: add builtin topic copyin copyout function declarations. */
#endif /* CYCLONEDDS_TOPIC_BUILTIN_TOPIC_COPY_HPP_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,71 @@
/*
* 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_TOPIC_BUILTIN_TOPIC_KEY_DELEGATE_HPP_
#define CYCLONEDDS_TOPIC_BUILTIN_TOPIC_KEY_DELEGATE_HPP_
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace topic
{
class BuiltinTopicKeyDelegate
{
public:
typedef uint32_t VALUE_T;
public:
BuiltinTopicKeyDelegate() { }
BuiltinTopicKeyDelegate(int32_t v[])
{
key_[0] = v[0];
key_[1] = v[1];
key_[2] = v[2];
}
public:
const int32_t* value() const
{
return key_;
}
void value(int32_t v[])
{
key_[0] = v[0];
key_[1] = v[1];
key_[2] = v[2];
}
bool operator ==(const BuiltinTopicKeyDelegate& other) const
{
return other.key_[0] == key_[0]
&& other.key_[1] == key_[1]
&& other.key_[2] == key_[2];
}
private:
int32_t key_[3];
};
}
}
}
}
#endif /* CYCLONEDDS_TOPIC_BUILTIN_TOPIC_KEY_DELEGATE_HPP_ */

View File

@@ -0,0 +1,21 @@
/*
* 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_TOPIC_BUILTIN_TOPIC_TRAITS_HPP
#define CYCLONEDDS_TOPIC_BUILTIN_TOPIC_TRAITS_HPP
#include <dds/topic/BuiltinTopic.hpp>
#include <org/eclipse/cyclonedds/topic/TopicTraits.hpp>
#include <org/eclipse/cyclonedds/topic/BuiltinTopicCopy.hpp>
/* TODO: add builtin topic traits. */
#endif /* CYCLONEDDS_TOPIC_BUILTIN_TOPIC_TRAITS_HPP */

View File

@@ -0,0 +1,68 @@
/*
* 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_TOPIC_CDRBLOB_HPP
#define CYCLONEDDS_TOPIC_CDRBLOB_HPP
#include <array>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace topic
{
enum class BlobKind
{
Empty,
KeyOnly,
Data,
};
class CDRBlob
{
private:
std::array<char, 4> encoding_ = { };
BlobKind kind_ = BlobKind::Empty;
std::vector<uint8_t> payload_;
public:
CDRBlob() = default;
explicit CDRBlob(
const std::array<char, 4>& encoding,
BlobKind kind,
const std::vector<uint8_t>& payload) :
encoding_(encoding),
kind_(kind),
payload_(payload) {}
const std::array<char, 4>& encoding() const { return this->encoding_; }
std::array<char, 4>& encoding() { return this->encoding_; }
void encoding(const std::array<char, 4>& _val_) { this->encoding_ = _val_; }
void encoding(std::array<char, 4>&& _val_) { this->encoding_ = _val_; }
BlobKind kind() const { return this->kind_; }
BlobKind& kind() { return this->kind_; }
void kind(BlobKind _val_) { this->kind_ = _val_; }
const std::vector<uint8_t>& payload() const { return this->payload_; }
std::vector<uint8_t>& payload() { return this->payload_; }
void payload(const std::vector<uint8_t>& _val_) { this->payload_ = _val_; }
void payload(std::vector<uint8_t>&& _val_) { this->payload_ = _val_; }
};
}
}
}
}
#endif /* CYCLONEDDS_TOPIC_CDRBLOB_HPP */

View File

@@ -0,0 +1,106 @@
/*
* 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_FILTER_HPP_
#define CYCLONEDDS_DDS_TOPIC_DETAIL_FILTER_HPP_
/**
* @file
*/
// Implementation
#include <string>
#include <vector>
#include <iterator>
#include <dds/core/detail/inttypes.hpp>
#include <dds/core/macros.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace topic
{
DDSCXX_WARNING_MSVC_OFF(4251)
class OMG_DDS_API FilterDelegate
{
public:
typedef std::vector<std::string>::iterator iterator;
typedef std::vector<std::string>::const_iterator const_iterator;
public:
FilterDelegate();
FilterDelegate(const std::string& query_expression);
template <typename FWIterator>
FilterDelegate(const std::string& query_expression,
const FWIterator& params_begin, const FWIterator& params_end)
: myExpression(query_expression)
{
std::copy(params_begin, params_end, std::back_insert_iterator<std::vector<std::string> >(myParams));
}
const std::string& expression() const;
/**
* @internal Provides the begin iterator to the parameter list.
*/
const_iterator begin() const;
/**
* @internal The const end iterator to the parameter list.
*/
const_iterator end() const;
/**
* @internal Provides the begin const iterator to the parameter list.
*/
iterator begin();
/**
* @internal The end iterator to the parameter list.
*/
iterator end();
template <typename FWIterator>
void parameters(const FWIterator& begin, const FWIterator end)
{
myParams.erase(myParams.begin(), myParams.end());
std::copy(begin, end, std::back_insert_iterator<std::vector<std::string> >(myParams));
}
void add_parameter(const std::string& param);
uint32_t parameters_length() const;
bool operator ==(const FilterDelegate& other) const;
private:
std::string myExpression;
std::vector<std::string> myParams;
};
DDSCXX_WARNING_MSVC_ON(4251)
// End of implementation
}
}
}
}
#endif /* CYCLONEDDS_DDS_TOPIC_DETAIL_FILTER_HPP_ */

View File

@@ -0,0 +1,186 @@
/*
* 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_TOPIC_TBUILTIN_TOPIC_HPP_
#define CYCLONEDDS_TOPIC_TBUILTIN_TOPIC_HPP_
#include <dds/core/detail/conformance.hpp>
#include <dds/core/Value.hpp>
#include <dds/core/policy/CorePolicy.hpp>
#include <dds/topic/BuiltinTopicKey.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace topic
{
template <typename D>
class TCMParticipantBuiltinTopicData;
template <typename D>
class TCMPublisherBuiltinTopicData;
template <typename D>
class TCMSubscriberBuiltinTopicData;
template <typename D>
class TCMDataWriterBuiltinTopicData;
template <typename D>
class TCMDataReaderBuiltinTopicData;
}
}
}
}
/**
* The CMParticipant topic...
*/
template <typename D>
class org::eclipse::cyclonedds::topic::TCMParticipantBuiltinTopicData : public ::dds::core::Value<D>
{
public:
const dds::topic::BuiltinTopicKey& key() const
{
return this->delegate().key();
}
};
/**
* The CMPublisher topic...
*/
template <typename D>
class org::eclipse::cyclonedds::topic::TCMPublisherBuiltinTopicData : public ::dds::core::Value<D>
{
public:
const dds::topic::BuiltinTopicKey& key() const
{
return this->delegate().key();
}
const dds::topic::BuiltinTopicKey& participant_key() const
{
return this->delegate().participant_key();
}
const std::string& name() const
{
return this->delegate().name();
}
const ::dds::core::policy::EntityFactory& entity_factory() const
{
return this->delegate().entity_factory();
}
const ::dds::core::policy::Partition& partition() const
{
return this->delegate().partition();
}
};
/**
* The CMSubscriber topic...
*/
template <typename D>
class org::eclipse::cyclonedds::topic::TCMSubscriberBuiltinTopicData : public ::dds::core::Value<D>
{
public:
const dds::topic::BuiltinTopicKey& key() const
{
return this->delegate().key();
}
const dds::topic::BuiltinTopicKey& participant_key() const
{
return this->delegate().participant_key();
}
const std::string& name() const
{
return this->delegate().name();
}
const ::dds::core::policy::EntityFactory& entity_factory() const
{
return this->delegate().entity_factory();
}
const ::dds::core::policy::Partition& partition() const
{
return this->delegate().partition();
}
};
/**
* The CMDataWriter topic...
*/
template <typename D>
class org::eclipse::cyclonedds::topic::TCMDataWriterBuiltinTopicData : public ::dds::core::Value<D>
{
public:
const dds::topic::BuiltinTopicKey& key() const
{
return this->delegate().key();
}
const dds::topic::BuiltinTopicKey& publisher_key() const
{
return this->delegate().publisher_key();
}
const std::string& name() const
{
return this->delegate().name();
}
const ::dds::core::policy::History& history() const
{
return this->delegate().history();
}
const ::dds::core::policy::ResourceLimits& resource_limits() const
{
return this->delegate().resource_limits();
}
const ::dds::core::policy::WriterDataLifecycle& writer_data_lifecycle() const
{
return this->delegate().writer_data_lifecycle();
}
};
/**
* The CMDataReader topic...
*/
template <typename D>
class org::eclipse::cyclonedds::topic::TCMDataReaderBuiltinTopicData : public ::dds::core::Value<D>
{
public:
const dds::topic::BuiltinTopicKey& key() const
{
return this->delegate().key();
}
const dds::topic::BuiltinTopicKey& subscriber_key() const
{
return this->delegate().subscriber_key();
}
const std::string& name() const
{
return this->delegate().name();
}
const ::dds::core::policy::History& history() const
{
return this->delegate().history();
}
const ::dds::core::policy::ResourceLimits& resource_limits() const
{
return this->delegate().resource_limits();
}
const ::dds::core::policy::ReaderDataLifecycle& reader_data_lifecycle() const
{
return this->delegate().reader_data_lifecycle();
}
};
#endif /* CYCLONEDDS_TOPIC_TBUILTIN_TOPIC_HPP_ */

View File

@@ -0,0 +1,88 @@
/*
* 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_TOPIC_TOPICDESCRIPTIONDELEGATE_HPP_
#define CYCLONEDDS_TOPIC_TOPICDESCRIPTIONDELEGATE_HPP_
#include <dds/domain/DomainParticipant.hpp>
#include <org/eclipse/cyclonedds/core/ObjectDelegate.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace topic
{
class OMG_DDS_API TopicDescriptionDelegate : public virtual org::eclipse::cyclonedds::core::DDScObjectDelegate
{
public:
typedef ::dds::core::smart_ptr_traits< TopicDescriptionDelegate >::ref_type ref_type;
typedef ::dds::core::smart_ptr_traits< TopicDescriptionDelegate >::weak_ref_type weak_ref_type;
public:
TopicDescriptionDelegate(const dds::domain::DomainParticipant& dp,
const std::string& name,
const std::string& type_name);
virtual ~TopicDescriptionDelegate();
public:
/**
* @internal Get the name used to create the TopicDescription.
*/
const std::string& name() const;
/**
* @internal The type_name used to create the TopicDescription.
*/
const std::string& type_name() const;
/**
* @internal This operation returns the DomainParticipant to which the
* TopicDescription belongs.
*/
const dds::domain::DomainParticipant& domain_participant() const;
void incrNrDependents();
void decrNrDependents();
bool hasDependents() const;
virtual std::string reader_expression() const = 0;
//@todo virtual c_value *reader_parameters() const = 0;
ddsi_sertype *get_ser_type() const;
protected:
dds::domain::DomainParticipant myParticipant;
std::string myTopicName;
std::string myTypeName;
uint32_t nrDependents;
ddsi_sertype *ser_type_;
};
}
}
}
}
#endif /* CYCLONEDDS_TOPIC_TOPICDESCRIPTIONDELEGATE_HPP_ */

View File

@@ -0,0 +1,52 @@
/*
* 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_TOPIC_TOPIC_LISTENER_HPP_
#define CYCLONEDDS_TOPIC_TOPIC_LISTENER_HPP_
#include "dds/topic/TopicListener.hpp"
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace topic
{
template <typename T>
class TopicListener : public dds::topic::TopicListener<T>
{
public:
virtual ~TopicListener() { }
};
template <typename T>
class NoOpTopicListener : public virtual TopicListener<T>
{
public:
virtual ~NoOpTopicListener() { }
public:
virtual void on_inconsistent_topic(
dds::topic::Topic<T>&,
const dds::core::status::InconsistentTopicStatus&) { }
};
}
}
}
}
#endif /* CYCLONEDDS_TOPIC_TOPIC_LISTENER_HPP_ */

View File

@@ -0,0 +1,290 @@
/*
* Copyright(c) 2006 to 2022 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_TOPIC_TOPICTRAITS_HPP_
#define CYCLONEDDS_TOPIC_TOPICTRAITS_HPP_
#include "dds/ddsrt/heap.h"
#include "dds/ddsi/ddsi_serdata.h"
#include "org/eclipse/cyclonedds/core/cdr/cdr_enums.hpp"
#include "dds/features.hpp"
//forward declaration of c++ sertype wrapper
template <typename T, class S> class ddscxx_sertype;
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace core
{
namespace cdr
{
//forward declarations of streamer types
class basic_cdr_stream;
class xcdr_v1_stream;
class xcdr_v2_stream;
}
}
namespace topic
{
using core::cdr::extensibility;
using core::cdr::encoding_version;
using core::cdr::allowable_encodings_t;
using core::cdr::basic_cdr_stream;
using core::cdr::xcdr_v1_stream;
using core::cdr::xcdr_v2_stream;
template <class TOPIC> class TopicTraits
{
public:
/**
* @brief Returns whether TOPIC contains no key fields.
*
* Used in creating the CycloneDDS writer and equality comparisons with other topics.
* This is one of the traits that is conditionally generated if there are any key fields.
*
* @return Whether TOPIC does not contain any fields marked as key fields.
*/
static constexpr bool isKeyless()
{
return false;
}
/**
* @brief Returns the name of the type of TOPIC.
*
* Used in creating the correct TopicDescription.
* This trait is always generated for user-defined types, and this function is just a placeholder.
*
* @return The name of the type of TOPIC.
*/
static constexpr const char *getTypeName()
{
return "";
}
/**
* @brief Returns an instance of ddsi_sertype for TOPIC.
*
* Used by CycloneDDS-CXX to get a sertype, which contains the functions used by CycloneDDS which are specific to TOPIC.
*
* @param[in] kinds The serialization of the of the sertype to create.
* @return A pointer to a new dssi_sertype.
*/
static ddsi_sertype *getSerType(allowable_encodings_t kinds = allowableEncodings())
{
if (kinds & allowableEncodings() & DDS_DATA_REPRESENTATION_FLAG_XCDR1)
return static_cast<ddsi_sertype*>(new ddscxx_sertype<TOPIC,basic_cdr_stream>());
else if (kinds & allowableEncodings() & DDS_DATA_REPRESENTATION_FLAG_XCDR2)
return static_cast<ddsi_sertype*>(new ddscxx_sertype<TOPIC,xcdr_v2_stream>());
else
return nullptr;
}
/**
* @brief Returns the size of an instance of TOPIC.
*
* Used by shared memory implementation to determine the size of the block necessary to contain an instance of TOPIC.
*
* @return The size of an instance of TOPIC.
*/
static constexpr size_t getSampleSize()
{
return sizeof(TOPIC);
}
/**
* @brief Returns whether instances of TOPIC reference memory outside its own declaration.
*
* Used by shared memory implementation.
* This trait will be generated as false if any strings or vectors are found anywhere in TOPIC's member tree.
*
* @return Whether TOPIC is a selfcontained type.
*/
static constexpr bool isSelfContained()
{
return true;
}
/**
* @brief Returns the allowable encodings for this topic.
*
* Used to determine which encoding type to write in combination with the data representation QoS.
*
* @return The allowable encodings of TOPIC.
*/
static constexpr allowable_encodings_t allowableEncodings()
{
return 0xFFFFFFFFu;
}
/**
* @brief Returns the xtypes extensibility of TOPIC.
*
* Used to determine which encoding type to write in the CDR header.
* This trait will be generated if the extensibility of TOPIC differs from final.
*
* @return The extensibility of TOPIC.
*/
static constexpr extensibility getExtensibility()
{
return extensibility::ext_final;
}
#ifdef DDSCXX_HAS_TYPE_DISCOVERY
/**
* @brief Returns the typeid for TOPIC.
*
* Is a simple pass-through for the derivation of the typeid from the type information.
* As C++ keeps the topic type as the template parameter, there is no need to look at the
* sertype for this topic.
*
* @param[in] kind The kind of typeid.
*
* @return A pointer to the typeid of this topic.
*/
static ddsi_typeid_t* getTypeId(const struct ddsi_sertype *, ddsi_typeid_kind_t kind)
{
auto ti = getTypeInfo(NULL);
if (ti) {
auto id = ddsi_typeinfo_typeid(ti, kind);
ddsi_typeinfo_fini(ti);
ddsrt_free(ti);
return id;
} else {
return nullptr;
}
}
/**
* @brief Returns the type map for TOPIC.
*
* Takes the type map blob for this topic which is part of the generated type traits, and deserializes
* the type map from this blob.
*
* @return A pointer to the typemap for this topic.
*/
static ddsi_typemap_t* getTypeMap(const struct ddsi_sertype *)
{
ddsi_sertype_cdr_data_t cdr{type_map_blob_sz(), const_cast<uint8_t*>(type_map_blob())};
return ddsi_typemap_deser(&cdr);
}
/**
* @brief Returns the type info for TOPIC.
*
* Takes the type info blob for this topic which is part of the generated type traits, and deserializes
* the type info from this blob.
*
* @return A pointer to the typeinfo for this topic.
*/
static ddsi_typeinfo_t* getTypeInfo(const struct ddsi_sertype *)
{
ddsi_sertype_cdr_data_t cdr{type_info_blob_sz(), const_cast<uint8_t*>(type_info_blob())};
return ddsi_typeinfo_deser(&cdr);
}
/**
* @brief Returns size of the blob of the cdr serialized type map.
*
* This function is a placeholder, it will be instantiated for all valid topics.
*
* @return The size of the serialized type map blob.
*/
static constexpr unsigned int type_map_blob_sz()
{
return static_cast<unsigned int>(-1);
}
/**
* @brief Returns size of the blob of the cdr serialized type info.
*
* This function is a placeholder, it will be instantiated for all valid topics.
*
* @return The size of the serialized type info blob.
*/
static constexpr unsigned int type_info_blob_sz()
{
return static_cast<unsigned int>(-1);
}
/**
* @brief Returns pointer to the blob of the cdr serialized type map.
*
* This function is a placeholder, it will be instantiated for all valid topics.
*
* @return Pointer to the serialized type map blob.
*/
static inline const uint8_t * type_map_blob()
{
return nullptr;
}
/**
* @brief Returns pointer to the blob of the cdr serialized type info.
*
* This function is a placeholder, it will be instantiated for all valid topics.
*
* @return Pointer to the serialized type info blob.
*/
static inline const uint8_t * type_info_blob()
{
return nullptr;
}
#endif //DDSCXX_HAS_TYPE_DISCOVERY
/**
* @brief Returns a pointer to the derived sertype.
*
* Returns a nullptr if no type can be derived succesfully.
*
* @param[in] data_representation The type of data representation to use.
*
* @return The pointer to the derived sertype.
*/
static struct ddsi_sertype* deriveSertype(const struct ddsi_sertype *, dds_data_representation_id_t data_representation, dds_type_consistency_enforcement_qospolicy_t)
{
struct ddsi_sertype *ptr = nullptr;
switch (data_representation) {
case DDS_DATA_REPRESENTATION_XCDR1:
ptr = getSerType(DDS_DATA_REPRESENTATION_FLAG_XCDR1);
break;
case DDS_DATA_REPRESENTATION_XCDR2:
ptr = getSerType(DDS_DATA_REPRESENTATION_FLAG_XCDR2);
break;
}
if (ptr) {
uint32_t refc = ddsrt_atomic_ld32 (&ptr->flags_refc);
ddsrt_atomic_st32 (&ptr->flags_refc, refc & ~DDSI_SERTYPE_REFC_MASK);
}
return ptr;
}
};
}
}
}
}
#endif /* CYCLONEDDS_TOPIC_TOPICTRAITS_HPP_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,169 @@
/*
* 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_TOPIC_DISCOVER_HPP_
#define CYCLONEDDS_TOPIC_DISCOVER_HPP_
#include <dds/domain/DomainParticipant.hpp>
#include <dds/topic/TopicDescription.hpp>
#include <dds/topic/AnyTopic.hpp>
#include <dds/topic/Topic.hpp>
#include <dds/topic/ContentFilteredTopic.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace topic
{
template <typename T, typename DELEGATE>
struct typed_lookup_topic {
template <typename TOPIC>
static inline TOPIC discover(
const dds::domain::DomainParticipant& dp,
const std::string& topic_name,
const dds::core::Duration& timeout);
template <typename TOPIC>
static inline void discover(
const dds::domain::DomainParticipant& dp,
std::vector<TOPIC>& list,
uint32_t max_size);
};
template <typename T>
struct typed_lookup_topic<T, dds::topic::detail::ContentFilteredTopic<T> > {
static inline dds::topic::ContentFilteredTopic<T> discover(
const dds::domain::DomainParticipant& dp,
const std::string& topic_name,
const dds::core::Duration& timeout)
{
(void)dp;
(void)topic_name;
(void)timeout;
ISOCPP_THROW_EXCEPTION(ISOCPP_UNSUPPORTED_ERROR, "Function not currently supported");
}
static inline void discover(
const dds::domain::DomainParticipant& dp,
std::vector<dds::topic::ContentFilteredTopic<T> >& list,
uint32_t max_size)
{
(void)dp;
(void)list;
(void)max_size;
ISOCPP_THROW_EXCEPTION(ISOCPP_UNSUPPORTED_ERROR, "Function not currently supported");
}
};
template <typename T>
struct typed_lookup_topic<T, dds::topic::detail::Topic<T> > {
static inline dds::topic::Topic<T> discover(
const dds::domain::DomainParticipant& dp,
const std::string& topic_name,
const dds::core::Duration& timeout)
{
return dds::topic::detail::Topic<T>::discover_topic(dp, topic_name, timeout);
}
static inline void discover(
const dds::domain::DomainParticipant& dp,
std::vector<dds::topic::Topic<T> >& list,
uint32_t max_size)
{
dds::topic::detail::Topic<T>::discover_topics(dp, list, max_size);
}
};
template <typename TOPIC, typename DELEGATE>
struct lookup_topic {
static inline TOPIC discover(
const dds::domain::DomainParticipant& dp,
const std::string& topic_name,
const dds::core::Duration& timeout)
{
return org::eclipse::cyclonedds::topic::typed_lookup_topic<typename TOPIC::DataType,
typename TOPIC::DELEGATE_T>::discover(dp, topic_name, timeout);
}
static inline void discover(
const dds::domain::DomainParticipant& dp,
std::vector<TOPIC>& list,
uint32_t max_size)
{
org::eclipse::cyclonedds::topic::typed_lookup_topic<typename TOPIC::DataType,
typename TOPIC::DELEGATE_T>::discover(dp, list, max_size);
}
};
template <>
struct lookup_topic<dds::topic::TopicDescription, org::eclipse::cyclonedds::topic::TopicDescriptionDelegate> {
static inline dds::topic::TopicDescription discover(
const dds::domain::DomainParticipant& dp,
const std::string& topic_name,
const dds::core::Duration& timeout)
{
return org::eclipse::cyclonedds::topic::AnyTopicDelegate::discover_topic(dp, topic_name, timeout);
}
static inline void discover(
const dds::domain::DomainParticipant& dp,
std::vector<dds::topic::TopicDescription>& list,
uint32_t max_size)
{
std::vector<dds::topic::AnyTopic> anyTopics;
org::eclipse::cyclonedds::topic::AnyTopicDelegate::discover_topics(dp, anyTopics, max_size);
for (std::vector<dds::topic::AnyTopic>::iterator it = anyTopics.begin(); it != anyTopics.end(); ++it) {
list.push_back(*it);
}
}
};
template <>
struct lookup_topic<dds::topic::AnyTopic, org::eclipse::cyclonedds::topic::AnyTopicDelegate> {
static inline dds::topic::AnyTopic discover(
const dds::domain::DomainParticipant& dp,
const std::string& topic_name,
const dds::core::Duration& timeout)
{
return org::eclipse::cyclonedds::topic::AnyTopicDelegate::discover_topic(dp, topic_name, timeout);
}
static inline void discover(
const dds::domain::DomainParticipant& dp,
std::vector<dds::topic::AnyTopic>& list,
uint32_t max_size)
{
org::eclipse::cyclonedds::topic::AnyTopicDelegate::discover_topics(dp, list, max_size);
}
};
}
}
}
}
#endif /* CYCLONEDDS_TOPIC_DISCOVER_HPP_ */

View File

@@ -0,0 +1,133 @@
/*
* 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_TOPIC_FIND_HPP_
#define CYCLONEDDS_TOPIC_FIND_HPP_
#include <dds/domain/DomainParticipant.hpp>
#include <dds/topic/TopicDescription.hpp>
#include <dds/topic/AnyTopic.hpp>
#include <dds/topic/Topic.hpp>
#include <dds/topic/ContentFilteredTopic.hpp>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace topic
{
OMG_DDS_API dds::topic::TopicDescription
find_topic_description(
const dds::domain::DomainParticipant& dp,
const std::string& topic_name);
OMG_DDS_API dds::topic::AnyTopic
find_any_topic(
const dds::domain::DomainParticipant& dp,
const std::string& topic_name);
template <typename T, typename DELEGATE>
struct typed_finder {
template <typename TOPIC>
static inline TOPIC find(
const dds::domain::DomainParticipant& dp,
const std::string& topic_name);
};
template <typename T>
struct typed_finder<T, dds::topic::detail::ContentFilteredTopic<T> > {
static inline dds::topic::ContentFilteredTopic<T> find(
const dds::domain::DomainParticipant& dp,
const std::string& topic_name)
{
dds::topic::ContentFilteredTopic<T> topic = dds::core::null;
org::eclipse::cyclonedds::core::ObjectDelegate::ref_type entity = dp.delegate()->find_cfTopic(topic_name);
if (entity) {
typename dds::topic::ContentFilteredTopic<T>::DELEGATE_REF_T topic_typed =
::std::dynamic_pointer_cast<typename dds::topic::ContentFilteredTopic<T>::DELEGATE_T>(entity);
topic = dds::topic::ContentFilteredTopic<T>(topic_typed);
}
return topic;
}
};
template <typename T>
struct typed_finder<T, dds::topic::detail::Topic<T> > {
static inline dds::topic::Topic<T> find(
const dds::domain::DomainParticipant& dp,
const std::string& topic_name)
{
dds::topic::Topic<T> topic = dds::core::null;
org::eclipse::cyclonedds::core::EntityDelegate::ref_type entity = dp.delegate()->find_topic(topic_name);
if (entity) {
typename dds::topic::Topic<T>::DELEGATE_REF_T topic_typed =
::std::dynamic_pointer_cast<typename dds::topic::Topic<T>::DELEGATE_T>(entity);
topic = dds::topic::Topic<T>(topic_typed);
}
return topic;
}
};
template <typename TOPIC, typename DELEGATE>
struct finder {
static inline TOPIC find(
const dds::domain::DomainParticipant& dp,
const std::string& topic_name)
{
return org::eclipse::cyclonedds::topic::typed_finder<typename TOPIC::DataType, typename TOPIC::DELEGATE_T>::find(dp, topic_name);
}
};
template <>
struct finder<dds::topic::TopicDescription, org::eclipse::cyclonedds::topic::TopicDescriptionDelegate> {
static inline dds::topic::TopicDescription find(
const dds::domain::DomainParticipant& dp,
const std::string& topic_name)
{
return find_topic_description(dp, topic_name);
}
};
template <>
struct finder<dds::topic::AnyTopic, org::eclipse::cyclonedds::topic::AnyTopicDelegate> {
static inline dds::topic::AnyTopic find(
const dds::domain::DomainParticipant& dp,
const std::string& topic_name)
{
return find_any_topic(dp, topic_name);
}
};
}
}
}
}
#endif /* CYCLONEDDS_TOPIC_FIND_HPP_ */

View File

@@ -0,0 +1,42 @@
/*
* 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 IDLCXX_HASH_HPP_
#define IDLCXX_HASH_HPP_
#include "dds/core/macros.hpp"
#include "dds/ddsi/ddsi_keyhash.h"
#include <vector>
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace topic
{
bool OMG_DDS_API simple_key(const std::vector<unsigned char>& in, ddsi_keyhash_t& out);
bool OMG_DDS_API complex_key(const std::vector<unsigned char>& in, ddsi_keyhash_t& out);
}
}
}
}
#endif /* IDLCXX_HASH_HPP_ */

View File

@@ -0,0 +1,289 @@
/*
* 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
*/
/**
* @file
*/
#ifndef CYCLONEDDS_TOPIC_QOS_TOPIC_QOS_DELEGATE_HPP_
#define CYCLONEDDS_TOPIC_QOS_TOPIC_QOS_DELEGATE_HPP_
#include <dds/core/detail/conformance.hpp>
#include <dds/core/policy/CorePolicy.hpp>
struct _DDS_NamedTopicQos;
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace topic
{
namespace qos
{
class OMG_DDS_API TopicQosDelegate
{
public:
TopicQosDelegate();
void policy(const dds::core::policy::TopicData& topic_data);
void policy(const dds::core::policy::Durability& durability);
#ifdef OMG_DDS_PERSISTENCE_SUPPORT
void policy(const dds::core::policy::DurabilityService& durability_service);
#endif // OMG_DDS_PERSISTENCE_SUPPORT
void policy(const dds::core::policy::Deadline& deadline);
void policy(const dds::core::policy::LatencyBudget& budget);
void policy(const dds::core::policy::Liveliness& liveliness);
void policy(const dds::core::policy::Reliability& reliability);
void policy(const dds::core::policy::DestinationOrder& order);
void policy(const dds::core::policy::History& history);
void policy(const dds::core::policy::ResourceLimits& resources);
void policy(const dds::core::policy::TransportPriority& priority);
void policy(const dds::core::policy::Lifespan& lifespan);
void policy(const dds::core::policy::Ownership& ownership);
#ifdef OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
void policy(const dds::core::policy::DataRepresentation& datarepresentation);
void policy(const dds::core::policy::TypeConsistencyEnforcement& typeconsistencyenforcement);
#endif // OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
template <typename POLICY> const POLICY& policy() const;
template <typename POLICY> POLICY& policy();
/* The returned ddsc QoS has to be freed. */
dds_qos_t* ddsc_qos() const;
void ddsc_qos(const dds_qos_t* qos);
void named_qos(const struct _DDS_NamedTopicQos &qos);
void check() const;
bool operator ==(const TopicQosDelegate& other) const;
private:
dds::core::policy::TopicData topic_data_;
dds::core::policy::Durability durability_;
#ifdef OMG_DDS_PERSISTENCE_SUPPORT
dds::core::policy::DurabilityService durability_service_;
#endif // OMG_DDS_PERSISTENCE_SUPPORT
dds::core::policy::Deadline deadline_;
dds::core::policy::LatencyBudget budget_;
dds::core::policy::Liveliness liveliness_;
dds::core::policy::Reliability reliability_;
dds::core::policy::DestinationOrder order_;
dds::core::policy::History history_;
dds::core::policy::ResourceLimits resources_;
dds::core::policy::TransportPriority priority_;
dds::core::policy::Lifespan lifespan_;
dds::core::policy::Ownership ownership_;
#ifdef OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
dds::core::policy::DataRepresentation datarepresentation_;
dds::core::policy::TypeConsistencyEnforcement typeconsistencyenforcement_;
#endif // OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
};
//==============================================================================
template<> inline const dds::core::policy::TopicData&
TopicQosDelegate::policy<dds::core::policy::TopicData>() const
{
return topic_data_;
}
template<> inline dds::core::policy::TopicData&
TopicQosDelegate::policy<dds::core::policy::TopicData>()
{
return topic_data_;
}
template<> inline const dds::core::policy::Durability&
TopicQosDelegate::policy<dds::core::policy::Durability>() const
{
return durability_;
}
template<> inline dds::core::policy::Durability&
TopicQosDelegate::policy<dds::core::policy::Durability>()
{
return durability_;
}
#ifdef OMG_DDS_PERSISTENCE_SUPPORT
template<> inline const dds::core::policy::DurabilityService&
TopicQosDelegate::policy<dds::core::policy::DurabilityService>() const
{
return durability_service_;
}
template<> inline dds::core::policy::DurabilityService&
TopicQosDelegate::policy<dds::core::policy::DurabilityService>()
{
return durability_service_;
}
#endif // OMG_DDS_PERSISTENCE_SUPPORT
template<> inline const dds::core::policy::Deadline&
TopicQosDelegate::policy<dds::core::policy::Deadline>() const
{
return deadline_;
}
template<> inline dds::core::policy::Deadline&
TopicQosDelegate::policy<dds::core::policy::Deadline>()
{
return deadline_;
}
template<> inline const dds::core::policy::LatencyBudget&
TopicQosDelegate::policy<dds::core::policy::LatencyBudget>() const
{
return budget_;
}
template<> inline dds::core::policy::LatencyBudget&
TopicQosDelegate::policy<dds::core::policy::LatencyBudget>()
{
return budget_;
}
template<> inline const dds::core::policy::Liveliness&
TopicQosDelegate::policy<dds::core::policy::Liveliness>() const
{
return liveliness_;
}
template<> inline dds::core::policy::Liveliness&
TopicQosDelegate::policy<dds::core::policy::Liveliness>()
{
return liveliness_;
}
template<> inline const dds::core::policy::Reliability&
TopicQosDelegate::policy<dds::core::policy::Reliability>() const
{
return reliability_;
}
template<> inline dds::core::policy::Reliability&
TopicQosDelegate::policy<dds::core::policy::Reliability>()
{
return reliability_;
}
template<> inline const dds::core::policy::DestinationOrder&
TopicQosDelegate::policy<dds::core::policy::DestinationOrder>() const
{
return order_;
}
template<> inline dds::core::policy::DestinationOrder&
TopicQosDelegate::policy<dds::core::policy::DestinationOrder>()
{
return order_;
}
template<> inline const dds::core::policy::History&
TopicQosDelegate::policy<dds::core::policy::History>() const
{
return history_;
}
template<> inline dds::core::policy::History&
TopicQosDelegate::policy<dds::core::policy::History>()
{
return history_;
}
template<> inline const dds::core::policy::ResourceLimits&
TopicQosDelegate::policy<dds::core::policy::ResourceLimits>() const
{
return resources_;
}
template<> inline dds::core::policy::ResourceLimits&
TopicQosDelegate::policy<dds::core::policy::ResourceLimits>()
{
return resources_;
}
template<> inline const dds::core::policy::TransportPriority&
TopicQosDelegate::policy<dds::core::policy::TransportPriority>() const
{
return priority_;
}
template<> inline dds::core::policy::TransportPriority&
TopicQosDelegate::policy<dds::core::policy::TransportPriority>()
{
return priority_;
}
template<> inline const dds::core::policy::Lifespan&
TopicQosDelegate::policy<dds::core::policy::Lifespan>() const
{
return lifespan_;
}
template<> inline dds::core::policy::Lifespan&
TopicQosDelegate::policy<dds::core::policy::Lifespan>()
{
return lifespan_;
}
template<> inline const dds::core::policy::Ownership&
TopicQosDelegate::policy<dds::core::policy::Ownership>() const
{
return ownership_;
}
template<> inline dds::core::policy::Ownership&
TopicQosDelegate::policy<dds::core::policy::Ownership>()
{
return ownership_;
}
#ifdef OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
template<> inline const dds::core::policy::DataRepresentation&
TopicQosDelegate::policy<dds::core::policy::DataRepresentation>() const
{
return datarepresentation_;
}
template<> inline dds::core::policy::DataRepresentation&
TopicQosDelegate::policy<dds::core::policy::DataRepresentation>()
{
return datarepresentation_;
}
template<> inline const dds::core::policy::TypeConsistencyEnforcement&
TopicQosDelegate::policy<dds::core::policy::TypeConsistencyEnforcement>() const
{
return typeconsistencyenforcement_;
}
template<> inline dds::core::policy::TypeConsistencyEnforcement&
TopicQosDelegate::policy<dds::core::policy::TypeConsistencyEnforcement>()
{
return typeconsistencyenforcement_;
}
#endif // OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT
}
}
}
}
}
#endif /* CYCLONEDDS_TOPIC_QOS_TOPIC_QOS_DELEGATE_HPP_ */