
io.joynr.generator.cpp.util.InterfaceSubscriptionUtil Maven / Gradle / Ivy
package io.joynr.generator.cpp.util;
import com.google.inject.Inject;
import io.joynr.generator.cpp.util.CppStdTypeUtil;
import io.joynr.generator.cpp.util.JoynrCppGeneratorExtensions;
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 InterfaceSubscriptionUtil {
@Inject
@Extension
private JoynrCppGeneratorExtensions _joynrCppGeneratorExtensions;
@Inject
@Extension
private CppStdTypeUtil _cppStdTypeUtil;
public CharSequence produceSubscribeUnsubscribeMethods(final FInterface serviceInterface, final boolean pure) {
StringConcatenation _builder = new StringConcatenation();
{
EList _attributes = this._joynrCppGeneratorExtensions.getAttributes(serviceInterface);
final Function1 _function = new Function1() {
public Boolean apply(final FAttribute attribute) {
return Boolean.valueOf(InterfaceSubscriptionUtil.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("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* @brief creates a new subscription to attribute ");
String _joynrName = this._joynrCppGeneratorExtensions.joynrName(attribute);
String _firstUpper = StringExtensions.toFirstUpper(_joynrName);
_builder.append(_firstUpper, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("* @param subscriptionListener The listener callback providing methods to call on publication and failure");
_builder.newLine();
_builder.append(" ");
_builder.append("* @param subscriptionQos The subscription quality of service settings");
_builder.newLine();
_builder.append(" ");
_builder.append("* @return the subscription id as string");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("virtual std::string subscribeTo");
String _joynrName_1 = this._joynrCppGeneratorExtensions.joynrName(attribute);
String _firstUpper_1 = StringExtensions.toFirstUpper(_joynrName_1);
_builder.append(_firstUpper_1, "");
_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)");
{
if (pure) {
_builder.append(" = 0");
}
}
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* @brief updates an existing subscription to attribute ");
String _joynrName_2 = this._joynrCppGeneratorExtensions.joynrName(attribute);
String _firstUpper_2 = StringExtensions.toFirstUpper(_joynrName_2);
_builder.append(_firstUpper_2, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("* @param subscriptionListener The listener callback providing methods to call on publication and failure");
_builder.newLine();
_builder.append(" ");
_builder.append("* @param subscriptionQos The subscription quality of service settings");
_builder.newLine();
_builder.append(" ");
_builder.append("* @param subscriptionId The subscription id returned earlier on creation of the subscription");
_builder.newLine();
_builder.append(" ");
_builder.append("* @return the subscription id as string");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("virtual std::string subscribeTo");
String _joynrName_3 = this._joynrCppGeneratorExtensions.joynrName(attribute);
String _firstUpper_3 = StringExtensions.toFirstUpper(_joynrName_3);
_builder.append(_firstUpper_3, "");
_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("std::string& subscriptionId)");
{
if (pure) {
_builder.append(" = 0");
}
}
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* @brief unsubscribes from attribute ");
String _joynrName_4 = this._joynrCppGeneratorExtensions.joynrName(attribute);
String _firstUpper_4 = StringExtensions.toFirstUpper(_joynrName_4);
_builder.append(_firstUpper_4, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("* @param subscriptionId The subscription id returned earlier on creation of the subscription");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("virtual void unsubscribeFrom");
String _joynrName_5 = this._joynrCppGeneratorExtensions.joynrName(attribute);
String _firstUpper_5 = StringExtensions.toFirstUpper(_joynrName_5);
_builder.append(_firstUpper_5, "");
_builder.append("(std::string& subscriptionId)");
{
if (pure) {
_builder.append(" = 0");
}
}
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.newLine();
}
}
{
EList _broadcasts = serviceInterface.getBroadcasts();
for(final FBroadcast broadcast : _broadcasts) {
final String returnTypes = this._cppStdTypeUtil.getCommaSeparatedOutputParameterTypes(broadcast);
_builder.newLineIfNotEmpty();
{
boolean _isSelective = this._joynrCppGeneratorExtensions.isSelective(broadcast);
if (_isSelective) {
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* @brief subscribes to selective broadcast ");
String _joynrName_6 = this._joynrCppGeneratorExtensions.joynrName(broadcast);
String _firstUpper_6 = StringExtensions.toFirstUpper(_joynrName_6);
_builder.append(_firstUpper_6, " ");
_builder.append(" with filter parameters");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("* @param filterParameters The filter parameters for selection of suitable broadcasts");
_builder.newLine();
_builder.append(" ");
_builder.append("* @param subscriptionListener The listener callback providing methods to call on publication and failure");
_builder.newLine();
_builder.append(" ");
_builder.append("* @param subscriptionQos The subscription quality of service settings");
_builder.newLine();
_builder.append(" ");
_builder.append("* @return the subscription id as string");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("virtual std::string subscribeTo");
String _joynrName_7 = this._joynrCppGeneratorExtensions.joynrName(broadcast);
String _firstUpper_7 = StringExtensions.toFirstUpper(_joynrName_7);
_builder.append(_firstUpper_7, "");
_builder.append("Broadcast(");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t");
_builder.append("const ");
String _name = serviceInterface.getName();
String _firstUpper_8 = StringExtensions.toFirstUpper(_name);
_builder.append(_firstUpper_8, "\t\t\t");
String _joynrName_8 = this._joynrCppGeneratorExtensions.joynrName(broadcast);
String _firstUpper_9 = StringExtensions.toFirstUpper(_joynrName_8);
_builder.append(_firstUpper_9, "\t\t\t");
_builder.append("BroadcastFilterParameters& filterParameters,");
_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)");
{
if (pure) {
_builder.append(" = 0");
}
}
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* @brief updates an existing subscription to selective broadcast ");
String _joynrName_9 = this._joynrCppGeneratorExtensions.joynrName(broadcast);
String _firstUpper_10 = StringExtensions.toFirstUpper(_joynrName_9);
_builder.append(_firstUpper_10, " ");
_builder.append(" with filter parameters");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("* @param filterParameters The filter parameters for selection of suitable broadcasts");
_builder.newLine();
_builder.append(" ");
_builder.append("* @param subscriptionListener The listener callback providing methods to call on publication and failure");
_builder.newLine();
_builder.append(" ");
_builder.append("* @param subscriptionQos The subscription quality of service settings");
_builder.newLine();
_builder.append(" ");
_builder.append("* @param subscriptionId The subscription id returned earlier on creation of the subscription");
_builder.newLine();
_builder.append(" ");
_builder.append("* @return the subscription id as string");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("virtual std::string subscribeTo");
String _joynrName_10 = this._joynrCppGeneratorExtensions.joynrName(broadcast);
String _firstUpper_11 = StringExtensions.toFirstUpper(_joynrName_10);
_builder.append(_firstUpper_11, "");
_builder.append("Broadcast(");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t");
_builder.append("const ");
String _name_1 = serviceInterface.getName();
String _firstUpper_12 = StringExtensions.toFirstUpper(_name_1);
_builder.append(_firstUpper_12, "\t\t\t");
String _joynrName_11 = this._joynrCppGeneratorExtensions.joynrName(broadcast);
String _firstUpper_13 = StringExtensions.toFirstUpper(_joynrName_11);
_builder.append(_firstUpper_13, "\t\t\t");
_builder.append("BroadcastFilterParameters& filterParameters,");
_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("std::string& subscriptionId)");
{
if (pure) {
_builder.append(" = 0");
}
}
_builder.append(";");
_builder.newLineIfNotEmpty();
} else {
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* @brief subscribes to broadcast ");
String _joynrName_12 = this._joynrCppGeneratorExtensions.joynrName(broadcast);
String _firstUpper_14 = StringExtensions.toFirstUpper(_joynrName_12);
_builder.append(_firstUpper_14, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("* @param subscriptionListener The listener callback providing methods to call on publication and failure");
_builder.newLine();
_builder.append(" ");
_builder.append("* @param subscriptionQos The subscription quality of service settings");
_builder.newLine();
_builder.append(" ");
_builder.append("* @return the subscription id as string");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("virtual std::string subscribeTo");
String _joynrName_13 = this._joynrCppGeneratorExtensions.joynrName(broadcast);
String _firstUpper_15 = StringExtensions.toFirstUpper(_joynrName_13);
_builder.append(_firstUpper_15, "");
_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)");
{
if (pure) {
_builder.append(" = 0");
}
}
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* @brief updates an existing subscription to broadcast ");
String _joynrName_14 = this._joynrCppGeneratorExtensions.joynrName(broadcast);
String _firstUpper_16 = StringExtensions.toFirstUpper(_joynrName_14);
_builder.append(_firstUpper_16, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("* @param filterParameters The filter parameters for selection of suitable broadcasts");
_builder.newLine();
_builder.append(" ");
_builder.append("* @param subscriptionListener The listener callback providing methods to call on publication and failure");
_builder.newLine();
_builder.append(" ");
_builder.append("* @param subscriptionQos The subscription quality of service settings");
_builder.newLine();
_builder.append(" ");
_builder.append("* @param subscriptionId The subscription id returned earlier on creation of the subscription");
_builder.newLine();
_builder.append(" ");
_builder.append("* @return the subscription id as string");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("virtual std::string subscribeTo");
String _joynrName_15 = this._joynrCppGeneratorExtensions.joynrName(broadcast);
String _firstUpper_17 = StringExtensions.toFirstUpper(_joynrName_15);
_builder.append(_firstUpper_17, "");
_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("std::string& subscriptionId)");
{
if (pure) {
_builder.append(" = 0");
}
}
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
_builder.newLine();
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* @brief unsubscribes from broadcast ");
String _joynrName_16 = this._joynrCppGeneratorExtensions.joynrName(broadcast);
String _firstUpper_18 = StringExtensions.toFirstUpper(_joynrName_16);
_builder.append(_firstUpper_18, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("* @param subscriptionId The subscription id returned earlier on creation of the subscription");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("virtual void unsubscribeFrom");
String _joynrName_17 = this._joynrCppGeneratorExtensions.joynrName(broadcast);
String _firstUpper_19 = StringExtensions.toFirstUpper(_joynrName_17);
_builder.append(_firstUpper_19, "");
_builder.append("Broadcast(std::string& subscriptionId)");
{
if (pure) {
_builder.append(" = 0");
}
}
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.newLine();
}
}
return _builder;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy