summaryrefslogtreecommitdiff
path: root/CommonAPI-Examples
diff options
context:
space:
mode:
Diffstat (limited to 'CommonAPI-Examples')
-rw-r--r--CommonAPI-Examples/.cproject42
-rw-r--r--CommonAPI-Examples/.gitignore5
-rw-r--r--CommonAPI-Examples/.project33
-rw-r--r--CommonAPI-Examples/AUTHORS2
-rw-r--r--CommonAPI-Examples/E01HelloWorld/.cproject71
-rw-r--r--CommonAPI-Examples/E01HelloWorld/.gitignore2
-rw-r--r--CommonAPI-Examples/E01HelloWorld/.project33
-rw-r--r--CommonAPI-Examples/E01HelloWorld/CMakeLists.txt141
-rw-r--r--CommonAPI-Examples/E01HelloWorld/README150
-rw-r--r--CommonAPI-Examples/E01HelloWorld/commonapi4dbus.ini8
-rw-r--r--CommonAPI-Examples/E01HelloWorld/commonapi4someip.ini8
-rw-r--r--CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl32
-rw-r--r--CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fidl (renamed from CommonAPI-Examples/e01HelloWorld/fidl/E01HelloWorld.fidl)4
-rw-r--r--CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldClient.cpp56
-rw-r--r--CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp33
-rw-r--r--CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.cpp24
-rw-r--r--CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.hpp (renamed from CommonAPI-Examples/e01HelloWorld/src/E01HelloWorldStubImpl.h)13
-rw-r--r--CommonAPI-Examples/E01HelloWorld/vsomeip.json62
-rw-r--r--CommonAPI-Examples/E02Attributes/.cproject66
-rw-r--r--CommonAPI-Examples/E02Attributes/.gitignore (renamed from CommonAPI-Examples/e01HelloWorld/.gitignore)0
-rw-r--r--CommonAPI-Examples/E02Attributes/.project33
-rw-r--r--CommonAPI-Examples/E02Attributes/CMakeLists.txt103
-rw-r--r--CommonAPI-Examples/E02Attributes/README131
-rw-r--r--CommonAPI-Examples/E02Attributes/fidl/E02Attributes.fdepl11
-rw-r--r--CommonAPI-Examples/E02Attributes/fidl/E02Attributes.fidl (renamed from CommonAPI-Examples/e02Attributes/fidl/E02Attributes.fidl)9
-rw-r--r--CommonAPI-Examples/E02Attributes/src/AttributeCacheExtension.hpp (renamed from CommonAPI-Examples/e02Attributes/src/AttributeCacheExtension.hpp)6
-rw-r--r--CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp (renamed from CommonAPI-Examples/e02Attributes/src/e02AttributesClient.cpp)63
-rw-r--r--CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp (renamed from CommonAPI-Examples/e02Attributes/src/e02AttributesService.cpp)19
-rw-r--r--CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.cpp (renamed from CommonAPI-Examples/e02Attributes/src/E02AttributesStubImpl.cpp)6
-rw-r--r--CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.hpp (renamed from CommonAPI-Examples/e02Attributes/src/E02AttributesStubImpl.h)10
-rw-r--r--CommonAPI-Examples/E03Methods/.cproject66
-rw-r--r--CommonAPI-Examples/E03Methods/.gitignore (renamed from CommonAPI-Examples/e02Attributes/.gitignore)0
-rw-r--r--CommonAPI-Examples/E03Methods/.project33
-rw-r--r--CommonAPI-Examples/E03Methods/CMakeLists.txt105
-rw-r--r--CommonAPI-Examples/E03Methods/README (renamed from CommonAPI-Examples/e03Methods/README)85
-rw-r--r--CommonAPI-Examples/E03Methods/fidl/E03Methods.fdepl8
-rw-r--r--CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl (renamed from CommonAPI-Examples/e03Methods/fidl/E03Methods.fidl)2
-rw-r--r--CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp (renamed from CommonAPI-Examples/e03Methods/src/e03MethodsClient.cpp)25
-rw-r--r--CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp (renamed from CommonAPI-Examples/e03Methods/src/e03MethodsService.cpp)16
-rw-r--r--CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.cpp (renamed from CommonAPI-Examples/e03Methods/src/E03MethodsStubImpl.cpp)22
-rw-r--r--CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.hpp (renamed from CommonAPI-Examples/e03Methods/src/E03MethodsStubImpl.h)17
-rw-r--r--CommonAPI-Examples/E04PhoneBook/.cproject70
-rw-r--r--CommonAPI-Examples/E04PhoneBook/.gitignore (renamed from CommonAPI-Examples/e03Methods/.gitignore)0
-rw-r--r--CommonAPI-Examples/E04PhoneBook/.project33
-rw-r--r--CommonAPI-Examples/E04PhoneBook/CMakeLists.txt90
-rw-r--r--CommonAPI-Examples/E04PhoneBook/README219
-rw-r--r--CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook.fdepl112
-rw-r--r--CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook.fidl (renamed from CommonAPI-Examples/e04PhoneBook/fidl/E04PhoneBook.fidl)3
-rw-r--r--CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp (renamed from CommonAPI-Examples/e04PhoneBook/src/e04PhoneBookClient.cpp)59
-rw-r--r--CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp (renamed from CommonAPI-Examples/e04PhoneBook/src/e04PhoneBookService.cpp)14
-rw-r--r--CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookStubImpl.cpp (renamed from CommonAPI-Examples/e04PhoneBook/src/E04PhoneBookStubImpl.cpp)112
-rw-r--r--CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookStubImpl.h (renamed from CommonAPI-Examples/e04PhoneBook/src/E04PhoneBookStubImpl.h)15
-rw-r--r--CommonAPI-Examples/E05Manager/.cproject66
-rw-r--r--CommonAPI-Examples/E05Manager/.gitignore (renamed from CommonAPI-Examples/e04PhoneBook/.gitignore)0
-rw-r--r--CommonAPI-Examples/E05Manager/.project27
-rw-r--r--CommonAPI-Examples/E05Manager/CMakeLists.txt90
-rw-r--r--CommonAPI-Examples/E05Manager/README125
-rw-r--r--CommonAPI-Examples/E05Manager/fidl/E05Manager.fidl (renamed from CommonAPI-Examples/e05Manager/fidl/E05Manager.fidl)0
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.cpp (renamed from CommonAPI-Examples/e05Manager/src/E05DeviceStubImpl.cpp)2
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.h (renamed from CommonAPI-Examples/e05Manager/src/E05DeviceStubImpl.h)4
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp (renamed from CommonAPI-Examples/e05Manager/src/e05ManagerClient.cpp)17
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp (renamed from CommonAPI-Examples/e05Manager/src/e05ManagerService.cpp)13
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05ManagerStubImpl.cpp (renamed from CommonAPI-Examples/e05Manager/src/E05ManagerStubImpl.cpp)2
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05ManagerStubImpl.h (renamed from CommonAPI-Examples/e05Manager/src/E05ManagerStubImpl.h)6
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.cpp (renamed from CommonAPI-Examples/e05Manager/src/E05SpecialDeviceStubImpl.cpp)2
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.h (renamed from CommonAPI-Examples/e05Manager/src/E05SpecialDeviceStubImpl.h)4
-rw-r--r--CommonAPI-Examples/E06Unions/.cproject66
-rw-r--r--CommonAPI-Examples/E06Unions/.gitignore (renamed from CommonAPI-Examples/e05Manager/.gitignore)0
-rw-r--r--CommonAPI-Examples/E06Unions/.project33
-rw-r--r--CommonAPI-Examples/E06Unions/CMakeLists.txt90
-rw-r--r--CommonAPI-Examples/E06Unions/README (renamed from CommonAPI-Examples/e06Unions/README)84
-rw-r--r--CommonAPI-Examples/E06Unions/fidl/E06Unions.fidl (renamed from CommonAPI-Examples/e06Unions/fidl/E06Unions.fidl)3
-rw-r--r--CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp (renamed from CommonAPI-Examples/e06Unions/src/e06UnionsClient.cpp)24
-rw-r--r--CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp34
-rw-r--r--CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.cpp (renamed from CommonAPI-Examples/e06Unions/src/E06UnionsStubImpl.cpp)3
-rw-r--r--CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.h (renamed from CommonAPI-Examples/e06Unions/src/E06UnionsStubImpl.h)5
-rw-r--r--CommonAPI-Examples/E06Unions/src/typeUtils.hpp (renamed from CommonAPI-Examples/e06Unions/src/typeUtils.hpp)0
-rw-r--r--CommonAPI-Examples/E07Mainloop/.cproject71
-rw-r--r--CommonAPI-Examples/E07Mainloop/.gitignore2
-rw-r--r--CommonAPI-Examples/E07Mainloop/.project33
-rw-r--r--CommonAPI-Examples/E07Mainloop/CMakeLists.txt125
-rw-r--r--CommonAPI-Examples/E07Mainloop/README6
-rw-r--r--CommonAPI-Examples/E07Mainloop/commonapi4dbus.ini8
-rw-r--r--CommonAPI-Examples/E07Mainloop/commonapi4someip.ini8
-rw-r--r--CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fdepl40
-rw-r--r--CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fidl22
-rw-r--r--CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp196
-rw-r--r--CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp140
-rw-r--r--CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.cpp33
-rw-r--r--CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.hpp24
-rw-r--r--CommonAPI-Examples/E07Mainloop/vsomeip.json47
-rw-r--r--CommonAPI-Examples/README26
-rw-r--r--CommonAPI-Examples/e01HelloWorld/CMakeLists.txt71
-rw-r--r--CommonAPI-Examples/e01HelloWorld/README5
-rw-r--r--CommonAPI-Examples/e01HelloWorld/src/E01HelloWorldStubImpl.cpp25
-rw-r--r--CommonAPI-Examples/e01HelloWorld/src/e01HelloWorldClient.cpp39
-rw-r--r--CommonAPI-Examples/e01HelloWorld/src/e01HelloWorldService.cpp31
-rw-r--r--CommonAPI-Examples/e02Attributes/CMakeLists.txt71
-rw-r--r--CommonAPI-Examples/e02Attributes/README170
-rw-r--r--CommonAPI-Examples/e03Methods/CMakeLists.txt71
-rw-r--r--CommonAPI-Examples/e04PhoneBook/CMakeLists.txt72
-rw-r--r--CommonAPI-Examples/e04PhoneBook/README237
-rw-r--r--CommonAPI-Examples/e05Manager/CMakeLists.txt72
-rw-r--r--CommonAPI-Examples/e05Manager/README135
-rw-r--r--CommonAPI-Examples/e06Unions/.gitignore2
-rw-r--r--CommonAPI-Examples/e06Unions/CMakeLists.txt71
-rw-r--r--CommonAPI-Examples/e06Unions/src/e06UnionsService.cpp37
107 files changed, 3422 insertions, 1450 deletions
diff --git a/CommonAPI-Examples/.cproject b/CommonAPI-Examples/.cproject
new file mode 100644
index 0000000..90d8045
--- /dev/null
+++ b/CommonAPI-Examples/.cproject
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1795347564">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.1795347564" moduleId="org.eclipse.cdt.core.settings" name="Default">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration buildProperties="" id="cdt.managedbuild.toolchain.gnu.base.1795347564" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
+ <folderInfo id="cdt.managedbuild.toolchain.gnu.base.1795347564.2114763938" name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.base.212284046" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.base">
+ <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.1511046083" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
+ <builder id="cdt.managedbuild.target.gnu.builder.base.592340197" managedBuildOn="false" name="Gnu Make Builder.Default" superClass="cdt.managedbuild.target.gnu.builder.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.base.190940641" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1354756355" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1924407065" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.base.2096802586" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1887025592" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.base.1110106674" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"/>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="CommonAPI-Examples.null.1362575265" name="CommonAPI-Examples"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+</cproject>
diff --git a/CommonAPI-Examples/.gitignore b/CommonAPI-Examples/.gitignore
index 7a50484..0e61d95 100644
--- a/CommonAPI-Examples/.gitignore
+++ b/CommonAPI-Examples/.gitignore
@@ -1,5 +1,4 @@
-.cproject
-.project
+*~
.settings
*/src-gen
-*/build \ No newline at end of file
+*/build
diff --git a/CommonAPI-Examples/.project b/CommonAPI-Examples/.project
new file mode 100644
index 0000000..efb06ea
--- /dev/null
+++ b/CommonAPI-Examples/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>CommonAPI-Examples</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/CommonAPI-Examples/AUTHORS b/CommonAPI-Examples/AUTHORS
index 2708c9d..632e479 100644
--- a/CommonAPI-Examples/AUTHORS
+++ b/CommonAPI-Examples/AUTHORS
@@ -1 +1 @@
-BMW Group \ No newline at end of file
+Bayerische Motoren Werke Aktiengesellschaft (BMW AG) \ No newline at end of file
diff --git a/CommonAPI-Examples/E01HelloWorld/.cproject b/CommonAPI-Examples/E01HelloWorld/.cproject
new file mode 100644
index 0000000..fc8a4e4
--- /dev/null
+++ b/CommonAPI-Examples/E01HelloWorld/.cproject
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="0.416559588">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.416559588" moduleId="org.eclipse.cdt.core.settings" name="Default">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildProperties="" description="" id="0.416559588" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
+ <folderInfo id="0.416559588." name="/" resourcePath="">
+ <toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1038958730" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
+ <targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1038958730.2115115764" name=""/>
+ <builder arguments="-C ${ProjDirPath}/build VERBOSE=0" buildPath="" command="make" id="org.eclipse.cdt.build.core.settings.default.builder.1812880292" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.libs.1019901481" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.259363632" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.840421715" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.1212471744" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <option id="org.eclipse.cdt.build.core.settings.holder.incpaths.427233418" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/ascgit017.CommonAPI/include}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/E01HelloWorld/src-gen}&quot;"/>
+ <listOptionValue builtIn="false" value="/usr/include/c++/4.8.2"/>
+ </option>
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1678702299" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.291757453" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1117944646" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="e01HelloWorld.null.741055877" name="e01HelloWorld"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="0.416559588">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Default">
+ <resource resourceType="PROJECT" workspacePath="/e01HelloWorld"/>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+ <buildTargets>
+ <target name="Run cmake" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+ <buildCommand>cmake</buildCommand>
+ <buildArguments>-E chdir build/ cmake -D CMAKE_BUILD_TYPE=Debug -DUSE_INSTALLED_COMMONAPI=OFF -DUSE_INSTALLED_DBUS=OFF ../</buildArguments>
+ <buildTarget/>
+ <stopOnError>true</stopOnError>
+ <useDefaultCommand>false</useDefaultCommand>
+ <runAllBuilders>true</runAllBuilders>
+ </target>
+ </buildTargets>
+ </storageModule>
+</cproject>
diff --git a/CommonAPI-Examples/E01HelloWorld/.gitignore b/CommonAPI-Examples/E01HelloWorld/.gitignore
new file mode 100644
index 0000000..5fb7e99
--- /dev/null
+++ b/CommonAPI-Examples/E01HelloWorld/.gitignore
@@ -0,0 +1,2 @@
+build
+src-gen
diff --git a/CommonAPI-Examples/E01HelloWorld/.project b/CommonAPI-Examples/E01HelloWorld/.project
new file mode 100644
index 0000000..06979a8
--- /dev/null
+++ b/CommonAPI-Examples/E01HelloWorld/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>E01HelloWorld</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/CommonAPI-Examples/E01HelloWorld/CMakeLists.txt b/CommonAPI-Examples/E01HelloWorld/CMakeLists.txt
new file mode 100644
index 0000000..b250e4d
--- /dev/null
+++ b/CommonAPI-Examples/E01HelloWorld/CMakeLists.txt
@@ -0,0 +1,141 @@
+# Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+cmake_minimum_required(VERSION 2.8)
+
+set(PRJ_NAME E01HelloWorld)
+
+set(CMAKE_VERBOSE_MAKEFILE on)
+
+if (MSVC)
+# Visual C++ is not always sure whether he is really C++
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /EHsc /wd\\\"4503\\\"")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd\\\"4503\\\"")
+else()
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP -DLINUX")
+endif()
+
+message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}")
+
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
+ "Choose the type of build, options are: Debug Release." FORCE)
+endif(NOT CMAKE_BUILD_TYPE)
+message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
+
+OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version of CommonAPI" ON)
+message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}")
+
+if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON")
+ FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+else()
+ FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+endif()
+
+message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
+message(STATUS "COMMONAPI_INCLUDE_DIRS: ${COMMONAPI_INCLUDE_DIRS}")
+message(STATUS "CommonAPI-DBus_CONSIDERED_CONFIGS: ${CommonAPI-DBus_CONSIDERED_CONFIGS}")
+message(STATUS "COMMONAPI_DBUS_INCLUDE_DIRS: ${COMMONAPI_DBUS_INCLUDE_DIRS}")
+
+# CommonAPI
+include(FindPkgConfig)
+###############################################################################
+# find DBus by using the 'pkg-config' tool
+if (MSVC)
+ #Not beautiful, but it works
+ if (DBus_DIR)
+ if (DBus_BUILD_DIR)
+ set(DBus_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};")
+ else ()
+ message (FATAL_ERROR "DBus_BUILD_DIR not set! Cannot continue.")
+ endif ()
+ else()
+ message (FATAL_ERROR "DBus_DIR not set! Cannot continue.")
+ endif ()
+else()
+ pkg_check_modules(DBus REQUIRED dbus-1>=1.4)
+endif()
+
+# SOME/IP
+find_package (CommonAPI-SomeIP 3.1.1 REQUIRED)
+find_package (vsomeip 1.1.0 REQUIRED)
+
+# Source Files
+set(PRJ_SRC_PATH src)
+set(PRJ_SRC_GEN_PATH src-gen)
+set(PRJ_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/v0_1/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/v0_1/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/v0_1/commonapi/examples)
+
+set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
+set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
+
+# Application
+FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Proxy.cpp)
+FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Stub*.cpp)
+FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_COMMONAPI_PATH}/*Stub*.cpp)
+set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
+set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_SRC_PATH}/${PRJ_NAME}StubImpl.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
+
+# Boost
+find_package( Boost 1.54 COMPONENTS system thread log REQUIRED )
+include_directories( ${Boost_INCLUDE_DIR} )
+
+# DBus library
+FILE(GLOB PRJ_DBUS_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_DBUS_PATH}/*cpp)
+
+# SOME/IP library
+FILE(GLOB PRJ_SOMEIP_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH}/*cpp)
+
+# Paths
+OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON)
+message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}")
+
+include_directories(
+ src-gen/core
+ src-gen/dbus
+ src-gen/someip
+ ${COMMONAPI_INCLUDE_DIRS}
+ ${COMMONAPI_DBUS_INCLUDE_DIRS}
+ ${COMMONAPI_SOMEIP_INCLUDE_DIRS}
+ ${DBus_INCLUDE_DIRS}
+ ${VSOMEIP_INCLUDE_DIRS}
+)
+
+if ("${USE_INSTALLED_DBUS}" STREQUAL "ON")
+link_directories(
+ ${COMMONAPI_LIBDIR}
+ ${COMMONAPI_DBUS_LIBDIR}
+ ${COMMONAPI_SOMEIP_CMAKE_DIR}/build
+ ${Boost_LIBRARY_DIR}
+)
+else()
+link_directories(
+ ${COMMONAPI_LIBDIR}
+ ${COMMONAPI_DBUS_LIBDIR}
+ ${COMMONAPI_SOMEIP_CMAKE_DIR}/build
+ ${DBus_INCLUDE_DIRS}/dbus/.libs
+)
+endif()
+
+set(LINK_LIBRARIES -Wl,--as-needed CommonAPI)
+
+# Build Client
+add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
+target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES})
+
+# Build service
+add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
+target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES})
+
+# Build DBus library
+add_library (${PRJ_NAME}-dbus SHARED ${PRJ_DBUS_LIB_SRCS})
+target_link_libraries(${PRJ_NAME}-dbus CommonAPI-DBus)
+
+# Build SOME/IP library
+add_library (${PRJ_NAME}-someip SHARED ${PRJ_SOMEIP_LIB_SRCS})
+target_link_libraries(${PRJ_NAME}-someip CommonAPI-SomeIP)
diff --git a/CommonAPI-Examples/E01HelloWorld/README b/CommonAPI-Examples/E01HelloWorld/README
new file mode 100644
index 0000000..b48e6f2
--- /dev/null
+++ b/CommonAPI-Examples/E01HelloWorld/README
@@ -0,0 +1,150 @@
+=== Example 01: Hello World
+
+This example contains step-by-step instructions how to create the code for the +Hello World+ introductory example of CommonAPI C++. Even this is a CommonAPI tutorial with no references to any special bindings, we give here some hints concerning existing bindings. For a deeper insight please refer to the binding specific tutorials. We assume that you use the Eclipse tool chain and that everything is properly installed as described in the Integration Guide of this tutorial.
+
+The first step in developing a CommonAPI application likely will be the definition of the RMI interface the client will use to communicate with the server. In the context of CommonAPI, the definition of this interface always happens via the Franca IDL, regardless of which communication mechanism you intend to use in the end.
+
+For this tutorial, create an arbitrarily named file ending in _.fidl_ in your Eclipse project (in this case _E01HelloWorld.fidl_). It is not relevant where in your project you have placed this file, as the code generated from this file will always be put in the automatically created src-gen folder at the top level of the project hierarchy.
+
+Open your newly created _E01HelloWorld.fidl_-file, and type the following lines:
+
+[source,java]
+----
+package commonapi.examples
+
+interface E01HelloWorld {
+ version { major 0 minor 1 }
+
+ method sayHello {
+ in {
+ String name
+ }
+ out {
+ String message
+ }
+ }
+}
+----
+
+Now, save the _.fidl_ file and right click it. As you have installed the CommonAPI code generator and further generators for the bindings, you will see a menu item saying _Common API_, with sub menu items for generating the Common API level code only (_Generate C\++ Code_) and for generating the required glue code (e.g. for D-Bus you find _Generate D-Bus C++ Code_).
+
+Now start the code generators. You will find the generated code in the sub-directory +src-gen+.
+
+All files that have a the name of your binding (e.g. _DBus_) in their name are glue code required by the binding and are not relevant while developing your application, they only need to be compiled with your application.
+
+All other files that have a _Proxy_ in their name are relevant for you if you develop a client, all other files that have a _Stub_ in their name are relevant for you if you develop a service. A proxy is a class that provides method calls that will result in remote method invocations on the service, plus registration methods for events that can be broadcasted by the service.
+
+A stub is the part of the service that will be called when a remote method invocation from a client arrives. It also contains methods to fire events (broadcasts) to several or all clients. The stub comes in two flavors: one default stub that contains empty implementations of all methods, thereby allowing you to implement only the ones you are interested in, and a Stub skeleton where you have to implement everything yourself before you can use it. A service will have to implement a subclass of either of the two in order to make itself available to the outside world (or just use the default stub if your service should not be able to do anything except firing events).
+
+In this tutorial, we will create both a client and a service in order to be able to see some communication going on.
+
+Start by implementing the client by creating a new +.cpp+ source file in your project (e.g. _e01HelloWorldClient.cpp_). Make sure you have a main method in order to start the client application.
+
+Here, you will need two includes in order to access the Common API client functionality:
+
+[source,{cppstr}]
+----
+#include <iostream>
+#include <string>
+#include <unistd.h>
+
+#include <CommonAPI/CommonAPI.hpp>
+#include <v0_1/commonapi/examples/E01HelloWorldProxy.hpp>
+----
+
+Please note that you always have to include +CommonAPI.hpp+ for accessing the runtime part of CommonAPI and the generated proxy. If your defined interface has a version number then you will find the version in the namespace of your interface class and in the directory structure.
+
+One of the first things each and every CommonAPI application will do is to get a pointer to the runtime object:
+
+[source,{cppstr}]
+----
+std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get();
+----
+
+Please ignore for this introduction the +CommonAPI::Runtime::setProperty+ calls (refer to the Integration Guide of this tutorial).
+
+In order to be able to communicate with a specific service, we need a proxy:
+
+[source,{cppstr}]
+----
+std::string domain = "local";
+std::string instance = "commonapi.examples.HelloWorld";
+std::string connection = "client-sample";
+
+std::shared_ptr<E01HelloWorldProxyDefault> myProxy = runtime->buildProxy<E01HelloWorldProxy>(domain, instance, connection);
+----
+
+The domain and the instance name determine explicitly together with the generated proxy class as template parameter which stub will be addressed by this proxy. The _connection_ is an optional argument. This argument allows to group several proxies in a so-called connection. Internally a connection corresponds to one receiver thread if there is no mainloop integration.
+
+With the instantiation of the proxy, the client is set up and ready to use. In this example we wait for the service to be available, then we start issuing calls:
+
+[source,{cppstr}]
+----
+while (!myProxy->isAvailable())
+ usleep(10);
+
+
+const std::string name = "World";
+CommonAPI::CallStatus callStatus;
+std::string returnMessage;
+
+while (true) {
+ myProxy->sayHello(name, callStatus, returnMessage);
+ if (callStatus != CommonAPI::CallStatus::SUCCESS) {
+ std::cerr << "Remote call failed!\n";
+ return -1;
+ }
+ std::cout << "Got message: '" << returnMessage << "'\n";
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+}
+----
+
+The implementation of the service works about the same way as implementing the client. The includes that are required are the following:
+
+[source,{cppstr}]
+----
+#include <iostream>
+#include <thread>
+
+#include <CommonAPI/CommonAPI.hpp>
+#include "E01HelloWorldStubImpl.hpp"
+----
+
+In the main function of the service one of the first things to do is to get the runtime object. After that we have to instantiate our stub implementation (here +E01HelloWorldStubImpl+) and then to register it:
+
+[source,{cppstr}]
+----
+std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
+
+std::string domain = "local";
+std::string instance = "commonapi.examples.HelloWorld";
+std::string connection = "service-sample";
+
+std::shared_ptr<E01HelloWorldStubImpl> myService = std::make_shared<E01HelloWorldStubImpl>();
+runtime->registerService(domain, instance, myService, connection);
+
+while (true) {
+ std::cout << "Waiting for calls... (Abort with CTRL+C)" << std::endl;
+ std::this_thread::sleep_for(std::chrono::seconds(60));
+}
+----
+
+The implementation of the generated stub method +sayHello+ looks like:
+
+[source,{cppstr}]
+----
+void E01HelloWorldStubImpl::sayHello(const std::shared_ptr<CommonAPI::ClientId> _client,
+ std::string _name,
+ sayHelloReply_t _reply) {
+
+ std::stringstream messageStream;
+
+ messageStream << "Hello " << _name << "!";
+ std::cout << "sayHello('" << _name << "'): '" << messageStream.str() << "'\n";
+
+ _reply(messageStream.str());
+};
+----
+
+Build the two applications using your favourite build system (e.g. see the CMake files in the example folder). If all worked well, you should see communication ongoing (e.g. via dbus-monitor), and you should get output from your client.
+
diff --git a/CommonAPI-Examples/E01HelloWorld/commonapi4dbus.ini b/CommonAPI-Examples/E01HelloWorld/commonapi4dbus.ini
new file mode 100644
index 0000000..ba5224f
--- /dev/null
+++ b/CommonAPI-Examples/E01HelloWorld/commonapi4dbus.ini
@@ -0,0 +1,8 @@
+[default]
+binding=dbus
+
+[logging]
+console = true
+file = ./mylog.log
+dlt = true
+level = verbose
diff --git a/CommonAPI-Examples/E01HelloWorld/commonapi4someip.ini b/CommonAPI-Examples/E01HelloWorld/commonapi4someip.ini
new file mode 100644
index 0000000..9d2e519
--- /dev/null
+++ b/CommonAPI-Examples/E01HelloWorld/commonapi4someip.ini
@@ -0,0 +1,8 @@
+[default]
+binding=someip
+
+[logging]
+console = true
+file = ./mylog.log
+dlt = true
+level = verbose
diff --git a/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl b/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl
new file mode 100644
index 0000000..4872a22
--- /dev/null
+++ b/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl
@@ -0,0 +1,32 @@
+/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
+import "E01HelloWorld.fidl"
+
+define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E01HelloWorld {
+ SomeIpServiceID = 4660
+
+ method sayHello {
+ SomeIpMethodID = 33000
+
+ in {
+ name {
+ SomeIpStringEncoding = utf16le
+ }
+ }
+ }
+}
+
+define org.genivi.commonapi.someip.deployment for provider Service {
+ instance commonapi.examples.E01HelloWorld {
+ InstanceId = "commonapi.examples.HelloWorld"
+
+ SomeIpInstanceID = 22136
+
+ SomeIpUnicastAddress = "192.168.0.2"
+ SomeIpUnicastPort = 30499
+ }
+} \ No newline at end of file
diff --git a/CommonAPI-Examples/e01HelloWorld/fidl/E01HelloWorld.fidl b/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fidl
index bb48cc3..d1360ba 100644
--- a/CommonAPI-Examples/e01HelloWorld/fidl/E01HelloWorld.fidl
+++ b/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fidl
@@ -1,6 +1,4 @@
-/* Copyright (C) 2014 BMW Group
- * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
- * Author: Juergen Gehring (juergen.gehring@bmw.de)
+/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
diff --git a/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldClient.cpp b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldClient.cpp
new file mode 100644
index 0000000..111fd5f
--- /dev/null
+++ b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldClient.cpp
@@ -0,0 +1,56 @@
+/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <iostream>
+#include <string>
+
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
+#include <CommonAPI/CommonAPI.hpp>
+#include <v0_1/commonapi/examples/E01HelloWorldProxy.hpp>
+
+using namespace v0_1::commonapi::examples;
+
+int main() {
+ CommonAPI::Runtime::setProperty("LogContext", "E01C");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E01HelloWorld");
+
+ std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get();
+
+ std::string domain = "local";
+ std::string instance = "commonapi.examples.HelloWorld";
+ std::string connection = "client-sample";
+
+ std::shared_ptr<E01HelloWorldProxy<>> myProxy = runtime->buildProxy<E01HelloWorldProxy>(domain,
+ instance, connection);
+
+ std::cout << "Checking availability!" << std::endl;
+ while (!myProxy->isAvailable())
+ usleep(10);
+ std::cout << "Available..." << std::endl;
+
+ const std::string name = "World";
+ CommonAPI::CallStatus callStatus;
+ std::string returnMessage;
+
+ CommonAPI::CallInfo info(1000);
+ info.sender_ = 1234;
+
+ while (true) {
+ myProxy->sayHello(name, callStatus, returnMessage, &info);
+ if (callStatus != CommonAPI::CallStatus::SUCCESS) {
+ std::cerr << "Remote call failed!\n";
+ return -1;
+ }
+ info.timeout_ = info.timeout_ + 1000;
+
+ std::cout << "Got message: '" << returnMessage << "'\n";
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+ }
+
+ return 0;
+}
diff --git a/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp
new file mode 100644
index 0000000..f92ae81
--- /dev/null
+++ b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp
@@ -0,0 +1,33 @@
+/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <iostream>
+#include <thread>
+
+#include <CommonAPI/CommonAPI.hpp>
+#include "E01HelloWorldStubImpl.hpp"
+
+using namespace std;
+
+int main() {
+ CommonAPI::Runtime::setProperty("LogContext", "E01S");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E01HelloWorld");
+
+ std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
+
+ std::string domain = "local";
+ std::string instance = "commonapi.examples.HelloWorld";
+ std::string connection = "service-sample";
+
+ std::shared_ptr<E01HelloWorldStubImpl> myService = std::make_shared<E01HelloWorldStubImpl>();
+ runtime->registerService(domain, instance, myService, connection);
+
+ while (true) {
+ std::cout << "Waiting for calls... (Abort with CTRL+C)" << std::endl;
+ std::this_thread::sleep_for(std::chrono::seconds(60));
+ }
+
+ return 0;
+}
diff --git a/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.cpp b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.cpp
new file mode 100644
index 0000000..df13c01
--- /dev/null
+++ b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.cpp
@@ -0,0 +1,24 @@
+/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "E01HelloWorldStubImpl.hpp"
+
+E01HelloWorldStubImpl::E01HelloWorldStubImpl() {
+}
+
+E01HelloWorldStubImpl::~E01HelloWorldStubImpl() {
+}
+
+void E01HelloWorldStubImpl::sayHello(const std::shared_ptr<CommonAPI::ClientId> _client,
+ std::string _name,
+ sayHelloReply_t _reply) {
+
+ std::stringstream messageStream;
+
+ messageStream << "Hello " << _name << "!";
+ std::cout << "sayHello('" << _name << "'): '" << messageStream.str() << "'\n";
+
+ _reply(messageStream.str());
+};
diff --git a/CommonAPI-Examples/e01HelloWorld/src/E01HelloWorldStubImpl.h b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.hpp
index 1079949..83a4112 100644
--- a/CommonAPI-Examples/e01HelloWorld/src/E01HelloWorldStubImpl.h
+++ b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.hpp
@@ -1,6 +1,4 @@
-/* Copyright (C) 2014 BMW Group
- * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
- * Author: Juergen Gehring (juergen.gehring@bmw.de)
+/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@@ -8,15 +6,16 @@
#ifndef E01HELLOWORLDSTUBIMPL_H_
#define E01HELLOWORLDSTUBIMPL_H_
-#include <CommonAPI/CommonAPI.h>
-#include <commonapi/examples/E01HelloWorldStubDefault.h>
+#include <CommonAPI/CommonAPI.hpp>
+#include <v0_1/commonapi/examples/E01HelloWorldStubDefault.hpp>
-class E01HelloWorldStubImpl: public commonapi::examples::E01HelloWorldStubDefault {
+class E01HelloWorldStubImpl: public v0_1::commonapi::examples::E01HelloWorldStubDefault {
public:
E01HelloWorldStubImpl();
virtual ~E01HelloWorldStubImpl();
- virtual void sayHello(const std::shared_ptr<CommonAPI::ClientId> clientId, std::string name, std::string& message);
+
+ virtual void sayHello(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _name, sayHelloReply_t _return);
};
diff --git a/CommonAPI-Examples/E01HelloWorld/vsomeip.json b/CommonAPI-Examples/E01HelloWorld/vsomeip.json
new file mode 100644
index 0000000..60c2f12
--- /dev/null
+++ b/CommonAPI-Examples/E01HelloWorld/vsomeip.json
@@ -0,0 +1,62 @@
+{
+ "unicast" : "192.168.56.101",
+ "logging" :
+ {
+ "level" : "debug",
+ "console" : "true",
+ "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" },
+ "dlt" : "false"
+ },
+ "applications" :
+ [
+ {
+ "name" : "client-sample",
+ "id" : "0x1343"
+ },
+ {
+ "name" : "other-client-sample",
+ "id" : "0x1344"
+ },
+ {
+ "name" : "service-sample",
+ "id" : "0x1277"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "default",
+ "delays" :
+ {
+ "initial" : { "minimum" : "10", "maximum" : "100" },
+ "repetition-base" : "200",
+ "repetition-max" : "3",
+ "cyclic-offer" : "2000",
+ "cyclic-request" : "2001"
+ },
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678",
+ "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" },
+ "unreliable" : "31000"
+ },
+ {
+ "service" : "0x1235",
+ "instance" : "0x5678",
+ "reliable" : { "port" : "30506", "enable-magic-cookies" : false },
+ "unreliable" : "31000"
+ }
+ ]
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/CommonAPI-Examples/E02Attributes/.cproject b/CommonAPI-Examples/E02Attributes/.cproject
new file mode 100644
index 0000000..298f904
--- /dev/null
+++ b/CommonAPI-Examples/E02Attributes/.cproject
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="0.1746289517">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1746289517" moduleId="org.eclipse.cdt.core.settings" name="Default">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1746289517" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
+ <folderInfo id="0.1746289517." name="/" resourcePath="">
+ <toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1278268694" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
+ <targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1278268694.1620791179" name=""/>
+ <builder arguments="-C ${ProjDirPath}/build VERBOSE=0" buildPath="" command="make" id="org.eclipse.cdt.build.core.settings.default.builder.539726246" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.libs.1439841201" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.1972152184" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.181323032" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.564325780" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.249714743" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.562188488" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1928601009" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="e02Attributes.null.774516289" name="e02Attributes"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="0.1746289517">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Default">
+ <resource resourceType="PROJECT" workspacePath="/e02Attributes"/>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+ <buildTargets>
+ <target name="Run cmake" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+ <buildCommand>cmake</buildCommand>
+ <buildArguments>-E chdir build/ cmake -D CMAKE_BUILD_TYPE=Debug -DUSE_INSTALLED_COMMONAPI=OFF -DUSE_INSTALLED_DBUS=OFF ../</buildArguments>
+ <buildTarget/>
+ <stopOnError>true</stopOnError>
+ <useDefaultCommand>false</useDefaultCommand>
+ <runAllBuilders>true</runAllBuilders>
+ </target>
+ </buildTargets>
+ </storageModule>
+</cproject>
diff --git a/CommonAPI-Examples/e01HelloWorld/.gitignore b/CommonAPI-Examples/E02Attributes/.gitignore
index 5897208..5897208 100644
--- a/CommonAPI-Examples/e01HelloWorld/.gitignore
+++ b/CommonAPI-Examples/E02Attributes/.gitignore
diff --git a/CommonAPI-Examples/E02Attributes/.project b/CommonAPI-Examples/E02Attributes/.project
new file mode 100644
index 0000000..851b8a1
--- /dev/null
+++ b/CommonAPI-Examples/E02Attributes/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>E02Attributes</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/CommonAPI-Examples/E02Attributes/CMakeLists.txt b/CommonAPI-Examples/E02Attributes/CMakeLists.txt
new file mode 100644
index 0000000..7da893e
--- /dev/null
+++ b/CommonAPI-Examples/E02Attributes/CMakeLists.txt
@@ -0,0 +1,103 @@
+# Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+cmake_minimum_required(VERSION 2.8)
+
+set(PRJ_NAME E02Attributes)
+
+set(CMAKE_VERBOSE_MAKEFILE on)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP")
+
+message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}")
+
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
+ "Choose the type of build, options are: Debug Release." FORCE)
+endif(NOT CMAKE_BUILD_TYPE)
+message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
+
+OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version of CommonAPI" ON)
+message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}")
+
+if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON")
+ FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+else()
+ FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+endif()
+
+message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
+message(STATUS "COMMONAPI_INCLUDE_DIRS: ${COMMONAPI_INCLUDE_DIRS}")
+message(STATUS "CommonAPI-DBus_CONSIDERED_CONFIGS: ${CommonAPI-DBus_CONSIDERED_CONFIGS}")
+message(STATUS "COMMONAPI_DBUS_INCLUDE_DIRS: ${COMMONAPI_DBUS_INCLUDE_DIRS}")
+
+# CommonAPI
+include(FindPkgConfig)
+###############################################################################
+# find DBus by using the 'pkg-config' tool
+if (MSVC)
+ #Not beautiful, but it works
+ if (DBus_DIR)
+ if (DBus_BUILD_DIR)
+ set(DBUS_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};")
+ else ()
+ message (FATAL_ERROR "DBus_BUILD_DIR not set! Cannot continue.")
+ endif ()
+ else()
+ message (FATAL_ERROR "DBus_DIR not set! Cannot continue.")
+ endif ()
+else()
+ pkg_check_modules(DBus REQUIRED dbus-1>=1.4)
+endif()
+
+# Source Files
+set(PRJ_SRC_PATH src)
+set(PRJ_SRC_GEN_PATH src-gen/v1_0/commonapi/examples)
+
+set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
+set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
+
+FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp)
+FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/CommonTypes.cpp)
+FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
+
+set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
+set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
+
+# Paths
+OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON)
+message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}")
+
+include_directories(
+ src-gen
+ ${COMMONAPI_INCLUDE_DIRS}
+ ${COMMONAPI_DBUS_INCLUDE_DIRS}
+ ${DBUS_INCLUDE_DIRS}
+)
+
+if ("${USE_INSTALLED_DBUS}" STREQUAL "ON")
+link_directories(
+ ${COMMONAPI_LIBDIR}
+ ${COMMONAPI_DBUS_LIBDIR}
+ ${DBUS_LIBDIR}
+)
+else()
+link_directories(
+ ${COMMONAPI_LIBDIR}
+ ${COMMONAPI_DBUS_LIBDIR}
+ ${DBUS_INCLUDE_DIRS}/dbus/.libs
+)
+endif()
+
+set(LINK_LIBRARIES -Wl,--no-as-needed CommonAPI-DBus -Wl,--as-needed CommonAPI ${DBUS_LIBRARIES})
+
+# Build Client
+add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
+target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES})
+
+# Build service
+add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
+target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES})
diff --git a/CommonAPI-Examples/E02Attributes/README b/CommonAPI-Examples/E02Attributes/README
new file mode 100644
index 0000000..25c13ce
--- /dev/null
+++ b/CommonAPI-Examples/E02Attributes/README
@@ -0,0 +1,131 @@
+=== Example 02: Attributes
+
+Consider the Franca IDL specification of example 2:
+
+[source,java]
+----
+package commonapi.examples
+
+interface E02Attributes {
+ version { major 1 minor 0 }
+
+ attribute Int32 x
+ attribute CommonTypes.a1Struct a1
+}
+
+typeCollection CommonTypes {
+ version { major 1 minor 0 }
+
+ struct a1Struct {
+ String s
+ a2Struct a2
+ }
+
+ struct a2Struct {
+ Int32 a
+ Boolean b
+ Double d
+ }
+}
+----
+
+Modelling attributes in interfaces means in general that the service that implements this interface has an internal state which shall be visible for external clients like a HMI (Human Machine Interface). A developer of a client would normally expect that he can set and get the attribute and that he can notify or subscribe to changes of the value of the attribute. We will see below in the implementation how exactly this is realized by CommonAPI. Franca offers two key words that indicate exactly how the attribute can be accessed: +readonly+ and +noSubscriptions+. The default setting is that everything is allowed; with these two additional key words these possibilities can be limited (e.g. if someone tries to call a set method and the attribute is +readonly+ he will get an error at compile time).
+
+The nested structure +a1Struct+ is defined in a type collection +CommonTypes+. Structures can be defined just like other type definitions within an interface definition or outside in a type collection. Since Franca 0.8.9 type collections can also be anonymous (without name). A type collection is transferred by the CommonAPI code generator in an additional namespace.
+
+The Franca interface specification of attributes does not contain any information about whether the access from client side is synchronous or asynchronous or whether the attribute is cached by the proxy. CommonAPI provides always methods for synchronous and asynchronous setter and getter methods; caching can be realized via an API extension.
+
+Now let's have a look to the CommonAPI code on the service side. The default implementation of the stub which is generated by the CommonAPI code generator defines the attribute as private attribute of the stub class. This attribute can be accessed from the stub implementation via getter and setter functions. Additionally the API for the stub implementation provides some callbacks (the following code snippet shows parts of the generated header of the stub class which refer to the attribute x):
+
+[source,{cppstr}]
+----
+class E02AttributesStubDefault : public virtual E02AttributesStub {
+public:
+ /* some other code here */
+ virtual const int32_t& getXAttribute();
+ virtual const int32_t& getXAttribute(const std::shared_ptr<CommonAPI::ClientId> _client);
+ virtual void setXAttribute(int32_t _value);
+ virtual void setXAttribute(const std::shared_ptr<CommonAPI::ClientId> _client, int32_t _value);
+
+protected:
+ /* some other code here */
+ virtual bool trySetXAttribute(int32_t _value);
+ virtual bool validateXAttributeRequestedValue(const int32_t &_value);
+ virtual void onRemoteXAttributeChanged();
+
+private:
+ /* some other code here */
+ int32_t xAttributeValue_;
+};
+----
+
+If the implementation of the stub has to change the value of the attribute +x+, let's say in a class +E02AttributesStubImpl+ that is derived from +E02AttributesStubDefault+, then it can call +setXAttribute+ (analog the usage of +getXAttribute+). The callback +onRemoteXAttributeChanged+ informs that a change of the attribute +x+ has been completed. The other callbacks can prevent the set of the attribute (+validateXAttributeRequestedValue+) or change the given value from the client (+trySetXAttribute+).
+
+In the example the service increments a counter every 2 seconds and publishes the counter value via the interface attribute +x+.
+
+Now see the implementation of the client. The simplest case is to get the current value of +x+. The following extract shows one part of the main function:
+
+[source,{cppstr}]
+----
+#include <iostream>
+#include <unistd.h>
+
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1_0/commonapi/examples/E02AttributesProxy.hpp>
+
+#include "AttributeCacheExtension.hpp"
+
+using namespace v1_0::commonapi::examples;
+
+int main() {
+
+ std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get();
+ std::string domain = "local";
+ std::string instance = "commonapi.examples.Attributes";
+
+ std::shared_ptr<CommonAPI::DefaultAttributeProxyHelper<E02AttributesProxy,
+ AttributeCacheExtension>::class_t> myProxy =
+ runtime->buildProxyWithDefaultAttributeExtension<E02AttributesProxy,
+ AttributeCacheExtension>(domain, instance);
+
+ while (!myProxy->isAvailable()) {
+ usleep(10);
+ }
+
+ CommonAPI::CallStatus callStatus;
+
+ int32_t value = 0;
+ myProxy->getXAttribute().getValue(callStatus, value);
+ std::cout << "Got attribute value: " << value << std::endl;
+
+ myProxy->getXAttribute().getChangedEvent().subscribe([&](const int32_t& val) {
+ std::cout << "Received change message: " << val << std::endl;
+ });
+
+ value = 100;
+ std::function<void(const CommonAPI::CallStatus&, int32_t)> fcb = recv_cb;
+ myProxy->getXAttribute().setValueAsync(value, fcb);
+
+ while (true) { usleep(1000000); }
+}
+----
+
+The +getXAttribute+ method will deliver the type +XAttribute+ which has to be used for the access to +x+. Every access returns a flag named callStatus (please see the CommonAPI specification). Subscription requires in general the definition of a callback function which is called in case of an attribute change. The subscribe method of CommonAPI requires a function object; for a compact notation this function object can be defined as lambda function.
+
+Of course it is also possible to define a separate callback function with an user-defined name (here recv_cb) as can be seen at the asynchronous set call for the attribute +x+:
+
+[source,{cppstr}]
+----
+void recv_cb(const CommonAPI::CallStatus& callStatus, const int32_t& val) {
+ std::cout << "Receive callback: " << val << std::endl;
+}
+
+.... // main method
+
+value = 100;
+std::function<void(const CommonAPI::CallStatus&, int32_t)> fcb = recv_cb;
+myProxy->getXAttribute().setValueAsync(value, fcb);
+----
+
+This example uses a special feature of CommonAPI which is called _Attribute Extension_. This feature is described separately. At this point we do not want to go into more detail. Please see the source code of the example for a deeper insight.
+
diff --git a/CommonAPI-Examples/E02Attributes/fidl/E02Attributes.fdepl b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes.fdepl
new file mode 100644
index 0000000..6ff6efd
--- /dev/null
+++ b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes.fdepl
@@ -0,0 +1,11 @@
+/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+import "platform:/plugin/org.genivi.commonapi.dbus/deployment/CommonAPI-DBus_deployment.fdepl"
+import "E02Attributes.fidl"
+
+define org.genivi.commonapi.dbus.deployment for interface commonapi.examples.E02Attributes {
+ PropertiesType = freedesktop
+} \ No newline at end of file
diff --git a/CommonAPI-Examples/e02Attributes/fidl/E02Attributes.fidl b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes.fidl
index ff2ad7d..dd47949 100644
--- a/CommonAPI-Examples/e02Attributes/fidl/E02Attributes.fidl
+++ b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes.fidl
@@ -1,6 +1,4 @@
-/* Copyright (C) 2014 BMW Group
- * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
- * Author: Juergen Gehring (juergen.gehring@bmw.de)
+/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@@ -11,18 +9,19 @@ interface E02Attributes {
version { major 1 minor 0 }
attribute Int32 x
-
attribute CommonTypes.a1Struct a1
}
typeCollection CommonTypes {
-
+ version { major 1 minor 0 }
+
struct a1Struct {
String s
a2Struct a2
}
struct a2Struct {
+ Int32 a
Boolean b
Double d
}
diff --git a/CommonAPI-Examples/e02Attributes/src/AttributeCacheExtension.hpp b/CommonAPI-Examples/E02Attributes/src/AttributeCacheExtension.hpp
index d9a7870..85e414a 100644
--- a/CommonAPI-Examples/e02Attributes/src/AttributeCacheExtension.hpp
+++ b/CommonAPI-Examples/E02Attributes/src/AttributeCacheExtension.hpp
@@ -1,11 +1,9 @@
-/* Copyright (C) 2014 BMW Group
- * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
- * Author: Juergen Gehring (juergen.gehring@bmw.de)
+/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include <CommonAPI/CommonAPI.h>
+#include <CommonAPI/CommonAPI.hpp>
template<typename _AttributeType>
class AttributeCacheExtension: public CommonAPI::AttributeExtension<_AttributeType> {
diff --git a/CommonAPI-Examples/e02Attributes/src/e02AttributesClient.cpp b/CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp
index a8ac509..e51eea7 100644
--- a/CommonAPI-Examples/e02Attributes/src/e02AttributesClient.cpp
+++ b/CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp
@@ -1,37 +1,37 @@
-/* Copyright (C) 2014 BMW Group
- * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
- * Author: Juergen Gehring (juergen.gehring@bmw.de)
+/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <iostream>
+#include <unistd.h>
-#include <CommonAPI/CommonAPI.h>
-#include <commonapi/examples/E02AttributesProxy.h>
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1_0/commonapi/examples/E02AttributesProxy.hpp>
#include "AttributeCacheExtension.hpp"
-using namespace commonapi::examples;
+using namespace v1_0::commonapi::examples;
void recv_cb(const CommonAPI::CallStatus& callStatus, const int32_t& val) {
std::cout << "Receive callback: " << val << std::endl;
}
void recv_cb_s(const CommonAPI::CallStatus& callStatus, const CommonTypes::a1Struct& valStruct) {
- std::cout << "Receive callback for structure: a1.s = " << valStruct.s << ", valStruct.a2.d = " << valStruct.a2.d
- << std::endl;
+ std::cout << "Receive callback for structure: a1.s = " << valStruct.getS()
+ << ", valStruct.a2.b = " << (valStruct.getA2().getB() ? "TRUE" : "FALSE")
+ << ", valStruct.a2.d = " << valStruct.getA2().getD()
+ << std::endl;
}
int main() {
- std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::load();
+ std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get();
- std::shared_ptr < CommonAPI::Factory > factory = runtime->createFactory();
- const std::string& serviceAddress = "local:commonapi.examples.Attributes:commonapi.examples.Attributes";
- //std::shared_ptr < E02AttributesProxyDefault > myProxy = factory->buildProxy < E02AttributesProxy > (serviceAddress);
- std::shared_ptr<CommonAPI::DefaultAttributeProxyFactoryHelper<E02AttributesProxy, AttributeCacheExtension>::class_t> myProxy =
- factory->buildProxyWithDefaultAttributeExtension<E02AttributesProxy, AttributeCacheExtension>(serviceAddress);
+ std::string domain = "local";
+ std::string instance = "commonapi.examples.Attributes";
+ std::shared_ptr<CommonAPI::DefaultAttributeProxyHelper<E02AttributesProxy, AttributeCacheExtension>::class_t> myProxy =
+ runtime->buildProxyWithDefaultAttributeExtension<E02AttributesProxy, AttributeCacheExtension>(domain, instance);
while (!myProxy->isAvailable()) {
usleep(10);
@@ -41,8 +41,12 @@ int main() {
int32_t value = 0;
+ CommonAPI::CallInfo info(1000);
+ info.sender_ = 5678;
+
// Get actual attribute value from service
- myProxy->getXAttribute().getValue(callStatus, value);
+ std::cout << "Getting attribute value: " << value << std::endl;
+ myProxy->getXAttribute().getValue(callStatus, value, &info);
if (callStatus != CommonAPI::CallStatus::SUCCESS) {
std::cerr << "Remote call A failed!\n";
return -1;
@@ -54,35 +58,32 @@ int main() {
std::cout << "Received change message: " << val << std::endl;
});
+ myProxy->getA1Attribute().getChangedEvent().subscribe([&](const CommonTypes::a1Struct& val) {
+ std::cout << "Received change message for A1" << std::endl;
+ });
+
value = 100;
// Asynchronous call to set attribute of service
std::function<void(const CommonAPI::CallStatus&, int32_t)> fcb = recv_cb;
- myProxy->getXAttribute().setValueAsync(value, fcb);
- if (callStatus != CommonAPI::CallStatus::SUCCESS) {
- std::cerr << "Remote call failed!\n";
- return -1;
- }
+ myProxy->getXAttribute().setValueAsync(value, fcb, &info);
// Asynchronous call to set attribute of type structure in service
CommonTypes::a1Struct valueStruct;
- valueStruct.s = "abc";
- valueStruct.a2.b = true;
- valueStruct.a2.d = 1234;
+ valueStruct.setS("abc");
+ CommonTypes::a2Struct a2Struct = valueStruct.getA2();
+ a2Struct.setA(123);
+ a2Struct.setB(true);
+ a2Struct.setD(1234);
+ valueStruct.setA2(a2Struct);
std::function<void(const CommonAPI::CallStatus&, CommonTypes::a1Struct)> fcb_s = recv_cb_s;
- myProxy->getA1Attribute().setValueAsync(valueStruct, fcb_s);
- if (callStatus != CommonAPI::CallStatus::SUCCESS) {
- std::cerr << "Remote set of structure failed!\n";
- return -1;
- }
+ myProxy->getA1Attribute().setValueAsync(valueStruct, fcb_s, &info);
while (true) {
-
int32_t valueCached = 0;
- bool r;
- r = myProxy->getXAttributeExtension().getCachedValue(valueCached);
+ bool r = myProxy->getXAttributeExtension().getCachedValue(valueCached);
std::cout << "Got cached attribute value[" << (int)r << "]: " << valueCached << std::endl;
usleep(1000000);
}
diff --git a/CommonAPI-Examples/e02Attributes/src/e02AttributesService.cpp b/CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp
index 8636a6e..60c743d 100644
--- a/CommonAPI-Examples/e02Attributes/src/e02AttributesService.cpp
+++ b/CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp
@@ -1,6 +1,4 @@
-/* Copyright (C) 2014 BMW Group
- * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
- * Author: Juergen Gehring (juergen.gehring@bmw.de)
+/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@@ -8,23 +6,22 @@
#include <thread>
#include <iostream>
-#include <CommonAPI/CommonAPI.h>
-#include "E02AttributesStubImpl.h"
+#include <CommonAPI/CommonAPI.hpp>
+#include "E02AttributesStubImpl.hpp"
int main() {
- std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
- std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory();
- std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher = runtime->getServicePublisher();
+ std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
+
+ std::string domain = "local";
+ std::string instance = "commonapi.examples.Attributes";
- const std::string& serviceAddress = "local:commonapi.examples.Attributes:commonapi.examples.Attributes";
std::shared_ptr<E02AttributesStubImpl> myService = std::make_shared<E02AttributesStubImpl>();
- servicePublisher->registerService(myService, serviceAddress, factory);
+ runtime->registerService(domain, instance, myService);
while (true) {
myService->incCounter(); // Change value of attribute, see stub implementation
std::cout << "Waiting for calls... (Abort with CTRL+C)" << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(2));
}
-
return 0;
}
diff --git a/CommonAPI-Examples/e02Attributes/src/E02AttributesStubImpl.cpp b/CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.cpp
index b43d92d..2eb226c 100644
--- a/CommonAPI-Examples/e02Attributes/src/E02AttributesStubImpl.cpp
+++ b/CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.cpp
@@ -1,11 +1,9 @@
-/* Copyright (C) 2014 BMW Group
- * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
- * Author: Juergen Gehring (juergen.gehring@bmw.de)
+/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include "E02AttributesStubImpl.h"
+#include "E02AttributesStubImpl.hpp"
E02AttributesStubImpl::E02AttributesStubImpl() {
cnt = 0;
diff --git a/CommonAPI-Examples/e02Attributes/src/E02AttributesStubImpl.h b/CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.hpp
index d415e77..655a094 100644
--- a/CommonAPI-Examples/e02Attributes/src/E02AttributesStubImpl.h
+++ b/CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.hpp
@@ -1,6 +1,4 @@
-/* Copyright (C) 2014 BMW Group
- * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
- * Author: Juergen Gehring (juergen.gehring@bmw.de)
+/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@@ -8,10 +6,10 @@
#ifndef E02ATTRIBUTESSTUBIMPL_H_
#define E02ATTRIBUTESSTUBIMPL_H_
-#include <CommonAPI/CommonAPI.h>
-#include <commonapi/examples/E02AttributesStubDefault.h>
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1_0/commonapi/examples/E02AttributesStubDefault.hpp>
-class E02AttributesStubImpl: public commonapi::examples::E02AttributesStubDefault {
+class E02AttributesStubImpl: public v1_0::commonapi::examples::E02AttributesStubDefault {
public:
E02AttributesStubImpl();
diff --git a/CommonAPI-Examples/E03Methods/.cproject b/CommonAPI-Examples/E03Methods/.cproject
new file mode 100644
index 0000000..531d398
--- /dev/null
+++ b/CommonAPI-Examples/E03Methods/.cproject
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="0.1261797899">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1261797899" moduleId="org.eclipse.cdt.core.settings" name="Default">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1261797899" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
+ <folderInfo id="0.1261797899." name="/" resourcePath="">
+ <toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.916883626" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
+ <targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.916883626.1691131813" name=""/>
+ <builder arguments="-C ${ProjDirPath}/build VERBOSE=0" buildPath="" command="make" id="org.eclipse.cdt.build.core.settings.default.builder.139656539" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.libs.1226446792" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.1436039019" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.995571325" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.702818460" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1872641988" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.538650938" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1863646962" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="e03Methods.null.1943542015" name="e03Methods"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="0.1261797899">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Default">
+ <resource resourceType="PROJECT" workspacePath="/e03Methods"/>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+ <buildTargets>
+ <target name="Run cmake" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+ <buildCommand>cmake</buildCommand>
+ <buildArguments>-E chdir build/ cmake -D CMAKE_BUILD_TYPE=Debug -DUSE_INSTALLED_COMMONAPI=OFF -DUSE_INSTALLED_DBUS=OFF ../</buildArguments>
+ <buildTarget/>
+ <stopOnError>true</stopOnError>
+ <useDefaultCommand>false</useDefaultCommand>
+ <runAllBuilders>true</runAllBuilders>
+ </target>
+ </buildTargets>
+ </storageModule>
+</cproject>
diff --git a/CommonAPI-Examples/e02Attributes/.gitignore b/CommonAPI-Examples/E03Methods/.gitignore
index 5897208..5897208 100644
--- a/CommonAPI-Examples/e02Attributes/.gitignore
+++ b/CommonAPI-Examples/E03Methods/.gitignore
diff --git a/CommonAPI-Examples/E03Methods/.project b/CommonAPI-Examples/E03Methods/.project
new file mode 100644
index 0000000..fe125d0
--- /dev/null
+++ b/CommonAPI-Examples/E03Methods/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>E03Methods</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/CommonAPI-Examples/E03Methods/CMakeLists.txt b/CommonAPI-Examples/E03Methods/CMakeLists.txt
new file mode 100644
index 0000000..5640fea
--- /dev/null
+++ b/CommonAPI-Examples/E03Methods/CMakeLists.txt
@@ -0,0 +1,105 @@
+# Copyright (C) 2014, 2015 BMW Group
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+cmake_minimum_required(VERSION 2.8)
+
+set(PRJ_NAME E03Methods)
+
+set(CMAKE_VERBOSE_MAKEFILE on)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP")
+
+message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}")
+
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
+ "Choose the type of build, options are: Debug Release." FORCE)
+endif(NOT CMAKE_BUILD_TYPE)
+message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
+
+OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version of CommonAPI" ON)
+message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}")
+
+if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON")
+ FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+else()
+ FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+endif()
+
+message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
+message(STATUS "COMMONAPI_INCLUDE_DIRS: ${COMMONAPI_INCLUDE_DIRS}")
+message(STATUS "CommonAPI-DBus_CONSIDERED_CONFIGS: ${CommonAPI-DBus_CONSIDERED_CONFIGS}")
+message(STATUS "COMMONAPI_DBUS_INCLUDE_DIRS: ${COMMONAPI_DBUS_INCLUDE_DIRS}")
+
+# CommonAPI
+include(FindPkgConfig)
+###############################################################################
+# find DBus by using the 'pkg-config' tool
+if (MSVC)
+ #Not beautiful, but it works
+ if (DBus_DIR)
+ if (DBus_BUILD_DIR)
+ set(DBUS_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};")
+ else ()
+ message (FATAL_ERROR "DBus_BUILD_DIR not set! Cannot continue.")
+ endif ()
+ else()
+ message (FATAL_ERROR "DBus_DIR not set! Cannot continue.")
+ endif ()
+else()
+ pkg_check_modules(DBus REQUIRED dbus-1>=1.4)
+endif()
+
+# Source Files
+set(PRJ_SRC_PATH src)
+set(PRJ_SRC_GEN_PATH src-gen/core/v1_2/commonapi/examples)
+set(PRJ_DBUS_SRC_GEN_PATH src-gen/dbus/v1_2/commonapi/examples)
+
+set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
+set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
+
+FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_DBUS_SRC_GEN_PATH}/*Proxy.cpp)
+FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_DBUS_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp)
+FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
+
+set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
+set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
+
+# Paths
+OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON)
+message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}")
+
+include_directories(
+ src-gen/core
+ src-gen/dbus
+ ${COMMONAPI_INCLUDE_DIRS}
+ ${COMMONAPI_DBUS_INCLUDE_DIRS}
+ ${DBUS_INCLUDE_DIRS}
+)
+
+if ("${USE_INSTALLED_DBUS}" STREQUAL "ON")
+link_directories(
+ ${COMMONAPI_LIBDIR}
+ ${COMMONAPI_DBUS_LIBDIR}
+ ${DBUS_LIBDIR}
+)
+else()
+link_directories(
+ ${COMMONAPI_LIBDIR}
+ ${COMMONAPI_DBUS_LIBDIR}
+ ${DBUS_INCLUDE_DIRS}/dbus/.libs
+)
+endif()
+
+set(LINK_LIBRARIES -Wl,--no-as-needed CommonAPI-DBus -Wl,--as-needed CommonAPI ${DBUS_LIBRARIES})
+
+# Build Client
+add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
+target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES})
+
+# Build service
+add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
+target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES})
diff --git a/CommonAPI-Examples/e03Methods/README b/CommonAPI-Examples/E03Methods/README
index 1216224..70488d3 100644
--- a/CommonAPI-Examples/e03Methods/README
+++ b/CommonAPI-Examples/E03Methods/README
@@ -1,7 +1,6 @@
-Example 3: Methods
-~~~~~~~~~~~~~~~~~~
+=== Example 03: Methods
-Franca attributes represent status variables or data sets of services which shall be accessible by the clients of the service. In contrast, methods can be used for example to start a process in the service or to query for certain information (eg, from a database). See the following example 3:
+Franca attributes represent status variables or data sets of services which shall be accessible by the clients of the service. In contrast, methods can be used for example to start a process in the service or to query for certain information (e.g., from a database). See the following example 3:
[source,java]
----
@@ -9,7 +8,7 @@ package commonapi.examples
interface E03Methods {
- version { major 1 minor 0 }
+ version { major 1 minor 2 }
method foo {
in {
@@ -22,7 +21,7 @@ interface E03Methods {
}
error {
stdErrorTypeEnum
- }
+ }
}
broadcast myStatus {
@@ -38,7 +37,7 @@ interface E03Methods {
}
----
-Basically Franca methods have input parameters and output parameters and can return an optional application error which reports for example if the started process in the sevice could be finished successfully or not. Input and output parameters can have arbitrarily complex types, a separate definition of so-called InOut arguments of functions was not considered necessary.
+Basically Franca methods have input parameters and output parameters and can return an optional application error which reports for example if the started process in the service could be finished successfully or not. Input and output parameters can have arbitrarily complex types, a separate definition of so-called InOut arguments of functions was not considered necessary.
A special case are broadcasts. They can be used like readonly attributes. But there are several output parameters allowed (and no input parameters). Another difference is the additional optional keyword selective, which indicates that only selected clients can register on the broadcast see example 4).
@@ -48,48 +47,62 @@ The implementation of the service class is straight:
[source,{cppstr}]
----
-#include "E03MethodsStubImpl.h"
-
-using namespace commonapi::examples;
-
-... // Additional code
-
-void E03MethodsStubImpl::foo(int32_t x1, std::string x2,
- E03Methods::fooError& methodError, int32_t& y1, std::string& y2) {
-
- std::cout << "foo called, setting new values." << std::endl;
-
- methodError = (E03Methods::fooError)E03Methods::stdErrorTypeEnum::MY_FAULT;
- y1 = 42;
- y2 = "xyz";
+void E03MethodsStubImpl::foo(const std::shared_ptr<CommonAPI::ClientId> _client,
+ int32_t _x1,
+ std::string _x2,
+ fooReply_t _reply) {
+
+
+ E03Methods::fooError methodError = (E03Methods::fooError)
+
+ E03Methods::stdErrorTypeEnum::MY_FAULT;
+ int32_t y1 = 42;
+ std::string y2 = "xyz";
+ _reply(methodError, y1, y2);
}
----
-The input parameters are available as values, the output parameter as references. The standard name for the application error is methodError. In the example there is another function incCounter implemented which sends the broadcast myStatus via the generated method fireMyStatusEvent:
+The input parameters are available as values, the output parameter are wrapped in a generated reply object with the type fooReply_t. This is slightly different to earlier versions of CommonAPI where the return values were passed as references.
+
+In the example there is another function incCounter implemented which sends the broadcast myStatus via the generated method fireMyStatusEvent:
[source,{cppstr}]
----
void E03MethodsStubImpl::incCounter() {
- cnt++;
- fireMyStatusEvent((int32_t)cnt);
- std::cout << "New counter value = " << cnt << "!" << std::endl;
-};
+ cnt++;
+ fireMyStatusEvent((int32_t) cnt);
+}
----
+
The subscription to the broadcast is nearly identical to the subscription to the change of the value of an attribute. The example shows further an asynchronous and a synchronous call of the function foo; in the asynchronous case the callback function +recv_cb+ is defined.
[source,{cppstr}]
----
#include <iostream>
-
-#include <CommonAPI/CommonAPI.h>
-#include <commonapi/examples/E03MethodsProxy.h>
-
-using namespace commonapi::examples;
-
-void recv_cb(const CommonAPI::CallStatus& callStatus, const E03Methods::fooError& methodError,
- const int32_t& y1, const std::string& y2) {
-
-... // your code
+#include <unistd.h>
+
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1_2/commonapi/examples/E03MethodsProxy.hpp>
+
+using namespace v1_2::commonapi::examples;
+
+void recv_cb(const CommonAPI::CallStatus& callStatus,
+ const E03Methods::fooError& methodError,
+ const int32_t& y1,
+ const std::string& y2) {
+
+ std::cout << "Result of asynchronous call of foo: " << std::endl;
+
+ std::cout << " callStatus: "
+ << ((callStatus == CommonAPI::CallStatus::SUCCESS) ? "SUCCESS" : "NO_SUCCESS")
+ << std::endl;
+
+ std::cout << " error: "
+ << ((methodError.stdErrorTypeEnum ==
+ E03Methods::stdErrorTypeEnum::NO_FAULT) ? "NO_FAULT" : "MY_FAULT")
+ << std::endl;
+
+ std::cout << " Output values: y1 = " << y1 << ", y2 = " << y2 << std::endl;
}
int main() {
@@ -131,5 +144,5 @@ A frequently asked question is what happens if the service does not answer. In t
- *NOT* considered to be a remote error is an application level error that is defined in the corresponding Franca interface, because from the point of view of the transport layer the service still returned a valid answer.
- It *IS* considered to be a remote error if no answer for a sent remote method call is returned within a defined time. It is discouraged to allow the sending of any method calls without a defined timeout. This timeout may be middleware specific. This timeout may also be configurable by means of a Franca Deployment Model. It is *NOT* configurable at runtime by means of the Common API.
-The actual version of the D-Bus binding has a non configurable timeout of about 5 seconds.
+The timeout of function calls can be set by the optional +CallInfo+ argument on client side.
diff --git a/CommonAPI-Examples/E03Methods/fidl/E03Methods.fdepl b/CommonAPI-Examples/E03Methods/fidl/E03Methods.fdepl
new file mode 100644
index 0000000..eb5d918
--- /dev/null
+++ b/CommonAPI-Examples/E03Methods/fidl/E03Methods.fdepl
@@ -0,0 +1,8 @@
+import "platform:/plugin/org.genivi.commonapi.dbus/deployment/CommonAPI-DBus_deployment.fdepl"
+import "E03Methods.fidl"
+
+define org.genivi.commonapi.dbus.deployment for interface commonapi.examples.E03Methods {
+ method foo {
+ Timeout = 1234
+ }
+} \ No newline at end of file
diff --git a/CommonAPI-Examples/e03Methods/fidl/E03Methods.fidl b/CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl
index 9c6c93e..edf8dc6 100644
--- a/CommonAPI-Examples/e03Methods/fidl/E03Methods.fidl
+++ b/CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl
@@ -9,7 +9,7 @@ package commonapi.examples
interface E03Methods {
- version { major 1 minor 0 }
+ version { major 1 minor 2 }
method foo {
in {
diff --git a/CommonAPI-Examples/e03Methods/src/e03MethodsClient.cpp b/CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp
index f5b4426..0c6bc56 100644
--- a/CommonAPI-Examples/e03Methods/src/e03MethodsClient.cpp
+++ b/CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2014 BMW Group
+/* Copyright (C) 2014, 2015 BMW Group
* Author: Manfred Bathelt (manfred.bathelt@bmw.de)
* Author: Juergen Gehring (juergen.gehring@bmw.de)
* This Source Code Form is subject to the terms of the Mozilla Public
@@ -7,10 +7,14 @@
#include <iostream>
-#include <CommonAPI/CommonAPI.h>
-#include <commonapi/examples/E03MethodsProxy.h>
+#ifndef WIN32
+#include <unistd.h>
+#endif
-using namespace commonapi::examples;
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1_2/commonapi/examples/E03MethodsProxy.hpp>
+
+using namespace v1_2::commonapi::examples;
void recv_cb(const CommonAPI::CallStatus& callStatus,
const E03Methods::fooError& methodError,
@@ -20,17 +24,18 @@ void recv_cb(const CommonAPI::CallStatus& callStatus,
std::cout << " callStatus: " << ((callStatus == CommonAPI::CallStatus::SUCCESS) ? "SUCCESS" : "NO_SUCCESS")
<< std::endl;
std::cout << " error: "
- << (((E03Methods::stdErrorTypeEnum) methodError == E03Methods::stdErrorTypeEnum::NO_FAULT) ? "NO_FAULT" :
+ << ((methodError.stdErrorTypeEnum == E03Methods::stdErrorTypeEnum::NO_FAULT) ? "NO_FAULT" :
"MY_FAULT") << std::endl;
std::cout << " Output values: y1 = " << y1 << ", y2 = " << y2 << std::endl;
}
int main() {
- std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
+ std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
+
+ std::string domain = "local";
+ std::string instance = "commonapi.examples.Methods";
- std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory();
- const std::string& serviceAddress = "local:commonapi.examples.Methods:commonapi.examples.Methods";
- std::shared_ptr<E03MethodsProxyDefault> myProxy = factory->buildProxy < E03MethodsProxy > (serviceAddress);
+ std::shared_ptr<E03MethodsProxy<>> myProxy = runtime->buildProxy < E03MethodsProxy > (domain, instance);
while (!myProxy->isAvailable()) {
usleep(10);
@@ -57,7 +62,7 @@ int main() {
std::cout << " callStatus: " << ((callStatus == CommonAPI::CallStatus::SUCCESS) ? "SUCCESS" : "NO_SUCCESS")
<< std::endl;
std::cout << " error: "
- << (((E03Methods::stdErrorTypeEnum) methodError == E03Methods::stdErrorTypeEnum::NO_FAULT) ? "NO_FAULT" : "MY_FAULT")
+ << ((methodError.stdErrorTypeEnum == E03Methods::stdErrorTypeEnum::NO_FAULT) ? "NO_FAULT" : "MY_FAULT")
<< std::endl;
std::cout << " Input values: x1 = " << inX1 << ", x2 = " << inX2 << std::endl;
std::cout << " Output values: y1 = " << outY1 << ", y2 = " << outY2 << std::endl;
diff --git a/CommonAPI-Examples/e03Methods/src/e03MethodsService.cpp b/CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp
index 71003bc..7c9528c 100644
--- a/CommonAPI-Examples/e03Methods/src/e03MethodsService.cpp
+++ b/CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2014 BMW Group
+/* Copyright (C) 2014, 2015 BMW Group
* Author: Manfred Bathelt (manfred.bathelt@bmw.de)
* Author: Juergen Gehring (juergen.gehring@bmw.de)
* This Source Code Form is subject to the terms of the Mozilla Public
@@ -8,17 +8,17 @@
#include <thread>
#include <iostream>
-#include <CommonAPI/CommonAPI.h>
-#include "E03MethodsStubImpl.h"
+#include <CommonAPI/CommonAPI.hpp>
+#include "E03MethodsStubImpl.hpp"
int main() {
- std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
- std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory();
- std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher = runtime->getServicePublisher();
+ std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
+
+ std::string domain = "local";
+ std::string instance = "commonapi.examples.Methods";
- const std::string& serviceAddress = "local:commonapi.examples.Methods:commonapi.examples.Methods";
std::shared_ptr<E03MethodsStubImpl> myService = std::make_shared<E03MethodsStubImpl>();
- servicePublisher->registerService(myService, serviceAddress, factory);
+ runtime->registerService(domain, instance, myService);
while (true) {
myService->incCounter(); // Change value of attribute, see stub implementation
diff --git a/CommonAPI-Examples/e03Methods/src/E03MethodsStubImpl.cpp b/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.cpp
index e0b47ef..d2856d2 100644
--- a/CommonAPI-Examples/e03Methods/src/E03MethodsStubImpl.cpp
+++ b/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.cpp
@@ -1,13 +1,13 @@
-/* Copyright (C) 2014 BMW Group
+/* Copyright (C) 2014, 2015 BMW Group
* Author: Manfred Bathelt (manfred.bathelt@bmw.de)
* Author: Juergen Gehring (juergen.gehring@bmw.de)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include "E03MethodsStubImpl.h"
+#include "E03MethodsStubImpl.hpp"
-using namespace commonapi::examples;
+using namespace v1_2::commonapi::examples;
E03MethodsStubImpl::E03MethodsStubImpl() {
cnt = 0;
@@ -23,15 +23,15 @@ void E03MethodsStubImpl::incCounter() {
}
;
-void E03MethodsStubImpl::foo(int32_t x1,
- std::string x2,
- E03Methods::fooError& methodError,
- int32_t& y1,
- std::string& y2) {
+void E03MethodsStubImpl::foo(const std::shared_ptr<CommonAPI::ClientId> _client,
+ int32_t _x1,
+ std::string _x2,
+ fooReply_t _reply) {
std::cout << "foo called, setting new values." << std::endl;
- methodError = (E03Methods::fooError) E03Methods::stdErrorTypeEnum::MY_FAULT;
- y1 = 42;
- y2 = "xyz";
+ E03Methods::fooError methodError = (E03Methods::fooError) E03Methods::stdErrorTypeEnum::MY_FAULT;
+ int32_t y1 = 42;
+ std::string y2 = "xyz";
+ _reply(methodError, y1, y2);
}
diff --git a/CommonAPI-Examples/e03Methods/src/E03MethodsStubImpl.h b/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.hpp
index 654620c..3afdbe8 100644
--- a/CommonAPI-Examples/e03Methods/src/E03MethodsStubImpl.h
+++ b/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.hpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2014 BMW Group
+/* Copyright (C) 2014, 2015 BMW Group
* Author: Manfred Bathelt (manfred.bathelt@bmw.de)
* Author: Juergen Gehring (juergen.gehring@bmw.de)
* This Source Code Form is subject to the terms of the Mozilla Public
@@ -8,20 +8,19 @@
#ifndef E03METHODSSTUBIMPL_H_
#define E03METHODSSTUBIMPL_H_
-#include <CommonAPI/CommonAPI.h>
-#include <commonapi/examples/E03MethodsStubDefault.h>
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1_2/commonapi/examples/E03MethodsStubDefault.hpp>
-class E03MethodsStubImpl: public commonapi::examples::E03MethodsStubDefault {
+class E03MethodsStubImpl: public v1_2::commonapi::examples::E03MethodsStubDefault {
public:
E03MethodsStubImpl();
virtual ~E03MethodsStubImpl();
virtual void incCounter();
- void foo(int32_t x1,
- std::string x2,
- commonapi::examples::E03Methods::fooError& methodError,
- int32_t& y1,
- std::string& y2);
+ virtual void foo(const std::shared_ptr<CommonAPI::ClientId> _client,
+ int32_t _x1,
+ std::string _x2,
+ fooReply_t _reply);
private:
int cnt;
diff --git a/CommonAPI-Examples/E04PhoneBook/.cproject b/CommonAPI-Examples/E04PhoneBook/.cproject
new file mode 100644
index 0000000..79b6194
--- /dev/null
+++ b/CommonAPI-Examples/E04PhoneBook/.cproject
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="0.1761849592">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1761849592" moduleId="org.eclipse.cdt.core.settings" name="Default">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1761849592" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
+ <folderInfo id="0.1761849592." name="/" resourcePath="">
+ <toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.577012360" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
+ <targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.577012360.957683016" name=""/>
+ <builder arguments="-C ${ProjDirPath}/build VERBOSE=0" buildPath="" command="make" id="org.eclipse.cdt.build.core.settings.default.builder.1653340291" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.libs.412065462" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.1143268066" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1234796833" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.458324329" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1205538846" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/ascgit017.CommonAPI/include}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/ascgit017.CommonAPI-D-Bus/include}&quot;"/>
+ </option>
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1956760823" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.1410105709" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1565544040" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="e04PhoneBook.null.84948954" name="e04PhoneBook"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="0.1761849592">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Default">
+ <resource resourceType="PROJECT" workspacePath="/e04PhoneBook"/>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+ <buildTargets>
+ <target name="Run cmake" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+ <buildCommand>cmake</buildCommand>
+ <buildArguments>-E chdir build/ cmake -D CMAKE_BUILD_TYPE=Debug -DUSE_INSTALLED_COMMONAPI=OFF -DUSE_INSTALLED_DBUS=OFF ../</buildArguments>
+ <buildTarget/>
+ <stopOnError>true</stopOnError>
+ <useDefaultCommand>false</useDefaultCommand>
+ <runAllBuilders>true</runAllBuilders>
+ </target>
+ </buildTargets>
+ </storageModule>
+</cproject>
diff --git a/CommonAPI-Examples/e03Methods/.gitignore b/CommonAPI-Examples/E04PhoneBook/.gitignore
index 5897208..5897208 100644
--- a/CommonAPI-Examples/e03Methods/.gitignore
+++ b/CommonAPI-Examples/E04PhoneBook/.gitignore
diff --git a/CommonAPI-Examples/E04PhoneBook/.project b/CommonAPI-Examples/E04PhoneBook/.project
new file mode 100644
index 0000000..af5f73a
--- /dev/null
+++ b/CommonAPI-Examples/E04PhoneBook/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>E04PhoneBook</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/CommonAPI-Examples/E04PhoneBook/CMakeLists.txt b/CommonAPI-Examples/E04PhoneBook/CMakeLists.txt
new file mode 100644
index 0000000..ed9840a
--- /dev/null
+++ b/CommonAPI-Examples/E04PhoneBook/CMakeLists.txt
@@ -0,0 +1,90 @@
+# Copyright (C) 2014, 2015 BMW Group
+# Author: Manfred Bathelt (manfred.bathelt@bmw.de)
+# Author: Juergen Gehring (juergen.gehring@bmw.de)
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+cmake_minimum_required(VERSION 2.8)
+
+set(PRJ_NAME E04PhoneBook)
+
+set(CMAKE_VERBOSE_MAKEFILE on)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP")
+
+message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}")
+
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
+ "Choose the type of build, options are: Debug Release." FORCE)
+endif(NOT CMAKE_BUILD_TYPE)
+message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
+
+OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version of CommonAPI" ON)
+message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}")
+
+if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON")
+ FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+else()
+ FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+endif()
+
+message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
+message(STATUS "COMMONAPI_INCLUDE_DIRS: ${COMMONAPI_INCLUDE_DIRS}")
+message(STATUS "CommonAPI-DBus_CONSIDERED_CONFIGS: ${CommonAPI-DBus_CONSIDERED_CONFIGS}")
+message(STATUS "COMMONAPI_DBUS_INCLUDE_DIRS: ${COMMONAPI_DBUS_INCLUDE_DIRS}")
+
+# CommonAPI
+include(FindPkgConfig)
+pkg_check_modules (DBUS "dbus-1 >= 1.4")
+
+# Source Files
+set(PRJ_SRC_PATH src)
+set(PRJ_SRC_GEN_PATH src-gen/commonapi/examples)
+
+set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
+set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
+
+FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp)
+FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp)
+FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
+
+set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
+set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
+
+# Paths
+OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON)
+message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}")
+
+include_directories(
+ src-gen
+ ${COMMONAPI_INCLUDE_DIRS}
+ ${COMMONAPI_DBUS_INCLUDE_DIRS}
+ ${DBUS_INCLUDE_DIRS}
+)
+
+if ("${USE_INSTALLED_DBUS}" STREQUAL "ON")
+link_directories(
+ ${COMMONAPI_LIBDIR}
+ ${COMMONAPI_DBUS_LIBDIR}
+ ${DBUS_LIBDIR}
+)
+else()
+link_directories(
+ ${COMMONAPI_LIBDIR}
+ ${COMMONAPI_DBUS_LIBDIR}
+ ${DBUS_INCLUDE_DIRS}/dbus/.libs
+)
+endif()
+
+set(LINK_LIBRARIES -Wl,--no-as-needed CommonAPI-DBus -Wl,--as-needed CommonAPI ${DBUS_LIBRARIES})
+
+# Build Client
+add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
+target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES})
+
+# Build service
+add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
+target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES})
diff --git a/CommonAPI-Examples/E04PhoneBook/README b/CommonAPI-Examples/E04PhoneBook/README
new file mode 100644
index 0000000..431351a
--- /dev/null
+++ b/CommonAPI-Examples/E04PhoneBook/README
@@ -0,0 +1,219 @@
+=== Example 04: PhoneBook
+
+This slightly more complex example illustrates the application of some Franca features in combination with CommonAPI:
+
+- explicit named arrays and inline arrays
+- selective broadcasts
+- polymorphic structs
+
+Concerning arrays please note the following points:
+
+- In Franca there are two ways to define arrays: explicitly named (array myArray of UInt8) or implicit without defining a new name for the array (UInt8 []).
+- The implicit definition of multidimensional arrays is not possible at the moment (like UInt8 [][]), but multidimensional arrays can be defined with explicit names.
+- In CommonAPI arrays are implemented and generated as std::vector.
+
+A common problem in the specification of interfaces between user frontends and services which contain large data sets is, that the clients usually need only extracts from the database. That means that only a filtered excerpt from the database has to be transmitted via IPC to the client, but probably every client needs a different excerpt. The filter can affect the selection of the elements (element filter), the contents of the elements (content filter) or the number of elements (array window).
+
+The following example shows how different extracts of a central data array can be accessed by several clients via a data filter mechanism and selective broadcasts. As example of a central data array a phone book is selected; the following picture shows the basic content of the example.
+
+image::{imagedir}/E04PhoneBook.png[PhoneBookExample image]
+
+The Franca IDL specification is:
+
+[source,java]
+----
+package commonapi.examples
+
+interface E04PhoneBook {
+ version { major 0 minor 0 }
+
+ <** @description : the phone book itself **>
+ attribute phoneBookStruct [] phoneBook readonly
+
+ <** @description : filter operations **>
+ method setPhoneBookDataFilter {
+ in {
+ elementFilterStruct elementFilter
+ contentFilterStruct [] contentFilter
+ }
+ }
+
+ <** @description : filter result **>
+ broadcast phoneBookDataSet selective {
+ out {
+ phoneBookDataElementMap [] phoneBookDataSet
+ }
+ }
+
+ <** @description : Data types of the phone book itself **>
+ enumeration phoneNumberEnum {
+ WORK
+ HOME
+ MOBILE1
+ MOBILE2
+ }
+
+ map phoneNumberMap {
+ phoneNumberEnum to String
+ }
+
+ struct phoneBookStruct {
+ String name
+ String forename
+ String organisation
+ String address
+ String email
+ phoneNumberMap phoneNumber
+ }
+
+ <** @description : Data types for the filter operations **>
+
+ struct elementFilterStruct {
+ Boolean addName
+ Boolean addForename
+ Boolean addOrganisation
+ Boolean addAddress
+ Boolean addEmail
+ Boolean addPhoneNumber
+ }
+
+ struct contentFilterStruct {
+ phoneBookDataElementEnum element
+ String expression
+ }
+
+ <** @description : Data types for the result of the phone book filter **>
+ enumeration phoneBookDataElementEnum {
+ NAME
+ FORENAME
+ ORGANISATION
+ ADDRESS
+ EMAIL
+ PHONENUMBER
+ }
+
+ struct phoneBookDataElement polymorphic {
+ }
+
+ struct phoneBookDataElementString extends phoneBookDataElement {
+ String content
+ }
+
+ struct phoneBookDataElementPhoneNumber extends phoneBookDataElement {
+ phoneNumberMap content
+ }
+
+ map phoneBookDataElementMap {
+ phoneBookDataElementEnum to phoneBookDataElement
+ }
+}
+----
+
+The phone book itself is modeled as an attribute which is an array of the structure +phoneBookStruct+. Here the phone book is +readonly+, that means that the whole content can be accessed only via subscription and the getter function. A special difficulty is the phone number, because there are several kinds of phone numbers allowed (home, mobile, ...). Therefore the element +phoneNumber+ in +phoneBookStruct+ is a map with an enumeration key and a value of type string for the number. The client can set a filter to the phone book data (in the example only content filter and element filter, but other filters are conceivable) via the method +setPhoneBookDataFilter+ and gets the data back via the selective broadcast +phoneBookDataSet+. Since the content of the data set depends on the filter, the elements of the client specific data set are specified as maps where the key is the type of the element (name, forename, ...) and the value is the content of the element. The content can be of the type String or of the user defined type phoneNumberMap. Therefore the value is defined as polymorphic struct which can be a String or a phoneNumberMap.
+
+In the following we consider only some interesting implementation details, for the complete implementation please see the source code.
+
+The interesting part of the service is the implementation of the set function for the data filter. At the moment only the element filter is implemented, but the implementation of the other filters can be added analogously.
+
+- Each client is identified via its client ID (+ClientId+); the implementation of client ID class allows the usage of client ID objects as key in a map (see the specification).
+- The data sets of the filtered data for the clients are stored in a map with the client ID as key; in this example the filtered data are sent back to the client directly in the filter set function. Please note, that +firePhoneBookDataSetSelective+ sends the data to only one receiver.
+- The value of the key has to be the right type (+phoneNumberMap+ for phoneNumbers and Strings for the rest).
+
+[source,{cppstr}]
+----
+void E04PhoneBookStubImpl::setPhoneBookDataFilter(
+ const std::shared_ptr<CommonAPI::ClientId> _client,
+ E04PhoneBook::elementFilterStruct _elementFilter,
+ std::vector<E04PhoneBook::contentFilterStruct> _contentFilter,
+ setPhoneBookDataFilterReply_t _reply) {
+
+ std::shared_ptr < CommonAPI::ClientIdList > clientList =
+ getSubscribersForPhoneBookDataSetSelective();
+
+ std::vector < E04PhoneBook::phoneBookDataElementMap > lPhoneBookDataSet;
+
+ phoneBookClientData.erase(_client);
+
+ std::vector<E04PhoneBook::phoneBookStruct>::const_iterator it0;
+ for (it0 = getPhoneBookAttribute().begin(); it0 != getPhoneBookAttribute().end(); it0++) {
+
+ E04PhoneBook::phoneBookDataElementMap lPhoneBookDataElement;
+
+ if (_elementFilter.getAddName()) {
+ std::shared_ptr<E04PhoneBook::phoneBookDataElementString> name =
+ std::make_shared<E04PhoneBook::phoneBookDataElementString>();
+ name->setContent(it0->getName());
+ lPhoneBookDataElement[E04PhoneBook::phoneBookDataElementEnum::NAME] = name;
+ }
+
+ /* ... Similar for all other elements */
+
+ lPhoneBookDataSet.push_back(lPhoneBookDataElement);
+ }
+
+ phoneBookClientData[_client] = lPhoneBookDataSet;
+
+ const std::shared_ptr<CommonAPI::ClientIdList> receivers(new CommonAPI::ClientIdList);
+ receivers->insert(_client);
+
+ firePhoneBookDataSetSelective(lPhoneBookDataSet, receivers);
+
+ receivers->erase(_client);
+
+ _reply();
+}
+----
+
+On client side we create two proxies which shall set different filters and get different data sets. With CommonAPI 2.x we needed two different factories for these two proxies; this can be achieved by now by creating a new Connection ID for the second proxy. Each proxy has to subscribe to phoneBookDataSet, but gets different contents depending on the filter. The whole phoneBookData can be obtained via the standard get function.
+
+[source,{cppstr}]
+----
+int main() {
+ std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
+
+ const std::string &domain = "local";
+ const std::string &instance = "commonapi.examples.PhoneBook";
+
+ std::shared_ptr < E04PhoneBookProxyDefault > myProxyA =
+ runtime->buildProxy < E04PhoneBookProxy > (domain, instance);
+
+ while (!myProxyA->isAvailable()) { usleep(10); }
+
+ const CommonAPI::ConnectionId_t otherConnectionId = "42";
+
+ std::shared_ptr < E04PhoneBookProxyDefault > myProxyB =
+ runtime->buildProxy < E04PhoneBookProxy > (domain, instance, otherConnectionId);
+
+ while (!myProxyB->isAvailable()) { usleep(10); }
+
+ myProxyA->getPhoneBookDataSetSelectiveEvent().subscribe([&](
+ const std::vector<E04PhoneBook::phoneBookDataElementMap>& phoneBookDataSet) {
+ printFilterResult(phoneBookDataSet, "A");});
+
+ myProxyB->getPhoneBookDataSetSelectiveEvent().subscribe([&](
+ const std::vector<E04PhoneBook::phoneBookDataElementMap>& phoneBookDataSet) {
+ printFilterResult(phoneBookDataSet, "B");});
+
+ CommonAPI::CallStatus myCallStatus;
+ std::vector<E04PhoneBook::phoneBookStruct> myValue;
+
+ myProxyA->getPhoneBookAttribute().getValue(myCallStatus, myValue);
+ printPhoneBook (myValue);
+
+ E04PhoneBook::elementFilterStruct lElementFilterA =
+ {true, true, false, false, false, false};
+ std::vector<E04PhoneBook::contentFilterStruct> lContentFilterA =
+ { {E04PhoneBook::phoneBookDataElementEnum::NAME, "*"}};
+ myProxyA->setPhoneBookDataFilter(lElementFilterA, lContentFilterA, myCallStatus);
+
+ E04PhoneBook::elementFilterStruct lElementFilterB =
+ {true, false, false, false, false, true};
+ std::vector<E04PhoneBook::contentFilterStruct> lContentFilterB =
+ { {E04PhoneBook::phoneBookDataElementEnum::NAME, "*"}};
+ myProxyB->setPhoneBookDataFilter(lElementFilterB, lContentFilterB, myCallStatus);
+
+ while (true) { std::this_thread::sleep_for(std::chrono::seconds(5)); }
+ return 0;
+}
+----
+
diff --git a/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook.fdepl b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook.fdepl
new file mode 100644
index 0000000..645b37e
--- /dev/null
+++ b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook.fdepl
@@ -0,0 +1,112 @@
+import "platform:/plugin/org.genivi.commonapi.dbus/deployment/CommonAPI-DBus_deployment.fdepl"
+import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
+import "E04PhoneBook.fidl"
+
+define org.genivi.commonapi.dbus.deployment for interface commonapi.examples.E04PhoneBook {
+ PropertiesType = freedesktop
+}
+
+define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E04PhoneBook {
+ SomeIpServiceID = 4660
+ SomeIpEventGroups = { 7000, 7001 }
+
+ attribute phoneBook {
+ SomeIpGetterID = 7000
+ }
+
+ method setPhoneBookDataFilter {
+ SomeIpMethodID = 33000
+ }
+
+ broadcast phoneBookDataSet {
+ SomeIpEventID = 8000
+ }
+
+ enumeration phoneNumberEnum {
+ WORK {
+ }
+ HOME {
+ }
+ MOBILE1 {
+ }
+ MOBILE2 {
+ }
+ }
+
+ struct phoneBookStruct {
+ name {
+ }
+ forename {
+ }
+ organisation {
+ }
+ address {
+ }
+ email {
+ }
+ phoneNumber {
+ }
+ }
+
+ struct elementFilterStruct {
+ addName {
+ }
+ addForename {
+ }
+ addOrganisation {
+ }
+ addAddress {
+ }
+ addEmail {
+ }
+ addPhoneNumber {
+ }
+ }
+
+ struct contentFilterStruct {
+ element {
+ }
+ expression {
+ }
+ }
+
+ enumeration phoneBookDataElementEnum {
+ NAME {
+ }
+ FORENAME {
+ }
+ ORGANISATION {
+ }
+ ADDRESS {
+ }
+ EMAIL {
+ }
+ PHONENUMBER {
+ }
+ }
+
+ struct phoneBookDataElement {
+ }
+
+ struct phoneBookDataElementString {
+ content {
+ }
+ }
+
+ struct phoneBookDataElementPhoneNumber {
+ content {
+ }
+ }
+
+}
+
+define org.genivi.commonapi.someip.deployment for provider Service {
+ instance commonapi.examples.E04PhoneBook {
+ InstanceId = "commonapi.examples.PhoneBook"
+
+ SomeIpInstanceID = 22136
+
+ SomeIpUnicastAddress = "192.168.0.2"
+ SomeIpUnicastPort = 30499
+ }
+} \ No newline at end of file
diff --git a/CommonAPI-Examples/e04PhoneBook/fidl/E04PhoneBook.fidl b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook.fidl
index 929b296..c22fd77 100644
--- a/CommonAPI-Examples/e04PhoneBook/fidl/E04PhoneBook.fidl
+++ b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook.fidl
@@ -8,8 +8,7 @@
package commonapi.examples
interface E04PhoneBook {
-
- version { major 1 minor 0 }
+ version { major 0 minor 0 }
<** @description : the phone book itself **>
attribute phoneBookStruct [] phoneBook readonly
diff --git a/CommonAPI-Examples/e04PhoneBook/src/e04PhoneBookClient.cpp b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp
index eb9a7c5..8250762 100644
--- a/CommonAPI-Examples/e04PhoneBook/src/e04PhoneBookClient.cpp
+++ b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp
@@ -1,16 +1,18 @@
-/* Copyright (C) 2014 BMW Group
+/* Copyright (C) 2014, 2015 BMW Group
* Author: Manfred Bathelt (manfred.bathelt@bmw.de)
* Author: Juergen Gehring (juergen.gehring@bmw.de)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+#include <unistd.h>
+
#include <map>
#include <iostream>
-#include <CommonAPI/CommonAPI.h>
-#include <commonapi/examples/E04PhoneBook.h>
-#include <commonapi/examples/E04PhoneBookProxy.h>
+#include <CommonAPI/CommonAPI.hpp>
+#include <commonapi/examples/E04PhoneBook.hpp>
+#include <commonapi/examples/E04PhoneBookProxy.hpp>
using namespace commonapi::examples;
@@ -18,7 +20,7 @@ using namespace commonapi::examples;
std::string phoneNumberType2String(E04PhoneBook::phoneNumberEnum phoneNumberType) {
- switch (static_cast<int32_t>(phoneNumberType)) {
+ switch (phoneNumberType) {
case 0:
return "WORK";
break;
@@ -43,14 +45,14 @@ void printPhoneBook(const std::vector<E04PhoneBook::phoneBookStruct>& myPhoneBoo
std::cout << "Actual phoneBook content: " << std::endl;
for (myIterator = myPhoneBook.begin(); myIterator != myPhoneBook.end(); myIterator++) {
- std::cout << "Name: " << myIterator->name << std::endl;
- std::cout << "Forename: " << myIterator->forename << std::endl;
- std::cout << "Organisation: " << myIterator->organisation << std::endl;
- std::cout << "Address: " << myIterator->address << std::endl;
- std::cout << "EMail: " << myIterator->email << std::endl;
+ std::cout << "Name: " << myIterator->getName() << std::endl;
+ std::cout << "Forename: " << myIterator->getForename() << std::endl;
+ std::cout << "Organisation: " << myIterator->getOrganisation() << std::endl;
+ std::cout << "Address: " << myIterator->getAddress() << std::endl;
+ std::cout << "EMail: " << myIterator->getEmail() << std::endl;
- for (E04PhoneBook::phoneNumberMap::const_iterator myPhoneNumberIterator = myIterator->phoneNumber.begin();
- myPhoneNumberIterator != myIterator->phoneNumber.end();
+ for (E04PhoneBook::phoneNumberMap::const_iterator myPhoneNumberIterator = myIterator->getPhoneNumber().begin();
+ myPhoneNumberIterator != myIterator->getPhoneNumber().end();
myPhoneNumberIterator++) {
std::cout << "phoneNumber[" << phoneNumberType2String(myPhoneNumberIterator->first) << "]: ";
std::cout << myPhoneNumberIterator->second << std::endl;
@@ -70,35 +72,35 @@ void printFilterResult(const std::vector<E04PhoneBook::phoneBookDataElementMap>&
switch (it1->first) {
case E04PhoneBook::phoneBookDataElementEnum::NAME: {
std::string name = (std::static_pointer_cast < E04PhoneBook::phoneBookDataElementString
- > (it1->second))->content;
+ > (it1->second))->getContent();
std::cout << "Name = " << name << std::endl;
}
break;
case E04PhoneBook::phoneBookDataElementEnum::FORENAME: {
std::string forename = (std::static_pointer_cast < E04PhoneBook::phoneBookDataElementString
- > (it1->second))->content;
+ > (it1->second))->getContent();
std::cout << "Forename = " << forename << std::endl;
}
break;
case E04PhoneBook::phoneBookDataElementEnum::ORGANISATION: {
std::string organisation = (std::static_pointer_cast < E04PhoneBook::phoneBookDataElementString
- > ((*it0).at(E04PhoneBook::phoneBookDataElementEnum::ORGANISATION)))->content;
+ > ((*it0).at(E04PhoneBook::phoneBookDataElementEnum::ORGANISATION)))->getContent();
std::cout << "Organisation = " << organisation << std::endl;
}
break;
case E04PhoneBook::phoneBookDataElementEnum::ADDRESS: {
std::string address = (std::static_pointer_cast < E04PhoneBook::phoneBookDataElementString
- > ((*it0).at(E04PhoneBook::phoneBookDataElementEnum::ADDRESS)))->content;
+ > ((*it0).at(E04PhoneBook::phoneBookDataElementEnum::ADDRESS)))->getContent();
std::cout << "Address = " << address << std::endl;
}
break;
case E04PhoneBook::phoneBookDataElementEnum::EMAIL: {
std::string email = (std::static_pointer_cast < E04PhoneBook::phoneBookDataElementString
- > ((*it0).at(E04PhoneBook::phoneBookDataElementEnum::EMAIL)))->content;
+ > ((*it0).at(E04PhoneBook::phoneBookDataElementEnum::EMAIL)))->getContent();
std::cout << "EMail = " << email << std::endl;
}
break;
@@ -106,7 +108,7 @@ void printFilterResult(const std::vector<E04PhoneBook::phoneBookDataElementMap>&
case E04PhoneBook::phoneBookDataElementEnum::PHONENUMBER: {
E04PhoneBook::phoneNumberMap phoneNumber = (std::static_pointer_cast
< E04PhoneBook::phoneBookDataElementPhoneNumber
- > ((*it0).at(E04PhoneBook::phoneBookDataElementEnum::PHONENUMBER)))->content;
+ > ((*it0).at(E04PhoneBook::phoneBookDataElementEnum::PHONENUMBER)))->getContent();
for (E04PhoneBook::phoneNumberMap::iterator myPhoneNumberIterator = phoneNumber.begin();
myPhoneNumberIterator != phoneNumber.end();
myPhoneNumberIterator++) {
@@ -126,17 +128,19 @@ void printFilterResult(const std::vector<E04PhoneBook::phoneBookDataElementMap>&
}
int main() {
- std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
+ std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
- std::shared_ptr<CommonAPI::Factory> factoryA = runtime->createFactory();
- std::shared_ptr<CommonAPI::Factory> factoryB = runtime->createFactory();
+ const std::string &domain = "local";
+ const std::string &instance = "commonapi.examples.PhoneBook";
- const std::string& serviceAddress = "local:commonapi.examples.PhoneBook:commonapi.examples.PhoneBook";
- std::shared_ptr < E04PhoneBookProxyDefault > myProxyA = factoryA->buildProxy < E04PhoneBookProxy > (serviceAddress);
+ std::shared_ptr < E04PhoneBookProxyDefault > myProxyA = runtime->buildProxy < E04PhoneBookProxy > (domain, instance);
while (!myProxyA->isAvailable()) {
usleep(10);
}
- std::shared_ptr < E04PhoneBookProxyDefault > myProxyB = factoryB->buildProxy < E04PhoneBookProxy > (serviceAddress);
+
+ const CommonAPI::ConnectionId_t otherConnectionId = "42";
+
+ std::shared_ptr < E04PhoneBookProxyDefault > myProxyB = runtime->buildProxy < E04PhoneBookProxy > (domain, instance, otherConnectionId);
while (!myProxyB->isAvailable()) {
usleep(10);
}
@@ -171,16 +175,21 @@ int main() {
myProxyA->setPhoneBookDataFilter(lElementFilterA, lContentFilterA, myCallStatus);
if (myCallStatus != CommonAPI::CallStatus::SUCCESS)
std::cerr << "Remote call setPhoneBookDataFilter A failed: " << (int) myCallStatus << std::endl;
+ else
+ std::cout << "Remote call setPhoneBookDataFilter A succeeded." << std::endl;
- std::cout << "Call setPhoneBookDataFilter B ..." << std::endl;
+ std::cout << "Call setPhoneBookDataFilter B ..." << std::endl;
E04PhoneBook::elementFilterStruct lElementFilterB = {true, false, false, false, false, true};
std::vector<E04PhoneBook::contentFilterStruct> lContentFilterB = { {E04PhoneBook::phoneBookDataElementEnum::NAME, "*"}};
myProxyB->setPhoneBookDataFilter(lElementFilterB, lContentFilterB, myCallStatus);
if (myCallStatus != CommonAPI::CallStatus::SUCCESS)
std::cerr << "Remote call setPhoneBookDataFilter B failed: " << (int) myCallStatus << std::endl;
+ else
+ std::cout << "Remote call setPhoneBookDataFilter B succeeded." << std::endl;
while (true) {
+ std::cout << "Now I am going to sleep for 5 seconds..." << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(5));
}
return 0;
diff --git a/CommonAPI-Examples/e04PhoneBook/src/e04PhoneBookService.cpp b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp
index fba15a2..03da5d8 100644
--- a/CommonAPI-Examples/e04PhoneBook/src/e04PhoneBookService.cpp
+++ b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2014 BMW Group
+/* Copyright (C) 2014, 2015 BMW Group
* Author: Manfred Bathelt (manfred.bathelt@bmw.de)
* Author: Juergen Gehring (juergen.gehring@bmw.de)
* This Source Code Form is subject to the terms of the Mozilla Public
@@ -8,20 +8,18 @@
#include <thread>
#include <iostream>
-#include <CommonAPI/CommonAPI.h>
+#include <CommonAPI/CommonAPI.hpp>
#include "E04PhoneBookStubImpl.h"
int main() {
- std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
- std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory();
- std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher = runtime->getServicePublisher();
+ std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
- const std::string& serviceAddress = "local:commonapi.examples.PhoneBook:commonapi.examples.PhoneBook";
+ const std::string &domain = "local";
+ const std::string &instance = "commonapi.examples.PhoneBook";
std::shared_ptr<E04PhoneBookStubImpl> myService = std::make_shared<E04PhoneBookStubImpl>();
- servicePublisher->registerService(myService, serviceAddress, factory);
-
myService->setPhoneBookAttribute(myService->createTestPhoneBook());
+ runtime->registerService(domain, instance, myService);
while (true) {
std::cout << "Waiting for calls... (Abort with CTRL+C)" << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(2));
diff --git a/CommonAPI-Examples/e04PhoneBook/src/E04PhoneBookStubImpl.cpp b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookStubImpl.cpp
index a0a8e05..bfd06bb 100644
--- a/CommonAPI-Examples/e04PhoneBook/src/E04PhoneBookStubImpl.cpp
+++ b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookStubImpl.cpp
@@ -1,10 +1,12 @@
-/* Copyright (C) 2014 BMW Group
+/* Copyright (C) 2014, 2015 BMW Group
* Author: Manfred Bathelt (manfred.bathelt@bmw.de)
* Author: Juergen Gehring (juergen.gehring@bmw.de)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+#include <algorithm>
+
#include "E04PhoneBookStubImpl.h"
using namespace commonapi::examples;
@@ -37,110 +39,122 @@ void E04PhoneBookStubImpl::onPhoneBookDataSetSelectiveSubscriptionChanged(const
}
}
-void E04PhoneBookStubImpl::setPhoneBookDataFilter(const std::shared_ptr<CommonAPI::ClientId> clientId,
- E04PhoneBook::elementFilterStruct elementFilter,
- std::vector<E04PhoneBook::contentFilterStruct> contentFilter) {
-
- std::shared_ptr < CommonAPI::ClientIdList > clientIdList = getSubscribersForPhoneBookDataSetSelective();
- std::cout << "setPhoneBookDataFilter called from client " << clientId->hashCode() << " of ("
- << clientIdList->size() << ")" << std::endl;
+void E04PhoneBookStubImpl::setPhoneBookDataFilter(const std::shared_ptr<CommonAPI::ClientId> _client,
+ E04PhoneBook::elementFilterStruct _elementFilter,
+ std::vector<E04PhoneBook::contentFilterStruct> _contentFilter,
+ setPhoneBookDataFilterReply_t _reply) {
+ std::shared_ptr < CommonAPI::ClientIdList > clientList = getSubscribersForPhoneBookDataSetSelective();
+ std::cout << "setPhoneBookDataFilter called from client " << _client->hashCode() << " of ("
+ << clientList->size() << ")" << std::endl;
std::vector < E04PhoneBook::phoneBookDataElementMap > lPhoneBookDataSet;
- phoneBookClientData.erase(clientId);
+
+ phoneBookClientData.erase(_client);
std::vector<E04PhoneBook::phoneBookStruct>::const_iterator it0;
for (it0 = getPhoneBookAttribute().begin(); it0 != getPhoneBookAttribute().end(); it0++) {
E04PhoneBook::phoneBookDataElementMap lPhoneBookDataElement;
- if (elementFilter.addName) {
+ if (_elementFilter.getAddName()) {
std::shared_ptr<E04PhoneBook::phoneBookDataElementString> name = std::make_shared<E04PhoneBook::phoneBookDataElementString>();
- name->content = it0->name;
+ name->setContent(it0->getName());
lPhoneBookDataElement[E04PhoneBook::phoneBookDataElementEnum::NAME] = name;
}
- if (elementFilter.addForename) {
+ if (_elementFilter.getAddForename()) {
std::shared_ptr<E04PhoneBook::phoneBookDataElementString> forename = std::make_shared<E04PhoneBook::phoneBookDataElementString>();
- forename->content = it0->forename;
+ forename->setContent(it0->getForename());
lPhoneBookDataElement[E04PhoneBook::phoneBookDataElementEnum::FORENAME] = forename;
}
- if (elementFilter.addOrganisation) {
+ if (_elementFilter.getAddOrganisation()) {
std::shared_ptr<E04PhoneBook::phoneBookDataElementString> organisation = std::make_shared<E04PhoneBook::phoneBookDataElementString>();
- organisation->content = it0->organisation;
+ organisation->setContent(it0->getOrganisation());
lPhoneBookDataElement[E04PhoneBook::phoneBookDataElementEnum::ORGANISATION] = organisation;
}
- if (elementFilter.addAddress) {
+ if (_elementFilter.getAddAddress()) {
std::shared_ptr<E04PhoneBook::phoneBookDataElementString> address = std::make_shared<E04PhoneBook::phoneBookDataElementString>();
- address->content = it0->address;
+ address->setContent(it0->getAddress());
lPhoneBookDataElement[E04PhoneBook::phoneBookDataElementEnum::ADDRESS] = address;
}
- if (elementFilter.addEmail) {
+ if (_elementFilter.getAddEmail()) {
std::shared_ptr<E04PhoneBook::phoneBookDataElementString> email = std::make_shared<E04PhoneBook::phoneBookDataElementString>();
- email->content = it0->email;
+ email->setContent(it0->getEmail());
lPhoneBookDataElement[E04PhoneBook::phoneBookDataElementEnum::EMAIL] = email;
}
- if (elementFilter.addPhoneNumber) {
+ if (_elementFilter.getAddPhoneNumber()) {
std::shared_ptr<E04PhoneBook::phoneBookDataElementPhoneNumber> phoneNumber = std::make_shared<E04PhoneBook::phoneBookDataElementPhoneNumber>();
- phoneNumber->content = it0->phoneNumber;
+ phoneNumber->setContent(it0->getPhoneNumber());
lPhoneBookDataElement[E04PhoneBook::phoneBookDataElementEnum::PHONENUMBER] = phoneNumber;
}
lPhoneBookDataSet.push_back(lPhoneBookDataElement);
-
}
- phoneBookClientData[clientId] = lPhoneBookDataSet;
+ phoneBookClientData[_client] = lPhoneBookDataSet;
// Send client data
const std::shared_ptr<CommonAPI::ClientIdList> receivers(new CommonAPI::ClientIdList);
- receivers->insert(clientId);
- std::cout << "firePhoneBookDataSetSelective: " << receivers->size() << " / " << phoneBookClientData[clientId].size()
- << std::endl;
+ receivers->insert(_client);
+ std::cout << "firePhoneBookDataSetSelective: " << receivers->size() << " / " << phoneBookClientData[_client].size() << std::endl;
+
firePhoneBookDataSetSelective(lPhoneBookDataSet, receivers);
- receivers->erase(clientId);
+
+ receivers->erase(_client);
std::cout << "setPhoneBookDataFilter end." << std::endl;
+ _reply();
}
std::vector<E04PhoneBook::phoneBookStruct> E04PhoneBookStubImpl::createTestPhoneBook() {
std::vector<E04PhoneBook::phoneBookStruct> lPhoneBook;
E04PhoneBook::phoneBookStruct lPhoneBookEntry;
+ E04PhoneBook::phoneNumberMap lPhoneBookEntryMap;
// 1. entry
- lPhoneBookEntry.name = "Gehring";
- lPhoneBookEntry.forename = "Jürgen";
- lPhoneBookEntry.organisation = "BMW";
- lPhoneBookEntry.address = "Max-Diamand-Straße 13, 80788 München";
- lPhoneBookEntry.email = "juergen.gehring@bmw.de";
- lPhoneBookEntry.phoneNumber[E04PhoneBook::phoneNumberEnum::WORK] = "0111/12345-0";
+ lPhoneBookEntryMap[E04PhoneBook::phoneNumberEnum::WORK] = "0111/12345-0";
+
+ lPhoneBookEntry.setName("Gehring");
+ lPhoneBookEntry.setForename("Jürgen");
+ lPhoneBookEntry.setOrganisation("BMW");
+ lPhoneBookEntry.setAddress("Max-Diamand-Straße 13, 80788 München");
+ lPhoneBookEntry.setEmail("juergen.gehring@bmw.de");
+ lPhoneBookEntry.setPhoneNumber(lPhoneBookEntryMap);
lPhoneBook.push_back(lPhoneBookEntry);
- lPhoneBookEntry.phoneNumber.clear();
+
+ lPhoneBookEntryMap.clear();
// 2. entry
- lPhoneBookEntry.name = "Müller";
- lPhoneBookEntry.forename = "Alfred";
- lPhoneBookEntry.organisation = "Audi";
- lPhoneBookEntry.address = "August-Horch-Straße 27, 85055 Ingolstadt";
- lPhoneBookEntry.email = "alfred.mueller@audi.de";
- lPhoneBookEntry.phoneNumber[E04PhoneBook::phoneNumberEnum::MOBILE1] = "0222/23456-0";
+ lPhoneBookEntryMap[E04PhoneBook::phoneNumberEnum::MOBILE1] = "0222/23456-0";
+
+ lPhoneBookEntry.setName("Müller");
+ lPhoneBookEntry.setForename("Alfred");
+ lPhoneBookEntry.setOrganisation("Audi");
+ lPhoneBookEntry.setAddress("August-Horch-Straße 27, 85055 Ingolstadt");
+ lPhoneBookEntry.setEmail("alfred.mueller@audi.de");
+ lPhoneBookEntry.setPhoneNumber(lPhoneBookEntryMap);
lPhoneBook.push_back(lPhoneBookEntry);
- lPhoneBookEntry.phoneNumber.clear();
+
+ lPhoneBookEntryMap.clear();
// 3. entry
- lPhoneBookEntry.name = "Maier";
- lPhoneBookEntry.forename = "Hansi";
- lPhoneBookEntry.organisation = "Daimler";
- lPhoneBookEntry.address = "Mercedesstraße 137, 70546 Stuttgart";
- lPhoneBookEntry.email = "hansi.maier@daimler.de";
- lPhoneBookEntry.phoneNumber[E04PhoneBook::phoneNumberEnum::HOME] = "0333/34567-0";
- lPhoneBookEntry.phoneNumber[E04PhoneBook::phoneNumberEnum::WORK] = "0444/34567-1";
+ lPhoneBookEntryMap[E04PhoneBook::phoneNumberEnum::HOME] = "0333/34567-0";
+ lPhoneBookEntryMap[E04PhoneBook::phoneNumberEnum::WORK] = "0444/34567-1";
+
+ lPhoneBookEntry.setName("Maier");
+ lPhoneBookEntry.setForename("Hansi");
+ lPhoneBookEntry.setOrganisation("Daimler");
+ lPhoneBookEntry.setAddress("Mercedesstraße 137, 70546 Stuttgart");
+ lPhoneBookEntry.setEmail("hansi.maier@daimler.de");
+ lPhoneBookEntry.setPhoneNumber(lPhoneBookEntryMap);
lPhoneBook.push_back(lPhoneBookEntry);
- lPhoneBookEntry.phoneNumber.clear();
+
+ lPhoneBookEntryMap.clear();
return lPhoneBook;
}
diff --git a/CommonAPI-Examples/e04PhoneBook/src/E04PhoneBookStubImpl.h b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookStubImpl.h
index 9eebb29..38fce08 100644
--- a/CommonAPI-Examples/e04PhoneBook/src/E04PhoneBookStubImpl.h
+++ b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookStubImpl.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2014 BMW Group
+/* Copyright (C) 2014, 2015 BMW Group
* Author: Manfred Bathelt (manfred.bathelt@bmw.de)
* Author: Juergen Gehring (juergen.gehring@bmw.de)
* This Source Code Form is subject to the terms of the Mozilla Public
@@ -8,8 +8,8 @@
#ifndef E04PHONEBOOKSTUBIMPL_H_
#define E04PHONEBOOKSTUBIMPL_H_
-#include <CommonAPI/CommonAPI.h>
-#include <commonapi/examples/E04PhoneBookStubDefault.h>
+#include <CommonAPI/CommonAPI.hpp>
+#include <commonapi/examples/E04PhoneBookStubDefault.hpp>
using namespace commonapi::examples;
@@ -24,10 +24,11 @@ public:
void onPhoneBookDataSetSelectiveSubscriptionChanged(
const std::shared_ptr<CommonAPI::ClientId>,
const CommonAPI::SelectiveBroadcastSubscriptionEvent);
- void setPhoneBookDataFilter(
- const std::shared_ptr<CommonAPI::ClientId>,
- E04PhoneBook::elementFilterStruct,
- std::vector<E04PhoneBook::contentFilterStruct>);
+
+ void setPhoneBookDataFilter(const std::shared_ptr<CommonAPI::ClientId> _client,
+ E04PhoneBook::elementFilterStruct _elementFilter,
+ std::vector<E04PhoneBook::contentFilterStruct> _contentFilter,
+ setPhoneBookDataFilterReply_t _reply);
private:
std::unordered_map<std::shared_ptr<CommonAPI::ClientId>, std::vector<E04PhoneBook::phoneBookDataElementMap>> phoneBookClientData;
diff --git a/CommonAPI-Examples/E05Manager/.cproject b/CommonAPI-Examples/E05Manager/.cproject
new file mode 100644
index 0000000..fe9fce2
--- /dev/null
+++ b/CommonAPI-Examples/E05Manager/.cproject
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="0.1351891989">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1351891989" moduleId="org.eclipse.cdt.core.settings" name="Default">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1351891989" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
+ <folderInfo id="0.1351891989." name="/" resourcePath="">
+ <toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1234274354" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
+ <targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1234274354.233049048" name=""/>
+ <builder arguments="-C ${ProjDirPath}/build VERBOSE=0" buildPath="" command="make" id="org.eclipse.cdt.build.core.settings.default.builder.1553075555" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.libs.2105323305" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.1122187189" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1459463066" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.1636660805" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1286572310" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.854927977" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.181992051" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="e05Manager.null.2055319143" name="e05Manager"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="0.1351891989">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Default">
+ <resource resourceType="PROJECT" workspacePath="/e05Manager"/>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+ <buildTargets>
+ <target name="Run cmake" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+ <buildCommand>cmake</buildCommand>
+ <buildArguments>-E chdir build/ cmake -D CMAKE_BUILD_TYPE=Debug -D USE_INSTALLED_COMMONAPI=OFF -DUSE_INSTALLED_DBUS=OFF ../</buildArguments>
+ <buildTarget/>
+ <stopOnError>true</stopOnError>
+ <useDefaultCommand>false</useDefaultCommand>
+ <runAllBuilders>true</runAllBuilders>
+ </target>
+ </buildTargets>
+ </storageModule>
+</cproject>
diff --git a/CommonAPI-Examples/e04PhoneBook/.gitignore b/CommonAPI-Examples/E05Manager/.gitignore
index 5897208..5897208 100644
--- a/CommonAPI-Examples/e04PhoneBook/.gitignore
+++ b/CommonAPI-Examples/E05Manager/.gitignore
diff --git a/CommonAPI-Examples/E05Manager/.project b/CommonAPI-Examples/E05Manager/.project
new file mode 100644
index 0000000..3deb967
--- /dev/null
+++ b/CommonAPI-Examples/E05Manager/.project
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>E05Manager</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ </natures>
+</projectDescription>
diff --git a/CommonAPI-Examples/E05Manager/CMakeLists.txt b/CommonAPI-Examples/E05Manager/CMakeLists.txt
new file mode 100644
index 0000000..db10047
--- /dev/null
+++ b/CommonAPI-Examples/E05Manager/CMakeLists.txt
@@ -0,0 +1,90 @@
+# Copyright (C) 2014, 2015 BMW Group
+# Author: Manfred Bathelt (manfred.bathelt@bmw.de)
+# Author: Juergen Gehring (juergen.gehring@bmw.de)
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+cmake_minimum_required(VERSION 2.8)
+
+set(PRJ_NAME E05Manager)
+
+set(CMAKE_VERBOSE_MAKEFILE on)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP")
+
+message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}")
+
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
+ "Choose the type of build, options are: Debug Release." FORCE)
+endif(NOT CMAKE_BUILD_TYPE)
+message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
+
+OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version of CommonAPI" ON)
+message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}")
+
+if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON")
+ FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+else()
+ FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+endif()
+
+message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
+message(STATUS "COMMONAPI_INCLUDE_DIRS: ${COMMONAPI_INCLUDE_DIRS}")
+message(STATUS "CommonAPI-DBus_CONSIDERED_CONFIGS: ${CommonAPI-DBus_CONSIDERED_CONFIGS}")
+message(STATUS "COMMONAPI_DBUS_INCLUDE_DIRS: ${COMMONAPI_DBUS_INCLUDE_DIRS}")
+
+# CommonAPI
+include(FindPkgConfig)
+pkg_check_modules (DBUS "dbus-1 >= 1.4")
+
+# Source Files
+set(PRJ_SRC_PATH src)
+set(PRJ_SRC_GEN_PATH src-gen/v1_0/commonapi/examples)
+
+set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
+set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
+
+FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp)
+FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp)
+FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
+
+set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
+set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
+
+# Paths
+OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON)
+message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}")
+
+include_directories(
+ src-gen
+ ${COMMONAPI_INCLUDE_DIRS}
+ ${COMMONAPI_DBUS_INCLUDE_DIRS}
+ ${DBUS_INCLUDE_DIRS}
+)
+
+if ("${USE_INSTALLED_DBUS}" STREQUAL "ON")
+link_directories(
+ ${COMMONAPI_LIBDIR}
+ ${COMMONAPI_DBUS_LIBDIR}
+ ${DBUS_LIBDIR}
+)
+else()
+link_directories(
+ ${COMMONAPI_LIBDIR}
+ ${COMMONAPI_DBUS_LIBDIR}
+ ${DBUS_INCLUDE_DIRS}/dbus/.libs
+)
+endif()
+
+set(LINK_LIBRARIES -Wl,--no-as-needed CommonAPI-DBus -Wl,--as-needed CommonAPI ${DBUS_LIBRARIES})
+
+# Build Client
+add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
+target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES})
+
+# Build service
+add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
+target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES})
diff --git a/CommonAPI-Examples/E05Manager/README b/CommonAPI-Examples/E05Manager/README
new file mode 100644
index 0000000..66bd9a0
--- /dev/null
+++ b/CommonAPI-Examples/E05Manager/README
@@ -0,0 +1,125 @@
+=== Example 05: Managed
+
+So far we have looked at software systems, which consisted of services and users of these services, the clients. However, in some systems there is a slightly different kind of relationship between the software components: a central manager manages other services (let's call them slaves or leaves). This central manager is a service itself but acts as client for the managed services. One example for such a system is, for example, a device manager that manages several devices, which can be available for usage in the system or not. The central manager handles all administrative tasks related to the slaves and provides a central, common interface to the user frontend.
+
+image::{imagedir}/E05Manager.png[ManagerExample image]
+
+Franca IDL supports this kind of software structure by the keyword _manages_, which can be added to the keyword interface. The following example illustrates the application of this keyword.
+
+[source,java]
+----
+package commonapi.examples
+
+interface E05Manager manages E05Device, E05SpecialDevice {
+ version { major 1 minor 0 }
+
+ attribute String [] myDevices
+
+}
+
+interface E05Device {
+ version { major 1 minor 0 }
+
+ method doSomething {
+ }
+}
+
+interface E05SpecialDevice extends E05Device {
+ version { major 1 minor 0 }
+
+ method doSomethingSpecial {
+ }
+}
+----
+
+The device manager has the service interface E05Manager and it manages devices with the interfaces E05Device and E05SpecialDevice. It is important to understand, that the exact meaning of the keyword +manages+ cannot be defined by the IDL; the keyword just indicates that there is a relationship between software components which implement manager and managed interfaces. It can be used in bindings as CommonAPI to provide API functions for a more convenient implementation of this certain kind of relationship.
+
+Therefore let's have a look at the generated and implemented source code. Since we have three interfaces the code generator generates for every interface proxy and stub classes. In our example we just want to illuminate one aspect of the managed interfaces: the registration of the managed interfaces via the manager. We assume that we have only one service (the manager) which gets informed about a detected or a removed device via the public function deviceDetected and deviceRemoved. The devices are distinguished by a number; in principle there is an arbitrary number of devices possible. The registration of the devices at CommonAPI does the manager in his stub implementation.
+
+[source,{cppstr}]
+----
+... // includes, namespaces, constructors as usual
+
+E05ManagerStubImpl::E05ManagerStubImpl(const std::string instanceName) {
+ managerInstanceName = instanceName;
+}
+
+
+void E05ManagerStubImpl::deviceDetected (unsigned int n) {
+
+ std::string deviceInstanceName = getDeviceName(n);
+ myDevices[deviceInstanceName] = DevicePtr (new E05DeviceStubImpl);
+ const bool deviceRegistered = this->registerManagedStubE05Device(
+ myDevices[deviceInstanceName], deviceInstanceName);
+}
+
+void E05ManagerStubImpl::deviceRemoved (unsigned int n) {
+
+ std::string deviceInstanceName = getDeviceName (n);
+ const bool deviceDeregistered = this->deregisterManagedStubE05Device(
+ deviceInstanceName);
+ if ( deviceDeregistered ) { myDevices.erase (deviceInstanceName); }
+}
+
+std::string E05ManagerStubImpl::getDeviceName (unsigned int n) {
+
+ std::stringstream ss;
+ ss << managerInstanceName <<
+ ".device" << std::setw(2) << std::hex << std::setfill('0') << n;
+ return ss.str();
+}
+
+... // implementation of special device analogously
+----
+
+The functions for the special device has been omitted for clarity.The implementations of the devices themselves are not important here as well. See now the implementation of the client. The client gets informed about new or removed devices including the addresses of these devices via the callback function newDeviceAvailable. This function can be subscribed as function object at an status event that is triggered when a device is added or removed.
+
+[source, {cppstr}]
+----
+#include <unistd.h>
+#include <iostream>
+
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1_0/commonapi/examples/E05ManagerProxy.hpp>
+
+using namespace v1_0::commonapi::examples;
+
+void newDeviceAvailable(const std::string address,
+ const CommonAPI::AvailabilityStatus status) {
+
+ if (status == CommonAPI::AvailabilityStatus::AVAILABLE) {
+ std::cout << "New device available: " << address << std::endl;
+ }
+
+ if (status == CommonAPI::AvailabilityStatus::NOT_AVAILABLE) {
+ std::cout << "Device removed: " << address << std::endl;
+ }
+}
+
+int main() {
+ std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
+
+ const std::string &domain = "local";
+ const std::string &instance = "commonapi.examples.Manager";
+
+ std::shared_ptr<E05ManagerProxyDefault> myProxy =
+ runtime->buildProxy<E05ManagerProxy>(domain, instance);
+
+ while (!myProxy->isAvailable()) { usleep(10); }
+
+ CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& deviceEvent =
+ myProxy->getProxyManagerE05Device().getInstanceAvailabilityStatusChangedEvent();
+
+ /* special device analogously */
+
+ std::function<void(const std::string, const CommonAPI::AvailabilityStatus)>
+ newDeviceAvailableFunc = newDeviceAvailable;
+
+ deviceEvent.subscribe(newDeviceAvailableFunc);
+ specialDeviceEvent.subscribe(newDeviceAvailableFunc);
+
+ while (true) { std::this_thread::sleep_for(std::chrono::seconds(5)); }
+ return 0;
+}
+----
+
diff --git a/CommonAPI-Examples/e05Manager/fidl/E05Manager.fidl b/CommonAPI-Examples/E05Manager/fidl/E05Manager.fidl
index ff020b0..ff020b0 100644
--- a/CommonAPI-Examples/e05Manager/fidl/E05Manager.fidl
+++ b/CommonAPI-Examples/E05Manager/fidl/E05Manager.fidl
diff --git a/CommonAPI-Examples/e05Manager/src/E05DeviceStubImpl.cpp b/CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.cpp
index f8edfa9..80bc2be 100644
--- a/CommonAPI-Examples/e05Manager/src/E05DeviceStubImpl.cpp
+++ b/CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.cpp
@@ -9,8 +9,6 @@
#include "E05DeviceStubImpl.h"
-using namespace commonapi::examples;
-
E05DeviceStubImpl::E05DeviceStubImpl() {
}
diff --git a/CommonAPI-Examples/e05Manager/src/E05DeviceStubImpl.h b/CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.h
index e61a3cb..7b1932f 100644
--- a/CommonAPI-Examples/e05Manager/src/E05DeviceStubImpl.h
+++ b/CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.h
@@ -8,9 +8,9 @@
#ifndef E05DEVICESTUBIMPL_H_
#define E05DEVICESTUBIMPL_H_
-#include <commonapi/examples/E05DeviceStubDefault.h>
+#include <v1_0/commonapi/examples/E05DeviceStubDefault.hpp>
-using namespace commonapi::examples;
+using namespace v1_0::commonapi::examples;
class E05DeviceStubImpl: public E05DeviceStubDefault {
public:
diff --git a/CommonAPI-Examples/e05Manager/src/e05ManagerClient.cpp b/CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp
index b04b56d..d43fb3d 100644
--- a/CommonAPI-Examples/e05Manager/src/e05ManagerClient.cpp
+++ b/CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp
@@ -5,12 +5,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+#include <unistd.h>
+
#include <iostream>
-#include <CommonAPI/CommonAPI.h>
-#include <commonapi/examples/E05ManagerProxy.h>
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1_0/commonapi/examples/E05ManagerProxy.hpp>
-using namespace commonapi::examples;
+using namespace v1_0::commonapi::examples;
void newDeviceAvailable(const std::string address, const CommonAPI::AvailabilityStatus status) {
if (status == CommonAPI::AvailabilityStatus::AVAILABLE) {
@@ -23,12 +25,11 @@ void newDeviceAvailable(const std::string address, const CommonAPI::Availability
}
int main() {
- std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
-
- std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory();
+ std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
- const std::string& serviceAddress = "local:commonapi.examples.Manager:commonapi.examples.Manager";
- std::shared_ptr<E05ManagerProxyDefault> myProxy = factory->buildProxy<E05ManagerProxy>(serviceAddress);
+ const std::string &domain = "local";
+ const std::string &instance = "commonapi.examples.Manager";
+ std::shared_ptr<E05ManagerProxyDefault> myProxy = runtime->buildProxy<E05ManagerProxy>(domain, instance);
while (!myProxy->isAvailable()) {
usleep(10);
}
diff --git a/CommonAPI-Examples/e05Manager/src/e05ManagerService.cpp b/CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp
index 2ae5d07..188d46c 100644
--- a/CommonAPI-Examples/e05Manager/src/e05ManagerService.cpp
+++ b/CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp
@@ -8,24 +8,19 @@
#include <thread>
#include <iostream>
-#include <CommonAPI/CommonAPI.h>
+#include <CommonAPI/CommonAPI.hpp>
#include "E05ManagerStubImpl.h"
-using namespace commonapi::examples;
+using namespace v1_0::commonapi::examples;
static unsigned int cnt = 0; // counter for simulating external events
const static unsigned int maxDeviceNumber = 3;
const static std::string managerInstanceName = "commonapi.examples.Manager";
int main() {
- std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
- std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory();
- std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher = runtime->getServicePublisher();
-
- const std::string& serviceAddress = "local:commonapi.examples.Manager:" + managerInstanceName;
+ std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
std::shared_ptr<E05ManagerStubImpl> myService = std::make_shared < E05ManagerStubImpl > (managerInstanceName);
-
- const bool serviceRegistered = servicePublisher->registerService(myService, serviceAddress, factory);
+ const bool serviceRegistered = runtime->registerService("local", managerInstanceName, myService);
if (!serviceRegistered) {
std::cout << "Error: Unable to register service." << std::endl;
diff --git a/CommonAPI-Examples/e05Manager/src/E05ManagerStubImpl.cpp b/CommonAPI-Examples/E05Manager/src/E05ManagerStubImpl.cpp
index ab02edd..82f73e0 100644
--- a/CommonAPI-Examples/e05Manager/src/E05ManagerStubImpl.cpp
+++ b/CommonAPI-Examples/E05Manager/src/E05ManagerStubImpl.cpp
@@ -10,7 +10,7 @@
#include "E05ManagerStubImpl.h"
-using namespace commonapi::examples;
+using namespace v1_0::commonapi::examples;
E05ManagerStubImpl::E05ManagerStubImpl() {
}
diff --git a/CommonAPI-Examples/e05Manager/src/E05ManagerStubImpl.h b/CommonAPI-Examples/E05Manager/src/E05ManagerStubImpl.h
index c03c742..94be54d 100644
--- a/CommonAPI-Examples/e05Manager/src/E05ManagerStubImpl.h
+++ b/CommonAPI-Examples/E05Manager/src/E05ManagerStubImpl.h
@@ -10,13 +10,13 @@
#include <map>
-#include <CommonAPI/CommonAPI.h>
-#include <commonapi/examples/E05ManagerStubDefault.h>
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1_0/commonapi/examples/E05ManagerStubDefault.hpp>
#include "E05DeviceStubImpl.h"
#include "E05SpecialDeviceStubImpl.h"
-using namespace commonapi::examples;
+using namespace v1_0::commonapi::examples;
class E05ManagerStubImpl: public E05ManagerStubDefault {
diff --git a/CommonAPI-Examples/e05Manager/src/E05SpecialDeviceStubImpl.cpp b/CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.cpp
index 4bbcf88..f31710c 100644
--- a/CommonAPI-Examples/e05Manager/src/E05SpecialDeviceStubImpl.cpp
+++ b/CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.cpp
@@ -9,8 +9,6 @@
#include "E05SpecialDeviceStubImpl.h"
-using namespace commonapi::examples;
-
E05SpecialDeviceStubImpl::E05SpecialDeviceStubImpl() {
}
diff --git a/CommonAPI-Examples/e05Manager/src/E05SpecialDeviceStubImpl.h b/CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.h
index eb172f6..0649ac5 100644
--- a/CommonAPI-Examples/e05Manager/src/E05SpecialDeviceStubImpl.h
+++ b/CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.h
@@ -8,9 +8,9 @@
#ifndef E05SPECIALDEVICESTUBIMPL_H_
#define E05SPECIALDEVICESTUBIMPL_H_
-#include <commonapi/examples/E05SpecialDeviceStubDefault.h>
+#include <v1_0/commonapi/examples/E05SpecialDeviceStubDefault.hpp>
-using namespace commonapi::examples;
+using namespace v1_0::commonapi::examples;
class E05SpecialDeviceStubImpl: public E05SpecialDeviceStubDefault {
public:
diff --git a/CommonAPI-Examples/E06Unions/.cproject b/CommonAPI-Examples/E06Unions/.cproject
new file mode 100644
index 0000000..95bebce
--- /dev/null
+++ b/CommonAPI-Examples/E06Unions/.cproject
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="0.1743517197">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1743517197" moduleId="org.eclipse.cdt.core.settings" name="Default">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1743517197" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
+ <folderInfo id="0.1743517197." name="/" resourcePath="">
+ <toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1356057110" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
+ <targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1356057110.1351683931" name=""/>
+ <builder arguments="-C ${ProjDirPath}/build VERBOSE=0" buildPath="" command="make" id="org.eclipse.cdt.build.core.settings.default.builder.1927391379" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.libs.576448025" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.1490051833" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1742293224" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.1873415814" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1872659220" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.1934675545" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1097099165" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="e06Unions.null.1703363965" name="e06Unions"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="0.1743517197">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Default">
+ <resource resourceType="PROJECT" workspacePath="/e06Unions"/>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+ <buildTargets>
+ <target name="Run cmake" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+ <buildCommand>cmake</buildCommand>
+ <buildArguments>-E chdir build/ cmake -D CMAKE_BUILD_TYPE=Debug -D USE_INSTALLED_COMMONAPI=OFF -DUSE_INSTALLED_DBUS=OFF ../</buildArguments>
+ <buildTarget/>
+ <stopOnError>true</stopOnError>
+ <useDefaultCommand>false</useDefaultCommand>
+ <runAllBuilders>true</runAllBuilders>
+ </target>
+ </buildTargets>
+ </storageModule>
+</cproject>
diff --git a/CommonAPI-Examples/e05Manager/.gitignore b/CommonAPI-Examples/E06Unions/.gitignore
index 5897208..5897208 100644
--- a/CommonAPI-Examples/e05Manager/.gitignore
+++ b/CommonAPI-Examples/E06Unions/.gitignore
diff --git a/CommonAPI-Examples/E06Unions/.project b/CommonAPI-Examples/E06Unions/.project
new file mode 100644
index 0000000..e24f0e5
--- /dev/null
+++ b/CommonAPI-Examples/E06Unions/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>E06Unions</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/CommonAPI-Examples/E06Unions/CMakeLists.txt b/CommonAPI-Examples/E06Unions/CMakeLists.txt
new file mode 100644
index 0000000..641fd78
--- /dev/null
+++ b/CommonAPI-Examples/E06Unions/CMakeLists.txt
@@ -0,0 +1,90 @@
+# Copyright (C) 2014, 2015 BMW Group
+# Author: Manfred Bathelt (manfred.bathelt@bmw.de)
+# Author: Juergen Gehring (juergen.gehring@bmw.de)
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+cmake_minimum_required(VERSION 2.8)
+
+set(PRJ_NAME E06Unions)
+
+set(CMAKE_VERBOSE_MAKEFILE on)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP")
+
+message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}")
+
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
+ "Choose the type of build, options are: Debug Release." FORCE)
+endif(NOT CMAKE_BUILD_TYPE)
+message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
+
+OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version of CommonAPI" ON)
+message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}")
+
+if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON")
+ FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+else()
+ FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+endif()
+
+message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
+message(STATUS "COMMONAPI_INCLUDE_DIRS: ${COMMONAPI_INCLUDE_DIRS}")
+message(STATUS "CommonAPI-DBus_CONSIDERED_CONFIGS: ${CommonAPI-DBus_CONSIDERED_CONFIGS}")
+message(STATUS "COMMONAPI_DBUS_INCLUDE_DIRS: ${COMMONAPI_DBUS_INCLUDE_DIRS}")
+
+# CommonAPI
+include(FindPkgConfig)
+pkg_check_modules (DBUS "dbus-1 >= 1.4")
+
+# Source Files
+set(PRJ_SRC_PATH src)
+set(PRJ_SRC_GEN_PATH src-gen/commonapi/examples)
+
+set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
+set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
+
+FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp ${PRJ_SRC_GEN_PATH}/CommonTypes.cpp)
+FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp ${PRJ_SRC_GEN_PATH}/CommonTypes.cpp)
+FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
+
+set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
+set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
+
+# Paths
+OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON)
+message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}")
+
+include_directories(
+ src-gen
+ ${COMMONAPI_INCLUDE_DIRS}
+ ${COMMONAPI_DBUS_INCLUDE_DIRS}
+ ${DBUS_INCLUDE_DIRS}
+)
+
+if ("${USE_INSTALLED_DBUS}" STREQUAL "ON")
+link_directories(
+ ${COMMONAPI_LIBDIR}
+ ${COMMONAPI_DBUS_LIBDIR}
+ ${DBUS_LIBDIR}
+)
+else()
+link_directories(
+ ${COMMONAPI_LIBDIR}
+ ${COMMONAPI_DBUS_LIBDIR}
+ ${DBUS_INCLUDE_DIRS}/dbus/.libs
+)
+endif()
+
+set(LINK_LIBRARIES -Wl,--no-as-needed CommonAPI-DBus -Wl,--as-needed CommonAPI ${DBUS_LIBRARIES})
+
+# Build Client
+add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
+target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES})
+
+# Build service
+add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
+target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES})
diff --git a/CommonAPI-Examples/e06Unions/README b/CommonAPI-Examples/E06Unions/README
index 774f9b4..c4f1884 100644
--- a/CommonAPI-Examples/e06Unions/README
+++ b/CommonAPI-Examples/E06Unions/README
@@ -1,5 +1,4 @@
-Example 6: Unions
-~~~~~~~~~~~~~~~~~
+=== Example 06: Unions
Until now, some simple and complex data types in the examples already occurred. This example intends to describe the use of unions closer and to compare it with the usage of polymorphic structs. Consider the following Franca IDL example:
@@ -8,13 +7,14 @@ Until now, some simple and complex data types in the examples already occurred.
package commonapi.examples
interface E06Unions {
- version { major 1 minor 0 }
+ version { major 0 minor 0 }
attribute CommonTypes.SettingsUnion u
attribute CommonTypes.SettingsStruct x
}
typeCollection CommonTypes {
+ version { major 0 minor 0 }
typedef MyTypedef is Int32
@@ -52,7 +52,7 @@ typeCollection CommonTypes {
}
----
-We first want to leave the question aside whether this example makes sense from an application point of view or not; it is just an example for demonstration purposes. With unions we can transmit data of different types in one attribute. These different types are enumerated in one structure with the keyword *union*. D-Bus knows a similar data type which is called variant. Variants are used in the D-Bus binding for the implementation of unions. The interesting point is here not the definition of the union, but the realization in CommonAPI. I just want to point out here that it can lead to problems with the compiler or generally to problems with your toolchain if you define unions with an significant number of members (eg. >10), because each of these members appears in the generated C++ code as template argument in the template declaration.
+We first want to leave the question aside whether this example makes sense from an application point of view or not; it is just an example for demonstration purposes. With unions we can transmit data of different types in one attribute. These different types are enumerated in one structure with the keyword +union+. D-Bus knows a similar data type which is called variant. Variants are used in the D-Bus binding for the implementation of unions. The interesting point is here not the definition of the union, but the realization in CommonAPI. I just want to point out here that it can lead to problems with the compiler or generally to problems with your toolchain if you define unions with an significant number of members (eg. >10), because each of these members appears in the generated C++ code as template argument in the template declaration.
On the other hand we see the definition of a +polymorphic struct+ which can lead to a similar but not the same behavior. The difference is that the types of the +polymorphic struct+ definitions are extensions of a base type (here +SettingsStruct+), that means that they are inherited from this base type. The base type might contain some base elements which are then be inherited by the children. Another difference is, that the C++ API allows real polymorphic behavior. With Unions that is not possible, since there is no base type as we will see below.
@@ -61,32 +61,35 @@ The implementation of the set function for the attribute u in the stub implement
[source,{cppstr}]
----
void E06UnionsStubImpl::setMyValue(int n) {
-
- if ( n >= 0 && n < 4 ) {
-
- CommonTypes::MyTypedef t0 = -5;
- CommonTypes::MyEnum t1 = CommonTypes::MyEnum::OFF;
- uint8_t t2 = 42;
- std::string t3 = "abc";
-
- if ( n == 0 ) {
- CommonTypes::SettingsUnion v(t0);
- setUAttribute(v);
- setXAttribute(std::make_shared<CommonTypes::SettingsStructMyTypedef>(t0));
- } else if ( n == 1 ) {
- CommonTypes::SettingsUnion v(t1);
- setUAttribute(v);
- setXAttribute(std::make_shared<CommonTypes::SettingsStructMyEnum>(t1));
- } else if ( n == 2 ) {
- CommonTypes::SettingsUnion v(t2);
- setUAttribute(v);
- setXAttribute(std::make_shared<CommonTypes::SettingsStructUInt8>(t2));
- } else if ( n == 3 ) {
- CommonTypes::SettingsUnion v(t3);
- setUAttribute(v);
- setXAttribute(std::make_shared<CommonTypes::SettingsStructString>(t3));
- }
- }
+
+ if (n >= 0 && n < 4) {
+
+ CommonTypes::MyTypedef t0 = -5;
+ CommonTypes::MyEnum t1 = CommonTypes::MyEnum::OFF;
+ uint8_t t2 = 42;
+ std::string t3 = "∃y ∀x ¬(x ≺ y)";
+
+ if (n == 0) {
+ CommonTypes::SettingsUnion v(t0);
+ setUAttribute(v);
+ setXAttribute(std::make_shared<CommonTypes::SettingsStructMyTypedef>(t0));
+ } else if (n == 1) {
+ CommonTypes::SettingsUnion v(t1);
+ setUAttribute(v);
+ setXAttribute(std::make_shared<CommonTypes::SettingsStructMyEnum>(t1));
+ } else if (n == 2) {
+ CommonTypes::SettingsUnion v(t2);
+ setUAttribute(v);
+ setXAttribute(std::make_shared<CommonTypes::SettingsStructUInt8>(t2));
+ } else if (n == 3) {
+ CommonTypes::SettingsUnion v(t3);
+ setUAttribute(v);
+ setXAttribute(std::make_shared<CommonTypes::SettingsStructString>(t3));
+ }
+
+ } else {
+ std::cout << "Type number " << n << " not possible." << std::endl;
+ }
}
----
@@ -96,11 +99,14 @@ The standard implementation on client side to get the value of the attribute use
[source,{cppstr}]
----
+#include <unistd.h>
#include <iostream>
-#include <CommonAPI/CommonAPI.h>
-#include <commonapi/examples/E06UnionsProxy.h>
-#include <commonapi/examples/CommonTypes.h>
+#include <CommonAPI/CommonAPI.hpp>
+
+#include "../src-gen/commonapi/examples/CommonTypes.hpp"
+#include "../src-gen/commonapi/examples/E06UnionsProxy.hpp"
+#include "typeUtils.hpp"
using namespace commonapi::examples;
@@ -131,18 +137,20 @@ void recv_msg(const CommonTypes::SettingsUnion& v) {
}
int main() {
- std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
- std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory();
- const std::string& serviceAddress =
- "local:commonapi.examples.Unions:commonapi.examples.Unions";
+ std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
+
+ const std::string &domain = "local";
+ const std::string &instance = "commonapi.examples.Unions";
std::shared_ptr<E06UnionsProxyDefault> myProxy =
- factory->buildProxy<E06UnionsProxy> (serviceAddress);
+ runtime->buildProxy<E06UnionsProxy>(domain, instance);
+
while (!myProxy->isAvailable()) { usleep(10); }
std::function<void (CommonTypes::SettingsUnion)> f = recv_msg;
myProxy->getUAttribute().getChangedEvent().subscribe(f);
while (true) { usleep(10); }
+
return 0;
}
----
diff --git a/CommonAPI-Examples/e06Unions/fidl/E06Unions.fidl b/CommonAPI-Examples/E06Unions/fidl/E06Unions.fidl
index b244625..60dae9d 100644
--- a/CommonAPI-Examples/e06Unions/fidl/E06Unions.fidl
+++ b/CommonAPI-Examples/E06Unions/fidl/E06Unions.fidl
@@ -8,13 +8,14 @@
package commonapi.examples
interface E06Unions {
- version { major 1 minor 0 }
+ version { major 0 minor 0 }
attribute CommonTypes.SettingsUnion u
attribute CommonTypes.SettingsStruct x
}
typeCollection CommonTypes {
+ version { major 0 minor 0 }
typedef MyTypedef is Int32
diff --git a/CommonAPI-Examples/e06Unions/src/e06UnionsClient.cpp b/CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp
index ddefcf0..2fa2527 100644
--- a/CommonAPI-Examples/e06Unions/src/e06UnionsClient.cpp
+++ b/CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp
@@ -5,12 +5,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+#include <unistd.h>
+
#include <iostream>
-#include <CommonAPI/CommonAPI.h>
-#include <commonapi/examples/E06UnionsProxy.h>
-#include <commonapi/examples/CommonTypes.h>
+#include <CommonAPI/CommonAPI.hpp>
+#include "../src-gen/commonapi/examples/CommonTypes.hpp"
+#include "../src-gen/commonapi/examples/E06UnionsProxy.hpp"
#include "typeUtils.hpp"
using namespace commonapi::examples;
@@ -131,19 +133,19 @@ void recv_msg1(std::shared_ptr<CommonTypes::SettingsStruct> x) {
if ( std::shared_ptr<CommonTypes::SettingsStructMyTypedef> sp = std::dynamic_pointer_cast<CommonTypes::SettingsStructMyTypedef>(x) ) {
- std::cout << "Received (D) MyTypedef with value " << (int)sp->id << std::endl;
+ std::cout << "Received (D) MyTypedef with value " << (int)sp->getId() << std::endl;
} else if ( std::shared_ptr<CommonTypes::SettingsStructMyEnum> sp = std::dynamic_pointer_cast<CommonTypes::SettingsStructMyEnum>(x) ) {
- std::cout << "Received (D) MyEnum with value " << (int)sp->status << std::endl;
+ std::cout << "Received (D) MyEnum with value " << (int)sp->getStatus() << std::endl;
} else if ( std::shared_ptr<CommonTypes::SettingsStructUInt8> sp = std::dynamic_pointer_cast<CommonTypes::SettingsStructUInt8>(x) ) {
- std::cout << "Received (D) uint8_t with value " << (int)sp->channel << std::endl;
+ std::cout << "Received (D) uint8_t with value " << (int)sp->getChannel() << std::endl;
} else if ( std::shared_ptr<CommonTypes::SettingsStructString> sp = std::dynamic_pointer_cast<CommonTypes::SettingsStructString>(x) ) {
- std::cout << "Received (D) string " << sp->name << std::endl;
+ std::cout << "Received (D) string " << sp->getName() << std::endl;
} else {
@@ -153,11 +155,11 @@ void recv_msg1(std::shared_ptr<CommonTypes::SettingsStruct> x) {
int main() {
- std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
+ std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
- std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory();
- const std::string& serviceAddress = "local:commonapi.examples.Unions:commonapi.examples.Unions";
- std::shared_ptr<E06UnionsProxyDefault> myProxy = factory->buildProxy<E06UnionsProxy> (serviceAddress);
+ const std::string &domain = "local";
+ const std::string &instance = "commonapi.examples.Unions";
+ std::shared_ptr<E06UnionsProxyDefault> myProxy = runtime->buildProxy<E06UnionsProxy>(domain, instance);
while (!myProxy->isAvailable()) {
usleep(10);
diff --git a/CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp b/CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp
new file mode 100644
index 0000000..0e1cf02
--- /dev/null
+++ b/CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp
@@ -0,0 +1,34 @@
+/* Copyright (C) 2014 BMW Group
+ * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
+ * Author: Juergen Gehring (juergen.gehring@bmw.de)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <thread>
+#include <iostream>
+
+#include <CommonAPI/CommonAPI.hpp>
+#include "E06UnionsStubImpl.h"
+
+int main() {
+ std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
+
+ const std::string &domain = "local";
+ const std::string &instance = "commonapi.examples.Unions";
+ std::shared_ptr<E06UnionsStubImpl> myService = std::make_shared<E06UnionsStubImpl>();
+
+ if (runtime->registerService(domain, instance, myService)) {
+ int n = 0;
+ while (true) {
+ std::cout << "Set value " << n << " for union u." << std::endl;
+ myService->setMyValue(n);
+ n++;
+ if (n == 4) {
+ n = 0;
+ }
+ std::this_thread::sleep_for(std::chrono::seconds(2));
+ }
+ }
+ return 0;
+}
diff --git a/CommonAPI-Examples/e06Unions/src/E06UnionsStubImpl.cpp b/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.cpp
index 31f2365..58e9f82 100644
--- a/CommonAPI-Examples/e06Unions/src/E06UnionsStubImpl.cpp
+++ b/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.cpp
@@ -6,7 +6,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "E06UnionsStubImpl.h"
-#include <commonapi/examples/CommonTypes.h>
+
+#include "../src-gen/commonapi/examples/CommonTypes.hpp"
using namespace commonapi::examples;
diff --git a/CommonAPI-Examples/e06Unions/src/E06UnionsStubImpl.h b/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.h
index 0297dbb..cc3b0bf 100644
--- a/CommonAPI-Examples/e06Unions/src/E06UnionsStubImpl.h
+++ b/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.h
@@ -8,8 +8,9 @@
#ifndef E06UNIONSSTUBIMPL_H_
#define E06UNIONSSTUBIMPL_H_
-#include <CommonAPI/CommonAPI.h>
-#include <commonapi/examples/E06UnionsStubDefault.h>
+#include <CommonAPI/CommonAPI.hpp>
+
+#include "../src-gen/commonapi/examples/E06UnionsStubDefault.hpp"
class E06UnionsStubImpl: public commonapi::examples::E06UnionsStubDefault {
diff --git a/CommonAPI-Examples/e06Unions/src/typeUtils.hpp b/CommonAPI-Examples/E06Unions/src/typeUtils.hpp
index 0dfb0f2..0dfb0f2 100644
--- a/CommonAPI-Examples/e06Unions/src/typeUtils.hpp
+++ b/CommonAPI-Examples/E06Unions/src/typeUtils.hpp
diff --git a/CommonAPI-Examples/E07Mainloop/.cproject b/CommonAPI-Examples/E07Mainloop/.cproject
new file mode 100644
index 0000000..fc8a4e4
--- /dev/null
+++ b/CommonAPI-Examples/E07Mainloop/.cproject
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="0.416559588">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.416559588" moduleId="org.eclipse.cdt.core.settings" name="Default">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildProperties="" description="" id="0.416559588" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
+ <folderInfo id="0.416559588." name="/" resourcePath="">
+ <toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1038958730" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
+ <targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1038958730.2115115764" name=""/>
+ <builder arguments="-C ${ProjDirPath}/build VERBOSE=0" buildPath="" command="make" id="org.eclipse.cdt.build.core.settings.default.builder.1812880292" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.libs.1019901481" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.259363632" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.840421715" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.1212471744" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <option id="org.eclipse.cdt.build.core.settings.holder.incpaths.427233418" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/ascgit017.CommonAPI/include}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/E01HelloWorld/src-gen}&quot;"/>
+ <listOptionValue builtIn="false" value="/usr/include/c++/4.8.2"/>
+ </option>
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1678702299" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ <tool id="org.eclipse.cdt.build.core.settings.holder.291757453" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
+ <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1117944646" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="e01HelloWorld.null.741055877" name="e01HelloWorld"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="0.416559588">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Default">
+ <resource resourceType="PROJECT" workspacePath="/e01HelloWorld"/>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+ <buildTargets>
+ <target name="Run cmake" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+ <buildCommand>cmake</buildCommand>
+ <buildArguments>-E chdir build/ cmake -D CMAKE_BUILD_TYPE=Debug -DUSE_INSTALLED_COMMONAPI=OFF -DUSE_INSTALLED_DBUS=OFF ../</buildArguments>
+ <buildTarget/>
+ <stopOnError>true</stopOnError>
+ <useDefaultCommand>false</useDefaultCommand>
+ <runAllBuilders>true</runAllBuilders>
+ </target>
+ </buildTargets>
+ </storageModule>
+</cproject>
diff --git a/CommonAPI-Examples/E07Mainloop/.gitignore b/CommonAPI-Examples/E07Mainloop/.gitignore
new file mode 100644
index 0000000..5fb7e99
--- /dev/null
+++ b/CommonAPI-Examples/E07Mainloop/.gitignore
@@ -0,0 +1,2 @@
+build
+src-gen
diff --git a/CommonAPI-Examples/E07Mainloop/.project b/CommonAPI-Examples/E07Mainloop/.project
new file mode 100644
index 0000000..93b34d5
--- /dev/null
+++ b/CommonAPI-Examples/E07Mainloop/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>E07Mainloop</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/CommonAPI-Examples/E07Mainloop/CMakeLists.txt b/CommonAPI-Examples/E07Mainloop/CMakeLists.txt
new file mode 100644
index 0000000..2642156
--- /dev/null
+++ b/CommonAPI-Examples/E07Mainloop/CMakeLists.txt
@@ -0,0 +1,125 @@
+# Copyright (C) 2015 BMW Group
+# Author: Lutz Bichler (lutz.bichler@bmw.de)
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+cmake_minimum_required(VERSION 2.8)
+
+set(PRJ_NAME E07Mainloop)
+
+set(CMAKE_VERBOSE_MAKEFILE on)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP -DLINUX")
+
+message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}")
+
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
+ "Choose the type of build, options are: Debug Release." FORCE)
+endif(NOT CMAKE_BUILD_TYPE)
+message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
+
+OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version of CommonAPI" ON)
+message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}")
+
+if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON")
+ FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+else()
+ FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+endif()
+
+message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
+message(STATUS "COMMONAPI_INCLUDE_DIRS: ${COMMONAPI_INCLUDE_DIRS}")
+message(STATUS "CommonAPI-DBus_CONSIDERED_CONFIGS: ${CommonAPI-DBus_CONSIDERED_CONFIGS}")
+message(STATUS "COMMONAPI_DBUS_INCLUDE_DIRS: ${COMMONAPI_DBUS_INCLUDE_DIRS}")
+
+# CommonAPI
+include(FindPkgConfig)
+pkg_check_modules (DBUS "dbus-1 >= 1.4")
+
+# SOME/IP
+find_package (CommonAPI-SomeIP 3.1.1 REQUIRED)
+find_package (vsomeip 1.1.0 REQUIRED)
+
+# GLib
+FIND_PACKAGE(glib-2.0)
+if (GLIB_FOUND)
+ message ( STATUS "Glib found: " ${GLIB_INCLUDE_DIRS} " " ${_GLIB_LIBRARY_DIR} " " ${GLIBCONFIG_INCLUDE_DIR} )
+ include_directories(${GLIB_INCLUDE_DIRS} ${GLIBCONFIG_INCLUDE_DIR})
+ #link_directories(${_GLIB_LIBRARY_DIR})
+else (GLIB_FOUND)
+ message ( WARNING "Glib not found.")
+endif (GLIB_FOUND)
+
+# Source Files
+set(PRJ_SRC_PATH src)
+set(PRJ_SRC_GEN_PATH src-gen)
+set(PRJ_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/v1_0/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/v1_0/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/v1_0/commonapi/examples)
+
+set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
+set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
+
+# Application
+FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Proxy.cpp)
+FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Stub*.cpp)
+FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_COMMONAPI_PATH}/*Stub*.cpp)
+set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
+set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_SRC_PATH}/${PRJ_NAME}StubImpl.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
+
+# DBus library
+FILE(GLOB PRJ_DBUS_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_DBUS_PATH}/*cpp)
+
+# SOME/IP library
+FILE(GLOB PRJ_SOMEIP_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH}/*cpp)
+
+# Paths
+OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON)
+message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}")
+
+include_directories(
+ src-gen/core
+ src-gen/dbus
+ src-gen/someip
+ ${COMMONAPI_INCLUDE_DIRS}
+ ${COMMONAPI_DBUS_INCLUDE_DIRS}
+ ${COMMONAPI_SOMEIP_INCLUDE_DIRS}
+ ${DBUS_INCLUDE_DIRS}
+ ${VSOMEIP_INCLUDE_DIRS}
+)
+
+if ("${USE_INSTALLED_DBUS}" STREQUAL "ON")
+link_directories(
+ ${COMMONAPI_LIBDIR}
+ ${COMMONAPI_DBUS_LIBDIR}
+ ${COMMONAPI_SOMEIP_CMAKE_DIR}/build
+)
+else()
+link_directories(
+ ${COMMONAPI_LIBDIR}
+ ${COMMONAPI_DBUS_LIBDIR}
+ ${COMMONAPI_SOMEIP_CMAKE_DIR}/build
+ ${DBUS_INCLUDE_DIRS}/dbus/.libs
+)
+endif()
+
+set(LINK_LIBRARIES -Wl,--as-needed CommonAPI glib-2.0)
+
+# Build Client
+add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
+target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES})
+
+# Build service
+add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
+target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES})
+
+# Build DBus library
+add_library (${PRJ_NAME}-DBus SHARED ${PRJ_DBUS_LIB_SRCS})
+target_link_libraries(${PRJ_NAME}-DBus CommonAPI-DBus)
+
+# Build SOME/IP library
+add_library (${PRJ_NAME}-SomeIP SHARED ${PRJ_SOMEIP_LIB_SRCS})
+target_link_libraries(${PRJ_NAME}-SomeIP CommonAPI-SomeIP) \ No newline at end of file
diff --git a/CommonAPI-Examples/E07Mainloop/README b/CommonAPI-Examples/E07Mainloop/README
new file mode 100644
index 0000000..b8c99d7
--- /dev/null
+++ b/CommonAPI-Examples/E07Mainloop/README
@@ -0,0 +1,6 @@
+=== Example 07: Mainloop
+
+This example shows how CommonAPI can be integrated with an external main loop. For demonstration purposes the +glib+ main loop is used.
+
+CommonAPI does not contain a main loop implementation itself; just a demo implementation is provided for test purposes (please have a look to the verification tests in the CommonAPI tools project to find out how the demo main loop is used).
+
diff --git a/CommonAPI-Examples/E07Mainloop/commonapi4dbus.ini b/CommonAPI-Examples/E07Mainloop/commonapi4dbus.ini
new file mode 100644
index 0000000..39a52b7
--- /dev/null
+++ b/CommonAPI-Examples/E07Mainloop/commonapi4dbus.ini
@@ -0,0 +1,8 @@
+[default]
+binding=dbus
+
+[proxy]
+local:commonapi.examples.E07Mainloop:commonapi.examples.Mainloop=libE07Mainloop-DBus.so
+
+[stub]
+local:commonapi.examples.E07Mainloop:commonapi.examples.Mainloop=libE07Mainloop-DBus.so
diff --git a/CommonAPI-Examples/E07Mainloop/commonapi4someip.ini b/CommonAPI-Examples/E07Mainloop/commonapi4someip.ini
new file mode 100644
index 0000000..0c68943
--- /dev/null
+++ b/CommonAPI-Examples/E07Mainloop/commonapi4someip.ini
@@ -0,0 +1,8 @@
+[default]
+binding=someip
+
+[proxy]
+local:commonapi.examples.E07Mainloop:commonapi.examples.Mainloop=libE07Mainloop-SomeIP.so
+
+[stub]
+local:commonapi.examples.E07Mainloop:commonapi.examples.Mainloop=libE07Mainloop-SomeIP.so
diff --git a/CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fdepl b/CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fdepl
new file mode 100644
index 0000000..c617777
--- /dev/null
+++ b/CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fdepl
@@ -0,0 +1,40 @@
+/* Copyright (C) 2015 BMW Group
+ * Author: Lutz Bichler (lutz.bichler@bmw.de)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
+import "E07Mainloop.fidl"
+
+define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E07Mainloop {
+ SomeIpServiceID = 4660
+
+ attribute x {
+ SomeIpGetterID = 3000
+ SomeIpSetterID = 3001
+ SomeIpNotifierID = 33010
+ SomeIpEventGroups = { 33010 }
+ }
+
+ method sayHello {
+ SomeIpMethodID = 33000
+
+ in {
+ name {
+ SomeIpStringEncoding = utf16le
+ }
+ }
+ }
+
+}
+
+define org.genivi.commonapi.someip.deployment for provider Service {
+ instance commonapi.examples.E07Mainloop {
+ InstanceId = "commonapi.examples.Mainloop"
+
+ SomeIpInstanceID = 22136
+
+ SomeIpUnicastAddress = "192.168.0.2"
+ SomeIpUnicastPort = 30499
+ }
+} \ No newline at end of file
diff --git a/CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fidl b/CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fidl
new file mode 100644
index 0000000..c835cd9
--- /dev/null
+++ b/CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fidl
@@ -0,0 +1,22 @@
+/* Copyright (C) 2015 BMW Group
+ * Author: Lutz Bichler (lutz.bichler@bmw.de)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package commonapi.examples
+
+interface E07Mainloop {
+ version { major 1 minor 0 }
+
+ attribute Int32 x
+
+ method sayHello {
+ in {
+ String name
+ }
+ out {
+ String message
+ }
+ }
+} \ No newline at end of file
diff --git a/CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp b/CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp
new file mode 100644
index 0000000..02954be
--- /dev/null
+++ b/CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp
@@ -0,0 +1,196 @@
+/* Copyright (C) 2015 BMW Group
+ * Author: Lutz Bichler (lutz.bichler@bmw.de)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <iostream>
+#include <unistd.h>
+#include <sstream>
+
+#include <glib.h>
+
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1_0/commonapi/examples/E07MainloopProxy.hpp>
+
+using namespace v1_0::commonapi::examples;
+
+GIOChannel* channel;
+
+std::future<CommonAPI::CallStatus> gFutureCallStatus;
+std::future<CommonAPI::CallStatus> gFutureCallStatusISIA;
+std::future<CommonAPI::CallStatus> gFutureCallStatusGetAttrX;
+
+int32_t gValueForX = 428394;
+
+void myAttrXCallback(const CommonAPI::CallStatus& callStatus, const int32_t& val) {
+ std::cout << "Receive callback for Attribute x: " << val << std::endl;
+}
+
+void mySayHelloCallback(const CommonAPI::CallStatus& _callStatus, const std::string& _returnMessage) {
+
+ if (_callStatus != CommonAPI::CallStatus::SUCCESS) {
+ std::cerr << "Remote call failed!\n";
+ return;
+ }
+ std::cout << "Got message: '" << _returnMessage << "'\n";
+
+}
+
+gboolean callSetAttrX(void* proxy) {
+
+ std::cout << "callSetAttrX called ..." << std::endl;
+
+ E07MainloopProxy<>* myProxy = static_cast<E07MainloopProxy<>*>(proxy);
+ myProxy->getXAttribute().setValueAsync(gValueForX , myAttrXCallback);
+
+ return false;
+}
+
+gboolean callGetAttrX(void* proxy) {
+
+ std::cout << "callGetAttrX called ..." << std::endl;
+
+ E07MainloopProxy<>* myProxy = static_cast<E07MainloopProxy<>*>(proxy);
+ myProxy->getXAttribute().getValueAsync(myAttrXCallback);
+
+ return false;
+}
+
+gboolean callSayHello(void* proxy) {
+
+ std::cout << "callSayHello called ..." << std::endl;
+
+ static int number = 1;
+
+ std::stringstream stream;
+ stream << "World (" << number << ")";
+ const std::string name = stream.str();
+
+ E07MainloopProxy<>* myProxy = static_cast<E07MainloopProxy<>*>(proxy);
+ gFutureCallStatus = myProxy->sayHelloAsync(name, mySayHelloCallback);
+
+ number++;
+
+ return true;
+}
+
+class GDispatchWrapper: public GSource {
+ public:
+ GDispatchWrapper(CommonAPI::DispatchSource* dispatchSource): dispatchSource_(dispatchSource) {}
+ CommonAPI::DispatchSource* dispatchSource_;
+};
+
+gboolean dispatchPrepare ( GSource* source, gint* timeout ) {
+
+ bool result = false;
+ int64_t eventTimeout;
+
+ result = static_cast<GDispatchWrapper*>(source)->dispatchSource_->prepare(eventTimeout);
+
+ *timeout = eventTimeout;
+
+ return result;
+}
+
+gboolean dispatchCheck ( GSource* source ) {
+
+ return static_cast<GDispatchWrapper*>(source)->dispatchSource_->check();
+}
+
+gboolean dispatchExecute ( GSource* source, GSourceFunc callback, gpointer userData ) {
+
+ static_cast<GDispatchWrapper*>(source)->dispatchSource_->dispatch();
+ return true;
+}
+
+static GSourceFuncs standardGLibSourceCallbackFuncs = {
+ dispatchPrepare,
+ dispatchCheck,
+ dispatchExecute,
+ NULL
+};
+
+gboolean gWatchDispatcher ( GIOChannel *source, GIOCondition condition, gpointer userData ) {
+
+ CommonAPI::Watch* watch = static_cast<CommonAPI::Watch*>(userData);
+ watch->dispatch(condition);
+ return true;
+}
+
+gboolean gTimeoutDispatcher ( void* userData ) {
+
+ return static_cast<CommonAPI::DispatchSource*>(userData)->dispatch();
+}
+
+void watchAddedCallback ( CommonAPI::Watch* watch, const CommonAPI::DispatchPriority dispatchPriority ) {
+
+ const pollfd& fileDesc = watch->getAssociatedFileDescriptor();
+ channel = g_io_channel_unix_new(fileDesc.fd);
+
+ GSource* gWatch = g_io_create_watch(channel, static_cast<GIOCondition>(fileDesc.events));
+ g_source_set_callback(gWatch, reinterpret_cast<GSourceFunc>(&gWatchDispatcher), watch, NULL);
+
+ const auto& dependentSources = watch->getDependentDispatchSources();
+ for (auto dependentSourceIterator = dependentSources.begin();
+ dependentSourceIterator != dependentSources.end();
+ dependentSourceIterator++) {
+ GSource* gDispatchSource = g_source_new(&standardGLibSourceCallbackFuncs, sizeof(GDispatchWrapper));
+ static_cast<GDispatchWrapper*>(gDispatchSource)->dispatchSource_ = *dependentSourceIterator;
+
+ g_source_add_child_source(gWatch, gDispatchSource);
+
+ }
+ g_source_attach(gWatch, NULL);
+}
+
+void watchRemovedCallback ( CommonAPI::Watch* watch ) {
+
+ g_source_remove_by_user_data(watch);
+
+ if(channel) {
+ g_io_channel_unref(channel);
+ channel = NULL;
+ }
+}
+
+int main() {
+ std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get();
+
+ std::string domain = "local";
+ std::string instance = "commonapi.examples.Mainloop";
+ std::string connection = "client-sample";
+
+ std::shared_ptr<CommonAPI::MainLoopContext> mainloopContext = std::make_shared<CommonAPI::MainLoopContext>(connection);
+
+ std::function<void(CommonAPI::Watch*, const CommonAPI::DispatchPriority)> f_watchAddedCallback = watchAddedCallback;
+ std::function<void(CommonAPI::Watch*)> f_watchRemovedCallback = watchRemovedCallback;
+ mainloopContext->subscribeForWatches(f_watchAddedCallback, f_watchRemovedCallback);
+
+ std::shared_ptr<E07MainloopProxyDefault> myProxy = runtime->buildProxy<E07MainloopProxy>(domain,
+ instance, mainloopContext);
+
+ std::cout << "Checking availability" << std::flush;
+ static constexpr bool mayBlock = false;
+ int count = 0;
+ while (!myProxy->isAvailable()) {
+ if (count % 10 == 0)
+ std::cout << "." << std::flush;
+ g_main_context_iteration(NULL, mayBlock);
+ usleep(50000);
+ }
+ std::cout << "done." << std::endl;
+
+ GMainLoop* mainloop = NULL;
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ void *proxyPtr = (void*)myProxy.get();
+ g_timeout_add(100, callSayHello, proxyPtr);
+ g_timeout_add(5000, callGetAttrX, proxyPtr);
+ g_timeout_add(9000, callSetAttrX, proxyPtr);
+
+ g_main_loop_run (mainloop);
+ g_main_loop_unref (mainloop);
+
+ return 0;
+}
diff --git a/CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp b/CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp
new file mode 100644
index 0000000..e57f192
--- /dev/null
+++ b/CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp
@@ -0,0 +1,140 @@
+/* Copyright (C) 2015 BMW Group
+ * Author: Lutz Bichler (lutz.bichler@bmw.de)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <iostream>
+#include <thread>
+
+#include <glib.h>
+
+#include <CommonAPI/CommonAPI.hpp>
+#include "E07MainloopStubImpl.hpp"
+
+using namespace std;
+
+GIOChannel* channel;
+
+gboolean callIncCounter(void* service) {
+
+ E07MainloopStubImpl* myService = static_cast<E07MainloopStubImpl*>(service);
+ myService->incAttrX();
+
+ return true;
+}
+
+gboolean callWaitingInfo(void* service) {
+ std::cout << "Waiting for calls... (Abort with CTRL+C)" << std::endl;
+
+ return true;
+}
+
+class GDispatchWrapper: public GSource {
+ public:
+ GDispatchWrapper(CommonAPI::DispatchSource* dispatchSource): dispatchSource_(dispatchSource) {}
+ CommonAPI::DispatchSource* dispatchSource_;
+};
+
+gboolean dispatchPrepare ( GSource* source, gint* timeout ) {
+
+ bool result = false;
+ int64_t eventTimeout;
+
+ result = static_cast<GDispatchWrapper*>(source)->dispatchSource_->prepare(eventTimeout);
+
+ *timeout = eventTimeout;
+
+ return result;
+}
+
+gboolean dispatchCheck ( GSource* source ) {
+
+ return static_cast<GDispatchWrapper*>(source)->dispatchSource_->check();
+}
+
+gboolean dispatchExecute ( GSource* source, GSourceFunc callback, gpointer userData ) {
+
+ static_cast<GDispatchWrapper*>(source)->dispatchSource_->dispatch();
+ return true;
+}
+
+static GSourceFuncs standardGLibSourceCallbackFuncs = {
+ dispatchPrepare,
+ dispatchCheck,
+ dispatchExecute,
+ NULL
+};
+
+gboolean gWatchDispatcher ( GIOChannel *source, GIOCondition condition, gpointer userData ) {
+
+ CommonAPI::Watch* watch = static_cast<CommonAPI::Watch*>(userData);
+ watch->dispatch(condition);
+ return true;
+}
+
+gboolean gTimeoutDispatcher ( void* userData ) {
+
+ return static_cast<CommonAPI::DispatchSource*>(userData)->dispatch();
+}
+
+void watchAddedCallback ( CommonAPI::Watch* watch, const CommonAPI::DispatchPriority dispatchPriority ) {
+
+ const pollfd& fileDesc = watch->getAssociatedFileDescriptor();
+ channel = g_io_channel_unix_new(fileDesc.fd);
+
+ GSource* gWatch = g_io_create_watch(channel, static_cast<GIOCondition>(fileDesc.events));
+ g_source_set_callback(gWatch, reinterpret_cast<GSourceFunc>(&gWatchDispatcher), watch, NULL);
+
+ const auto& dependentSources = watch->getDependentDispatchSources();
+ for (auto dependentSourceIterator = dependentSources.begin();
+ dependentSourceIterator != dependentSources.end();
+ dependentSourceIterator++) {
+ GSource* gDispatchSource = g_source_new(&standardGLibSourceCallbackFuncs, sizeof(GDispatchWrapper));
+ static_cast<GDispatchWrapper*>(gDispatchSource)->dispatchSource_ = *dependentSourceIterator;
+
+ g_source_add_child_source(gWatch, gDispatchSource);
+
+ }
+ g_source_attach(gWatch, NULL);
+}
+
+void watchRemovedCallback ( CommonAPI::Watch* watch ) {
+
+ g_source_remove_by_user_data(watch);
+
+ if(channel) {
+ g_io_channel_unref(channel);
+ channel = NULL;
+ }
+}
+
+int main() {
+ std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
+
+ std::string domain = "local";
+ std::string instance = "commonapi.examples.Mainloop";
+ std::string connection = "service-sample";
+
+ std::shared_ptr<CommonAPI::MainLoopContext> mainloopContext = std::make_shared<CommonAPI::MainLoopContext>(connection);
+
+ std::function<void(CommonAPI::Watch*, const CommonAPI::DispatchPriority)> f_watchAddedCallback = watchAddedCallback;
+ std::function<void(CommonAPI::Watch*)> f_watchRemovedCallback = watchRemovedCallback;
+ mainloopContext->subscribeForWatches(f_watchAddedCallback, f_watchRemovedCallback);
+
+ std::shared_ptr<E07MainloopStubImpl> myService = std::make_shared<E07MainloopStubImpl>();
+ runtime->registerService(domain, instance, myService, mainloopContext);
+
+ GMainLoop* mainloop = NULL;
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ void *servicePtr = (void*)myService.get();
+ g_timeout_add_seconds(10, callWaitingInfo, servicePtr);
+
+ g_timeout_add(2500, callIncCounter, servicePtr);
+
+ g_main_loop_run (mainloop);
+ g_main_loop_unref (mainloop);
+
+ return 0;
+}
diff --git a/CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.cpp b/CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.cpp
new file mode 100644
index 0000000..53a2cd0
--- /dev/null
+++ b/CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.cpp
@@ -0,0 +1,33 @@
+/* Copyright (C) 2015 BMW Group
+ * Author: Lutz Bichler (lutz.bichler@bmw.de)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "E07MainloopStubImpl.hpp"
+
+E07MainloopStubImpl::E07MainloopStubImpl() {
+ setXAttribute(0);
+}
+
+E07MainloopStubImpl::~E07MainloopStubImpl() {
+}
+
+void E07MainloopStubImpl::sayHello(const std::shared_ptr<CommonAPI::ClientId> _client,
+ std::string _name,
+ sayHelloReply_t _reply) {
+
+ std::stringstream messageStream;
+
+ messageStream << "Hello " << _name << "!";
+ std::cout << "sayHello('" << _name << "'): '" << messageStream.str() << "'\n";
+
+ _reply(messageStream.str());
+}
+
+void E07MainloopStubImpl::incAttrX() {
+ int32_t xValue = getXAttribute();
+ xValue++;
+ setXAttribute((int32_t)xValue);
+ std::cout << "New counter value = " << xValue << "!" << std::endl;
+}
diff --git a/CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.hpp b/CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.hpp
new file mode 100644
index 0000000..1cd82b1
--- /dev/null
+++ b/CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.hpp
@@ -0,0 +1,24 @@
+/* Copyright (C) 2015 BMW Group
+ * Author: Lutz Bichler (lutz.bichler@bmw.de)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef E07MAINLOOPSTUBIMPL_H_
+#define E07MAINLOOPSTUBIMPL_H_
+
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1_0/commonapi/examples/E07MainloopStubDefault.hpp>
+
+class E07MainloopStubImpl: public v1_0::commonapi::examples::E07MainloopStubDefault {
+
+public:
+ E07MainloopStubImpl();
+ virtual ~E07MainloopStubImpl();
+
+ virtual void sayHello(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _name, sayHelloReply_t _return);
+ virtual void incAttrX();
+
+};
+
+#endif /* E07MAINLOOPSTUBIMPL_H_ */
diff --git a/CommonAPI-Examples/E07Mainloop/vsomeip.json b/CommonAPI-Examples/E07Mainloop/vsomeip.json
new file mode 100644
index 0000000..641f13b
--- /dev/null
+++ b/CommonAPI-Examples/E07Mainloop/vsomeip.json
@@ -0,0 +1,47 @@
+{
+ "unicast" : "192.168.0.235",
+ "logging" :
+ {
+ "level" : "info",
+ "console" : "true",
+ "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" },
+ "dlt" : "false"
+ },
+ "applications" :
+ [
+ {
+ "name" : "client-sample",
+ "id" : "0x1343"
+ },
+ {
+ "name" : "other-client-sample",
+ "id" : "0x1344"
+ },
+ {
+ "name" : "service-sample",
+ "id" : "0x1277"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "default",
+ "delays" :
+ {
+ "initial" : { "minimum" : "10", "maximum" : "100" },
+ "repetition-base" : "200",
+ "repetition-max" : "3",
+ "cyclic-offer" : "2000",
+ "cyclic-request" : "2001"
+ }
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/CommonAPI-Examples/README b/CommonAPI-Examples/README
index 19ce46c..8425ed4 100644
--- a/CommonAPI-Examples/README
+++ b/CommonAPI-Examples/README
@@ -1,23 +1,16 @@
-Preliminary remarks
-~~~~~~~~~~~~~~~~~~~
+=== Preliminary remarks
-The examples describe how some standard problems of interface design and implementation can be solved with Franca IDL and CommonAPI. Before you start make sure that your environment is properly installed. That means:
-
-- You can start the code generator in your Eclipse installation or from command line.
-- Your PKG_CONFIG_PATH contains the paths to the package config files of CommnAPI, CommonAPI-DBus and your patched D-Bus.
-- You have patched the DBus library with the patch in CommonAPI-D-Bus and you are sure that your LD_LIBRARY_PATH contains the path to the patched DBus library.
-- Make sure dbus session bus is available ($ env |grep DBUS_SESSION_BUS_ADDRESS, output must not be empty!).
-- If your platform is Windows, please read the instructions for Windows first. The following instructions assume that your are working on a Linux platform.
+The examples describe how some standard problems of interface design and implementation can be solved with Franca IDL and CommonAPI. Before you start make sure that your environment is properly installed as described in the integration guide. Please do not consider only the integration guide in this document but also in the binding specific tutorial.
The examples provide a more or less generic CMake file for building the executables. Two executables are needed: a service and a client program. The standard procedure to build one of these example programs is:
----
-$ mkdir build; cd build
-$ cmake -D DBUS_PATH_LOCAL=<your_local_path_of_the_patched_dbus_library> -D PRJ_NAME=<name_of_the_example> ..
+$ cd build
+$ cmake -D USE_INSTALLED_COMMONAPI=ON/OFF ..
$ make
----
-_name_of_the_example_ is +e01HelloWorld+ for the first example.
+Set USE_INSTALLED_COMMONAPI to ON if you use an installed version of CommonAPI; set it to OFF if you use working copy.
Here are some hints if you want to configure your eclipse project for the CMake build:
@@ -27,13 +20,10 @@ Here are some hints if you want to configure your eclipse project for the CMake
----
make -C ${ProjDirPath}/build VERBOSE=1
----
-- The Build Directory must be empty.
-- Create a make target (eg via Window->Show View->Make Target). Set the build command to:
+
+The Build Directory must be empty. Create a make target (eg via Window->Show View->Make Target). Set the build command to:
----
-cmake -E chdir build/ cmake -D DBUS_PATH_LOCAL=
- <your_local_path_of_the_patched_dbus_library> -D PRJ_NAME=<name_of_the_example> ..
+cmake -E chdir build/ cmake ..
----
-and leave the Make Target field empty. Finally, create in "Run Configurations" two configurations for client and service. Note that it might be necessary to start the executables with a local setting of the +LD_LIBRARY_PATH+ (eg to +/usr/local/lib+) since CommonAPI applications use a patched version of libdbus.
-
diff --git a/CommonAPI-Examples/e01HelloWorld/CMakeLists.txt b/CommonAPI-Examples/e01HelloWorld/CMakeLists.txt
deleted file mode 100644
index d558653..0000000
--- a/CommonAPI-Examples/e01HelloWorld/CMakeLists.txt
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright (C) 2014 BMW Group
-# Author: Manfred Bathelt (manfred.bathelt@bmw.de)
-# Author: Juergen Gehring (juergen.gehring@bmw.de)
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-cmake_minimum_required(VERSION 2.8)
-
-# Project settings
-if (PRJ_NAME)
- message(STATUS "Start CMake for Project " ${PRJ_NAME})
-else()
- message(FATAL_ERROR "Please specify your project name using -D PRJ_NAME=yourName")
-endif()
-project(${PRJ_NAME})
-set(CMAKE_VERBOSE_MAKEFILE on)
-set(CMAKE_CXX_FLAGS "-Wall -O0 -std=c++0x")
-set(CMAKE_BUILD_TYPE Debug)
-
-# DBus Path
-if (DBUS_LIB_PATH)
- message(STATUS "DBUS_LIB_PATH = " ${DBUS_LIB_PATH})
-else()
- message(FATAL_ERROR "Please specify the path to your patched DBus library using -D DBUS_LIB_PATH=yourPath")
-endif()
-
-# CommonAPI
-include(FindPkgConfig)
-pkg_check_modules (DBUS "dbus-1 >= 1.4")
-pkg_check_modules (COMMONAPI "CommonAPI >= 2.1")
-pkg_check_modules (COMMONAPI_DBUS "CommonAPI-DBus >= 2.1")
-
-# Source Files
-set(PRJ_SRC_PATH src)
-set(PRJ_SRC_GEN_PATH src-gen/commonapi/examples)
-
-set(PRJ_NAME_CLIENT ${PROJECT_NAME}Client)
-set(PRJ_NAME_SERVICE ${PROJECT_NAME}Service)
-
-FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp)
-FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp)
-FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
-
-set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
-set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
-
-# Paths
-message(STATUS "COMMONAPI_INCLUDEDIR = " ${COMMONAPI_INCLUDEDIR})
-message(STATUS "COMMONAPI_DBUS_INCLUDEDIR = " ${COMMONAPI_DBUS_INCLUDEDIR})
-
-include_directories(
- src-gen
- ${DBUS_INCLUDE_DIRS}
- ${COMMONAPI_INCLUDEDIR}
- ${COMMONAPI_DBUS_INCLUDEDIR}
-)
-
-link_directories(
- ${DBUS_LIB_PATH}
- ${COMMONAPI_LIBDIR}
- ${COMMONAPI_DBUS_LIBDIR}
-)
-
-# Build Client
-add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
-target_link_libraries(${PRJ_NAME_CLIENT} CommonAPI CommonAPI-DBus)
-
-# Build service
-add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
-target_link_libraries(${PRJ_NAME_SERVICE} CommonAPI CommonAPI-DBus)
diff --git a/CommonAPI-Examples/e01HelloWorld/README b/CommonAPI-Examples/e01HelloWorld/README
deleted file mode 100644
index 8128fd9..0000000
--- a/CommonAPI-Examples/e01HelloWorld/README
+++ /dev/null
@@ -1,5 +0,0 @@
-Example 1: Hello World
-~~~~~~~~~~~~~~~~~~~~~~
-
-This example contains the code for the step by step introduction to CommonAPI.
-
diff --git a/CommonAPI-Examples/e01HelloWorld/src/E01HelloWorldStubImpl.cpp b/CommonAPI-Examples/e01HelloWorld/src/E01HelloWorldStubImpl.cpp
deleted file mode 100644
index 2e50ce9..0000000
--- a/CommonAPI-Examples/e01HelloWorld/src/E01HelloWorldStubImpl.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (C) 2014 BMW Group
- * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
- * Author: Juergen Gehring (juergen.gehring@bmw.de)
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "E01HelloWorldStubImpl.h"
-
-E01HelloWorldStubImpl::E01HelloWorldStubImpl() {
-}
-
-E01HelloWorldStubImpl::~E01HelloWorldStubImpl() {
-}
-
-void E01HelloWorldStubImpl::sayHello(const std::shared_ptr<CommonAPI::ClientId> clientId,
- std::string name,
- std::string& message) {
- std::stringstream messageStream;
-
- messageStream << "Hello " << name << "!";
- message = messageStream.str();
-
- std::cout << "sayHello('" << name << "'): '" << message << "'\n";
-};
diff --git a/CommonAPI-Examples/e01HelloWorld/src/e01HelloWorldClient.cpp b/CommonAPI-Examples/e01HelloWorld/src/e01HelloWorldClient.cpp
deleted file mode 100644
index 6537a02..0000000
--- a/CommonAPI-Examples/e01HelloWorld/src/e01HelloWorldClient.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright (C) 2014 BMW Group
- * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
- * Author: Juergen Gehring (juergen.gehring@bmw.de)
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include <iostream>
-
-#include <CommonAPI/CommonAPI.h> //Defined in the Common API Runtime library
-#include <commonapi/examples/E01HelloWorldProxy.h> //Part of the code we just generated
-
-using namespace commonapi::examples;
-
-int main() {
- std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::load();
-
- std::shared_ptr < CommonAPI::Factory > factory = runtime->createFactory();
- const std::string& serviceAddress = "local:commonapi.examples.HelloWorld:commonapi.examples.HelloWorld";
- std::shared_ptr<E01HelloWorldProxyDefault> myProxy = factory->buildProxy<E01HelloWorldProxy>(serviceAddress);
-
- while (!myProxy->isAvailable()) {
- usleep(10);
- }
-
- const std::string name = "World";
- CommonAPI::CallStatus callStatus;
- std::string returnMessage;
-
- myProxy->sayHello(name, callStatus, returnMessage);
- if (callStatus != CommonAPI::CallStatus::SUCCESS) {
- std::cerr << "Remote call failed!\n";
- return -1;
- }
-
- std::cout << "Got message: '" << returnMessage << "'\n";
-
- return 0;
-}
diff --git a/CommonAPI-Examples/e01HelloWorld/src/e01HelloWorldService.cpp b/CommonAPI-Examples/e01HelloWorld/src/e01HelloWorldService.cpp
deleted file mode 100644
index 5351065..0000000
--- a/CommonAPI-Examples/e01HelloWorld/src/e01HelloWorldService.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright (C) 2014 BMW Group
- * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
- * Author: Juergen Gehring (juergen.gehring@bmw.de)
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include <iostream>
-#include <thread>
-
-#include <CommonAPI/CommonAPI.h>
-#include "E01HelloWorldStubImpl.h"
-
-using namespace std;
-
-int main() {
- std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
- std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory();
- std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher = runtime->getServicePublisher();
-
- const std::string& serviceAddress = "local:commonapi.examples.HelloWorld:commonapi.examples.HelloWorld";
- std::shared_ptr<E01HelloWorldStubImpl> myService = std::make_shared<E01HelloWorldStubImpl>();
- servicePublisher->registerService(myService, serviceAddress, factory);
-
- while (true) {
- std::cout << "Waiting for calls... (Abort with CTRL+C)" << std::endl;
- std::this_thread::sleep_for(std::chrono::seconds(60));
- }
-
- return 0;
-}
diff --git a/CommonAPI-Examples/e02Attributes/CMakeLists.txt b/CommonAPI-Examples/e02Attributes/CMakeLists.txt
deleted file mode 100644
index 15aa464..0000000
--- a/CommonAPI-Examples/e02Attributes/CMakeLists.txt
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright (C) 2014 BMW Group
-# Author: Manfred Bathelt (manfred.bathelt@bmw.de)
-# Author: Juergen Gehring (juergen.gehring@bmw.de)
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-cmake_minimum_required(VERSION 2.8)
-
-# Project settings
-if (PRJ_NAME)
- message(STATUS "Start CMake for Project " ${PRJ_NAME})
-else()
- message(FATAL_ERROR "Please specify your project name using -D PRJ_NAME=yourName")
-endif()
-project(${PRJ_NAME})
-set(CMAKE_VERBOSE_MAKEFILE on)
-set(CMAKE_CXX_FLAGS "-Wall -O0 -std=c++0x")
-set(CMAKE_BUILD_TYPE Debug)
-
-# DBus Path
-if (DBUS_LIB_PATH)
- message(STATUS "DBUS_LIB_PATH = " ${DBUS_LIB_PATH})
-else()
- message(FATAL_ERROR "Please specify the path to your patched DBus library using -D DBUS_LIB_PATH=yourPath")
-endif()
-
-# CommonAPI
-include(FindPkgConfig)
-pkg_check_modules (DBUS "dbus-1 >= 1.4")
-pkg_check_modules (COMMONAPI "CommonAPI >= 2.1")
-pkg_check_modules (COMMONAPI_DBUS "CommonAPI-DBus >= 2.1")
-
-# Source Files
-set(PRJ_SRC_PATH src)
-set(PRJ_SRC_GEN_PATH src-gen/commonapi/examples)
-
-set(PRJ_NAME_CLIENT ${PROJECT_NAME}Client)
-set(PRJ_NAME_SERVICE ${PROJECT_NAME}Service)
-
-FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_SRC_GEN_PATH}/*Types.cpp)
-FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/*Types.cpp)
-FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
-
-set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
-set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
-
-# Paths
-message(STATUS "COMMONAPI_INCLUDEDIR = " ${COMMONAPI_INCLUDEDIR})
-message(STATUS "COMMONAPI_DBUS_INCLUDEDIR = " ${COMMONAPI_DBUS_INCLUDEDIR})
-
-include_directories(
- src-gen
- ${DBUS_INCLUDE_DIRS}
- ${COMMONAPI_INCLUDEDIR}
- ${COMMONAPI_DBUS_INCLUDEDIR}
-)
-
-link_directories(
- ${DBUS_LIB_PATH}
- ${COMMONAPI_LIBDIR}
- ${COMMONAPI_DBUS_LIBDIR}
-)
-
-# Build Client
-add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
-target_link_libraries(${PRJ_NAME_CLIENT} CommonAPI CommonAPI-DBus)
-
-# Build service
-add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
-target_link_libraries(${PRJ_NAME_SERVICE} CommonAPI CommonAPI-DBus)
diff --git a/CommonAPI-Examples/e02Attributes/README b/CommonAPI-Examples/e02Attributes/README
deleted file mode 100644
index 758e4ff..0000000
--- a/CommonAPI-Examples/e02Attributes/README
+++ /dev/null
@@ -1,170 +0,0 @@
-Example 2: Attributes
-~~~~~~~~~~~~~~~~~~~~~~
-
-Consider the Franca IDL specification of example 2:
-
-[source,java]
-----
-package commonapi.examples
-
-interface E02Attributes {
- version { major 1 minor 0 }
-
- attribute Int32 x
-
- attribute CommonTypes.a1Struct a1
-}
-
-typeCollection CommonTypes {
-
- struct a1Struct {
- String s
- a2Struct a2
- }
-
- struct a2Struct {
- Boolean b
- Double d
- }
-}
-----
-
-Modelling attributes in interfaces means in general that the service that implements this interface has an internal state which shall be visible for external clients like a HMI (Human Machine Interface). A developer of a client would normally expect that he can set and get the attribute and that he can notify or subscribe to changes of the value of the attribute. We will see below in the implementation how exactly this is realized by CommonAPI. Franca offers two key words that indicate exactly how the attribute can be accessed: +readonly+ and +noSubscriptions+. The default setting is that everything is allowed; with these two additional key words these possibilies can be limited (eg if someone tries to call a set method and the attribute is readonly he will get an error at compile time).
-
-The nested structure +a1Struct+ is defined in a type collection +CommonTypes+. Structures can be defined just like other type definitions within an interface definition or outside in a type collection. Since Franca 0.8.9 type collections can also be anonymous (without name). A type collection is transferred by the CommonAPI code generator in an additional namespace.
-
-The Franca interface specification of attributes does not contain any information about whether the access from client side is synchronous or asynchronous or whether the attribute is cached by the proxy. CommonAPI provides always methods for synchronous and asynchronous setter and getter methods; caching can be realized via an API extension.
-
-Now let's have a look to the CommonAPI code on the service side. The default implementation of the stub which is generated by the CommonAPI codegenerator defines the attribute as private attribute of the stub class. This attribute can be accessed from the stub implementation via getter and setter functions. Additionaly the API for the stub implementation provides some callbacks (the following code snippet shows parts of the generated stub class which refer to the attribute x):
-
-[source,{cppstr}]
-----
-class E02AttributesStubDefault : public virtual E02AttributesStub {
- public:
- E02AttributesStubDefault();
-
- virtual const int32_t& getXAttribute(
- const std::shared_ptr<CommonAPI::ClientId> clientId);
-
- virtual void setXAttribute(
- const std::shared_ptr<CommonAPI::ClientId> clientId, int32_t value);
-
- protected:
- virtual bool trySetXAttribute(int32_t value);
- virtual bool validateXAttributeRequestedValue(const int32_t& value);
- virtual void onRemoteXAttributeChanged();
-
- private:
- int32_t xAttributeValue_;
-};
-----
-
-If the implementation of the stub has to change the value of the attribute +x+, let's say in a class +E02AttributesStubImpl+ that is derived from +E02AttributesStubDefault+, then it can call +setXAttribute+ (analog the usage of +getXAttribute+). The callback +onRemoteXAttributeChanged+ informs that a change of the attribute +x+ has been completed. The other callbacks can prevent the set of the attribute (+validateXAttributeRequestedValue+) or change the given value from the client (+trySetXAttribute+).
-
-In the example the service increments a counter every 2 seconds and publishes the counter value via the interface attribute +x+.
-
-Now see the implementation of the client. The simplest case is to get the current value of +x+. The following extract shows one part of the main function:
-
-[source,{cppstr}]
-----
-#include <iostream>
-
-#include <CommonAPI/CommonAPI.h>
-#include <commonapi/examples/E02AttributesProxy.h>
-
-using namespace commonapi::examples;
-
-int main() {
-
- std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::load();
-
- std::shared_ptr < CommonAPI::Factory > factory = runtime->createFactory();
- const std::string& serviceAddress =
- "local:commonapi.examples.Attributes:commonapi.examples.Attributes";
- std::shared_ptr < E02AttributesProxyDefault > myProxy =
- factory->buildProxy < E02AttributesProxy > (serviceAddress);
-
- while (!myProxy->isAvailable()) { usleep(10); }
-
- CommonAPI::CallStatus callStatus;
- int32_t value = 0;
-
- // Get actual attribute value from service
- myProxy->getXAttribute().getValue(callStatus, value);
- if (callStatus != CommonAPI::CallStatus::SUCCESS) {
- std::cerr << "Remote call A failed!\n";
- return -1;
- }
- std::cout << "Got attribute value: " << value << std::endl;
-
-}
-----
-
-The +getXAttribute+ method will deliver the type +XAttribute+ which has to be used for the access to +x+. Every access returns a flag named callStatus (please see the CommonAPI specification). Subscription requires in general the definition of a callback function which is called in case of an attribute change. The subscribe method of CommonAPI requires a function object; for a compact notation this function object can be defined as lambda function:
-
-[source,{cppstr}]
-----
-myProxy->getXAttribute().getChangedEvent().subscribe([&](const int32_t& val) {
- std::cout << "Received change message: " << val << std::endl;
-});
-----
-
-Of course it is also possible to define a separate callback function with an user-defined name (here recv_cb):
-
-[source,{cppstr}]
-----
-void recv_cb(const CommonAPI::CallStatus& callStatus, const int32_t& val) {
- std::cout << "Receive callback: " << val << std::endl;
-}
-
-.... // main method
-
-// Subscribe for receiving values, alternative implementation 1
-std::function<void (int32_t)> f = recv_msg;
-myProxy->getXAttribute().getChangedEvent().subscribe(f);
-
-// Subscribe for receiving values, alternative implementation 2
-myProxy->getXAttribute().getChangedEvent().subscribe(
- std::bind(recv_msg, std::placeholders::_1));
-----
-
-Asynchronous setting of attributes via setValueAsync works analog as shown in the following code extract where the more complex attribute _a1_ is set from the client:
-
-[source,{cppstr}]
-----
-void recv_cb_s(const CommonAPI::CallStatus& callStatus,
- const CommonTypes::a1Struct& valStruct) {
-
- std::cout << "Receive callback for structure: a1.s = " <<
- valStruct.s << ", valStruct.a2.d = " << valStruct.a2.d << std::endl;
-}
-.... // main method
-
-CommonTypes::a1Struct valueStruct;
-
-valueStruct.s = "abc";
-valueStruct.a2.b = true;
-valueStruct.a2.d = 1234;
-
-std::function<void (const CommonAPI::CallStatus&, CommonTypes::a1Struct)> fcb_s =
- recv_cb_s;
-
-myProxy->getA1Attribute().setValueAsync(valueStruct, fcb_s);
-----
-
-As described above, in the chapter "Attribute Extensions" of this tutorial, it is possible to extend the standard CommonAPI for attributes by defining Attribute Extensions. In this example you have to:
-
-* include the template definition of the extension (AttributeCacheExtension.hpp)
-* to call a different factory method for creating the proxy (e.g. buildProxyWithDefaultAttributeExtension)
-* and then it is possible to call the new defined methods, e.g.
-
-[source,{cppstr}]
-----
-int32_t valueCached = 0;
-bool r;
-r = myProxy->getXAttributeExtension().getCachedValue(valueCached);
-std::cout << "Got cached attribute value[" << (int)r << "]: " << valueCached << std::endl;
-----
-
-See the source code of the example for a deeper insight.
-
diff --git a/CommonAPI-Examples/e03Methods/CMakeLists.txt b/CommonAPI-Examples/e03Methods/CMakeLists.txt
deleted file mode 100644
index e321988..0000000
--- a/CommonAPI-Examples/e03Methods/CMakeLists.txt
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright (C) 2014 BMW Group
-# Author: Manfred Bathelt (manfred.bathelt@bmw.de)
-# Author: Juergen Gehring (juergen.gehring@bmw.de)
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-cmake_minimum_required(VERSION 2.8)
-
-# Project settings
-if (PRJ_NAME)
- message(STATUS "Start CMake for Project " ${PRJ_NAME})
-else()
- message(FATAL_ERROR "Please specify your project name using -D PRJ_NAME=yourName")
-endif()
-project(${PRJ_NAME})
-set(CMAKE_VERBOSE_MAKEFILE on)
-set(CMAKE_CXX_FLAGS "-Wall -std=c++0x")
-set(CMAKE_BUILD_TYPE Debug)
-
-# DBus Path
-if (DBUS_LIB_PATH)
- message(STATUS "DBUS_LIB_PATH = " ${DBUS_LIB_PATH})
-else()
- message(FATAL_ERROR "Please specify the path to your patched DBus library using -D DBUS_LIB_PATH=yourPath")
-endif()
-
-# CommonAPI
-include(FindPkgConfig)
-pkg_check_modules (DBUS "dbus-1 >= 1.4")
-pkg_check_modules (COMMONAPI "CommonAPI >= 2.1")
-pkg_check_modules (COMMONAPI_DBUS "CommonAPI-DBus >= 2.1")
-
-# Source Files
-set(PRJ_SRC_PATH src)
-set(PRJ_SRC_GEN_PATH src-gen/commonapi/examples)
-
-set(PRJ_NAME_CLIENT ${PROJECT_NAME}Client)
-set(PRJ_NAME_SERVICE ${PROJECT_NAME}Service)
-
-FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_SRC_GEN_PATH}/*Types.cpp)
-FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/*Types.cpp)
-FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
-
-set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
-set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
-
-# Paths
-message(STATUS "COMMONAPI_INCLUDEDIR = " ${COMMONAPI_INCLUDEDIR})
-message(STATUS "COMMONAPI_DBUS_INCLUDEDIR = " ${COMMONAPI_DBUS_INCLUDEDIR})
-
-include_directories(
- src-gen
- ${DBUS_INCLUDE_DIRS}
- ${COMMONAPI_INCLUDEDIR}
- ${COMMONAPI_DBUS_INCLUDEDIR}
-)
-
-link_directories(
- ${DBUS_LIB_PATH}
- ${COMMONAPI_LIBDIR}
- ${COMMONAPI_DBUS_LIBDIR}
-)
-
-# Build Client
-add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
-target_link_libraries(${PRJ_NAME_CLIENT} CommonAPI CommonAPI-DBus)
-
-# Build service
-add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
-target_link_libraries(${PRJ_NAME_SERVICE} CommonAPI CommonAPI-DBus)
diff --git a/CommonAPI-Examples/e04PhoneBook/CMakeLists.txt b/CommonAPI-Examples/e04PhoneBook/CMakeLists.txt
deleted file mode 100644
index 64346fb..0000000
--- a/CommonAPI-Examples/e04PhoneBook/CMakeLists.txt
+++ /dev/null
@@ -1,72 +0,0 @@
-# Copyright (C) 2014 BMW Group
-# Author: Manfred Bathelt (manfred.bathelt@bmw.de)
-# Author: Juergen Gehring (juergen.gehring@bmw.de)
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-cmake_minimum_required(VERSION 2.8)
-
-# Project settings
-if (PRJ_NAME)
- message(STATUS "Start CMake for Project " ${PRJ_NAME})
-else()
- message(FATAL_ERROR "Please specify your project name using -D PRJ_NAME=yourName")
-endif()
-project(${PRJ_NAME})
-set(CMAKE_VERBOSE_MAKEFILE on)
-set(CMAKE_CXX_FLAGS "-Wall -std=c++0x")
-set(CMAKE_BUILD_TYPE Debug)
-
-# DBus Path
-if (DBUS_LIB_PATH)
- message(STATUS "DBUS_LIB_PATH = " ${DBUS_LIB_PATH})
-else()
- message(FATAL_ERROR "Please specify the path to your patched DBus library using -D DBUS_LIB_PATH=yourPath")
-endif()
-
-# CommonAPI
-include(FindPkgConfig)
-pkg_check_modules (DBUS "dbus-1 >= 1.4")
-pkg_check_modules (COMMONAPI "CommonAPI >= 2.1")
-pkg_check_modules (COMMONAPI_DBUS "CommonAPI-DBus >= 2.1")
-
-# Source Files
-set(PRJ_SRC_PATH src)
-set(PRJ_SRC_GEN_PATH src-gen/commonapi/examples)
-
-set(PRJ_NAME_CLIENT ${PROJECT_NAME}Client)
-set(PRJ_NAME_SERVICE ${PROJECT_NAME}Service)
-
-STRING(REGEX REPLACE "^e" "E" PRJ_DATA_IMPL ${PRJ_NAME})
-FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_SRC_GEN_PATH}/*Types.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_DATA_IMPL}.cpp)
-FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/*Types.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_DATA_IMPL}.cpp)
-FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
-
-set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
-set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
-
-# Paths
-message(STATUS "COMMONAPI_INCLUDEDIR = " ${COMMONAPI_INCLUDEDIR})
-message(STATUS "COMMONAPI_DBUS_INCLUDEDIR = " ${COMMONAPI_DBUS_INCLUDEDIR})
-
-include_directories(
- src-gen
- ${DBUS_INCLUDE_DIRS}
- ${COMMONAPI_INCLUDEDIR}
- ${COMMONAPI_DBUS_INCLUDEDIR}
-)
-
-link_directories(
- ${DBUS_LIB_PATH}
- ${COMMONAPI_LIBDIR}
- ${COMMONAPI_DBUS_LIBDIR}
-)
-
-# Build Client
-add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
-target_link_libraries(${PRJ_NAME_CLIENT} CommonAPI CommonAPI-DBus)
-
-# Build service
-add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
-target_link_libraries(${PRJ_NAME_SERVICE} CommonAPI CommonAPI-DBus)
diff --git a/CommonAPI-Examples/e04PhoneBook/README b/CommonAPI-Examples/e04PhoneBook/README
deleted file mode 100644
index 90a2eb5..0000000
--- a/CommonAPI-Examples/e04PhoneBook/README
+++ /dev/null
@@ -1,237 +0,0 @@
-Example 4: PhoneBook
-~~~~~~~~~~~~~~~~~~~~
-
-This slightly more complex example illustrates the application of some Franca features in combination with CommonAPI:
-
-- explicit named arrays and inline arrays
-- selective broadcasts
-- polymorphic structs
-
-Concerning arrays please note the following points:
-
-- In Franca there are two ways to define arrays: explicitly named (array myArray of UInt8) or implicit without defining a new name for the array (UInt8 []).
-- The implicit definition of multidimensional arrays is not possible at the moment (like UInt8 [][]), but multidimensional arrays can be defined with explicit names.
-- In CommonAPI arrays are implemented and generated as std::vector.
-
-A common problem in the specification of interfaces between user frontends and services which contain large data sets is, that the clients usually need only extracts from the database. That means that only a filtered excerpt from the database has to be transmitted via IPC to the client, but probably every client needs a different excerpt. The filter can affect the selection of the elements (element filter), the contents of the elements (content filter) or the number of elements (array window).
-
-The following example shows how different extracts of a central data array can be accessed by the several clients via a data filter mechansim and selective broadcasts. As example of a central data array a phonebook is selected; the following picture shows the basic content of the example.
-
-image::{imagedir}/E04PhoneBook.png[PhoneBookExample image]
-
-The Franca IDL specification is:
-
-[source,java]
-----
-package commonapi.examples
-
-interface E04PhoneBook {
-
- version { major 1 minor 0 }
-
- <** @description : the phone book itself **>
- attribute phoneBookStruct [] phoneBook readonly
-
- <** @description : filter operations **>
- method setPhoneBookDataFilter {
- in {
- elementFilterStruct elementFilter
- contentFilterStruct [] contentFilter
- }
- }
-
- <** @description : filter result **>
- broadcast phoneBookDataSet selective {
- out {
- phoneBookDataElementMap [] phoneBookDataSet
- }
- }
-
- <** @description : Data types of the phone book itself **>
- enumeration phoneNumberEnum {
- WORK
- HOME
- MOBILE1
- MOBILE2
- }
-
- map phoneNumberMap {
- phoneNumberEnum to String
- }
-
- struct phoneBookStruct {
- String name
- String forename
- String organisation
- String address
- String email
- phoneNumberMap phoneNumber
- }
-
- <** @description : Data types for the filter operations **>
-
- struct elementFilterStruct {
- Boolean addName
- Boolean addForename
- Boolean addOrganisation
- Boolean addAddress
- Boolean addEmail
- Boolean addPhoneNumber
- }
-
- struct contentFilterStruct {
- phoneBookDataElementEnum element
- String expression
- }
-
- <** @description : Data types for the result of the phone book filter **>
- enumeration phoneBookDataElementEnum {
- NAME
- FORENAME
- ORGANISATION
- ADDRESS
- EMAIL
- PHONENUMBER
- }
-
- struct phoneBookDataElement polymorphic {
- }
-
- struct phoneBookDataElementString extends phoneBookDataElement {
- String content
- }
-
- struct phoneBookDataElementPhoneNumber extends phoneBookDataElement {
- phoneNumberMap content
- }
-
- map phoneBookDataElementMap {
- phoneBookDataElementEnum to phoneBookDataElement
- }
-}
-----
-
-The phone book itself is modeled as an attribute which is an array of the structure +phoneBookStruct+. Here the phone book is readonly, that means that the whole content can be accessed only via subscription and the getter function. A special difficulty is the phone number, because there are several kinds of phone numbers allowed (home, mobile, ...). Therefore the element +phoneNumber+ in +phoneBookStruct+ is a map with an enumeration key and a value of type string for the number. The client can set a filter to the phone book data (in the example only content filter and element filter, but other filters are conceivable) via the method +setPhoneBookDataFilter+ and gets the data back via the selective broadcast +phoneBookDataSet+. Since the content of the data set depends on the filter, the elements of the client specific data set are specified as maps where the key is the type of the element (name, forename, ...) and the value is the content of the element. The content can be of the type String or of the user defined type phoneNumberMap. Therefore the value is defined as polymorphic struct which can be a String or a phoneNumberMap.
-
-In the following we consider only some interesting implementation details, for the complete implementation please see the source code.
-
-The interesting part of the service is the implementation of the set function for the data filter. At the moment only the element filter is implemented, but the implementation of the other filters can be added analogously.
-
-- Each client is identified via its clientId; the implementation of client ID class allows the usage of cientId objects as key in a map (see the specification).
-- The data sets of the filtered data for the clients are stored in a map with the clientId as key; in this example the filtered data are sent back to the client directly in the filter set function. Please note, that firePhoneBookDataSetSelective sends the data to only one receiver.
-- The value of the key has to be the right type (+phoneNumberMap+ for phoneNumbers and Strings for the rest).
-
-[source,{cppstr}]
-----
-void E04PhoneBookStubImpl::setPhoneBookDataFilter (
- const std::shared_ptr<CommonAPI::ClientId> clientId,
- E04PhoneBook::elementFilterStruct elementFilter,
- std::vector<E04PhoneBook::contentFilterStruct> contentFilter ) {
-
- std::shared_ptr<CommonAPI::ClientIdList> clientIdList =
- getSubscribersForPhoneBookDataSetSelective();
-
- std::vector<E04PhoneBook::phoneBookDataElementMap> lPhoneBookDataSet;
- phoneBookClientData.erase (clientId);
-
- std::vector<E04PhoneBook::phoneBookStruct>::const_iterator it0;
- for (it0 = getPhoneBookAttribute().begin();
- it0 != getPhoneBookAttribute().end(); it0++ ) {
-
- E04PhoneBook::phoneBookDataElementMap lPhoneBookDataElement;
-
- if ( elementFilter.addName ) {
- std::shared_ptr<E04PhoneBook::phoneBookDataElementString> name =
- std::make_shared<E04PhoneBook::phoneBookDataElementString>();
-
- name->content = it0->name;
-
- lPhoneBookDataElement[E04PhoneBook::phoneBookDataElementEnum::NAME] =
- name;
- }
-
- ... // analogue for the other elements
-
- if ( elementFilter.addPhoneNumber ) {
- std::shared_ptr<E04PhoneBook::phoneBookDataElementPhoneNumber> phoneNumber =
- std::make_shared<E04PhoneBook::phoneBookDataElementPhoneNumber>();
-
- phoneNumber->content = it0->phoneNumber;
-
- lPhoneBookDataElement[E04PhoneBook::phoneBookDataElementEnum::PHONENUMBER] =
- phoneNumber;
- }
-
- lPhoneBookDataSet.push_back(lPhoneBookDataElement);
-
- }
-
- phoneBookClientData[clientId] = lPhoneBookDataSet;
-
- // Send client data
- const std::shared_ptr<CommonAPI::ClientIdList> receivers(new CommonAPI::ClientIdList);
- receivers->insert(clientId);
-
- firePhoneBookDataSetSelective(lPhoneBookDataSet, receivers);
- receivers->erase(clientId);
-}
-----
-
-On client side we create two proxies which shall set different filters and get different data sets. For these two proxies we need different factories! Otherwise CommonAPI cannot keep the proxies apart. Each proxy has to subscribe to phoneBookDataSet, but gets different contents depending on the filter. The whole phoneBookData can be obtained via the standard get function.
-
-[source,{cppstr}]
-----
-int main() {
-
- std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
-
- std::shared_ptr<CommonAPI::Factory> factoryA = runtime->createFactory();
- std::shared_ptr<CommonAPI::Factory> factoryB = runtime->createFactory();
-
- const std::string& serviceAddress =
- "local:commonapi.examples.PhoneBook:commonapi.examples.PhoneBook";
-
- std::shared_ptr<E04PhoneBookProxy<>> myProxyA =
- factoryA->buildProxy<E04PhoneBookProxy>(serviceAddress);
- while (!myProxyA->isAvailable()) { usleep(10); }
-
- std::shared_ptr<E04PhoneBookProxy<>> myProxyB =
- factoryB->buildProxy<E04PhoneBookProxy>(serviceAddress);
- while (!myProxyB->isAvailable()) { usleep(10); }
-
- // Subscribe A to broadcast
- myProxyA->getPhoneBookDataSetSelectiveEvent().subscribe(
- [&](const std::vector<E04PhoneBook::phoneBookDataElementMap>& phoneBookDataSet) {
- printFilterResult(phoneBookDataSet, "A");
- });
-
- // Subscribe B to broadcast
- myProxyB->getPhoneBookDataSetSelectiveEvent().subscribe(
- [&](const std::vector<E04PhoneBook::phoneBookDataElementMap>& phoneBookDataSet) {
- printFilterResult(phoneBookDataSet, "B");
- });
-
- // Get actual phoneBook from service
- CommonAPI::CallStatus myCallStatus;
- std::vector<E04PhoneBook::phoneBookStruct> myValue;
- myProxyA->getPhoneBookAttribute().getValue(myCallStatus, myValue);
-
- // Synchronous call setPhoneBookDataFilter
- E04PhoneBook::elementFilterStruct lElementFilterA =
- { true, true, false, false, false, false};
-
- std::vector<E04PhoneBook::contentFilterStruct> lContentFilterA =
- { {E04PhoneBook::phoneBookDataElementEnum::NAME, "*"} };
- myProxyA->setPhoneBookDataFilter(lElementFilterA, lContentFilterA, myCallStatus);
-
- E04PhoneBook::elementFilterStruct lElementFilterB =
- { true, false, false, false, false, true };
-
- std::vector<E04PhoneBook::contentFilterStruct> lContentFilterB =
- { {E04PhoneBook::phoneBookDataElementEnum::NAME, "*"} };
- myProxyB->setPhoneBookDataFilter(lElementFilterB, lContentFilterB, myCallStatus);
-
- ... // further code
-}
-----
-
diff --git a/CommonAPI-Examples/e05Manager/CMakeLists.txt b/CommonAPI-Examples/e05Manager/CMakeLists.txt
deleted file mode 100644
index 64346fb..0000000
--- a/CommonAPI-Examples/e05Manager/CMakeLists.txt
+++ /dev/null
@@ -1,72 +0,0 @@
-# Copyright (C) 2014 BMW Group
-# Author: Manfred Bathelt (manfred.bathelt@bmw.de)
-# Author: Juergen Gehring (juergen.gehring@bmw.de)
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-cmake_minimum_required(VERSION 2.8)
-
-# Project settings
-if (PRJ_NAME)
- message(STATUS "Start CMake for Project " ${PRJ_NAME})
-else()
- message(FATAL_ERROR "Please specify your project name using -D PRJ_NAME=yourName")
-endif()
-project(${PRJ_NAME})
-set(CMAKE_VERBOSE_MAKEFILE on)
-set(CMAKE_CXX_FLAGS "-Wall -std=c++0x")
-set(CMAKE_BUILD_TYPE Debug)
-
-# DBus Path
-if (DBUS_LIB_PATH)
- message(STATUS "DBUS_LIB_PATH = " ${DBUS_LIB_PATH})
-else()
- message(FATAL_ERROR "Please specify the path to your patched DBus library using -D DBUS_LIB_PATH=yourPath")
-endif()
-
-# CommonAPI
-include(FindPkgConfig)
-pkg_check_modules (DBUS "dbus-1 >= 1.4")
-pkg_check_modules (COMMONAPI "CommonAPI >= 2.1")
-pkg_check_modules (COMMONAPI_DBUS "CommonAPI-DBus >= 2.1")
-
-# Source Files
-set(PRJ_SRC_PATH src)
-set(PRJ_SRC_GEN_PATH src-gen/commonapi/examples)
-
-set(PRJ_NAME_CLIENT ${PROJECT_NAME}Client)
-set(PRJ_NAME_SERVICE ${PROJECT_NAME}Service)
-
-STRING(REGEX REPLACE "^e" "E" PRJ_DATA_IMPL ${PRJ_NAME})
-FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_SRC_GEN_PATH}/*Types.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_DATA_IMPL}.cpp)
-FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/*Types.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_DATA_IMPL}.cpp)
-FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
-
-set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
-set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
-
-# Paths
-message(STATUS "COMMONAPI_INCLUDEDIR = " ${COMMONAPI_INCLUDEDIR})
-message(STATUS "COMMONAPI_DBUS_INCLUDEDIR = " ${COMMONAPI_DBUS_INCLUDEDIR})
-
-include_directories(
- src-gen
- ${DBUS_INCLUDE_DIRS}
- ${COMMONAPI_INCLUDEDIR}
- ${COMMONAPI_DBUS_INCLUDEDIR}
-)
-
-link_directories(
- ${DBUS_LIB_PATH}
- ${COMMONAPI_LIBDIR}
- ${COMMONAPI_DBUS_LIBDIR}
-)
-
-# Build Client
-add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
-target_link_libraries(${PRJ_NAME_CLIENT} CommonAPI CommonAPI-DBus)
-
-# Build service
-add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
-target_link_libraries(${PRJ_NAME_SERVICE} CommonAPI CommonAPI-DBus)
diff --git a/CommonAPI-Examples/e05Manager/README b/CommonAPI-Examples/e05Manager/README
deleted file mode 100644
index 5a1da8a..0000000
--- a/CommonAPI-Examples/e05Manager/README
+++ /dev/null
@@ -1,135 +0,0 @@
-Example 5: Managed
-~~~~~~~~~~~~~~~~~~
-
-So far we have looked at software systems, which consisted of services and users of these servces, the clients. However, in some systems there is a slightly different kind of relationship between the software components: a central manager manages other services (let's call them slaves or leaves). This central manager is a service itself but acts as client for the managed services. One example for such a system is, for example, a device manager that manages several devices, which can be availabe for usage in the system or not. The central manager handles all adminitrative tasks related to the slaves and provides a central, common interface to the user frontend.
-
-image::{imagedir}/E05Manager.png[ManagerExample image]
-
-Franca IDL supports this kind of software structure by the keyword _manages_, which can be added to the keyword interface. The following example illustrates the application of this keyword.
-
-[source,java]
-----
-package commonapi.examples
-
-interface E05Manager manages E05Device, E05SpecialDevice {
- version { major 1 minor 0 }
-
- attribute String [] myDevices
-}
-
-interface E05Device {
- version { major 1 minor 0 }
-
- method doSomething {
- }
-}
-
-interface E05SpecialDevice extends E05Device {
- version { major 1 minor 0 }
-
- method doSomethingSpecial {
- }
-}
-----
-
-The device manager has the service interface E05Manager and it manages devices with the interfaces E05Device and E05SpecialDevice. It is important to understand, that the exact meaning of the keyword +manages+ cannot be defined by the IDL; the keyword just indicates that there is a relationship between software components which implement manager and managed interfaces. It can be used in bindings as CommonAPI to provide API functions for a more convenient implementation of this certain kind of relationship.
-
-Therefore let's have a look at the generated and implemented source code. Since we have three interfaces the code generator generates for every interface proxy and stub classes. In our example we just want to illuminate one aspect of the managed interfaces: the registration of the managed interfaces via the manager. We assume that we have only one service (the manager) which gets informed about a detected or a removed device via the public function deviceDetected and deviceRemoved. The devices are distinguished by a number; in principle there is an arbitrary number of devices possible. The registration of the devices at CommonAPI does the manager in his stub implementation.
-
-[source,{cppstr}]
-----
-... // includes, namespaces, constructors as usual
-
-E05ManagerStubImpl::E05ManagerStubImpl (const std::string instanceName) {
-
- managerInstanceName = instanceName;
-}
-
-void E05ManagerStubImpl::deviceDetected (unsigned int n) {
-
- std::string deviceInstanceName = getDeviceName (n);
- myDevices[deviceInstanceName] = DevicePtr (new E05DeviceStubImpl);
- const bool deviceRegistered = this->registerManagedStubE05Device(
- myDevices[deviceInstanceName], deviceInstanceName);
-}
-
-void E05ManagerStubImpl::deviceRemoved (unsigned int n) {
-
- std::string deviceInstanceName = getDeviceName (n);
- const bool deviceDeregistered = this->deregisterManagedStubE05Device(
- deviceInstanceName);
- if ( deviceDeregistered ) { myDevices.erase (deviceInstanceName); }
-}
-
-std::string E05ManagerStubImpl::getDeviceName (unsigned int n) {
-
- std::stringstream ss;
- ss << managerInstanceName <<
- ".device" << std::setw(2) << std::hex << std::setfill('0') << n;
- return ss.str();
-}
-
-... // implementation of special device analogously
-----
-
-The functions for the special device has been omitted for clarity.The implementations of the devices themselves are not important here as well. See now the implementation of the client. The client gets informed about new or removed devices including the addresses of these devices via the callback function newDeviceAvailable. This function can be subscribed as function object at an status event that is triggered when a device is added or removed.
-
-[source, {cppstr}]
-----
-#include <iostream>
-
-#include <CommonAPI/CommonAPI.h>
-#include <commonapi/examples/E05ManagerProxy.h>
-
-using namespace commonapi::examples;
-
-void newDeviceAvailable (const std::string address,
- const CommonAPI::AvailabilityStatus status) {
-
- if ( status == CommonAPI::AvailabilityStatus::AVAILABLE ) {
-
- std::cout << "New device available: " << address << std::endl;
- }
-
- if ( status == CommonAPI::AvailabilityStatus::NOT_AVAILABLE ) {
-
- std::cout << "Device removed: " << address << std::endl;
- }
-}
-
-int main() {
-
- std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
-
- std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory();
-
- const std::string& serviceAddress =
- "local:commonapi.examples.Manager:commonapi.examples.Manager";
-
- std::shared_ptr<E05ManagerProxy<>> myProxy =
- factory->buildProxy<E05ManagerProxy>(serviceAddress);
-
- while (!myProxy->isAvailable()) { usleep(10); }
-
- std::cout << "Proxy available." << std::endl;
-
- CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& deviceEvent =
- myProxy->getProxyManagerE05Device().
- getInstanceAvailabilityStatusChangedEvent();
-
- CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& specialDeviceEvent =
- myProxy->getProxyManagerE05SpecialDevice().
- getInstanceAvailabilityStatusChangedEvent();
-
- std::function<void (const std::string, const CommonAPI::AvailabilityStatus)>
- newDeviceAvailableFunc = newDeviceAvailable;
-
- deviceEvent.subscribe(newDeviceAvailableFunc);
- specialDeviceEvent.subscribe(newDeviceAvailableFunc);
-
- while(true) {
- std::this_thread::sleep_for(std::chrono::seconds(5));
- }
- return 0;
-}
-----
diff --git a/CommonAPI-Examples/e06Unions/.gitignore b/CommonAPI-Examples/e06Unions/.gitignore
deleted file mode 100644
index 5897208..0000000
--- a/CommonAPI-Examples/e06Unions/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-build
-src-gen \ No newline at end of file
diff --git a/CommonAPI-Examples/e06Unions/CMakeLists.txt b/CommonAPI-Examples/e06Unions/CMakeLists.txt
deleted file mode 100644
index e321988..0000000
--- a/CommonAPI-Examples/e06Unions/CMakeLists.txt
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright (C) 2014 BMW Group
-# Author: Manfred Bathelt (manfred.bathelt@bmw.de)
-# Author: Juergen Gehring (juergen.gehring@bmw.de)
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-cmake_minimum_required(VERSION 2.8)
-
-# Project settings
-if (PRJ_NAME)
- message(STATUS "Start CMake for Project " ${PRJ_NAME})
-else()
- message(FATAL_ERROR "Please specify your project name using -D PRJ_NAME=yourName")
-endif()
-project(${PRJ_NAME})
-set(CMAKE_VERBOSE_MAKEFILE on)
-set(CMAKE_CXX_FLAGS "-Wall -std=c++0x")
-set(CMAKE_BUILD_TYPE Debug)
-
-# DBus Path
-if (DBUS_LIB_PATH)
- message(STATUS "DBUS_LIB_PATH = " ${DBUS_LIB_PATH})
-else()
- message(FATAL_ERROR "Please specify the path to your patched DBus library using -D DBUS_LIB_PATH=yourPath")
-endif()
-
-# CommonAPI
-include(FindPkgConfig)
-pkg_check_modules (DBUS "dbus-1 >= 1.4")
-pkg_check_modules (COMMONAPI "CommonAPI >= 2.1")
-pkg_check_modules (COMMONAPI_DBUS "CommonAPI-DBus >= 2.1")
-
-# Source Files
-set(PRJ_SRC_PATH src)
-set(PRJ_SRC_GEN_PATH src-gen/commonapi/examples)
-
-set(PRJ_NAME_CLIENT ${PROJECT_NAME}Client)
-set(PRJ_NAME_SERVICE ${PROJECT_NAME}Service)
-
-FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_SRC_GEN_PATH}/*Types.cpp)
-FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/*Types.cpp)
-FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)
-
-set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
-set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})
-
-# Paths
-message(STATUS "COMMONAPI_INCLUDEDIR = " ${COMMONAPI_INCLUDEDIR})
-message(STATUS "COMMONAPI_DBUS_INCLUDEDIR = " ${COMMONAPI_DBUS_INCLUDEDIR})
-
-include_directories(
- src-gen
- ${DBUS_INCLUDE_DIRS}
- ${COMMONAPI_INCLUDEDIR}
- ${COMMONAPI_DBUS_INCLUDEDIR}
-)
-
-link_directories(
- ${DBUS_LIB_PATH}
- ${COMMONAPI_LIBDIR}
- ${COMMONAPI_DBUS_LIBDIR}
-)
-
-# Build Client
-add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS})
-target_link_libraries(${PRJ_NAME_CLIENT} CommonAPI CommonAPI-DBus)
-
-# Build service
-add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS})
-target_link_libraries(${PRJ_NAME_SERVICE} CommonAPI CommonAPI-DBus)
diff --git a/CommonAPI-Examples/e06Unions/src/e06UnionsService.cpp b/CommonAPI-Examples/e06Unions/src/e06UnionsService.cpp
deleted file mode 100644
index d8486f5..0000000
--- a/CommonAPI-Examples/e06Unions/src/e06UnionsService.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (C) 2014 BMW Group
- * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
- * Author: Juergen Gehring (juergen.gehring@bmw.de)
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include <thread>
-#include <iostream>
-
-#include <CommonAPI/CommonAPI.h>
-#include "E06UnionsStubImpl.h"
-
-int main() {
- int n = 0;
-
- std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
- std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory();
- std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher = runtime->getServicePublisher();
-
- const std::string& serviceAddress = "local:commonapi.examples.Unions:commonapi.examples.Unions";
- std::shared_ptr<E06UnionsStubImpl> myService = std::make_shared<E06UnionsStubImpl>();
- servicePublisher->registerService(myService, serviceAddress, factory);
-
- while (true) {
- std::cout << "Set value " << n << " for union u." << std::endl;
- myService->setMyValue(n);
- n++;
- if (n == 4) {
- n = 0;
- }
-
- std::this_thread::sleep_for(std::chrono::seconds(2));
- }
-
- return 0;
-}