d_storeResult d_topicInfoInject( d_topicInfo _this, d_store store, u_participant participant) { d_storeResult result; c_type type; struct baseFind f; u_topic utopic; u_entityAction(u_entity(participant), d_storeGetBase, &f); type = cloneType(c_getBase(_this), f.base, _this->dataType); if(type){ utopic = u_topicNew(participant, _this->name, _this->typeName, _this->keyExpr, _this->qos); if(utopic) { d_storeReport(store, D_LEVEL_FINE, "Topic %s created.\n", _this->name); u_topicFree(utopic); result = D_STORE_RESULT_OK; } else { result = D_STORE_RESULT_METADATA_MISMATCH; d_storeReport(store, D_LEVEL_SEVERE, "Topic '%s' with typeName '%s' and keyList '%s' could NOT be created.\n", _this->name, _this->typeName, _this->keyExpr); OS_REPORT_3(OS_ERROR, "d_topicInfoInject", (os_int32)result, "Topic '%s' with typeName '%s' and keyList '%s' could NOT be created.\n", _this->name, _this->typeName, _this->keyExpr); } } else { result = D_STORE_RESULT_METADATA_MISMATCH; OS_REPORT_1(OS_ERROR, "d_topicInfoInject",(os_int32)result, "Failed to register type '%s'.", _this->typeName); } return result; }
d_storeResult d_groupInfoInject( d_groupInfo _this, const d_store store, u_participant participant, d_group* group) { d_storeResult result; u_group ugroup; u_partition upartition; v_partitionQos partitionQos; v_duration timeout; c_string name; if(_this && store && participant){ result = d_topicInfoInject(_this->topic, store, participant); if(result == D_STORE_RESULT_OK){ partitionQos = u_partitionQosNew(NULL); if(partitionQos) { d_storeReport(store, D_LEVEL_FINE, "PartitionQoS created.\n"); upartition = u_partitionNew(participant, _this->partition, partitionQos); if(upartition) { name = d_topicInfoGetName(_this->topic); d_storeReport(store, D_LEVEL_FINE, "Partition %s created.\n", _this->partition); timeout.seconds = 0; timeout.nanoseconds = 0; ugroup = u_groupNew(participant, _this->partition, name, timeout); if(ugroup) { d_storeReport(store, D_LEVEL_INFO, "Group %s.%s created.\n", _this->partition, name); *group = d_groupNew(_this->partition, name, D_DURABILITY_PERSISTENT, _this->completeness, _this->quality); u_entityAction(u_entity(ugroup), setKernelGroup, *group); u_entityFree(u_entity(ugroup)); result = D_STORE_RESULT_OK; } else { result = D_STORE_RESULT_OUT_OF_RESOURCES; d_storeReport(store, D_LEVEL_SEVERE, "Group %s.%s could NOT be created.\n", _this->partition, name); OS_REPORT_2(OS_ERROR, "d_groupInfoInject", (os_int32)result, "Group %s.%s could NOT be created.\n", _this->partition, name); } c_free(name); u_partitionFree(upartition); } else { result = D_STORE_RESULT_OUT_OF_RESOURCES; d_storeReport(store, D_LEVEL_SEVERE, "Partition %s could NOT be created.\n", _this->partition); OS_REPORT_1(OS_ERROR, "d_groupInfoInject", (os_int32)result, "Partition %s could NOT be created.\n", _this->partition); } u_partitionQosFree(partitionQos); } else { result = D_STORE_RESULT_OUT_OF_RESOURCES; d_storeReport(store, D_LEVEL_SEVERE, "PartitionQos could NOT be created.\n"); OS_REPORT(OS_ERROR, "d_groupInfoInject", (os_int32)result, "PartitionQos could NOT be created.\n"); } } } else { result = D_STORE_RESULT_ILL_PARAM; } return result; }