void cmx_writerDataTypeAction( v_entity entity, c_voidp args) { sd_serializer ser; sd_serializedData data; c_type type; struct cmx_writerTypeArg *arg; arg = (struct cmx_writerTypeArg *)args; type = NULL; switch(v_object(entity)->kind){ case K_WRITER: type = v_topicDataType(v_writer(entity)->topic); break; default: OS_REPORT(OS_ERROR, CM_XML_CONTEXT, 0, "Trying to resolve dataType of writer that is not a writer.\n"); assert(FALSE); break; } if(type != NULL){ ser = sd_serializerXMLMetadataNew(c_getBase(type)); data = sd_serializerSerialize(ser, type); arg->result = sd_serializerToString(ser, data); sd_serializedDataFree(data); sd_serializerFree(ser); } }
/* 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; }
static void jni_writerTypeAction( v_entity entity, c_voidp args) { struct jni_writerTypeArg *arg; arg = (struct jni_writerTypeArg *)args; arg->type = NULL; switch(v_objectKind(entity)){ case K_TOPIC: arg->type = v_topicDataType(entity); break; default: OS_REPORT(OS_ERROR, "dcpsjni", 0, "Trying to resolve dataType of writer that is not a writer.\n"); assert(FALSE); break; } }
os_uint32 u_topicTypeSize( const u_topic _this) { v_topic kt; u_result r; os_uint32 size = 0; assert(_this); r = u_topicReadClaim(_this, &kt, C_MM_RESERVATION_ZERO); if (r == U_RESULT_OK) { assert(kt); size = (os_uint32)c_typeSize(v_topicDataType(kt)); u_topicRelease(_this, C_MM_RESERVATION_ZERO); } else { OS_REPORT(OS_WARNING, "u_topicTypeSize", r, "Could not claim topic."); } return size; }
void cmx_writerUnregisterCopy( v_entity entity, c_voidp args) { v_writer kw; v_message message; void *to; sd_serializer ser; sd_serializedData data; sd_validationResult valResult; struct cmx_writerArg *arg; arg = (struct cmx_writerArg *)args; kw = v_writer(entity); message = v_topicMessageNew(kw->topic); to = C_DISPLACE(message,v_topicDataOffset(kw->topic)); ser = sd_serializerXMLNewTyped(v_topicDataType(kw->topic)); data = sd_serializerFromString(ser, arg->result); sd_serializerDeserializeIntoValidated(ser, data, to); valResult = sd_serializerLastValidationResult(ser); if(valResult != SD_VAL_SUCCESS){ OS_REPORT_2(OS_ERROR, CM_XML_CONTEXT, 0, "Unregister of userdata failed.\nReason: %s\nError: %s\n", sd_serializerLastValidationMessage(ser), sd_serializerLastValidationLocation(ser)); arg->success = CMX_RESULT_FAILED; } else { arg->success = CMX_RESULT_OK; } sd_serializedDataFree(data); sd_serializerFree(ser); /* Note that the last param of v_writerWriteDispose is NULL, performance can be improved if the instance is provided. */ v_writerUnregister(kw,message,v_timeGet(),NULL); c_free(message); }
c_char * u_topicTypeName( u_topic t) { v_topic kt; u_result r; c_char *name; r = u_entityReadClaim(u_entity(t),(v_entity*)(&kt)); if (r == U_RESULT_OK) { assert(kt); name = (c_char *)c_metaScopedName(c_metaObject(v_topicDataType(kt))); u_entityRelease(u_entity(t)); } else { OS_REPORT(OS_WARNING, "u_topicTypeName", 0, "Could not claim topic."); name = NULL; } return name; }
os_char * u_topicTypeName( const u_topic _this) { v_topic kt; u_result r; os_char *name; assert(_this); r = u_topicReadClaim(_this, &kt, C_MM_RESERVATION_ZERO); if (r == U_RESULT_OK) { assert(kt); name = (c_char *)c_metaScopedName(c_metaObject(v_topicDataType(kt))); u_topicRelease(_this, C_MM_RESERVATION_ZERO); } else { OS_REPORT(OS_WARNING, "u_topicTypeName", r, "Could not claim topic."); name = NULL; } return name; }
void cmx_readerDataTypeAction( v_entity entity, c_voidp args) { sd_serializer ser; sd_serializedData data; c_type type; v_dataReader r; v_query query; v_topic topic; struct cmx_readerArg *arg; arg = (struct cmx_readerArg *)args; type = NULL; switch(v_object(entity)->kind){ case K_DATAREADER: r = v_dataReader(entity); v_observerLock(v_observer(r)); topic = v_dataReaderGetTopic(r); type = v_topicDataType(topic); c_free(topic); v_observerUnlock(v_observer(r)); break; case K_DATAREADERQUERY: query = v_query(entity); r = v_dataReader(v_querySource(query)); v_observerLock(v_observer(r)); topic = v_dataReaderGetTopic(r); type = v_topicDataType(topic); c_free(topic); v_observerUnlock(v_observer(r)); c_free(r); break; case K_NETWORKREADER: OS_REPORT(OS_ERROR, CM_XML_CONTEXT, 0, "Resolving data type of networkReader unsupported.\n"); assert(FALSE); break; case K_GROUPQUEUE: OS_REPORT(OS_ERROR, CM_XML_CONTEXT, 0, "Resolving data type of groupQueue unsupported.\n"); assert(FALSE); break; default: OS_REPORT(OS_ERROR, CM_XML_CONTEXT, 0, "Trying to resolve dataType of unknown reader type.\n"); assert(FALSE); break; } if(type != NULL){ ser = sd_serializerXMLMetadataNew(c_getBase(type)); data = sd_serializerSerialize(ser, type); arg->result = sd_serializerToString(ser, data); sd_serializedDataFree(data); sd_serializerFree(ser); } }
d_topicInfo d_topicInfoNew( d_storeMMFKernel kernel, const v_topic vtopic) { d_topicInfo topic; c_base base, ddsBase; c_type type, srcDataType; c_string name; if(kernel && vtopic){ base = c_getBase(kernel); ddsBase = c_getBase(vtopic); type = c_resolve(base,"durabilityModule2::d_topicInfo"); if(type){ topic = c_new(type); c_free(type); if(topic){ topic->name = c_stringNew(base, v_entity(vtopic)->name); srcDataType = v_topicDataType(vtopic); name = c_metaScopedName(c_metaObject(srcDataType)); topic->typeName = c_stringNew(base, name); assert(topic->typeName); os_free(name); topic->dataType = cloneType(ddsBase, base, srcDataType); assert(topic->dataType); topic->keyExpr = c_stringNew(base, vtopic->keyExpr); assert(topic->keyExpr); topic->messageType = messageTypeNew(base, topic->typeName); assert(topic->messageType); topic->keyType = createTopicKeyType(topic->messageType, topic->keyExpr); assert(topic->keyType); topic->instanceKeyExpr = createInstanceKeyExpr(base, vtopic); topic->sampleType = createSampleType( topic->messageType, topic->name); assert(topic->sampleType); topic->instanceType = createInstanceType( topic->messageType, topic); assert(topic->instanceType); topic->qos = cloneObject(ddsBase, base, vtopic->qos); assert(topic->qos); } } else { OS_REPORT(OS_ERROR, "d_topicInfoNew",0, "Failed to allocate d_topicInfo."); topic = NULL; } } else { OS_REPORT(OS_ERROR, "d_topicInfoNew",0, "Illegal constructor parameter."); topic = NULL; } return topic; }