Ejemplo n.º 1
0
u_bool
u_topicContentFilterValidate2 (
    const u_topic _this,
    const q_expr expr,
    const c_value params[],
    os_uint32 nrOfParams)
{
    v_topic topic;
    u_bool result;
    v_filter filter;
    u_result uResult;

    assert(_this);
    assert(expr);

    result = FALSE;
    filter = NULL;
    uResult = u_topicReadClaim(_this, &topic, C_MM_RESERVATION_LOW);
    if (uResult == U_RESULT_OK) {
        assert(topic);
        filter = v_filterNew(v_topicMessageType(topic), v_topicMessageKeyList(topic), expr, params, nrOfParams);
        u_topicRelease(_this, C_MM_RESERVATION_LOW);
    }
    if (filter != NULL) {
        result = TRUE;
        c_free(filter);
    }
    return result;
}
Ejemplo n.º 2
0
c_bool
u_topicContentFilterValidate (
    u_topic _this,
    q_expr expr,
    c_value params[])
{
    v_topic topic;
    c_type type;
    c_bool result;
    q_expr subexpr, term;
    int i;
    v_filter filter;
    u_result uResult;

    result = FALSE;
    filter = NULL;
    uResult = u_entityReadClaim(u_entity(_this), (v_entity*)(&topic));
    if (uResult == U_RESULT_OK) {
        assert(topic);
        type = v_topicMessageType(topic);
        i = 0;
        subexpr = q_getPar(expr, i); /* get rid of Q_EXPR_PROGRAM */
        while ((term = q_getPar(subexpr, i++)) != NULL) {
            if (q_getTag(term) == Q_EXPR_WHERE) {
                filter = v_filterNew(topic, term, params);
            }
        }
        u_entityRelease(u_entity(_this));
    }
    if (filter != NULL) {
        result = TRUE;
        c_free(filter);
    }
    return result;
}
Ejemplo n.º 3
0
/* may return null */
in_result
in_messageDeserializerRead(
    in_messageDeserializer _this,
    v_topic topic,
    os_boolean isBigEndian,
    v_message* object)
{
    in_result result = IN_RESULT_OK;
    in_messageTransformer transformer = in_messageTransformer(_this);
    c_object displacedMessage;
    c_type messageType;

    assert(_this);
    assert(in_messageDeserializerIsValid(_this));
    assert(object);
    assert(topic);

    if (topic)
    {
        /* work around, replace cdrLength in transformer by ->length */
        in_messageTransformerSetCdrLength(transformer, (os_ushort) (transformer->length));
        if (_requiresSwap(isBigEndian)) {
            in_messageTransformerSetCopyKind(transformer, IN_MESSAGE_TRANSFORMER_CM_KIND_SWAP);
        } else {
            in_messageTransformerSetCopyKind(transformer, IN_MESSAGE_TRANSFORMER_CM_KIND_COPY);
        }
        messageType = v_topicMessageType(topic);

        if (c_typeIsRef(messageType))
        {
            *object = v_topicMessageNew(topic);

            if(*object == NULL)
            {
                result = IN_RESULT_OUT_OF_MEMORY;
            } else
            {
                displacedMessage = v_topicData(topic, *object);
                in_messageDeserializerReadType(_this, v_topicDataType(topic),
                    displacedMessage);
            }
        } else
        {
            assert(FALSE);
            result = IN_RESULT_ERROR;
            *object = NULL;
        }
    } else
    {
        *object = NULL;
    }
    return result;
}
Ejemplo n.º 4
0
static c_type
onTypeLookup(
    v_networkHashValue hashValue,
    const c_char *partitionName,
    const c_char *topicName,
    nw_typeLookupArg arg)
{
    c_type result = NULL;
    nw_lookupArg lookupArg = (nw_lookupArg)arg;
    nw_receiveChannel receiveChannel = lookupArg->receiveChannel;
    v_networkReaderEntry entry;

    NW_CONFIDENCE(receiveChannel != NULL);

#ifdef NW_LOOPBACK
    if (nw_configurationUseComplementPartitions()) {
        entry = nw_entryHashLookupByNamesOnly(receiveChannel->hash,
                                              partitionName, topicName);
    } else {
        entry = nw_entryHashLookup(receiveChannel->hash, hashValue,
                                   partitionName, topicName);
    }
#else
    entry = nw_entryHashLookup(receiveChannel->hash, hashValue,
                               partitionName, topicName);
#endif
    if ((entry == NULL) && (lookupArg->entryLookupAction != NULL)) {
        entry = lookupArg->entryLookupAction(hashValue, partitionName,
            topicName, lookupArg->entryLookupArg);
    }
    lookupArg->entryFound = entry;

    if (entry != NULL) {
        result = v_topicMessageType(v_group(entry->group)->topic);
    }

    return result;
}
Ejemplo n.º 5
0
u_bool
u_topicContentFilterValidate (
    const u_topic _this,
    const q_expr expr,
    const c_value params[],
    os_uint32 nrOfParams)
{
    v_topic topic;
    u_bool result;
    q_expr subexpr, term;
    int i;
    v_filter filter;
    u_result uResult;

    assert(_this);
    assert(expr);

    result = FALSE;
    filter = NULL;
    uResult = u_topicReadClaim(_this, &topic, C_MM_RESERVATION_LOW);
    if (uResult == U_RESULT_OK) {
        assert(topic);
        i = 0;
        subexpr = q_getPar(expr, i); /* get rid of Q_EXPR_PROGRAM */
        while ((term = q_getPar(subexpr, i++)) != NULL) {
            if (q_getTag(term) == Q_EXPR_WHERE) {
                filter = v_filterNew(v_topicMessageType(topic), v_topicMessageKeyList(topic), term, params, nrOfParams);
            }
        }
        u_topicRelease(_this, C_MM_RESERVATION_LOW);
    }
    if (filter != NULL) {
        result = TRUE;
        c_free(filter);
    }
    return result;
}
Ejemplo n.º 6
0
static c_type
sampleTypeNew(
    v_topic topic)
{
    c_metaObject o;
    c_type msgType,sampleType,foundType;
    c_base base;
    c_char *name;
    os_size_t length;
    int sres;

    assert(C_TYPECHECK(topic,v_topic));
    assert(topic);

    name = NULL;
    foundType = NULL;

    if (v_topicName(topic) == NULL) {
        OS_REPORT(OS_ERROR,
                  "v_index::sampleTypeNew failed",V_RESULT_ILL_PARAM,
                  "failed to retreive topic name");
        return NULL;
    }

    base = c_getBase(topic);

    if (base == NULL) {
        OS_REPORT(OS_ERROR,
                  "v_index::sampleTypeNew failed",V_RESULT_ILL_PARAM,
                  "failed to retreive base");
        return NULL;
    }

    msgType = c_keep(v_topicMessageType(topic));

    if (msgType == NULL) {
        OS_REPORT(OS_ERROR,
                  "v_index::sampleTypeNew failed",V_RESULT_ILL_PARAM,
                  "failed to retreive topic message type");
        return NULL;
    }

    sampleType = c_type(c_metaDefine(c_metaObject(base),M_CLASS));
    if (sampleType) {
        c_class(sampleType)->extends = v_dataReaderSample_t(base);
        o = c_metaDeclare(c_metaObject(sampleType),"message",M_ATTRIBUTE);
        if (o) {
            c_property(o)->type = c_keep(msgType);
            c_metaObject(sampleType)->definedIn = c_keep(base);
            c_metaFinalize(c_metaObject(sampleType));

#define SAMPLE_FORMAT "v_indexSample<%s>"
#define SAMPLE_NAME   "v_indexSample<>"
            /* sizeof contains \0 */
            length = sizeof(SAMPLE_NAME) + strlen(v_topicName(topic));
            name = os_malloc(length);
            sres = snprintf(name,length,SAMPLE_FORMAT,v_topicName(topic));
            assert(sres >= 0 && (os_size_t) sres == (length-1));
            OS_UNUSED_ARG(sres);
#undef SAMPLE_FORMAT
#undef SAMPLE_NAME

            foundType = c_type(c_metaBind(c_metaObject(base),
                                          name,
                                          c_metaObject(sampleType)));
            c_free(o);
        } else {
            foundType = NULL;
        }
        c_free(sampleType);
    } else {
        OS_REPORT(OS_ERROR,
                  "v_index::sampleTypeNew failed",V_RESULT_ILL_PARAM,
                  "failed to retreive topic sample type");
    }
    os_free(name);
    c_free(msgType);

    return foundType;
}
Ejemplo n.º 7
0
static in_result
in_ddsiStreamReaderImplProcessAppdefDataPayloadNoData(
    in_ddsiStreamReaderImpl _this,
    in_ddsiSubmessageData submessage,
    in_connectivityPeerWriter peerWriter,
    v_message *messageObject)
{
	v_topic topic;
	in_result result;
	c_type messageType;
	c_octet* keyHash;

	assert(peerWriter);
	assert(messageObject);
	assert(submessage);

	*messageObject = NULL;
	topic = lookupTopic(_this, peerWriter);

	if(topic)
	{
		messageType = v_topicMessageType(topic);

		if (c_typeIsRef(messageType))
		{
			*messageObject = v_topicMessageNew(topic);

			if(*messageObject)
			{
				(*messageObject)->sequenceNumber = (submessage->writerSN.low);
				(*messageObject)->writerGID = in_connectivityPeerWriterGetGid(
					peerWriter);
				(*messageObject)->allocTime = _this->receiver.haveTimestamp ?
					_this->receiver.timestamp : C_TIME_ZERO;
				(*messageObject)->writeTime = _this->receiver.haveTimestamp ?
					_this->receiver.timestamp : C_TIME_ZERO;

				/* WriterInstanceGID unused in kernel, so not necessary to fill it*/
				(*messageObject)->writerInstanceGID.systemId =
					(*messageObject)->writerGID.systemId;
				(*messageObject)->writerInstanceGID.localId = 0;
				(*messageObject)->writerInstanceGID.serial = 0;
				(*messageObject)->qos = in_messageQos_new(peerWriter,
					c_getBase(topic));

				result = in_ddsiParameterListGetPidKeyHash(
					&(submessage->inlineQos), &keyHash);

				if(result == IN_RESULT_OK)
				{
					result = in_ddsiStreamReaderImplDerializePayloadByKeyHash(
						_this, submessage, peerWriter, topic, messageObject,
						keyHash);
					os_free(keyHash);

					if(result == IN_RESULT_OK)
					{
						result = in_ddsiParameterListGetPidStatusInfo(
										&(submessage->inlineQos),
										&(v_messageState(*messageObject)));
					} else
					{
                        IN_REPORT_WARNING(IN_SPOT, "Unable to copy key values in message.");
					}
				} else
				{
                    IN_REPORT_WARNING(IN_SPOT, "Found DATA submessage without serializedPayload and no PID_KEY_HASH inlineQos.");
					result = IN_RESULT_ERROR;
				}


			} else
			{
				result = IN_RESULT_OUT_OF_MEMORY;
			}
		} else
		{
			result = IN_RESULT_ERROR;
		}
		c_free(topic);
	} else
	{
		result = IN_RESULT_ERROR;
	}
	return result;
}