All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
io.joynr.generator.cpp.provider.InterfaceAbstractProviderCppTemplate 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.AttributeUtil;
import io.joynr.generator.templates.util.NamingUtil;
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.FArgument;
import org.franca.core.franca.FAttribute;
import org.franca.core.franca.FBroadcast;
@SuppressWarnings("all")
public class InterfaceAbstractProviderCppTemplate extends InterfaceTemplate {
@Inject
@Extension
private TemplateBase _templateBase;
@Inject
@Extension
private CppStdTypeUtil _cppStdTypeUtil;
@Inject
@Extension
private JoynrCppGeneratorExtensions _joynrCppGeneratorExtensions;
@Inject
@Extension
private NamingUtil _namingUtil;
@Inject
@Extension
private AttributeUtil _attributeUtil;
@Override
public CharSequence generate(final boolean generateVersion) {
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("AbstractProvider.h\"");
_builder.newLineIfNotEmpty();
_builder.append("#include \"joynr/InterfaceRegistrar.h\"");
_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();
_builder.newLine();
{
Set _dataTypeIncludesFor = this._cppStdTypeUtil.getDataTypeIncludesFor(this.francaIntf, generateVersion);
for(final String parameterType : _dataTypeIncludesFor) {
_builder.append("#include ");
_builder.append(parameterType);
_builder.newLineIfNotEmpty();
}
}
_builder.newLine();
{
final Function1 _function = new Function1() {
@Override
public Boolean apply(final FBroadcast it) {
return Boolean.valueOf(it.isSelective());
}
};
Iterable _filter = IterableExtensions.filter(this.francaIntf.getBroadcasts(), _function);
for(final FBroadcast broadcast : _filter) {
_builder.append("#include \"");
String _packagePathWithJoynrPrefix_2 = this._joynrCppGeneratorExtensions.getPackagePathWithJoynrPrefix(this.francaIntf, "/", generateVersion);
_builder.append(_packagePathWithJoynrPrefix_2);
_builder.append("/");
String _broadcastFilterClassName = this.getBroadcastFilterClassName(broadcast);
_builder.append(_broadcastFilterClassName);
_builder.append(".h\"");
_builder.newLineIfNotEmpty();
}
}
_builder.newLine();
String _namespaceStarter = this._joynrCppGeneratorExtensions.getNamespaceStarter(this.francaIntf, generateVersion);
_builder.append(_namespaceStarter);
_builder.newLineIfNotEmpty();
_builder.append(interfaceName);
_builder.append("AbstractProvider::");
_builder.append(interfaceName);
_builder.append("AbstractProvider()");
_builder.newLineIfNotEmpty();
{
boolean _hasSelectiveBroadcast = this.hasSelectiveBroadcast();
if (_hasSelectiveBroadcast) {
_builder.append(":");
_builder.newLine();
{
final Function1 _function_1 = new Function1() {
@Override
public Boolean apply(final FBroadcast it) {
return Boolean.valueOf(it.isSelective());
}
};
Iterable _filter_1 = IterableExtensions.filter(this.francaIntf.getBroadcasts(), _function_1);
boolean _hasElements = false;
for(final FBroadcast broadcast_1 : _filter_1) {
if (!_hasElements) {
_hasElements = true;
} else {
_builder.appendImmediate(",", "");
}
final String broadcastName = this._namingUtil.joynrName(broadcast_1);
_builder.newLineIfNotEmpty();
_builder.append(broadcastName);
_builder.append("Filters()");
_builder.newLineIfNotEmpty();
}
}
}
}
_builder.append("{");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append(interfaceName);
_builder.append("AbstractProvider::~");
_builder.append(interfaceName);
_builder.append("AbstractProvider()");
_builder.newLineIfNotEmpty();
_builder.append("{");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("const std::string& ");
_builder.append(interfaceName);
_builder.append("AbstractProvider::getInterfaceName() const {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("return I");
_builder.append(interfaceName, "\t");
_builder.append("Base::INTERFACE_NAME();");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
_builder.newLine();
{
EList _attributes = this.francaIntf.getAttributes();
for(final FAttribute attribute : _attributes) {
{
boolean _isNotifiable = this._attributeUtil.isNotifiable(attribute);
if (_isNotifiable) {
String attributeName = this._namingUtil.joynrName(attribute);
_builder.newLineIfNotEmpty();
_builder.append("void ");
_builder.append(interfaceName);
_builder.append("AbstractProvider::");
_builder.append(attributeName);
_builder.append("Changed(");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("const ");
String _typeName = this._cppStdTypeUtil.getTypeName(attribute, generateVersion);
_builder.append(_typeName, "\t\t");
_builder.append("& ");
_builder.append(attributeName, "\t\t");
_builder.newLineIfNotEmpty();
_builder.append(") {");
_builder.newLine();
_builder.append("\t");
_builder.append("onAttributeValueChanged(\"");
_builder.append(attributeName, "\t");
_builder.append("\",");
_builder.append(attributeName, "\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
}
}
}
}
_builder.newLine();
{
EList _broadcasts = this.francaIntf.getBroadcasts();
for(final FBroadcast broadcast_2 : _broadcasts) {
final String broadcastName_1 = this._namingUtil.joynrName(broadcast_2);
_builder.newLineIfNotEmpty();
_builder.append("void ");
_builder.append(interfaceName);
_builder.append("AbstractProvider::fire");
String _firstUpper = StringExtensions.toFirstUpper(broadcastName_1);
_builder.append(_firstUpper);
_builder.append("(");
_builder.newLineIfNotEmpty();
{
boolean _isEmpty = IterableExtensions.isEmpty(this._broadcastUtil.getOutputParameters(broadcast_2));
boolean _not = (!_isEmpty);
if (_not) {
_builder.append("\t\t");
String _commaSeperatedTypedConstOutputParameterList = this._cppStdTypeUtil.getCommaSeperatedTypedConstOutputParameterList(broadcast_2, generateVersion);
_builder.append(_commaSeperatedTypedConstOutputParameterList, "\t\t");
{
boolean _isSelective = broadcast_2.isSelective();
boolean _not_1 = (!_isSelective);
if (_not_1) {
_builder.append(",");
}
}
_builder.newLineIfNotEmpty();
}
}
{
boolean _isSelective_1 = broadcast_2.isSelective();
boolean _not_2 = (!_isSelective_1);
if (_not_2) {
_builder.append("\t\t");
_builder.append("const std::vector& partitions");
_builder.newLine();
}
}
_builder.append(") {");
_builder.newLine();
{
boolean _isSelective_2 = broadcast_2.isSelective();
if (_isSelective_2) {
_builder.append("\t");
_builder.append("fireSelectiveBroadcast(");
_builder.newLine();
} else {
_builder.append("\t");
_builder.append("fireBroadcast(");
_builder.newLine();
}
}
_builder.append("\t\t\t");
_builder.append("\"");
_builder.append(broadcastName_1, "\t\t\t");
_builder.append("\",");
_builder.newLineIfNotEmpty();
{
boolean _isSelective_3 = broadcast_2.isSelective();
if (_isSelective_3) {
_builder.append("\t\t\t");
_builder.append(broadcastName_1, "\t\t\t");
_builder.append("Filters");
} else {
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t");
_builder.append("partitions");
}
}
{
boolean _isEmpty_1 = IterableExtensions.isEmpty(this._broadcastUtil.getOutputParameters(broadcast_2));
boolean _not_3 = (!_isEmpty_1);
if (_not_3) {
_builder.append(",");
_builder.newLineIfNotEmpty();
{
Iterable _outputParameters = this._broadcastUtil.getOutputParameters(broadcast_2);
boolean _hasElements_1 = false;
for(final FArgument parameter : _outputParameters) {
if (!_hasElements_1) {
_hasElements_1 = true;
} else {
_builder.appendImmediate(",", "\t\t\t");
}
_builder.append("\t\t\t");
String _joynrName = this._namingUtil.joynrName(parameter);
_builder.append(_joynrName, "\t\t\t");
_builder.newLineIfNotEmpty();
}
}
}
}
_builder.append("\t");
_builder.append(");");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
{
boolean _isSelective_4 = broadcast_2.isSelective();
if (_isSelective_4) {
String _firstUpper_1 = StringExtensions.toFirstUpper(interfaceName);
String _firstUpper_2 = StringExtensions.toFirstUpper(broadcastName_1);
String _plus = (_firstUpper_1 + _firstUpper_2);
final String broadCastFilterClassName = (_plus + "BroadcastFilter");
_builder.newLineIfNotEmpty();
_builder.append("void ");
_builder.append(interfaceName);
_builder.append("AbstractProvider::addBroadcastFilter(std::shared_ptr<");
_builder.append(broadCastFilterClassName);
_builder.append("> filter)");
_builder.newLineIfNotEmpty();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append(broadcastName_1, "\t");
_builder.append("Filters.push_back(std::move(filter));");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
}
}
}
}
String _namespaceEnder = this._joynrCppGeneratorExtensions.getNamespaceEnder(this.francaIntf, generateVersion);
_builder.append(_namespaceEnder);
_builder.newLineIfNotEmpty();
return _builder;
}
}