Esempio n. 1
0
void
dds::topic::detail::Topic<T>::discover_topics(
        const dds::domain::DomainParticipant& dp,
        std::vector<dds::topic::Topic<T, dds::topic::detail::Topic> >& topics,
        uint32_t max_size)
{
    std::vector<u_topic> uTopics;

    dp.delegate()->lookup_topics(topic_type_name<T>::value(), uTopics, max_size);

    topics.clear();
    topics.reserve(uTopics.size());

    for (std::vector<u_topic>::const_iterator it = uTopics.begin(); it != uTopics.end(); ++it) {
        u_topic uTopic = *it;
        os_char *topic_name = u_topicName(uTopic);
        os_char *type_name = u_topicTypeName(uTopic);

        u_topicQos uQos;
        u_result uResult = u_topicGetQos(uTopic, &uQos);
        ISOCPP_U_RESULT_CHECK_AND_THROW(uResult, "Failed to get user layer topic qos");

        dds::topic::qos::TopicQos qos;
        qos.delegate().u_qos(uQos);
        u_topicQosFree(uQos);

        typename dds::topic::Topic<T, dds::topic::detail::Topic>::DELEGATE_REF_T ref(new Topic<T>(dp, topic_name, type_name, qos, uTopic));
        ref->init(ref);

        os_free(topic_name);
        os_free(type_name);

        topics.push_back(dds::topic::Topic<T>(ref));
    }
}
Esempio n. 2
0
dds::topic::Topic<T, dds::topic::detail::Topic>
dds::topic::detail::Topic<T>::discover_topic(
        const dds::domain::DomainParticipant& dp,
        const std::string& name,
        const dds::core::Duration& timeout)
{
    u_topic uTopic = dp.delegate()->lookup_topic(name, timeout);

    if (uTopic == NULL) {
        return dds::core::null;
    }

    os_char *uTypename = u_topicTypeName(uTopic);
    std::string type_name = uTypename;
    os_free(uTypename);

    u_topicQos uQos;
    u_result uResult = u_topicGetQos(uTopic, &uQos);
    ISOCPP_U_RESULT_CHECK_AND_THROW(uResult, "Failed to get user layer topic qos");

    qos::TopicQos qos;
    qos.delegate().u_qos(uQos);
    u_topicQosFree(uQos);

    typename dds::topic::Topic<T, dds::topic::detail::Topic>::DELEGATE_REF_T ref(new Topic<T>(dp, name, type_name, qos, uTopic));
    ref->init(ref);

    return dds::topic::Topic<T>(ref);
}
Esempio n. 3
0
dds::topic::TopicDescription
find_topic_description(
    const dds::domain::DomainParticipant& dp,
    const std::string& topic_name)
{
    dds::topic::TopicDescription t = dds::core::null;

    org::opensplice::core::ObjectDelegate::ref_type entity = dp.delegate()->find_topic(topic_name);
    if (!entity) {
        entity = dp.delegate()->find_cfTopic(topic_name);
    }
    if (entity) {
        dds::topic::TopicDescription::DELEGATE_REF_T ref =
                OSPL_CXX11_STD_MODULE::dynamic_pointer_cast<org::opensplice::topic::TopicDescriptionDelegate>(entity);
        t = dds::topic::TopicDescription(ref);
    }

    return t;
}
Esempio n. 4
0
dds::topic::AnyTopic
find_any_topic(
    const dds::domain::DomainParticipant& dp,
    const std::string& topic_name)
{
    dds::topic::AnyTopic t = dds::core::null;

    org::opensplice::core::EntityDelegate::ref_type entity = dp.delegate()->find_topic(topic_name);
    if (entity) {
        dds::topic::AnyTopic::DELEGATE_REF_T ref =
                OSPL_CXX11_STD_MODULE::dynamic_pointer_cast<org::opensplice::topic::AnyTopicDelegate>(entity);
        t = dds::topic::AnyTopic(ref);
    }

    return t;
}
Esempio n. 5
0
SubscriberDelegate::SubscriberDelegate(
    const dds::domain::DomainParticipant& dp,
    const dds::sub::qos::SubscriberQos& qos,
    dds::sub::SubscriberListener* listener,
    const dds::core::status::StatusMask& event_mask) :
    dp_(dp),
    qos_(qos)
{
    ISOCPP_REPORT_STACK_DDS_BEGIN(dp);

    u_subscriber uSub;
    u_participant uPar;
    u_subscriberQos uQos;

    uPar = u_participant(this->dp_.delegate()->get_user_handle());
    if (!uPar) {
        ISOCPP_THROW_EXCEPTION(ISOCPP_ERROR, "Could not get subscriber participant.");
    }

    qos.delegate().check();
    uQos = qos.delegate().u_qos();
    if (!uQos) {
        ISOCPP_THROW_EXCEPTION(ISOCPP_ERROR, "Could not convert subscriber QoS.");
    }

    std::string name = this->dp_.delegate()->create_child_name("subscriber");
    uSub = u_subscriberNew(uPar, name.c_str(), uQos);
    u_subscriberQosFree (uQos);
    if (!uSub) {
        ISOCPP_THROW_EXCEPTION(ISOCPP_ERROR, "Could not create subscriber.");
    }

    /* ObjectDelegate class will free the userlayer object in its destructor. */
    this->userHandle = u_object(uSub);
    this->listener_set((void*)listener, event_mask);
    set_domain_id(dp.delegate()->get_domain_id());
}