protected fun constructFBInterfaceDeclaration()

in code/4diac-integration/src/main/kotlin/org/fbme/ide/integration/fordiac/translator/cpp/AbstractTranslator.kt [186:229]


    protected fun constructFBInterfaceDeclaration(indent: String): String {
        val sb = StringBuilder()
        val hasInputVars = this.type().inputParameters.isNotEmpty()

        if (hasInputVars) {
            sb.append(indent)
                .appendLine("static const CStringDictionary::TStringId scm_anDataInputNames[];")
                .append(indent)
                .appendLine("static const CStringDictionary::TStringId scm_anDataInputTypeIds[];")
        }

        val hasOutputVars = this.type().outputParameters.isNotEmpty()

        if (hasOutputVars) {
            sb.append(indent)
                .appendLine("static const CStringDictionary::TStringId scm_anDataOutputNames[];")
                .append(indent)
                .appendLine("static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];")
        }

        sb.appendLine(this.constructFBEventInputInterfaceDecl(indent))
            .appendLine(this.constructFBEventOutputInterfaceDecl(indent))

        this.type().templateTypeDescriptor.socketPorts.forEachIndexed { index, socketPort ->
            sb.append(indent)
                .appendLine("static const int scm_n${socketPort.name}AdpNum = $index;")
        }

        val socketPortAmount = this.type().templateTypeDescriptor.socketPorts.size

        this.type().templateTypeDescriptor.plugPorts.forEachIndexed { index, plugPort ->
            sb.append(indent)
                .appendLine("static const int scm_n${plugPort.name}AdpNum = ${index + socketPortAmount};")
        }

        val plugPortAmount = this.type().templateTypeDescriptor.plugPorts.size

        if (socketPortAmount != 0 || plugPortAmount != 0) {
            sb.append(indent)
                .appendLine("static const SAdapterInstanceDef scm_astAdapterInstances[];")
        }

        return sb.toString()
    }