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

io.joynr.generator.cpp.proxy.InterfaceAsyncProxyHTemplate Maven / Gradle / Ivy

There is a newer version: 1.25.0
Show newest version
package io.joynr.generator.cpp.proxy;

import com.google.inject.Inject;
import io.joynr.generator.cpp.util.CppInterfaceUtil;
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.NamingUtil;
import java.util.Set;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Extension;

@SuppressWarnings("all")
public class InterfaceAsyncProxyHTemplate extends InterfaceTemplate {
  @Inject
  @Extension
  private JoynrCppGeneratorExtensions _joynrCppGeneratorExtensions;

  @Inject
  @Extension
  private TemplateBase _templateBase;

  @Inject
  @Extension
  private CppStdTypeUtil _cppStdTypeUtil;

  @Inject
  @Extension
  private CppInterfaceUtil _cppInterfaceUtil;

  @Inject
  @Extension
  private NamingUtil _namingUtil;

  @Override
  public CharSequence generate(final boolean generateVersion) {
    StringConcatenation _builder = new StringConcatenation();
    final String interfaceName = this._namingUtil.joynrName(this.francaIntf);
    _builder.newLineIfNotEmpty();
    final String className = (interfaceName + "Proxy");
    _builder.newLineIfNotEmpty();
    final String asyncClassName = (interfaceName + "AsyncProxy");
    _builder.newLineIfNotEmpty();
    String _packagePathWithJoynrPrefix = this._joynrCppGeneratorExtensions.getPackagePathWithJoynrPrefix(this.francaIntf, "_", generateVersion);
    String _plus = ("GENERATED_INTERFACE_" + _packagePathWithJoynrPrefix);
    String _plus_1 = (_plus + 
      "_");
    String _plus_2 = (_plus_1 + interfaceName);
    final String headerGuard = (_plus_2 + "AsyncProxy_h").toUpperCase();
    _builder.newLineIfNotEmpty();
    CharSequence _warning = this._templateBase.warning();
    _builder.append(_warning);
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("#ifndef ");
    _builder.append(headerGuard);
    _builder.newLineIfNotEmpty();
    _builder.append("#define ");
    _builder.append(headerGuard);
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("#include \"joynr/PrivateCopyAssign.h\"");
    _builder.newLine();
    _builder.append("#include \"");
    String _packagePathWithJoynrPrefix_1 = this._joynrCppGeneratorExtensions.getPackagePathWithJoynrPrefix(this.francaIntf, "/", generateVersion);
    _builder.append(_packagePathWithJoynrPrefix_1);
    _builder.append("/");
    _builder.append(className);
    _builder.append("Base.h\"");
    _builder.newLineIfNotEmpty();
    {
      boolean _hasFireAndForgetMethods = this._cppInterfaceUtil.hasFireAndForgetMethods(this.francaIntf);
      if (_hasFireAndForgetMethods) {
        _builder.append("#include \"");
        String _packagePathWithJoynrPrefix_2 = this._joynrCppGeneratorExtensions.getPackagePathWithJoynrPrefix(this.francaIntf, "/", generateVersion);
        _builder.append(_packagePathWithJoynrPrefix_2);
        _builder.append("/");
        _builder.append(interfaceName);
        _builder.append("FireAndForgetProxy.h\"");
        _builder.newLineIfNotEmpty();
      }
    }
    _builder.newLine();
    _builder.append("namespace joynr");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("template  class Future;");
    _builder.newLine();
    _builder.newLine();
    _builder.append("namespace exceptions");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("class JoynrException;");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("class JoynrRuntimeException;");
    _builder.newLine();
    _builder.append("} // namespace exceptions");
    _builder.newLine();
    _builder.append("} // namespace joynr");
    _builder.newLine();
    _builder.newLine();
    {
      Set _addElements = this._cppStdTypeUtil.addElements(this._cppStdTypeUtil.getDataTypeIncludesFor(this.francaIntf, generateVersion), this._cppStdTypeUtil.getIncludeForString());
      for(final String parameterType : _addElements) {
        _builder.append("#include ");
        _builder.append(parameterType);
        _builder.newLineIfNotEmpty();
      }
    }
    _builder.newLine();
    _builder.append("#include ");
    _builder.newLine();
    _builder.newLine();
    String _namespaceStarter = this._joynrCppGeneratorExtensions.getNamespaceStarter(this.francaIntf, generateVersion);
    _builder.append(_namespaceStarter);
    _builder.newLineIfNotEmpty();
    _builder.append("/** @brief proxy class for asynchronous calls of interface ");
    _builder.append(interfaceName);
    _builder.newLineIfNotEmpty();
    _builder.append(" ");
    _builder.append("*");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* @version ");
    _builder.append(this.majorVersion, " ");
    _builder.append(".");
    _builder.append(this.minorVersion, " ");
    _builder.newLineIfNotEmpty();
    _builder.append(" ");
    _builder.append("*/");
    _builder.newLine();
    _builder.append("class ");
    _builder.append(asyncClassName);
    _builder.append(" :");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t");
    _builder.append("virtual public ");
    _builder.append(className, "\t\t");
    _builder.append("Base,");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t");
    _builder.append("virtual public I");
    _builder.append(interfaceName, "\t\t");
    _builder.append("Async");
    {
      boolean _hasFireAndForgetMethods_1 = this._cppInterfaceUtil.hasFireAndForgetMethods(this.francaIntf);
      if (_hasFireAndForgetMethods_1) {
        _builder.append(",");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t");
        _builder.append("virtual public ");
        _builder.append(interfaceName, "\t\t");
        _builder.append("FireAndForgetProxy");
      }
    }
    _builder.newLineIfNotEmpty();
    _builder.append("{");
    _builder.newLine();
    _builder.append("public:");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("/**");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* @brief Parameterized constructor");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* @param connectorFactory The connector factory");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* @param domain The provider domain");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* @param qosSettings The quality of service settings");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("*/");
    _builder.newLine();
    _builder.append("\t");
    _builder.append(asyncClassName, "\t");
    _builder.append("(");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t\t");
    _builder.append("std::weak_ptr runtime,");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("std::shared_ptr connectorFactory,");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("const std::string& domain,");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("const joynr::MessagingQos& qosSettings");
    _builder.newLine();
    _builder.append("\t");
    _builder.append(");");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    CharSequence _produceAsyncGetterDeclarations = this._cppInterfaceUtil.produceAsyncGetterDeclarations(this.francaIntf, false, generateVersion);
    _builder.append(_produceAsyncGetterDeclarations, "\t");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    CharSequence _produceAsyncSetterDeclarations = this._cppInterfaceUtil.produceAsyncSetterDeclarations(this.francaIntf, false, generateVersion);
    _builder.append(_produceAsyncSetterDeclarations, "\t");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    CharSequence _produceAsyncMethodDeclarations = this._cppInterfaceUtil.produceAsyncMethodDeclarations(this.francaIntf, false, true, generateVersion);
    _builder.append(_produceAsyncMethodDeclarations, "\t");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("friend class ");
    _builder.append(className, "\t");
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("private:");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("DISALLOW_COPY_AND_ASSIGN(");
    _builder.append(asyncClassName, "\t");
    _builder.append(");");
    _builder.newLineIfNotEmpty();
    _builder.append("};");
    _builder.newLine();
    String _namespaceEnder = this._joynrCppGeneratorExtensions.getNamespaceEnder(this.francaIntf, generateVersion);
    _builder.append(_namespaceEnder);
    _builder.newLineIfNotEmpty();
    _builder.append("#endif // ");
    _builder.append(headerGuard);
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    return _builder;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy