All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.joynr.generator.cpp.provider.InterfaceProviderCppTemplate Maven / Gradle / Ivy

package io.joynr.generator.cpp.provider;

import com.google.inject.Inject;
import io.joynr.generator.cpp.util.CppStdTypeUtil;
import io.joynr.generator.cpp.util.JoynrCppGeneratorExtensions;
import io.joynr.generator.cpp.util.TemplateBase;
import io.joynr.generator.templates.InterfaceTemplate;
import io.joynr.generator.templates.util.InterfaceUtil;
import io.joynr.generator.templates.util.NamingUtil;
import java.util.Set;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Extension;

@SuppressWarnings("all")
public class InterfaceProviderCppTemplate extends InterfaceTemplate {
  @Inject
  @Extension
  private TemplateBase _templateBase;

  @Inject
  @Extension
  private CppStdTypeUtil _cppStdTypeUtil;

  @Inject
  @Extension
  private JoynrCppGeneratorExtensions _joynrCppGeneratorExtensions;

  @Inject
  @Extension
  private NamingUtil _namingUtil;

  @Override
  public CharSequence generate(final boolean generateVersion) {
    CharSequence _xblockexpression = null;
    {
      InterfaceUtil.TypeSelector selector = InterfaceUtil.TypeSelector.defaultTypeSelector();
      selector.transitiveTypes(true);
      StringConcatenation _builder = new StringConcatenation();
      CharSequence _warning = this._templateBase.warning();
      _builder.append(_warning);
      _builder.newLineIfNotEmpty();
      final String interfaceName = this._namingUtil.joynrName(this.francaIntf);
      _builder.newLineIfNotEmpty();
      _builder.append("#include \"");
      String _packagePathWithJoynrPrefix = this._joynrCppGeneratorExtensions.getPackagePathWithJoynrPrefix(this.francaIntf, "/", generateVersion);
      _builder.append(_packagePathWithJoynrPrefix);
      _builder.append("/");
      _builder.append(interfaceName);
      _builder.append("Provider.h\"");
      _builder.newLineIfNotEmpty();
      _builder.append("#include \"joynr/InterfaceRegistrar.h\"");
      _builder.newLine();
      _builder.newLine();
      _builder.append("#include \"");
      String _packagePathWithJoynrPrefix_1 = this._joynrCppGeneratorExtensions.getPackagePathWithJoynrPrefix(this.francaIntf, "/", generateVersion);
      _builder.append(_packagePathWithJoynrPrefix_1);
      _builder.append("/");
      _builder.append(interfaceName);
      _builder.append("RequestInterpreter.h\"");
      _builder.newLineIfNotEmpty();
      {
        Set _dataTypeIncludesFor = this._cppStdTypeUtil.getDataTypeIncludesFor(this.francaIntf, generateVersion);
        for(final String parameterType : _dataTypeIncludesFor) {
          _builder.append("#include ");
          _builder.append(parameterType);
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.newLine();
      String _namespaceStarter = this._joynrCppGeneratorExtensions.getNamespaceStarter(this.francaIntf, generateVersion);
      _builder.append(_namespaceStarter);
      _builder.newLineIfNotEmpty();
      _builder.append(interfaceName);
      _builder.append("Provider::");
      _builder.append(interfaceName);
      _builder.append("Provider()");
      _builder.newLineIfNotEmpty();
      _builder.append("{");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("// Register a request interpreter to interpret requests to this interface");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("joynr::InterfaceRegistrar::instance().registerRequestInterpreter<");
      _builder.append(interfaceName, "\t");
      _builder.append("RequestInterpreter>(INTERFACE_NAME() + std::to_string(MAJOR_VERSION));");
      _builder.newLineIfNotEmpty();
      _builder.append("}");
      _builder.newLine();
      _builder.newLine();
      _builder.append(interfaceName);
      _builder.append("Provider::~");
      _builder.append(interfaceName);
      _builder.append("Provider()");
      _builder.newLineIfNotEmpty();
      _builder.append("{");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("// Unregister the request interpreter");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("joynr::InterfaceRegistrar::instance().unregisterRequestInterpreter(");
      _builder.newLine();
      _builder.append("\t\t\t");
      _builder.append("INTERFACE_NAME() + std::to_string(MAJOR_VERSION)");
      _builder.newLine();
      _builder.append("\t");
      _builder.append(");");
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      _builder.newLine();
      _builder.append("const std::string& ");
      _builder.append(interfaceName);
      _builder.append("Provider::INTERFACE_NAME()");
      _builder.newLineIfNotEmpty();
      _builder.append("{");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("static const std::string INTERFACE_NAME(\"");
      String _fullyQualifiedName = this._joynrCppGeneratorExtensions.getFullyQualifiedName(this.francaIntf);
      _builder.append(_fullyQualifiedName, "\t");
      _builder.append("\");");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("return INTERFACE_NAME;");
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      _builder.newLine();
      _builder.append("const std::int32_t ");
      _builder.append(interfaceName);
      _builder.append("Provider::MAJOR_VERSION = ");
      _builder.append(this.majorVersion);
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.append("const std::int32_t ");
      _builder.append(interfaceName);
      _builder.append("Provider::MINOR_VERSION = ");
      _builder.append(this.minorVersion);
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      String _namespaceEnder = this._joynrCppGeneratorExtensions.getNamespaceEnder(this.francaIntf, generateVersion);
      _builder.append(_namespaceEnder);
      _builder.newLineIfNotEmpty();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy