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.InterfaceAbstractProviderHTemplate 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 InterfaceAbstractProviderHTemplate extends InterfaceTemplate {
@Inject
@Extension
private TemplateBase _templateBase;
@Inject
@Extension
private JoynrCppGeneratorExtensions _joynrCppGeneratorExtensions;
@Inject
@Extension
private CppStdTypeUtil _cppStdTypeUtil;
@Inject
@Extension
private NamingUtil _namingUtil;
@Inject
@Extension
private AttributeUtil _attributeUtil;
@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 + "AbstractProvider_h").toUpperCase();
_builder.newLineIfNotEmpty();
CharSequence _warning = this._templateBase.warning();
_builder.append(_warning);
_builder.newLineIfNotEmpty();
_builder.append("#ifndef ");
_builder.append(headerGuard);
_builder.newLineIfNotEmpty();
_builder.append("#define ");
_builder.append(headerGuard);
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("#include ");
_builder.newLine();
_builder.append("#include ");
_builder.newLine();
_builder.append("#include ");
_builder.newLine();
_builder.newLine();
_builder.append("#include \"joynr/PrivateCopyAssign.h\"");
_builder.newLine();
_builder.append("#include \"joynr/AbstractJoynrProvider.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("Provider.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();
_builder.newLine();
String _namespaceStarter = this._joynrCppGeneratorExtensions.getNamespaceStarter(this.francaIntf, generateVersion);
_builder.append(_namespaceStarter);
_builder.newLineIfNotEmpty();
_builder.newLine();
{
final Function1 _function = new Function1() {
@Override
public Boolean apply(final FBroadcast it) {
return Boolean.valueOf(it.isSelective());
}
};
boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(IterableExtensions.filter(this.francaIntf.getBroadcasts(), _function));
boolean _not = (!_isNullOrEmpty);
if (_not) {
_builder.append("// forward declare broadcast filter classes");
_builder.newLine();
}
}
{
final Function1 _function_1 = new Function1() {
@Override
public Boolean apply(final FBroadcast it) {
return Boolean.valueOf(it.isSelective());
}
};
Iterable _filter = IterableExtensions.filter(this.francaIntf.getBroadcasts(), _function_1);
for(final FBroadcast broadcast : _filter) {
_builder.append("class ");
String _broadcastFilterClassName = this.getBroadcastFilterClassName(broadcast);
_builder.append(_broadcastFilterClassName);
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
_builder.newLine();
_builder.append("/** @brief Abstract provider class for interface ");
_builder.append(interfaceName);
_builder.append(" */");
_builder.newLineIfNotEmpty();
_builder.append("class ");
_builder.append(interfaceName);
_builder.append("AbstractProvider :");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("public ");
String _packagePathWithJoynrPrefix_2 = this._joynrCppGeneratorExtensions.getPackagePathWithJoynrPrefix(this.francaIntf, "::", generateVersion);
_builder.append(_packagePathWithJoynrPrefix_2, "\t\t");
_builder.append("::");
_builder.append(interfaceName, "\t\t");
_builder.append("Provider,");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("public joynr::AbstractJoynrProvider");
_builder.newLine();
_builder.append("{");
_builder.newLine();
_builder.newLine();
_builder.append("public:");
_builder.newLine();
_builder.append("\t");
_builder.append("/** @brief Default constructor */");
_builder.newLine();
_builder.append("\t");
_builder.append(interfaceName, "\t");
_builder.append("AbstractProvider();");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("/** @brief Destructor */");
_builder.newLine();
_builder.append("\t");
_builder.append("~");
_builder.append(interfaceName, "\t");
_builder.append("AbstractProvider() override;");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("/**");
_builder.newLine();
_builder.append("\t ");
_builder.append("* @brief Get the interface name");
_builder.newLine();
_builder.append("\t ");
_builder.append("* @return The name of the interface");
_builder.newLine();
_builder.append("\t ");
_builder.append("*/");
_builder.newLine();
_builder.append("\t");
_builder.append("const std::string& getInterfaceName() const override;");
_builder.newLine();
{
if (((!IterableExtensions.isNullOrEmpty(this.francaIntf.getAttributes())) || (!IterableExtensions.isNullOrEmpty(this.francaIntf.getBroadcasts())))) {
_builder.newLine();
{
EList _broadcasts = this.francaIntf.getBroadcasts();
for(final FBroadcast broadcast_1 : _broadcasts) {
_builder.append(" ");
final String broadcastName = this._namingUtil.joynrName(broadcast_1);
_builder.newLineIfNotEmpty();
{
boolean _isSelective = broadcast_1.isSelective();
if (_isSelective) {
_builder.append(" ");
String _firstUpper = StringExtensions.toFirstUpper(interfaceName);
String _firstUpper_1 = StringExtensions.toFirstUpper(broadcastName);
String _plus_3 = (_firstUpper + _firstUpper_1);
final String broadCastFilterClassName = (_plus_3 + "BroadcastFilter");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append(" ");
_builder.append("* @brief Adds a specific broadcastFilter");
_builder.newLine();
_builder.append(" ");
_builder.append(" ");
_builder.append("* @param filter an shared_ptr instance of ");
_builder.append(broadCastFilterClassName, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append(" ");
_builder.append("void addBroadcastFilter(std::shared_ptr<");
_builder.append(broadCastFilterClassName, " ");
_builder.append("> filter);");
_builder.newLineIfNotEmpty();
}
}
}
}
_builder.newLine();
_builder.append("protected:");
_builder.newLine();
}
}
{
boolean _isNullOrEmpty_1 = IterableExtensions.isNullOrEmpty(this.francaIntf.getAttributes());
boolean _not_1 = (!_isNullOrEmpty_1);
if (_not_1) {
_builder.newLine();
_builder.append("\t");
_builder.append("// attributes");
_builder.newLine();
}
}
{
EList _attributes = this.francaIntf.getAttributes();
for(final FAttribute attribute : _attributes) {
{
boolean _isNotifiable = this._attributeUtil.isNotifiable(attribute);
if (_isNotifiable) {
_builder.append("\t");
String attributeName = this._namingUtil.joynrName(attribute);
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("/**");
_builder.newLine();
_builder.append("\t");
_builder.append(" ");
_builder.append("* @brief ");
_builder.append(attributeName, "\t ");
_builder.append("Changed must be called by a concrete provider to signal attribute");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(" ");
_builder.append("* modifications. It is used to implement onchange subscriptions.");
_builder.newLine();
_builder.append("\t");
_builder.append(" ");
_builder.append("* @param ");
_builder.append(attributeName, "\t ");
_builder.append(" the new attribute value");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("\t");
_builder.append("void ");
_builder.append(attributeName, "\t");
_builder.append("Changed(");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("const ");
String _typeName = this._cppStdTypeUtil.getTypeName(attribute, generateVersion);
_builder.append(_typeName, "\t\t\t");
_builder.append("& ");
_builder.append(attributeName, "\t\t\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(") override;");
_builder.newLine();
}
}
}
}
{
boolean _isNullOrEmpty_2 = IterableExtensions.isNullOrEmpty(this.francaIntf.getBroadcasts());
boolean _not_2 = (!_isNullOrEmpty_2);
if (_not_2) {
_builder.newLine();
_builder.append("\t");
_builder.append("// broadcasts");
_builder.newLine();
}
}
{
EList _broadcasts_1 = this.francaIntf.getBroadcasts();
for(final FBroadcast broadcast_2 : _broadcasts_1) {
_builder.append("\t");
final String broadcastName_1 = this._namingUtil.joynrName(broadcast_2);
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("/**");
_builder.newLine();
_builder.append("\t");
_builder.append(" ");
_builder.append("* @brief fire");
String _firstUpper_2 = StringExtensions.toFirstUpper(broadcastName_1);
_builder.append(_firstUpper_2, "\t ");
_builder.append(" must be called by a concrete provider to signal an occured");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(" ");
_builder.append("* event. It is used to implement broadcast publications.");
_builder.newLine();
{
Iterable _outputParameters = this._broadcastUtil.getOutputParameters(broadcast_2);
for(final FArgument parameter : _outputParameters) {
_builder.append("\t");
_builder.append(" ");
_builder.append("* @param ");
String _name = parameter.getName();
_builder.append(_name, "\t ");
_builder.append(" the value for the broadcast output parameter ");
String _name_1 = parameter.getName();
_builder.append(_name_1, "\t ");
_builder.newLineIfNotEmpty();
}
}
{
boolean _isSelective_1 = broadcast_2.isSelective();
boolean _not_3 = (!_isSelective_1);
if (_not_3) {
_builder.append("\t");
_builder.append(" ");
_builder.append("* @param partitions optional list of partitions for this broadcast. Broadcast notifications");
_builder.newLine();
_builder.append("\t");
_builder.append(" ");
_builder.append("* are only sent to subscribers for these partitions.");
_builder.newLine();
}
}
_builder.append("\t");
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("\t");
_builder.append("void fire");
String _firstUpper_3 = StringExtensions.toFirstUpper(broadcastName_1);
_builder.append(_firstUpper_3, "\t");
_builder.append("(");
_builder.newLineIfNotEmpty();
{
boolean _isEmpty = IterableExtensions.isEmpty(this._broadcastUtil.getOutputParameters(broadcast_2));
boolean _not_4 = (!_isEmpty);
if (_not_4) {
_builder.append("\t");
_builder.append("\t\t");
String _commaSeperatedTypedConstOutputParameterList = this._cppStdTypeUtil.getCommaSeperatedTypedConstOutputParameterList(broadcast_2, generateVersion);
_builder.append(_commaSeperatedTypedConstOutputParameterList, "\t\t\t");
{
boolean _isSelective_2 = broadcast_2.isSelective();
boolean _not_5 = (!_isSelective_2);
if (_not_5) {
_builder.append(",");
}
}
_builder.newLineIfNotEmpty();
}
}
{
boolean _isSelective_3 = broadcast_2.isSelective();
boolean _not_6 = (!_isSelective_3);
if (_not_6) {
_builder.append("\t");
_builder.append("\t\t");
_builder.append("const std::vector& partitions = std::vector()");
_builder.newLine();
}
}
_builder.append("\t");
_builder.append(") 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("AbstractProvider);");
_builder.newLineIfNotEmpty();
_builder.newLine();
{
final Function1 _function_2 = new Function1() {
@Override
public Boolean apply(final FBroadcast it) {
return Boolean.valueOf(it.isSelective());
}
};
Iterable _filter_1 = IterableExtensions.filter(this.francaIntf.getBroadcasts(), _function_2);
for(final FBroadcast broadcast_3 : _filter_1) {
_builder.append("\t");
final String broadcastName_2 = this._namingUtil.joynrName(broadcast_3);
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("std::vector> ");
_builder.append(broadcastName_2, "\t");
_builder.append("Filters;");
_builder.newLineIfNotEmpty();
}
}
_builder.append("};");
_builder.newLine();
String _namespaceEnder = this._joynrCppGeneratorExtensions.getNamespaceEnder(this.francaIntf, generateVersion);
_builder.append(_namespaceEnder);
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("#endif // ");
_builder.append(headerGuard);
_builder.newLineIfNotEmpty();
return _builder;
}
}