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; }
v_index v__indexNew( v_dataReader reader, q_expr _from, c_iter indexList, v_indexNewAction action, c_voidp arg) { v_kernel kernel; v_index index; v_topic topic; c_type instanceType; c_iter list; c_char *keyExpr; c_array keyList; c_ulong nrOfTopics; assert(C_TYPECHECK(reader,v_dataReader)); kernel = v_objectKernel(reader); if (q_isId(_from)) { list = v_resolveTopics(kernel,q_getId(_from)); nrOfTopics = c_iterLength(list); if (nrOfTopics == 0) { OS_REPORT(OS_ERROR, "v__indexNew", V_RESULT_ILL_PARAM, "Unknown topic %s", q_getId(_from)); c_iterFree(list); return NULL; } if (nrOfTopics > 1) { OS_REPORT(OS_ERROR, "v__indexNew", V_RESULT_ILL_PARAM, "Multiple topic definitions of: %s", q_getId(_from)); topic = v_topic(c_iterTakeFirst(list)); while (topic != NULL) { c_free(topic); topic = v_topic(c_iterTakeFirst(list)); } c_iterFree(list); return NULL; } topic = c_iterTakeFirst(list); c_iterFree(list); index = v_index(c_iterReadAction(indexList, indexCompare, topic)); if (index == NULL) { /* If the userKey is enabled then the instance type key field type * will be determined from the user key expression and topic. * Otherwise when no user key is specified the default Topic key * type will be used. */ if (v_reader(reader)->qos->userKey.v.enable) { keyExpr = v_reader(reader)->qos->userKey.v.expression; } else { keyExpr = NULL; } instanceType = createInstanceType(topic,keyExpr,&keyList); if (instanceType) { index = v_index(v_objectNew(kernel,K_INDEX)); v_indexInit(index, instanceType, keyList, v_reader(reader)); } c_free(keyList); c_free(instanceType); if (index != NULL) { if (action != NULL && !action(index, topic, arg)) { OS_REPORT(OS_ERROR, "v_indexNew", V_RESULT_INTERNAL_ERROR, "v_indexNewAction failed!"); c_free(index); index = NULL; } else { (void)c_iterAppend(indexList, index); } } } } else { OS_REPORT(OS_ERROR, "v_indexNew failed",V_RESULT_ILL_PARAM, "illegal from clause specified"); assert(FALSE); index = NULL; } return index; }