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,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_ */