Exemple #1
0
void
org::opensplice::core::ObjectDelegate::check() const
{
    /* This method is not-thread-safe, and should only
     * be used with a lock.
     */
    if (closed) {
        ISOCPP_THROW_EXCEPTION(ISOCPP_ALREADY_CLOSED_ERROR, "Trying to invoke an oparation on an object that was already closed");
    }
}
void
DomainParticipantQosDelegate::defaults()
{
    /* Get default QoS from userlayer and copy result. */
    u_participantQos qos = u_participantQosNew(NULL);
    if (!qos) {
        ISOCPP_THROW_EXCEPTION(ISOCPP_OUT_OF_RESOURCES_ERROR, "Could not create internal QoS.");
    }
    this->u_qos(qos);
    u_participantQosFree(qos);
}
u_participantQos
DomainParticipantQosDelegate::u_qos() const
{
    u_participantQos qos = u_participantQosNew(NULL);
    if (!qos) {
        ISOCPP_THROW_EXCEPTION(ISOCPP_OUT_OF_RESOURCES_ERROR, "Could not create internal QoS.");
    }
    qos->userData           = user_data_.delegate().v_policyI();
    qos->entityFactory      = entity_factory_.delegate().v_policyI();
    qos->watchdogScheduling = watchdog_scheduling_.delegate().v_policyI();
    /* u_participantQos does not contain a listenerScheduling. */
    return qos;
}
u_publisherQos
PublisherQosDelegate::u_qos() const
{
    u_publisherQos qos = u_publisherQosNew(NULL);
    if (!qos) {
        ISOCPP_THROW_EXCEPTION(ISOCPP_OUT_OF_RESOURCES_ERROR, "Could not create internal QoS.");
    }
    qos->presentation  = presentation_   .delegate().v_policyI();
    qos->partition     = partition_      .delegate().v_policyI();
    qos->groupData     = gdata_          .delegate().v_policyI();
    qos->entityFactory = factory_policy_ .delegate().v_policyI();
    return qos;
}
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());
}
bool
org::opensplice::core::cond::ConditionDelegate::remove_waitset(
        org::opensplice::core::cond::WaitSetDelegate *waitset)
{
    org::opensplice::core::ScopedMutexLock scopedLock(this->waitSetListMutex);

    bool erased = this->waitsets.erase(waitset);
    if (erased) {
        waitset->remove_condition_locked(this);
    } else {
        ISOCPP_THROW_EXCEPTION(ISOCPP_PRECONDITION_NOT_MET_ERROR, "Condition was not attached to WaitSet");
    }

    return erased;
}
Exemple #7
0
dds::topic::detail::Topic<T>::Topic(const dds::domain::DomainParticipant& dp,
      const std::string& name,
      const std::string& type_name,
      const dds::topic::qos::TopicQos& qos,
      dds::topic::TopicListener<T>* listener,
      const dds::core::status::StatusMask& mask)
    : org::opensplice::topic::TopicDescriptionDelegate(dp, name, type_name),
      org::opensplice::topic::AnyTopicDelegate(qos, dp, name, type_name)
{
    ISOCPP_REPORT_STACK_NC_BEGIN();

    dds::domain::DomainParticipant participant = dds::core::null;

    /* The dp argument can be nil. Use the participant we know isn't nil because
     * the TopicDescriptionDelegate would have created it when needed. */
    participant = this->domain_participant();

    // Set the correct (IDL) type_name in the TopicDescription.
    org::opensplice::topic::TopicDescriptionDelegate::myTypeName = org::opensplice::topic::TopicTraits<T>::getTypeName();

    // get and validate the kernel qos
    org::opensplice::topic::qos::TopicQosDelegate tQos = qos.delegate();
    tQos.check();
    u_topicQos uTopicQos = tQos.u_qos();
    u_participant uParticipant = participant->registerType(
            org::opensplice::topic::TopicTraits<T>::getTypeName(),
            org::opensplice::topic::TopicTraits<T>::getDescriptor(),
            org::opensplice::topic::TopicTraits<T>::getDataRepresentationId(),
            org::opensplice::topic::TopicTraits<T>::getTypeHash(),
            org::opensplice::topic::TopicTraits<T>::getMetaData(),
            org::opensplice::topic::TopicTraits<T>::getExtentions());

    u_topic uTopic = u_topicNew(
            uParticipant,
            name.c_str(),
            org::opensplice::topic::TopicDescriptionDelegate::myTypeName.c_str(),
            org::opensplice::topic::TopicTraits<T>::getKeyList(),
            uTopicQos);

    u_topicQosFree(uTopicQos);

    if (!uTopic) {
        ISOCPP_THROW_EXCEPTION(ISOCPP_ERROR, "Failed to create Topic");
    }

    this->userHandle = (u_object)uTopic;
    this->listener_set((void*)listener, mask);
}
Exemple #8
0
void
dds::topic::detail::Topic<T>::close()
{
    this->listener(NULL, dds::core::status::StatusMask::none());
    this->listener_dispatcher_reset();

    org::opensplice::core::ScopedObjectLock scopedLock(*this);

    if (this->hasDependents()) {
        ISOCPP_THROW_EXCEPTION(ISOCPP_PRECONDITION_NOT_MET_ERROR, "Topic still has unclosed dependencies (e.g. Readers/Writers/ContentFilteredTopics)");
    }

    this->myParticipant.delegate()->remove_topic(*this);

    org::opensplice::core::EntityDelegate::close();
}
void
SubscriberDelegate::qos(const dds::sub::qos::SubscriberQos& sqos)
{
    org::opensplice::core::ScopedObjectLock scopedLock(*this);
    u_subscriberQos uQos;
    u_result uResult;

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

    uResult = u_subscriberSetQos(u_subscriber(this->userHandle), uQos);
    u_subscriberQosFree(uQos);
    ISOCPP_U_RESULT_CHECK_AND_THROW(uResult, "Could not set subscriber qos.");

    this->qos_ = sqos;
}
void
PublisherDelegate::wait_for_acknowledgments(const dds::core::Duration& max_wait)
{
    ISOCPP_THROW_EXCEPTION(ISOCPP_UNSUPPORTED_ERROR, "Function not currently supported");
}