gapi_returnCode_t
gapi_dataWriter_wait_for_acknowledgments (
	gapi_dataWriter _this,
    const gapi_duration_t *max_wait
    )
{
	_DataWriter datawriter;
	u_result uResult;
	gapi_returnCode_t result;
	c_time timeout;

	datawriter = gapi_dataWriterClaim(_this, NULL);

	if ( datawriter != NULL ) {
		kernelCopyInDuration(max_wait, &timeout);
		uResult = u_writerWaitForAcknowledgments(
					u_writer(_EntityUEntity(datawriter)),
					timeout);
		result = kernelResultToApiResult(uResult);
	} else {
		result = GAPI_RETCODE_BAD_PARAMETER;
	}
	_EntityRelease(datawriter);

	return result;
}
Exemple #2
0
gapi_returnCode_t
gapi_dataReader_wait_for_historical_data (
    gapi_dataReader _this,
    const gapi_duration_t *max_wait)
{
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    _DataReader datareader;
    c_time  c_time_max_wait;
    u_result  uResult;

    datareader = gapi_dataReaderClaim(_this, &result);

    if (datareader) {
        if ( !max_wait || !gapi_validDuration(max_wait)) {
            result = GAPI_RETCODE_BAD_PARAMETER;
        } else if (!_EntityEnabled(datareader)) {
            result = GAPI_RETCODE_NOT_ENABLED;
        } else {
            kernelCopyInDuration(max_wait, &c_time_max_wait);

            uResult = u_dataReaderWaitForHistoricalData(
                          U_DATAREADER_GET(datareader),
                          c_time_max_wait);
            result = kernelResultToApiResult(uResult);
        }
        _EntityRelease(datareader);
    }
    return result;
}
static gapi_boolean
copyWriterQosIn (
    const gapi_dataWriterQos *srcQos,
    v_writerQos dstQos)
{
    gapi_boolean copied = FALSE;

    /* Important note: The sequence related to policies is created on
     * heap and will be copied into the database by the kernel itself,
     * therefor the c_array does not need to be allocated with c_arrayNew,
     * but can be allocated on heap.
     */

    if (dstQos->userData.value) {
        os_free(dstQos->userData.value);
        dstQos->userData.value = NULL;
    }
    dstQos->userData.size = srcQos->user_data.value._length;
    if (dstQos->userData.size) {
        dstQos->userData.value = os_malloc (dstQos->userData.size);
    }
    if ((srcQos->user_data.value._length == 0) || dstQos->userData.value) {
        kernelCopyInDuration(&srcQos->deadline.period, &dstQos->deadline.period);
        dstQos->durability.kind = srcQos->durability.kind;
        dstQos->history.kind = srcQos->history.kind;
        dstQos->history.depth = srcQos->history.depth;
        kernelCopyInDuration(&srcQos->latency_budget.duration,
                             &dstQos->latency.duration);
        dstQos->liveliness.kind = srcQos->liveliness.kind;
        kernelCopyInDuration(&srcQos->liveliness.lease_duration,
                             &dstQos->liveliness.lease_duration);
        dstQos->orderby.kind = srcQos->destination_order.kind;
        dstQos->reliability.kind = srcQos->reliability.kind;
        kernelCopyInDuration(&srcQos->reliability.max_blocking_time,
                             &dstQos->reliability.max_blocking_time);
        dstQos->reliability.synchronous = srcQos->reliability.synchronous;
        dstQos->resource.max_samples = srcQos->resource_limits.max_samples;
        dstQos->resource.max_instances = srcQos->resource_limits.max_instances;
        dstQos->resource.max_samples_per_instance =
                     srcQos->resource_limits.max_samples_per_instance;
        dstQos->ownership.kind = srcQos->ownership.kind;
        dstQos->strength.value = srcQos->ownership_strength.value;
        dstQos->transport.value = srcQos->transport_priority.value;
        kernelCopyInDuration(&srcQos->lifespan.duration,
                             &dstQos->lifespan.duration);
        if (srcQos->user_data.value._length) {
            memcpy (dstQos->userData.value,
                    srcQos->user_data.value._buffer,
                    srcQos->user_data.value._length);
        }
        dstQos->lifecycle.autodispose_unregistered_instances =
            srcQos->writer_data_lifecycle.autodispose_unregistered_instances;
        kernelCopyInDuration(&srcQos->writer_data_lifecycle.autopurge_suspended_samples_delay,
                             &dstQos->lifecycle.autopurge_suspended_samples_delay);
        kernelCopyInDuration(&srcQos->writer_data_lifecycle.autounregister_instance_delay,
                             &dstQos->lifecycle.autounregister_instance_delay);
        copied = TRUE;
    }

    return copied;
}
Exemple #4
0
gapi_boolean
gapi_kernelReaderQosCopyIn (
    const gapi_dataReaderQos *srcQos,
    v_readerQos               dstQos)
{
    gapi_boolean copied = FALSE;

    /* Important note: The sequence related to policies is created on heap and
     * will be copied into the database by the kernel itself, therefore the
     * c_array does not need to be allocated with c_arrayNew, but can be
     * allocated on heap.
     */

    if (dstQos->userData.value) {
        os_free(dstQos->userData.value);
        dstQos->userData.value = NULL;
    }
    dstQos->userData.size = srcQos->user_data.value._length;
    if (dstQos->userData.size) {
        dstQos->userData.value = os_malloc (dstQos->userData.size);
    }
    if ((srcQos->user_data.value._length == 0) || dstQos->userData.value) {
        dstQos->durability.kind = srcQos->durability.kind;
        kernelCopyInDuration(&srcQos->deadline.period, &dstQos->deadline.period);
        kernelCopyInDuration(&srcQos->latency_budget.duration,
                             &dstQos->latency.duration);
        dstQos->liveliness.kind = srcQos->liveliness.kind;
        kernelCopyInDuration(&srcQos->liveliness.lease_duration,
                             &dstQos->liveliness.lease_duration);
        dstQos->reliability.kind = srcQos->reliability.kind;
        kernelCopyInDuration(&srcQos->reliability.max_blocking_time,
                             &dstQos->reliability.max_blocking_time);
        dstQos->reliability.synchronous = srcQos->reliability.synchronous;
        dstQos->orderby.kind = srcQos->destination_order.kind;
        dstQos->history.kind = srcQos->history.kind;
        dstQos->history.depth = srcQos->history.depth;
        dstQos->resource.max_samples = srcQos->resource_limits.max_samples;
        dstQos->resource.max_instances = srcQos->resource_limits.max_instances;
        dstQos->resource.max_samples_per_instance = srcQos->resource_limits.max_samples_per_instance;
        dstQos->ownership.kind = srcQos->ownership.kind;

        if (srcQos->user_data.value._length) {
            memcpy (dstQos->userData.value, srcQos->user_data.value._buffer, srcQos->user_data.value._length);
        }
        kernelCopyInDuration(&srcQos->time_based_filter.minimum_separation,
                             &dstQos->pacing.minSeperation);
        kernelCopyInDuration(&srcQos->reader_data_lifecycle.autopurge_nowriter_samples_delay,
                             &dstQos->lifecycle.autopurge_nowriter_samples_delay);
        kernelCopyInDuration(&srcQos->reader_data_lifecycle.autopurge_disposed_samples_delay,
                             &dstQos->lifecycle.autopurge_disposed_samples_delay);
        dstQos->lifecycle.enable_invalid_samples = srcQos->reader_data_lifecycle.enable_invalid_samples;

        dstQos->lifespan.used = srcQos->reader_lifespan.use_lifespan;
        kernelCopyInDuration(&srcQos->reader_lifespan.duration,
                             &dstQos->lifespan.duration);

        dstQos->share.enable = srcQos->share.enable;
        if ( srcQos->share.enable ) {
            dstQos->share.name = gapi_strdup(srcQos->share.name);
        } else {
            dstQos->share.name = NULL;
        }
        dstQos->userKey.enable = srcQos->subscription_keys.use_key_list;
        if ( srcQos->subscription_keys.use_key_list ) {
            dstQos->userKey.expression = gapi_stringSeq_to_String(&srcQos->subscription_keys.key_list, ",");
        } else {
            dstQos->userKey.expression = NULL;
        }
        copied = TRUE;
    }

    return copied;
}
Exemple #5
0
gapi_returnCode_t
gapi_dataReader_wait_for_historical_data_w_condition (
    gapi_dataReader _this,
    const gapi_char *filter_expression,
    const gapi_stringSeq *filter_parameters,
    const gapi_time_t *min_source_timestamp,
    const gapi_time_t *max_source_timestamp,
    const gapi_resourceLimitsQosPolicy *resource_limits,
    const gapi_duration_t *max_wait)
{
    gapi_returnCode_t result;
    _DataReader datareader;
    c_time  c_time_max_wait,
            c_time_min_source_timestamp,
            c_time_max_source_timestamp;
    u_result  uResult;
    c_ulong length, i;
    c_char** params;
    struct v_resourcePolicy resource;

    datareader = gapi_dataReaderClaim(_this, &result);

    if (datareader) {
        if ( !max_wait || !gapi_validDuration(max_wait)) {
            result = GAPI_RETCODE_BAD_PARAMETER;
        } else if (!_EntityEnabled(datareader)) {
            result = GAPI_RETCODE_NOT_ENABLED;
        } else if(filter_parameters && !gapi_stringSeqValid(filter_parameters)){
            result = GAPI_RETCODE_BAD_PARAMETER;
        } else {
            if(filter_parameters){
                length = filter_parameters->_length;
                params = (c_char**)(os_malloc(length*sizeof(c_char*)));

                for(i=0; i<length; i++){
                    params[i] = filter_parameters->_buffer[i];
                }
            } else {
                params = NULL;
                length = 0;
            }
            kernelCopyInDuration(max_wait, &c_time_max_wait);
            if ( (kernelCopyInTime(min_source_timestamp, &c_time_min_source_timestamp) != GAPI_RETCODE_OK) ||
                 (kernelCopyInTime(max_source_timestamp, &c_time_max_source_timestamp) != GAPI_RETCODE_OK) ) {
                result = GAPI_RETCODE_BAD_PARAMETER;
            } else {
                resource.max_samples = resource_limits->max_samples;
                resource.max_instances = resource_limits->max_instances;
                resource.max_samples_per_instance = resource_limits->max_samples_per_instance;

                uResult= u_dataReaderWaitForHistoricalDataWithCondition(
                        U_DATAREADER_GET(datareader),
                        (c_char*)filter_expression,
                        params,
                        length,
                        c_time_min_source_timestamp,
                        c_time_max_source_timestamp,
                        &resource,
                        c_time_max_wait);

                result = kernelResultToApiResult(uResult);
            }
        }
        _EntityRelease(datareader);
    }
    return result;
}