in code/4diac-integration/src/main/kotlin/org/fbme/ide/integration/fordiac/translator/cpp/basic/BasicFBTypeHeaderTranslator.kt [13:79]
override fun translate(): String {
sb.appendLine(this.constructIncludeGuardStart())
.appendLine(this.constructHeaderIncludes())
.appendLine(this.constructFBClassHeader())
.append(" ")
.appendLine(this.constructFBDeclaration())
.appendLine("private:")
.appendLine(this.constructFBInterfaceDeclaration(indent = " "))
.append(" ")
.appendLine(this.constructFBInterfaceSpecDeclaration())
addInternalVarDelcaration()
if (fb.inputParameters.isNotEmpty() || fb.outputParameters.isNotEmpty()) {
addInitialValueAssignmentDeclaration()
}
sb.appendLine(this.constructAccessors(parameters = fb.inputParameters, functionName = "getDI", indent = " "))
.appendLine(
this.constructAccessors(
parameters = fb.outputParameters,
functionName = "getDO",
indent = " "
)
)
.appendLine(
this.constructAccessors(
parameters = fb.internalVariables,
functionName = "getVarInternal",
indent = " "
)
)
sb.append(constructAccessors(type().sockets + type().plugs, indent = " "))
addAlgorithms(indent = " ")
addStates(indent = " ")
sb.appendLine(" virtual void executeEvent(int pa_nEIID);")
addBasicFBDataArray(indent = " ")
sb.appendLine("public:")
.append(" ")
.append(this.constructFBClassName())
.appendLine("(CStringDictionary::TStringId pa_nInstanceNameId, CResource *pa_poSrcRes) :")
.append(" ")
.append(baseClass)
.append("(pa_poSrcRes, &scm_stFBInterfaceSpec, pa_nInstanceNameId, ")
.append(
if (fb.internalVariables.isNotEmpty()) {
"&scm_stInternalVars"
} else {
"nullptr"
}
)
.appendLine(", m_anFBConnData, m_anFBVarsData) {")
.appendLine(" };")
.append(" virtual ~")
.append(this.constructFBClassName())
.appendLine("() = default;")
.appendLine("};")
.appendLine(this.constructIncludeGuardEnd())
val res = sb.toString()
sb.clear()
return res
}