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

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

package io.joynr.generator.cpp.provider;

import com.google.inject.Inject;
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 org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Extension;

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

  @Inject
  @Extension
  private JoynrCppGeneratorExtensions _joynrCppGeneratorExtensions;

  @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();
    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 + "RequestInterpreter_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 ");
    _builder.newLine();
    _builder.newLine();
    _builder.append("#include \"joynr/PrivateCopyAssign.h\"");
    _builder.newLine();
    _builder.append("#include \"joynr/IRequestInterpreter.h\"");
    _builder.newLine();
    _builder.append("#include \"joynr/Logger.h\"");
    _builder.newLine();
    _builder.newLine();
    _builder.append("namespace joynr");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class RequestCaller;");
    _builder.newLine();
    _builder.append("class Request;");
    _builder.newLine();
    _builder.append("class OneWayRequest;");
    _builder.newLine();
    _builder.append("class BaseReply;");
    _builder.newLine();
    _builder.newLine();
    _builder.append("namespace exceptions");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("class JoynrException;");
    _builder.newLine();
    _builder.append("} // namespace exceptions");
    _builder.newLine();
    _builder.newLine();
    _builder.append("} // namespace joynr");
    _builder.newLine();
    _builder.newLine();
    String _namespaceStarter = this._joynrCppGeneratorExtensions.getNamespaceStarter(this.francaIntf, generateVersion);
    _builder.append(_namespaceStarter);
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("/** @brief RequestInterpreter class for interface ");
    _builder.append(interfaceName);
    _builder.append(" */");
    _builder.newLineIfNotEmpty();
    _builder.append("class ");
    _builder.append(interfaceName);
    _builder.append("RequestInterpreter: public joynr::IRequestInterpreter {");
    _builder.newLineIfNotEmpty();
    _builder.append("public:");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("/** @brief Default constructor */");
    _builder.newLine();
    _builder.append("\t");
    _builder.append(interfaceName, "\t");
    _builder.append("RequestInterpreter() = default;");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("/** @brief Destructor */");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("~");
    _builder.append(interfaceName, "\t");
    _builder.append("RequestInterpreter() override = default;");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("/**");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* @brief Implements IRequestInterpreter.execute().");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* Executes method methodName with given parameters on the requestCaller object.");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* @param requestCaller Object on which the method is to be executed");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* @param request Request which was received");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* @param onSuccess A callback function to be called once the asynchronous computation has");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* finished with success. Its signature expects a BaseReply containing the output parameters.");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* @param onError A callback function to be called once the asynchronous computation fails.");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* Its signature expects a JoynrException.");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("*/");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("void execute(std::shared_ptr requestCaller,");
    _builder.newLine();
    _builder.append("\t\t\t\t ");
    _builder.append("Request& request,");
    _builder.newLine();
    _builder.append("\t\t\t\t ");
    _builder.append("std::function&& onSuccess,");
    _builder.newLine();
    _builder.append("\t\t\t\t ");
    _builder.append("std::function& exception)>&& onError) override;");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("/**");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* @brief Implements IRequestInterpreter.execute().");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* Executes fire-and-forget method methodName with given parameters on the requestCaller object.");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* @param request OneWayRequest which was received");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("*/");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("void execute(std::shared_ptr requestCaller,");
    _builder.newLine();
    _builder.append("\t\t\t\t\t ");
    _builder.append("OneWayRequest& request) override;");
    _builder.newLine();
    _builder.newLine();
    _builder.append("private:");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("DISALLOW_COPY_AND_ASSIGN(");
    _builder.append(interfaceName, "\t");
    _builder.append("RequestInterpreter);");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("ADD_LOGGER(");
    _builder.append(interfaceName, "\t");
    _builder.append("RequestInterpreter)");
    _builder.newLineIfNotEmpty();
    _builder.append("};");
    _builder.newLine();
    _builder.newLine();
    String _namespaceEnder = this._joynrCppGeneratorExtensions.getNamespaceEnder(this.francaIntf, generateVersion);
    _builder.append(_namespaceEnder);
    _builder.newLineIfNotEmpty();
    _builder.append("#endif // ");
    _builder.append(headerGuard);
    _builder.newLineIfNotEmpty();
    return _builder;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy