
io.joynr.generator.cpp.inprocess.InterfaceInProcessConnectorHTemplate Maven / Gradle / Ivy
package io.joynr.generator.cpp.inprocess;
import com.google.inject.Inject;
import io.joynr.generator.cpp.util.CppStdTypeUtil;
import io.joynr.generator.cpp.util.InterfaceSubscriptionUtil;
import io.joynr.generator.cpp.util.InterfaceUtil;
import io.joynr.generator.cpp.util.JoynrCppGeneratorExtensions;
import io.joynr.generator.cpp.util.TemplateBase;
import io.joynr.generator.util.InterfaceTemplate;
import java.util.Set;
import org.eclipse.emf.common.util.EList;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.franca.core.franca.FAttribute;
import org.franca.core.franca.FBroadcast;
import org.franca.core.franca.FInterface;
@SuppressWarnings("all")
public class InterfaceInProcessConnectorHTemplate implements InterfaceTemplate {
@Inject
@Extension
private TemplateBase _templateBase;
@Inject
@Extension
private CppStdTypeUtil _cppStdTypeUtil;
@Inject
@Extension
private JoynrCppGeneratorExtensions _joynrCppGeneratorExtensions;
@Inject
@Extension
private InterfaceUtil _interfaceUtil;
@Inject
@Extension
private InterfaceSubscriptionUtil _interfaceSubscriptionUtil;
public CharSequence generate(final FInterface serviceInterface) {
StringConcatenation _builder = new StringConcatenation();
final String interfaceName = this._joynrCppGeneratorExtensions.joynrName(serviceInterface);
_builder.newLineIfNotEmpty();
String _packagePathWithJoynrPrefix = this._joynrCppGeneratorExtensions.getPackagePathWithJoynrPrefix(serviceInterface, "_");
String _plus = ("GENERATED_INTERFACE_" + _packagePathWithJoynrPrefix);
String _plus_1 = (_plus +
"_");
String _plus_2 = (_plus_1 + interfaceName);
String _plus_3 = (_plus_2 + "InProcessConnector_h");
final String headerGuard = _plus_3.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(serviceInterface, "/");
_builder.append(_packagePathWithJoynrPrefix_1, "");
_builder.append("/I");
_builder.append(interfaceName, "");
_builder.append("Connector.h\"");
_builder.newLineIfNotEmpty();
_builder.append("#include \"joynr/InProcessPublicationSender.h\"");
_builder.newLine();
_builder.append("#include \"joynr/InProcessConnectorFactory.h\"");
_builder.newLine();
_builder.append("#include \"joynr/SubscriptionRequest.h\"");
_builder.newLine();
_builder.append("#include \"joynr/BroadcastSubscriptionRequest.h\"");
_builder.newLine();
_builder.append("#include \"joynr/SubscriptionQos.h\"");
_builder.newLine();
_builder.append("#include \"joynr/OnChangeSubscriptionQos.h\"");
_builder.newLine();
_builder.newLine();
_builder.append("#include ");
_builder.newLine();
_builder.append("#include \"joynr/TypeUtil.h\"");
_builder.newLine();
_builder.newLine();
{
Set _requiredIncludesFor = this._cppStdTypeUtil.getRequiredIncludesFor(serviceInterface);
String _includeForString = this._cppStdTypeUtil.getIncludeForString();
Set _addElements = this._cppStdTypeUtil.addElements(_requiredIncludesFor, _includeForString);
for(final String parameterType : _addElements) {
_builder.append("#include ");
_builder.append(parameterType, "");
_builder.newLineIfNotEmpty();
}
}
_builder.append("#include ");
_builder.newLine();
_builder.newLine();
_builder.append("namespace joynr {");
_builder.newLine();
_builder.append("\t");
_builder.append("class RequestStatus;");
_builder.newLine();
_builder.append("\t");
_builder.append("class InProcessAddress;");
_builder.newLine();
_builder.append("\t");
_builder.append("class ISubscriptionManager;");
_builder.newLine();
_builder.append("\t");
_builder.append("class PublicationManager;");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
String _namespaceStarter = this._joynrCppGeneratorExtensions.getNamespaceStarter(serviceInterface);
_builder.append(_namespaceStarter, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("/** @brief InProcessConnector class for interface ");
_builder.append(interfaceName, "");
_builder.append(" */");
_builder.newLineIfNotEmpty();
_builder.append("class ");
_builder.append(interfaceName, "");
_builder.append("InProcessConnector : public I");
_builder.append(interfaceName, "");
_builder.append("Connector {");
_builder.newLineIfNotEmpty();
_builder.append("private:");
_builder.newLine();
{
EList _attributes = this._joynrCppGeneratorExtensions.getAttributes(serviceInterface);
final Function1 _function = new Function1() {
public Boolean apply(final FAttribute attribute) {
return Boolean.valueOf(InterfaceInProcessConnectorHTemplate.this._joynrCppGeneratorExtensions.isNotifiable(attribute));
}
};
Iterable _filter = IterableExtensions.filter(_attributes, _function);
for(final FAttribute attribute : _filter) {
final String returnType = this._cppStdTypeUtil.getTypeName(attribute);
_builder.newLineIfNotEmpty();
_builder.append("std::string subscribeTo");
String _joynrName = this._joynrCppGeneratorExtensions.joynrName(attribute);
String _firstUpper = StringExtensions.toFirstUpper(_joynrName);
_builder.append(_firstUpper, "");
_builder.append("(");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t");
_builder.append("std::shared_ptr > subscriptionListener,");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t");
_builder.append("const joynr::SubscriptionQos& subscriptionQos,");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("SubscriptionRequest& subscriptionRequest);");
_builder.newLine();
}
}
{
EList _broadcasts = serviceInterface.getBroadcasts();
for(final FBroadcast broadcast : _broadcasts) {
final String returnTypes = this._cppStdTypeUtil.getCommaSeparatedOutputParameterTypes(broadcast);
_builder.newLineIfNotEmpty();
final String broadcastName = this._joynrCppGeneratorExtensions.joynrName(broadcast);
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("std::string subscribeTo");
String _firstUpper_1 = StringExtensions.toFirstUpper(broadcastName);
_builder.append(_firstUpper_1, "\t");
_builder.append("Broadcast(");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t");
_builder.append("std::shared_ptr > subscriptionListener,");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t");
_builder.append("const joynr::OnChangeSubscriptionQos& subscriptionQos,");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("BroadcastSubscriptionRequest& subscriptionRequest);");
_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 subscriptionManager Subscription manager instance");
_builder.newLine();
_builder.append("\t ");
_builder.append("* @param publicationManager Publication manager instance");
_builder.newLine();
_builder.append("\t ");
_builder.append("* @param inProcessPublicationSender InProcessPublicationSender instance,");
_builder.newLine();
_builder.append("\t ");
_builder.append("* used to transfer publications from the PublicationManager to the (local) SubscriptionManager.");
_builder.newLine();
_builder.append("\t ");
_builder.append("* @param proxyParticipantId The participant id of the proxy");
_builder.newLine();
_builder.append("\t ");
_builder.append("* @param providerParticipantId The participant id of the provider");
_builder.newLine();
_builder.append("\t ");
_builder.append("* @param address The address");
_builder.newLine();
_builder.append("\t ");
_builder.append("*/");
_builder.newLine();
_builder.append("\t");
_builder.append(interfaceName, "\t");
_builder.append("InProcessConnector(");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t\t");
_builder.append("joynr::ISubscriptionManager* subscriptionManager,");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("joynr::PublicationManager* publicationManager,");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("joynr::InProcessPublicationSender* inProcessPublicationSender,");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("const std::string& proxyParticipantId,");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("const std::string& providerParticipantId,");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("QSharedPointer address");
_builder.newLine();
_builder.append("\t");
_builder.append(");");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("/**");
_builder.newLine();
_builder.append("\t ");
_builder.append("* @brief Checks whether cluster controller is used");
_builder.newLine();
_builder.append("\t ");
_builder.append("* @return true, if cluster controller is used");
_builder.newLine();
_builder.append("\t ");
_builder.append("*/");
_builder.newLine();
_builder.append("\t");
_builder.append("virtual bool usesClusterController() const;");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
CharSequence _produceSyncGetters = this._interfaceUtil.produceSyncGetters(serviceInterface, false);
_builder.append(_produceSyncGetters, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
CharSequence _produceSyncSetters = this._interfaceUtil.produceSyncSetters(serviceInterface, false);
_builder.append(_produceSyncSetters, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
CharSequence _produceSyncMethods = this._interfaceUtil.produceSyncMethods(serviceInterface, false);
_builder.append(_produceSyncMethods, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
CharSequence _produceAsyncGetters = this._interfaceUtil.produceAsyncGetters(serviceInterface, false);
_builder.append(_produceAsyncGetters, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
CharSequence _produceAsyncSetters = this._interfaceUtil.produceAsyncSetters(serviceInterface, false);
_builder.append(_produceAsyncSetters, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
CharSequence _produceAsyncMethods = this._interfaceUtil.produceAsyncMethods(serviceInterface, false);
_builder.append(_produceAsyncMethods, "\t");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
CharSequence _produceSubscribeUnsubscribeMethods = this._interfaceSubscriptionUtil.produceSubscribeUnsubscribeMethods(serviceInterface, false);
_builder.append(_produceSubscribeUnsubscribeMethods, "\t");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("private:");
_builder.newLine();
_builder.append("\t");
_builder.append("static joynr::joynr_logging::Logger* logger;");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("DISALLOW_COPY_AND_ASSIGN(");
_builder.append(interfaceName, "\t");
_builder.append("InProcessConnector);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("std::string proxyParticipantId;");
_builder.newLine();
_builder.append("\t");
_builder.append("std::string providerParticipantId;");
_builder.newLine();
_builder.append("\t");
_builder.append("QSharedPointer address;");
_builder.newLine();
_builder.append("\t");
_builder.append("joynr::ISubscriptionManager* subscriptionManager;");
_builder.newLine();
_builder.append("\t");
_builder.append("joynr::PublicationManager* publicationManager;");
_builder.newLine();
_builder.append("\t");
_builder.append("joynr::InProcessPublicationSender* inProcessPublicationSender;");
_builder.newLine();
_builder.append("};");
_builder.newLine();
String _namespaceEnder = this._joynrCppGeneratorExtensions.getNamespaceEnder(serviceInterface);
_builder.append(_namespaceEnder, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("namespace joynr {");
_builder.newLine();
_builder.newLine();
String packagePrefix = this._joynrCppGeneratorExtensions.getPackagePathWithJoynrPrefix(serviceInterface, "::");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("// Helper class for use by the InProcessConnectorFactory");
_builder.newLine();
_builder.append("// This class creates instances of ");
_builder.append(interfaceName, "");
_builder.append("InProcessConnector");
_builder.newLineIfNotEmpty();
_builder.append("template <>");
_builder.newLine();
_builder.append("class InProcessConnectorFactoryHelper <");
_builder.append(packagePrefix, "");
_builder.append("::I");
_builder.append(interfaceName, "");
_builder.append("Connector> {");
_builder.newLineIfNotEmpty();
_builder.append("public:");
_builder.newLine();
_builder.append("\t");
_builder.append(packagePrefix, "\t");
_builder.append("::");
_builder.append(interfaceName, "\t");
_builder.append("InProcessConnector* create(");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t");
_builder.append("ISubscriptionManager* subscriptionManager,");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("PublicationManager* publicationManager,");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("InProcessPublicationSender* inProcessPublicationSender,");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("const std::string& proxyParticipantId,");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("const std::string& providerParticipantId,");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("QSharedPointer address");
_builder.newLine();
_builder.append("\t\t");
_builder.append(") {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("return new ");
_builder.append(packagePrefix, "\t\t");
_builder.append("::");
_builder.append(interfaceName, "\t\t");
_builder.append("InProcessConnector(");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t\t");
_builder.append("subscriptionManager,");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("publicationManager,");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("inProcessPublicationSender,");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("proxyParticipantId,");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("providerParticipantId,");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("address");
_builder.newLine();
_builder.append("\t\t");
_builder.append(");");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("};");
_builder.newLine();
_builder.append("} // namespace joynr");
_builder.newLine();
_builder.newLine();
_builder.append("#endif // ");
_builder.append(headerGuard, "");
_builder.newLineIfNotEmpty();
return _builder;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy