summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürgen Gehring <juergen.gehring@bmw.de>2015-06-11 06:57:47 -0700
committerJürgen Gehring <juergen.gehring@bmw.de>2015-06-11 06:57:47 -0700
commit6c463fcc3dcee619925f08ea09e19a86b9e581cc (patch)
tree17e765e0623c58778150605d1cd0340c658ce6ab
parent1d83eb38e546e0165f1ad6821f04445b2b9b19d2 (diff)
downloadgenivi-common-api-runtime-6c463fcc3dcee619925f08ea09e19a86b9e581cc.tar.gz
CommonAPI 3.1.1
-rw-r--r--.cproject158
-rw-r--r--.gitignore29
-rw-r--r--.project27
-rw-r--r--AUTHORS2
-rw-r--r--CMakeLists.txt228
-rw-r--r--CommonAPI-uninstalled.pc.in12
-rw-r--r--CommonAPI.pc.in10
-rw-r--r--CommonAPI.vcxproj81
-rw-r--r--INSTALL43
-rw-r--r--Makefile.am99
-rw-r--r--NEWS1
-rw-r--r--README219
-rw-r--r--aminclude.am168
-rw-r--r--cmake/CommonAPIConfig.cmake.in13
-rw-r--r--cmake/CommonAPIConfigVersion.cmake.in12
-rw-r--r--commonapi.spec.in123
-rw-r--r--configure.ac96
-rw-r--r--docx/01_mainpage.dox34
-rw-r--r--doxygen.in (renamed from doxygen.cfg)54
-rw-r--r--include/CommonAPI/Address.hpp52
-rw-r--r--include/CommonAPI/Attribute.hpp (renamed from src/CommonAPI/Attribute.h)46
-rw-r--r--include/CommonAPI/AttributeExtension.hpp (renamed from src/CommonAPI/AttributeExtension.h)28
-rw-r--r--include/CommonAPI/ByteBuffer.hpp18
-rw-r--r--include/CommonAPI/CallInfo.hpp31
-rw-r--r--include/CommonAPI/CommonAPI.hpp22
-rw-r--r--include/CommonAPI/Config.hpp17
-rw-r--r--include/CommonAPI/ContainerUtils.hpp33
-rw-r--r--include/CommonAPI/Deployable.hpp59
-rw-r--r--include/CommonAPI/Deployment.hpp75
-rw-r--r--include/CommonAPI/Enumeration.hpp40
-rw-r--r--include/CommonAPI/Event.hpp158
-rw-r--r--include/CommonAPI/Export.hpp22
-rw-r--r--include/CommonAPI/Factory.hpp58
-rw-r--r--include/CommonAPI/IniFileReader.hpp40
-rw-r--r--include/CommonAPI/InputStream.hpp241
-rw-r--r--include/CommonAPI/Logger.hpp179
-rw-r--r--include/CommonAPI/MainLoopContext.hpp (renamed from src/CommonAPI/MainLoopContext.h)77
-rw-r--r--include/CommonAPI/OutputStream.hpp241
-rw-r--r--include/CommonAPI/Proxy.hpp47
-rw-r--r--include/CommonAPI/ProxyManager.hpp73
-rw-r--r--include/CommonAPI/Runtime.hpp203
-rw-r--r--include/CommonAPI/SelectiveEvent.hpp28
-rw-r--r--include/CommonAPI/SerializableArguments.hpp62
-rw-r--r--include/CommonAPI/Struct.hpp174
-rw-r--r--include/CommonAPI/Stub.hpp (renamed from src/CommonAPI/Stub.h)42
-rw-r--r--include/CommonAPI/TypeOutputStream.hpp197
-rw-r--r--include/CommonAPI/Types.hpp (renamed from src/CommonAPI/types.h)64
-rw-r--r--include/CommonAPI/Utils.hpp22
-rw-r--r--include/CommonAPI/Variant.hpp746
-rw-r--r--include/CommonAPI/Version.hpp29
-rw-r--r--m4/ax_cxx_compile_stdcxx_11.m4107
-rw-r--r--m4/ax_prog_doxygen.m4532
-rw-r--r--src/CommonAPI/Address.cpp122
-rw-r--r--src/CommonAPI/ByteBuffer.h19
-rw-r--r--src/CommonAPI/CommonAPI.h25
-rw-r--r--src/CommonAPI/Configuration.cpp179
-rw-r--r--src/CommonAPI/Configuration.h121
-rw-r--r--src/CommonAPI/ContainerUtils.cpp16
-rw-r--r--src/CommonAPI/ContainerUtils.h33
-rw-r--r--src/CommonAPI/Event.h193
-rw-r--r--src/CommonAPI/Factory.cpp16
-rw-r--r--src/CommonAPI/Factory.h369
-rw-r--r--src/CommonAPI/Factory.hpp71
-rw-r--r--src/CommonAPI/IniFileReader.cpp114
-rw-r--r--src/CommonAPI/InputStream.cpp77
-rw-r--r--src/CommonAPI/InputStream.h341
-rw-r--r--src/CommonAPI/Logger.cpp152
-rw-r--r--src/CommonAPI/MainLoopContext.cpp19
-rw-r--r--src/CommonAPI/MiddlewareInfo.h47
-rw-r--r--src/CommonAPI/OutputStream.h555
-rw-r--r--src/CommonAPI/Proxy.cpp15
-rw-r--r--src/CommonAPI/Proxy.h54
-rw-r--r--src/CommonAPI/ProxyManager.cpp18
-rw-r--r--src/CommonAPI/ProxyManager.h92
-rw-r--r--src/CommonAPI/Runtime.cpp702
-rw-r--r--src/CommonAPI/Runtime.h203
-rw-r--r--src/CommonAPI/SelectiveEvent.h53
-rw-r--r--src/CommonAPI/SerializableStruct.h39
-rw-r--r--src/CommonAPI/SerializableVariant.h257
-rw-r--r--src/CommonAPI/SerializableVariant.hpp522
-rw-r--r--src/CommonAPI/ServicePublisher.cpp22
-rw-r--r--src/CommonAPI/ServicePublisher.h140
-rw-r--r--src/CommonAPI/ServicePublisher.hpp43
-rw-r--r--src/CommonAPI/Utils.cpp47
-rw-r--r--src/CommonAPI/utils.cpp181
-rw-r--r--src/CommonAPI/utils.h230
-rwxr-xr-xsrc/test/VariantTest.cpp245
87 files changed, 4522 insertions, 5982 deletions
diff --git a/.cproject b/.cproject
new file mode 100644
index 0000000..30aab95
--- /dev/null
+++ b/.cproject
@@ -0,0 +1,158 @@
+<?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.config.gnu.so.debug.2004816766">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.so.debug.2004816766" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+ <externalSettings>
+ <externalSetting>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/CommonAPI"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/CommonAPI/Debug"/>
+ <entry flags="RESOLVED" kind="libraryFile" name="CommonAPI" srcPrefixMapping="" srcRootPath=""/>
+ </externalSetting>
+ </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 artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.so.debug.2004816766" name="Debug" parent="cdt.managedbuild.config.gnu.so.debug">
+ <folderInfo id="cdt.managedbuild.config.gnu.so.debug.2004816766." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.so.debug.497381271" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.so.debug">
+ <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.so.debug.1370267250" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.so.debug"/>
+ <builder arguments="-C ${ProjDirPath}/build" buildPath="" command="make" id="cdt.managedbuild.target.gnu.builder.so.debug.519407999" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.so.debug"/>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.base.1925371138" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug.1270137030" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug">
+ <option id="gnu.cpp.compiler.so.debug.option.optimization.level.1684435105" name="Optimization Level" superClass="gnu.cpp.compiler.so.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.so.debug.option.debugging.level.1146943018" name="Debug Level" superClass="gnu.cpp.compiler.so.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.option.include.paths.1636146351" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths"/>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.2137374827" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.so.debug.1730014309" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.so.debug">
+ <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.so.debug.option.optimization.level.2106113516" name="Optimization Level" superClass="gnu.c.compiler.so.debug.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.so.debug.option.debugging.level.438248361" name="Debug Level" superClass="gnu.c.compiler.so.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+ <option id="gnu.c.compiler.option.include.paths.1749492263" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths"/>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.902470379" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.so.debug.703198397" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.so.debug">
+ <option defaultValue="true" id="gnu.c.link.so.debug.option.shared.831754320" name="Shared (-shared)" superClass="gnu.c.link.so.debug.option.shared" valueType="boolean"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.so.debug.847083839" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.so.debug">
+ <option defaultValue="true" id="gnu.cpp.link.so.debug.option.shared.629193581" name="Shared (-shared)" superClass="gnu.cpp.link.so.debug.option.shared" valueType="boolean"/>
+ <option id="gnu.cpp.link.option.paths.2015212926" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths"/>
+ <option id="gnu.cpp.link.option.libs.1584502257" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs"/>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.61199527" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.so.debug.55718477" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.so.debug">
+ <option id="gnu.both.asm.option.include.paths.633248275" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths"/>
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1589853807" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ <cconfiguration id="cdt.managedbuild.config.gnu.so.release.784058498">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.so.release.784058498" moduleId="org.eclipse.cdt.core.settings" name="Release">
+ <externalSettings>
+ <externalSetting>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/CommonAPI"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/CommonAPI/Release"/>
+ <entry flags="RESOLVED" kind="libraryFile" name="CommonAPI" srcPrefixMapping="" srcRootPath=""/>
+ </externalSetting>
+ </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 artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.so.release.784058498" name="Release" parent="cdt.managedbuild.config.gnu.so.release">
+ <folderInfo id="cdt.managedbuild.config.gnu.so.release.784058498." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.so.release.1704197754" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.so.release">
+ <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.so.release.1724952823" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.so.release"/>
+ <builder buildPath="${workspace_loc:/ascgit017.CommonAPI}/Release" id="cdt.managedbuild.target.gnu.builder.so.release.525957098" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.so.release"/>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.base.1707794608" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.so.release.1110361147" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.release">
+ <option id="gnu.cpp.compiler.so.release.option.optimization.level.1280823978" name="Optimization Level" superClass="gnu.cpp.compiler.so.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.so.release.option.debugging.level.4407501" name="Debug Level" superClass="gnu.cpp.compiler.so.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.953820603" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.so.release.523128546" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.so.release">
+ <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.so.release.option.optimization.level.1500245439" name="Optimization Level" superClass="gnu.c.compiler.so.release.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.so.release.option.debugging.level.1054034731" name="Debug Level" superClass="gnu.c.compiler.so.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1634087900" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.so.release.1726119538" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.so.release">
+ <option defaultValue="true" id="gnu.c.link.so.release.option.shared.1850583711" name="Shared (-shared)" superClass="gnu.c.link.so.release.option.shared" valueType="boolean"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.so.release.1470862717" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.so.release">
+ <option defaultValue="true" id="gnu.cpp.link.so.release.option.shared.1097520032" name="Shared (-shared)" superClass="gnu.cpp.link.so.release.option.shared" valueType="boolean"/>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1001678157" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.so.release.910811714" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.so.release">
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.975507970" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="ascgit017.CommonAPI.cdt.managedbuild.target.gnu.so.1931182818" name="Shared Library" projectType="cdt.managedbuild.target.gnu.so"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.so.release.784058498;cdt.managedbuild.config.gnu.so.release.784058498.;cdt.managedbuild.tool.gnu.c.compiler.so.release.523128546;cdt.managedbuild.tool.gnu.c.compiler.input.1634087900">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.so.release.784058498;cdt.managedbuild.config.gnu.so.release.784058498.;cdt.managedbuild.tool.gnu.cpp.compiler.so.release.1110361147;cdt.managedbuild.tool.gnu.cpp.compiler.input.953820603">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.so.debug.2004816766;cdt.managedbuild.config.gnu.so.debug.2004816766.;cdt.managedbuild.tool.gnu.c.compiler.so.debug.1730014309;cdt.managedbuild.tool.gnu.c.compiler.input.902470379">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.so.debug.2004816766;cdt.managedbuild.config.gnu.so.debug.2004816766.;cdt.managedbuild.tool.gnu.cpp.compiler.so.debug.1270137030;cdt.managedbuild.tool.gnu.cpp.compiler.input.2137374827">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Release">
+ <resource resourceType="PROJECT" workspacePath="/CommonAPI"/>
+ </configuration>
+ <configuration configurationName="Debug">
+ <resource resourceType="PROJECT" workspacePath="/CommonAPI"/>
+ </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 -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=debug ../</buildArguments>
+ <buildTarget/>
+ <stopOnError>true</stopOnError>
+ <useDefaultCommand>false</useDefaultCommand>
+ <runAllBuilders>true</runAllBuilders>
+ </target>
+ </buildTargets>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
+</cproject>
diff --git a/.gitignore b/.gitignore
index 3ea38c9..65f8040 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,27 +1,2 @@
-.deps
-.dirstamp
-.libs
-*.la
-*.lo
-*.o
-*.gz
-*~
-/.autotools
-/.cproject
-/.project
-/.settings
-/*.pc
-/Makefile
-/Makefile.in
-/aclocal.m4
-/autom4te.cache
-/build-aux
-/config.log
-/config.status
-/configure
-/doc
-/libtool
-/m4/libtool.m4
-/m4/lt*.m4
-
-/VariantTest
+build/*
+.settings/*
diff --git a/.project b/.project
new file mode 100644
index 0000000..98d09b1
--- /dev/null
+++ b/.project
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>CommonAPI</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/AUTHORS b/AUTHORS
index 635f0a3..632e479 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1 +1 @@
-BMW Group
+Bayerische Motoren Werke Aktiengesellschaft (BMW AG) \ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..79dd2a9
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,228 @@
+# Copyright (C) 2013-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.12)
+
+PROJECT(libcommonapi)
+
+# version of CommonAPI
+SET( LIBCOMMONAPI_MAJOR_VERSION 3 )
+SET( LIBCOMMONAPI_MINOR_VERSION 1 )
+SET( LIBCOMMONAPI_PATCH_VERSION 1 )
+
+message(STATUS "Project name: ${PROJECT_NAME}")
+
+set(COMPONENT_VERSION ${LIBCOMMONAPI_MAJOR_VERSION}.${LIBCOMMONAPI_MINOR_VERSION}.${LIBCOMMONAPI_PATCH_VERSION})
+set(COMMONAPI_API_HEADER_VERSION ${LIBCOMMONAPI_MAJOR_VERSION}.${LIBCOMMONAPI_MINOR_VERSION}) # used in *.cmake.in
+
+SET(PACKAGE_VERSION "${COMPONENT_VERSION}") # used in *.cmake.in
+message(STATUS "This is CMake for Common API C++ Version ${COMPONENT_VERSION}.")
+
+# OS
+set(DL_LIBRARY "")
+if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+ set(DL_LIBRARY "dl")
+endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+
+##############################################################################
+
+# define standard installation path in case CMAKE_INSTALL_PREFIX is not set
+if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "")
+ SET(CMAKE_INSTALL_PREFIX "/usr/local")
+endif()
+message(STATUS "CMAKE_INSTALL_PREFIX set to: ${CMAKE_INSTALL_PREFIX}")
+
+# create the commandline variables:
+OPTION(BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON )
+message(STATUS "BUILD_SHARED_LIBS is set to value: ${BUILD_SHARED_LIBS}")
+SET(RPM_PACKAGE_VERSION "r0" CACHE STRING "rpm packet version") # used in e.g. commonapi.spec.in
+
+SET(MAX_LOG_LEVEL "DEBUG" CACHE STRING "maximum log level")
+message(STATUS "MAX_LOG_LEVEL is set to value: ${MAX_LOG_LEVEL}")
+
+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)
+
+set(CMAKE_BUILD_TYPE_FOR_SPEC_IN "")
+string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_FOR_SPEC_IN)
+
+# Offer the user the choice of overriding the installation directories
+set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
+set(INSTALL_INCLUDE_DIR include/CommonAPI-${COMMONAPI_API_HEADER_VERSION} CACHE PATH "Installation directory for header files")
+if(WIN32 AND NOT CYGWIN)
+ set(DEF_INSTALL_CMAKE_DIR cmake)
+else()
+ set(DEF_INSTALL_CMAKE_DIR lib/cmake/CommonAPI-${COMPONENT_VERSION})
+endif()
+set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
+
+# Make relative paths absolute (needed later on)
+foreach(p LIB INCLUDE CMAKE)
+ set(var INSTALL_${p}_DIR)
+ if(NOT IS_ABSOLUTE "${${var}}")
+ set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
+ endif()
+endforeach()
+
+message(STATUS "RPM packet version set to ${RPM_PACKAGE_VERSION}")
+##################### RPM CONFIG ########################
+SET( LICENSE "MPLv2" )
+#########################################################
+
+message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
+
+##############################################################################
+
+# CommonAPI build section
+IF(MSVC)
+ message("using MSVC Compiler")
+ add_definitions(-DCOMMONAPI_INTERNAL_COMPILATION)
+ add_compile_options(/EHsc /wd"4996")
+ELSE ()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -DCOMMONAPI_INTERNAL_COMPILATION -DUSE_CONSOLE")
+ENDIF(MSVC)
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCOMMONAPI_LOGLEVEL=COMMONAPI_LOGLEVEL_${MAX_LOG_LEVEL}")
+
+FIND_PACKAGE(PkgConfig)
+pkg_check_modules(DLT "automotive-dlt >= 2.11")
+IF(DLT_FOUND)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_DLT")
+ENDIF(DLT_FOUND)
+
+##############################################################################
+
+include_directories(
+ include
+ ${DLT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${DLT_LIBDIR}
+)
+
+file(GLOB CAPI_SRCS "src/CommonAPI/*.cpp")
+add_library(CommonAPI ${CAPI_SRCS})
+target_link_libraries(CommonAPI PRIVATE ${DL_LIBRARY} ${DLT_LIBRARIES})
+set_target_properties(CommonAPI PROPERTIES VERSION ${LIBCOMMONAPI_MAJOR_VERSION}.${LIBCOMMONAPI_MINOR_VERSION}.${LIBCOMMONAPI_PATCH_VERSION} SOVERSION ${LIBCOMMONAPI_MAJOR_VERSION} LINKER_LANGUAGE C)
+set_target_properties (CommonAPI PROPERTIES INTERFACE_LINK_LIBRARY "")
+
+##############################################################################
+# configure files
+
+CONFIGURE_FILE(commonapi.spec.in commonapi.spec)
+
+##############################################################################
+# installing files
+
+# for installation of CommonAPI header files
+file (GLOB_RECURSE CommonAPI_INCLUDE_INSTALL_FILES "include/CommonAPI/*.hpp")
+set_target_properties (CommonAPI PROPERTIES PUBLIC_HEADER "${CommonAPI_INCLUDE_INSTALL_FILES}")
+
+# install CommonAPI library including headers
+install(TARGETS CommonAPI
+ EXPORT CommonAPITargets
+ LIBRARY DESTINATION ${INSTALL_LIB_DIR}
+ ARCHIVE DESTINATION ${INSTALL_LIB_DIR}
+ PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/CommonAPI"
+)
+
+##############################################################################
+# exporting, configuring and installing of cmake files
+
+# Add all targets to the build-tree export set
+export(TARGETS CommonAPI
+ FILE "${PROJECT_BINARY_DIR}/CommonAPITargets.cmake")
+
+# Export the package for use from the build-tree
+# (this registers the build-tree with a global CMake-registry)
+export(PACKAGE CommonAPI)
+
+# Create the CommonAPIConfig.cmake and CommonAPIConfigVersion files ...
+file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}")
+
+# ... for the build tree
+set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" )
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CommonAPIConfig.cmake.in
+ "${PROJECT_BINARY_DIR}/CommonAPIConfig.cmake" @ONLY)
+
+# ... for the install tree
+set(CONF_INCLUDE_DIRS "\${COMMONAPI_CMAKE_DIR}/${REL_INCLUDE_DIR}")
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CommonAPIConfig.cmake.in
+ "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CommonAPIConfig.cmake" @ONLY)
+
+# ... for both
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CommonAPIConfigVersion.cmake.in
+ "${PROJECT_BINARY_DIR}/CommonAPIConfigVersion.cmake" @ONLY)
+
+# Install the CommonAPIConfig.cmake and CommonAPIConfigVersion.cmake
+install(FILES
+ "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CommonAPIConfig.cmake"
+ "${PROJECT_BINARY_DIR}/CommonAPIConfigVersion.cmake"
+ DESTINATION "${INSTALL_CMAKE_DIR}")
+
+# Install the export set for use with the install-tree
+install(EXPORT CommonAPITargets DESTINATION
+ "${INSTALL_CMAKE_DIR}")
+
+##############################################################################
+# maintainer-clean
+add_custom_target(maintainer-clean
+ COMMAND rm -rf *
+)
+
+##############################################################################
+# dist
+add_custom_target(dist
+ COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && git archive --format=tar.gz ${COMPONENT_VERSION} -o CommonAPI${COMPONENT_VERSION}.tar.gz
+)
+
+##############################################################################
+# build documentation
+FIND_PACKAGE(Doxygen)
+FIND_PROGRAM(ASCIIDOC_PATH asciidoc)
+if (NOT DOXYGEN_FOUND)
+ message(STATUS "Doxygen is not installed. Documentation can not be built.")
+else()
+ # set configuration variables for doxygen.in
+ set(PROJECT "Common API C++")
+ set(DOCDIR doc)
+ set(SRCDIR .)
+ set(GENERATE_HTML YES)
+ set(GENERATE_HTMLHELP NO)
+ set(GENERATE_CHI NO)
+ set(GENERATE_LATEX NO)
+ set(GENERATE_PDF NO)
+ set(GENERATE_RTF NO)
+ set(GENERATE_MAN NO)
+ set(GENERATE_XML NO)
+
+ configure_file(doxygen.in ${PROJECT_BINARY_DIR}/Doxyfile @ONLY)
+
+ add_custom_target(doc)
+
+ add_custom_target(doxygen-doc
+ COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile
+ SOURCES ${PROJECT_BINARY_DIR}/Doxyfile)
+
+ add_dependencies(doc doxygen-doc)
+
+ if ("${ASCIIDOC_PATH}" STREQUAL "ASCIIDOC_PATH-NOTFOUND")
+ message(STATUS "asciidoc is not installed. Readme can not be built.")
+ else()
+ message(STATUS "asciidoc found")
+ add_custom_command(TARGET doc
+ POST_BUILD
+ COMMAND asciidoc
+ -a version=${PACKAGE_VERSION}
+ -b html
+ -o doc/README.html
+ ${PROJECT_BINARY_DIR}/../INSTALL)
+ endif()
+endif()
+
+##############################################################################
diff --git a/CommonAPI-uninstalled.pc.in b/CommonAPI-uninstalled.pc.in
deleted file mode 100644
index 0995e47..0000000
--- a/CommonAPI-uninstalled.pc.in
+++ /dev/null
@@ -1,12 +0,0 @@
-abs_top_builddir=@abs_top_builddir@
-abs_top_srcdir=@abs_top_srcdir@
-prefix=${abs_top_srcdir}
-exec_prefix=${prefix}
-includedir=${prefix}/src
-libdir=${exec_prefix}/.libs
-
-Name: Common API C++
-Description: GENIVI Common API C++ Library (uninstalled copy)
-Version: @PACKAGE_VERSION@
-Libs: ${abs_top_builddir}/libCommonAPI.la
-Cflags: -I${abs_top_srcdir}/src \ No newline at end of file
diff --git a/CommonAPI.pc.in b/CommonAPI.pc.in
deleted file mode 100644
index 015516b..0000000
--- a/CommonAPI.pc.in
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: Common API C++
-Description: GENIVI Common API C++ Library
-Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -lCommonAPI
-Cflags: -I${includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@ \ No newline at end of file
diff --git a/CommonAPI.vcxproj b/CommonAPI.vcxproj
index 86e1d04..d2061f1 100644
--- a/CommonAPI.vcxproj
+++ b/CommonAPI.vcxproj
@@ -10,6 +10,47 @@
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="src\CommonAPI\Address.cpp" />
+ <ClCompile Include="src\CommonAPI\ContainerUtils.cpp" />
+ <ClCompile Include="src\CommonAPI\IniFileReader.cpp" />
+ <ClCompile Include="src\CommonAPI\MainLoopContext.cpp" />
+ <ClCompile Include="src\CommonAPI\Proxy.cpp" />
+ <ClCompile Include="src\CommonAPI\ProxyManager.cpp" />
+ <ClCompile Include="src\CommonAPI\Runtime.cpp" />
+ <ClCompile Include="src\CommonAPI\Types.cpp" />
+ <ClCompile Include="src\CommonAPI\Utils.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="include\CommonAPI\Address.hpp" />
+ <ClInclude Include="include\CommonAPI\Attribute.hpp" />
+ <ClInclude Include="include\CommonAPI\AttributeExtension.hpp" />
+ <ClInclude Include="include\CommonAPI\ByteBuffer.hpp" />
+ <ClInclude Include="include\CommonAPI\CommonAPI.hpp" />
+ <ClInclude Include="include\CommonAPI\ContainerUtils.hpp" />
+ <ClInclude Include="include\CommonAPI\Deployable.hpp" />
+ <ClInclude Include="include\CommonAPI\Deployment.hpp" />
+ <ClInclude Include="include\CommonAPI\Enumeration.hpp" />
+ <ClInclude Include="include\CommonAPI\Event.hpp" />
+ <ClInclude Include="include\CommonAPI\Factory.hpp" />
+ <ClInclude Include="include\CommonAPI\IniFileReader.hpp" />
+ <ClInclude Include="include\CommonAPI\InputStream.hpp" />
+ <ClInclude Include="include\CommonAPI\Logger.hpp" />
+ <ClInclude Include="include\CommonAPI\MainLoopContext.hpp" />
+ <ClInclude Include="include\CommonAPI\OutputStream.hpp" />
+ <ClInclude Include="include\CommonAPI\Proxy.hpp" />
+ <ClInclude Include="include\CommonAPI\ProxyManager.hpp" />
+ <ClInclude Include="include\CommonAPI\Runtime.hpp" />
+ <ClInclude Include="include\CommonAPI\SelectiveEvent.hpp" />
+ <ClInclude Include="include\CommonAPI\SerializableArguments.hpp" />
+ <ClInclude Include="include\CommonAPI\Struct.hpp" />
+ <ClInclude Include="include\CommonAPI\Stub.hpp" />
+ <ClInclude Include="include\CommonAPI\TypeOutputStream.hpp" />
+ <ClInclude Include="include\CommonAPI\Types.hpp" />
+ <ClInclude Include="include\CommonAPI\Utils.hpp" />
+ <ClInclude Include="include\CommonAPI\Variant.hpp" />
+ <ClInclude Include="include\CommonAPI\Version.hpp" />
+ </ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{C18FDEDE-810E-405D-9100-57A1CC5C78A9}</ProjectGuid>
<RootNamespace>CommonAPI</RootNamespace>
@@ -49,10 +90,11 @@
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <PreprocessorDefinitions>WIN32;COMMONAPI_INTERNAL_COMPILATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;COMMONAPI_INTERNAL_COMPILATION;__EXCEPTIONS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MinimalRebuild>false</MinimalRebuild>
+ <AdditionalIncludeDirectories>include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -83,43 +125,6 @@
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
- <ItemGroup>
- <ClInclude Include="src\CommonAPI\Attribute.h" />
- <ClInclude Include="src\CommonAPI\AttributeExtension.h" />
- <ClInclude Include="src\CommonAPI\ByteBuffer.h" />
- <ClInclude Include="src\CommonAPI\CommonAPI.h" />
- <ClInclude Include="src\CommonAPI\Configuration.h" />
- <ClInclude Include="src\CommonAPI\ContainerUtils.h" />
- <ClInclude Include="src\CommonAPI\Event.h" />
- <ClInclude Include="src\CommonAPI\Factory.h" />
- <ClInclude Include="src\CommonAPI\Factory.hpp" />
- <ClInclude Include="src\CommonAPI\InputStream.h" />
- <ClInclude Include="src\CommonAPI\MainLoopContext.h" />
- <ClInclude Include="src\CommonAPI\MiddlewareInfo.h" />
- <ClInclude Include="src\CommonAPI\OutputStream.h" />
- <ClInclude Include="src\CommonAPI\Proxy.h" />
- <ClInclude Include="src\CommonAPI\ProxyManager.h" />
- <ClInclude Include="src\CommonAPI\Runtime.h" />
- <ClInclude Include="src\CommonAPI\SelectiveEvent.h" />
- <ClInclude Include="src\CommonAPI\SerializableStruct.h" />
- <ClInclude Include="src\CommonAPI\SerializableVariant.h" />
- <ClInclude Include="src\CommonAPI\SerializableVariant.hpp" />
- <ClInclude Include="src\CommonAPI\ServicePublisher.h" />
- <ClInclude Include="src\CommonAPI\ServicePublisher.hpp" />
- <ClInclude Include="src\CommonAPI\Stub.h" />
- <ClInclude Include="src\CommonAPI\types.h" />
- <ClInclude Include="src\CommonAPI\utils.h" />
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="src\CommonAPI\Configuration.cpp" />
- <ClCompile Include="src\CommonAPI\ContainerUtils.cpp" />
- <ClCompile Include="src\CommonAPI\Factory.cpp" />
- <ClCompile Include="src\CommonAPI\InputStream.cpp" />
- <ClCompile Include="src\CommonAPI\MainLoopContext.cpp" />
- <ClCompile Include="src\CommonAPI\Runtime.cpp" />
- <ClCompile Include="src\CommonAPI\ServicePublisher.cpp" />
- <ClCompile Include="src\CommonAPI\utils.cpp" />
- </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..991f46a
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,43 @@
+= IPC CommonAPI C++
+
+:doctitle: IPC CommonAPI C++
+:version:
+
+== Copyright
+Copyright (C) 2015, Bayerische Motoren Werke Aktiengesellschaft (BMW AG).
+Copyright (C) 2015, GENIVI Alliance, Inc.
+
+This file is part of GENIVI Project IPC Common API C++.
+
+Contributions are licensed to the GENIVI Alliance under one or more Contribution License Agreements or MPL 2.0.
+
+== License
+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/.
+
+== Version
+{version}
+
+== CommonAPI C++ Specification and User Guide
+The specification document and the user guide can be found in the CommonAPI documentation directory of the CommonAPI-Tools project.
+
+== Further information
+Source code and latest news can be found at http://projects.genivi.org/commonapi/.
+
+== Build Instructions for Linux
+
+Use CMake to build this library. We assume that your source directory is +common-api-runtime+:
+
+----
+$ cd common-api-runtime
+$ mkdir build
+$ cd build
+$ cmake -D CMAKE_INSTALL_PREFIX=/usr/local ..
+$ make
+$ make install
+----
+
+You can change the installation directory by the CMake variable +CMAKE_INSTALL_PREFIX+ or you can let it uninstalled (skip the +make install+ command). Please refer to the installation description of the binding runtime how to use uninstalled versions of CommonAPI.
+
+For further build instructions (build for windows, build documentation, tests etc.) please refer to the CommonAPI tutorial.
+
+
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index d9d3e92..0000000
--- a/Makefile.am
+++ /dev/null
@@ -1,99 +0,0 @@
-ACLOCAL_AMFLAGS = -I m4
-EXTRA_DIST = LICENSE
-MOSTLYCLEANFILES =
-# Library interface (not package version!)
-LIBCOMMONAPI_CURRENT=3
-LIBCOMMONAPI_REVISION=1
-LIBCOMMONAPI_AGE=0
-
-AM_CPPFLAGS = \
- -DCOMMONAPI_INTERNAL_COMPILATION
-
-# ------------------------------------------------------------------------------
-# Doxygen
-include $(top_srcdir)/aminclude.am
-EXTRA_DIST += doxygen.cfg
-MOSTLYCLEANFILES += ${DX_CLEANFILES}
-
-# ------------------------------------------------------------------------------
-MAINTAINERCLEANFILES = \
- Makefile.in \
- aclocal.m4 \
- configure
-
-clean-local:
- -rm -rf src-gen
-
-maintainer-clean-local:
- -rm -rf build-aux
- -rm -f config.h.in*
- -rm -f m4/libtool*.m4
- -rm -f m4/lt*.m4
-
-
-lib_LTLIBRARIES = libCommonAPI.la
-
-libCommonAPI_la_SOURCES = \
- src/CommonAPI/Runtime.cpp \
- src/CommonAPI/Configuration.cpp \
- src/CommonAPI/ServicePublisher.cpp \
- src/CommonAPI/ContainerUtils.cpp \
- src/CommonAPI/MainLoopContext.cpp \
- src/CommonAPI/InputStream.cpp \
- src/CommonAPI/Factory.cpp \
- src/CommonAPI/utils.cpp
-
-CommonAPI_includedir=$(includedir)/CommonAPI-${COMMONAPI_API_HEADER_VERSION}/CommonAPI
-CommonAPI_include_HEADERS = \
- src/CommonAPI/Attribute.h \
- src/CommonAPI/AttributeExtension.h \
- src/CommonAPI/ByteBuffer.h \
- src/CommonAPI/CommonAPI.h \
- src/CommonAPI/Configuration.h \
- src/CommonAPI/ContainerUtils.h \
- src/CommonAPI/Event.h \
- src/CommonAPI/Factory.h \
- src/CommonAPI/Factory.hpp \
- src/CommonAPI/InputStream.h \
- src/CommonAPI/MainLoopContext.h \
- src/CommonAPI/MiddlewareInfo.h \
- src/CommonAPI/OutputStream.h \
- src/CommonAPI/Proxy.h \
- src/CommonAPI/ProxyManager.h \
- src/CommonAPI/Runtime.h \
- src/CommonAPI/SelectiveEvent.h \
- src/CommonAPI/SerializableStruct.h \
- src/CommonAPI/SerializableVariant.h \
- src/CommonAPI/SerializableVariant.hpp \
- src/CommonAPI/ServicePublisher.h \
- src/CommonAPI/ServicePublisher.hpp \
- src/CommonAPI/Stub.h \
- src/CommonAPI/types.h \
- src/CommonAPI/utils.h
-
-libCommonAPI_la_LIBADD = -ldl
-libCommonAPI_la_LDFLAGS = \
- ${AM_LDFLAGS} \
- -version-info ${LIBCOMMONAPI_CURRENT}:${LIBCOMMONAPI_REVISION}:${LIBCOMMONAPI_AGE}
-
-pkgconfigdir = ${libdir}/pkgconfig
-pkgconfig_DATA = CommonAPI.pc
-
-# ------------------------------------------------------------------------------
-if ENABLE_TESTS
-
-check_PROGRAMS = \
- VariantTest
-
-
-TESTS = ${check_PROGRAMS}
-VariantTest_includedir=$(includedir)/CommonAPI-${COMMONAPI_API_HEADER_VERSION}/CommonAPI
-VariantTest_SOURCES = src/test/VariantTest.cpp
-VariantTest_CPPFLAGS = ${AM_CPPFLAGS} ${GTEST_CPPFLAGS}
-VariantTest_CXXFLAGS = ${GTEST_CXXFLAGS} -Isrc
-VariantTest_LDADD = ${LDADD} ${GTEST_LIBS} libCommonAPI.la
-
-endif
-
-doc: doxygen-doc
- asciidoc -a version=@PACKAGE_VERSION@ -b html -o doc/html/README.html README
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..ffe601c
--- /dev/null
+++ b/NEWS
@@ -0,0 +1 @@
+This is CommonAPI 3.1.1
diff --git a/README b/README
deleted file mode 100644
index 4a015f7..0000000
--- a/README
+++ /dev/null
@@ -1,219 +0,0 @@
-IPC CommonAPI C++
------------------
-:Author: Juergen Gehring - juergen.gehring@bmw.de, Manfred Bathelt - manfred.bathelt@bmw.de
-:doctitle: IPC CommonAPI C++
-:version:
-
-Copyright
-+++++++++
-Copyright (C) 2014, BMW AG.
-Copyright (C) 2014, GENIVI Alliance, Inc.
-This file is part of GENIVI Project IPC Common API C++.
-
-Contributions are licensed to the GENIVI Alliance under one or more Contribution License Agreements or MPL 2.0.
-
-License
-+++++++
-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/.
-
-Version
-+++++++
-{version}
-
-Further information
-+++++++++++++++++++
-Source code and latest news can be found at http://projects.genivi.org/commonapi/.
-
-Common API Overview
-~~~~~~~~~~~~~~~~~~~
-
-Common API C++ and its mechanism specific bindings (e.g. Common API D-Bus) provide a set of libraries and tools to work with
-RPC communication in a way independent of which mechanism is used. It currently consists of four sub-projects:
-
-*CommonAPI* - This is the base C++ library, which provides the application interface for users and can load runtime bindings such as DBus.
-
-*CommonAPI-Tools* - The Eclipse based tools for CommonAPI. This is essentially the code generator for the generation of C++ code from Franca IDL.
-
-*CommonAPI-D-Bus* - This is the D-Bus binding C++ library, which provides the necessary code to communicate over D-Bus. This is invisible to the application code, and simply needs to be linked against.
-
-*CommonAPI-D-Bus-Tools* - The eclipse based tools for CommonAPI D-Bus. This is the code generator for Franca IDL to Common API D-Bus C++ code.
-
-Build Instructions
-~~~~~~~~~~~~~~~~~~
-
-Linux
-+++++
-
-Use Autotools to build this package:
-----
-# autoreconf -i
-# ./configure
-# make
-# sudo make install (or alternative install process, eg. checkinstall on debian-based distributions, such as Ubuntu)
-----
-
-If the environment variable +GTEST_CONFIG+ is set to the path of the gtest-config script in a Gtest tree test will also be built.
-
-Windows
-+++++++
-
-To build the Windows version of CommonAPI with Visual Studio, you can use the solution file CommonAPI.sln. It is configured to build CommonAPI as a static library. To build the test project you have to set an environment variable called +GTEST+ pointing to your gtest directory (e.g. C:\gtest-1.7.0), and if applicable restart your Visual Studio.
-
-Information for building of gtest:
-
-- Download gtest from https://code.google.com/p/googletest/ e.g. gtest-1.7.0.zip
-- Unpack the archiv into a directory
-- Open the solution gtest-md.sln with Visual Studio 2013 and build gtest
-
-Linking
-~~~~~~~
-
-Against CommonAPI
-+++++++++++++++++
-
-CommonAPI bindings require successful activation of all static initialization code on library load. Therefore it is necessary to activate certain linker flags to ensure this is always the case. These should be specified in the pkg-config files of the respective bindings, but are also listed here. In case of dynamic linking (.so) --no-as-needed must be specified:
-----
--Wl,--no-as-needed -lbindingLib -Wl,--as-needed
-----
-
-In case of static linking --whole-archive must be specified:
-----
--Wl,--whole-archive bindingLib.a -Wl,--no-whole-archive
-----
-
-Generated Proxies and Stubs
-+++++++++++++++++++++++++++
-
-Generated proxies and stubs also require successful activation of all static initialization code on load. If they are provided in either a static or dynamic library to the application they must also be linked wrapped in the flags described above.
-
-Deprecated Elements
-+++++++++++++++++++
-
-All elements that are marked as deprecated on CommonAPI level are considered to be redundant, and normally the other way of achieving the same (the way pointed to by the marked elements) is the way we recommend to use. Elements marked as deprecated will be removed once we have reliable and comprehensive feedback telling us they are not used anymore by anybody, but they will remain in Common API for compatibility reasons at least until then.
-
-Dynamic Loading of Middleware Bindings
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-CommonAPI supports the loading of middleware specific libraries at runtime, without even linking them to the executable beforehand. For this purpose, each middleware binding library provides a short well known name that can be used to identify the library. If such a well known name is passed as an argument to _CommonAPI::Runtime::load()_, CommonAPI will try to dynamically resolve the given name (i.e. find an appropriate library for it), if it is not already provided by a library that was linked at compile time.
-
-In order to resolve a middleware specific library, the default search paths _/usr/lib_ and _/usr/local/lib/_ will be searched for all libraries that match the name pattern "libCommonAPI-<arbitraryName>.so[.major[.minor.revision]]". This naming constraint exists in order to prevent too many libraries to be opened and closed again, as each of the libraries found will be searched for the presence of the identifying well known name.
-
-If there are more libraries for the same binding, the library with the higher version will take precedence.
-The resolution procedure can be extended by providing an environment variable with additional search paths (see below),
-or by specifying a specific path for a specific binding using configuration files (see below).
-
-[NOTE]
-If you call _CommonAPI::Runtime::load()_ without an parameter when no middleware library has been linked at compile time, CommonAPI will load the first middleware library it encounters on the default and specified search paths, regardless of its version.
-
-Configuring CommonAPI
-~~~~~~~~~~~~~~~~~~~~~
-
-It is possible to provide additional configuration parameters to tailor CommonAPI to your specific system architecture. This can be done either by providing configuration files or by setting appropriate environment variables.
-
-Configuration Files
-+++++++++++++++++++
-
-Each CommonAPI configuration file will define additional parameters for specific categories. Which categories and which parameters for each of those categories are available will be detailed below. All parameters for all categories are optional. For each omitted parameter a reasonable default will be set. Because of this, it is not mandatory to provide a config file unless you want to alter any of the configurable default values.
-
-CommonAPI configuration files can be defined locally per binary, globally per binary or globally for all binaries. If more than one configuration file is defined for a given binary (e.g. one locally and one globally) and a given category is defined in several of these configuration files, for each parameter that may be provided for this category the value found in the most specific configuration file will take precedence. If a category is defined several times within the same configuration file,
-the first occurrence of each parameter will take precedence.
-
-All categories and all parameters are separated from each other by one or more newline characters.
-
-CommonAPI Configuration files have to be named this way:
-----
-# Binary local: "<FqnOfBinary>.conf", e.g. "/usr/bin/myBinary.conf" if the binary is "/usr/bin/myBinary"
-# Binary global: "/etc/CommonApi/<NameOfBinary>.conf", e.g. "/etc/CommonAPI/myBinary.conf"
-# Global: "/etc/CommonAPI/CommonAPI.conf"
-----
-
-Available Categories:
-
-.Well known names of specific middleware bindings
-Allows to set parameters that influence the loading procedure of specific middleware bindings. The syntax is:
-
-----
-{binding:<well known binding name>}
-libpath=<Fully qualified name of the library of the binding>
-alias=<One or more desired aliases for the binding, separated by ":">
-genpath=<One or more fully qualified names to libraries containing additional (generated) code for this binding, separated by ":">
-default
-----
-
-*libpath*
-
-Provides a fully qualified name that replaces the search path when trying to dynamically load the identified binding. The library found at +libpath+ will take precedence over all other dynamically discoverable libraries for this binding.
-
-[NOTE]
-If a library for the specified middleware binding is linked to the binary already, this parameter will have no effect. _Not_ finding an appropriate library at +libpath+ is considered to be an error! In this case, no further attempts to resolve the library will be made. If you want to have an explicit error state, call the overloaded _Runtime::load()_ functions and pass in an instance of _Runtime::LoadState_ as argument.
-
-*alias*
-
-In order to load a specific middleware binding, one normally has to know the well known name of the middleware (e.g. "DBus" for the D-Bus middleware binding) and pass this name as parameter when calling _CommonAPI::Runtime::load("<name>")_. _alias_ maps the well known name for this purpose to one or more arbitrary aliases, thereby decoupling the loading of a specific middleware binding from its specific name.
-
-[NOTE]
-You MAY specify this parameter more than once for a binding. The effect will be the same as if you had one alias parameter specifying the exact same names separated by ":". If the same alias is specified more than once, only the first occurrence of the alias will be considered. As CommonAPI itself does not know about which well known middleware names there are, it is possible to specify the well known name of an actual binding as an alias for any other middleware binding. In this case, the actual middleware binding will not be accessible any longer, unless you specify another unique alias for it.
-
-*genpath*
-
-Specifies one or more paths at which a generic library containing additional (e.g. generated middleware and interface specific) code for the middleware binding is to be found. This additional code will be injected when the specific middleware considers it to be the right time to do so.
-
-[NOTE]
-You MAY specify this parameter more than once for a binding. The effect will be the same as if you had one genpath parameter specifying the exact same values separated by ":". If _No_ such parameter is defined, the standard search paths "/usr/lib" and "/usr/local/lib" plus any additional paths defined in the environment variable COMMONAPI_BINDING_PATH (see below) will be searched for any libraries that match the name pattern "lib<wellKnownMiddlewareName>Gen-<arbitraryName>.so[.major[.minor.revision]]". All matching libraries will be loaded. _Not_ finding an appropriate library at any single one of the defined genpaths may result in undefined behavior.
-
-NOTE FOR DEVELOPERS:
-The _genpath_ parameter will be parsed by the CommonAPI framework and stored in _CommonAPI::Configuration_. Actually loading the libraries and following the rules described here however is task of the specific middleware binding. You might want to use the convenience methods provided in <CommonAPI/utils.h> for this purpose. By taking control of the actual proceedings, you may introduce additional mechanisms of discovering and loading such libraries, and you can defer the loading of the libraries until you deem it to be the right time to do so.
-
-*default*
-
-Specifies the library for this binding as the default that is to be loaded if no parameter is given to _CommonAPI::Runtime::load()_. _Not_ finding an appropriate library for a configured default binding at neither specified nor the default paths is considered to be an error! In this case, no further attempts to find another default library will be made! If you want to have an explicit error state, call the overloaded _Runtime::load()_ functions and pass in an instance of _Runtime::LoadState_ as argument.
-
-Environment Variables
-+++++++++++++++++++++
-
-*COMMONAPI_BINDING_PATH*
-By default, the standard paths "/usr/lib" and "/usr/local/lib" will be searched for binding libraries that are loaded dynamically (i.e. at runtime without linking them to the binary beforehand). All paths defined in this environment variable will take precedence over those two default paths. Separator between several paths is ":".
-
-Remarks on Windows Version
-~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Restrictions
-++++++++++++
-
-- Due to a compiler bug in Visual Studio 2013, which is not able to call constructors of variadic template packs, if they contain zero elements, the factory’s buildProxy method does not return a proxy without AttributeExtensions, but implicitly adds a WINDummyAttributeExtension. So to assign such a proxy use the auto keyword or the typedef ***ProxyDefault in the generated ***Proxy.h. This restriction does only affect the windows port. The typedef is cross platform compatible as it points to a proxy with empty template list on Linux.
-- The Windows version does not support dynamic loading.
-
-Working on the code & contribution
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-- First get the code from the git:
-----
-git clone
-----
-
-- Get an overview of all branches:
-----
-git branch
-----
-
-- Switch to the branch you want to work on (master is the feature branch) and verify that it has switched (* changed)
-----
-git checkout <your branch>
-git branch
-----
-
-- Best practice is to create a local branch based on the current branch:
-----
-git branch working_branch
-----
-
-Start working, best practice is to commit smaller, compilable pieces during the development process that makes it easier to handle later on.
-
-- If you want to commit you changes, send them to the author, you can create a patch like this:
-----
-git format-patch working_branch <your branch>
-----
-
-This creates a set of patches that are published via the mailing list. The patches will be discussed and then merged & uploaded on the git by the maintainer.
-
-Patches can be accepted under MPL 2.0 (see section License). Please be sure that the signed-off-by is set correctly. For more, check out http://gerrit.googlecode.com/svn/documentation/2.0/user-signedoffby.html
diff --git a/aminclude.am b/aminclude.am
deleted file mode 100644
index 7dfed8d..0000000
--- a/aminclude.am
+++ /dev/null
@@ -1,168 +0,0 @@
-# Copyright (c) 2009 Oren Ben-Kiki <oren@ben-kiki.org>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved. This file is offered as-is, without any
-# warranty.
-#
-# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_prog_doxygen.html
-# ===========================================================================
-#
-
-## --------------------------------- ##
-## Format-independent Doxygen rules. ##
-## --------------------------------- ##
-
-if DX_COND_doc
-
-## ------------------------------- ##
-## Rules specific for HTML output. ##
-## ------------------------------- ##
-
-if DX_COND_html
-
-DX_CLEAN_HTML = @DX_DOCDIR@/html
-
-endif # DX_COND_html
-
-## ------------------------------ ##
-## Rules specific for CHM output. ##
-## ------------------------------ ##
-
-if DX_COND_chm
-
-DX_CLEAN_CHM = @DX_DOCDIR@/chm
-
-if DX_COND_chi
-
-DX_CLEAN_CHI = @DX_DOCDIR@/@PACKAGE@.chi
-
-endif # DX_COND_chi
-
-endif # DX_COND_chm
-
-## ------------------------------ ##
-## Rules specific for MAN output. ##
-## ------------------------------ ##
-
-if DX_COND_man
-
-DX_CLEAN_MAN = @DX_DOCDIR@/man
-
-endif # DX_COND_man
-
-## ------------------------------ ##
-## Rules specific for RTF output. ##
-## ------------------------------ ##
-
-if DX_COND_rtf
-
-DX_CLEAN_RTF = @DX_DOCDIR@/rtf
-
-endif # DX_COND_rtf
-
-## ------------------------------ ##
-## Rules specific for XML output. ##
-## ------------------------------ ##
-
-if DX_COND_xml
-
-DX_CLEAN_XML = @DX_DOCDIR@/xml
-
-endif # DX_COND_xml
-
-## ----------------------------- ##
-## Rules specific for PS output. ##
-## ----------------------------- ##
-
-if DX_COND_ps
-
-DX_CLEAN_PS = @DX_DOCDIR@/@PACKAGE@.ps
-
-DX_PS_GOAL = doxygen-ps
-
-doxygen-ps: @DX_DOCDIR@/@PACKAGE@.ps
-
-@DX_DOCDIR@/@PACKAGE@.ps: @DX_DOCDIR@/@PACKAGE@.tag
- cd @DX_DOCDIR@/latex; \
- rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \
- $(DX_LATEX) refman.tex; \
- $(MAKEINDEX_PATH) refman.idx; \
- $(DX_LATEX) refman.tex; \
- countdown=5; \
- while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \
- refman.log > /dev/null 2>&1 \
- && test $$countdown -gt 0; do \
- $(DX_LATEX) refman.tex; \
- countdown=`expr $$countdown - 1`; \
- done; \
- $(DX_DVIPS) -o ../@PACKAGE@.ps refman.dvi
-
-endif # DX_COND_ps
-
-## ------------------------------ ##
-## Rules specific for PDF output. ##
-## ------------------------------ ##
-
-if DX_COND_pdf
-
-DX_CLEAN_PDF = @DX_DOCDIR@/@PACKAGE@.pdf
-
-DX_PDF_GOAL = doxygen-pdf
-
-doxygen-pdf: @DX_DOCDIR@/@PACKAGE@.pdf
-
-@DX_DOCDIR@/@PACKAGE@.pdf: @DX_DOCDIR@/@PACKAGE@.tag
- cd @DX_DOCDIR@/latex; \
- rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \
- $(DX_PDFLATEX) refman.tex; \
- $(DX_MAKEINDEX) refman.idx; \
- $(DX_PDFLATEX) refman.tex; \
- countdown=5; \
- while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \
- refman.log > /dev/null 2>&1 \
- && test $$countdown -gt 0; do \
- $(DX_PDFLATEX) refman.tex; \
- countdown=`expr $$countdown - 1`; \
- done; \
- mv refman.pdf ../@PACKAGE@.pdf
-
-endif # DX_COND_pdf
-
-## ------------------------------------------------- ##
-## Rules specific for LaTeX (shared for PS and PDF). ##
-## ------------------------------------------------- ##
-
-if DX_COND_latex
-
-DX_CLEAN_LATEX = @DX_DOCDIR@/latex
-
-endif # DX_COND_latex
-
-.PHONY: doxygen-run doxygen-doc $(DX_PS_GOAL) $(DX_PDF_GOAL)
-
-.INTERMEDIATE: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL)
-
-doxygen-run: @DX_DOCDIR@/@PACKAGE@.tag
-
-doxygen-doc: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL)
-
-@DX_DOCDIR@/@PACKAGE@.tag: $(DX_CONFIG) $(pkginclude_HEADERS)
- rm -rf @DX_DOCDIR@
- $(DX_ENV) $(DX_DOXYGEN) $(srcdir)/$(DX_CONFIG)
-
-DX_CLEANFILES = \
- @DX_DOCDIR@/@PACKAGE@.tag \
- -r \
- $(DX_CLEAN_HTML) \
- $(DX_CLEAN_CHM) \
- $(DX_CLEAN_CHI) \
- $(DX_CLEAN_MAN) \
- $(DX_CLEAN_RTF) \
- $(DX_CLEAN_XML) \
- $(DX_CLEAN_PS) \
- $(DX_CLEAN_PDF) \
- $(DX_CLEAN_LATEX)
-
-endif # DX_COND_doc \ No newline at end of file
diff --git a/cmake/CommonAPIConfig.cmake.in b/cmake/CommonAPIConfig.cmake.in
new file mode 100644
index 0000000..2c4fea4
--- /dev/null
+++ b/cmake/CommonAPIConfig.cmake.in
@@ -0,0 +1,13 @@
+# Config file for the CommonAPI package
+# It defines the following variables
+# COMMONAPI_INCLUDE_DIRS - include directories for CommonAPI
+
+# Compute paths
+get_filename_component(COMMONAPI_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+set(COMMONAPI_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
+
+# Our library dependencies (contains definitions for IMPORTED targets)
+include("${COMMONAPI_CMAKE_DIR}/CommonAPITargets.cmake")
+
+set(COMMONAPI_VERSION @PACKAGE_VERSION@)
+set(COMMONAPI_VERSION_STRING "@PACKAGE_VERSION@")
diff --git a/cmake/CommonAPIConfigVersion.cmake.in b/cmake/CommonAPIConfigVersion.cmake.in
new file mode 100644
index 0000000..9d6ff4f
--- /dev/null
+++ b/cmake/CommonAPIConfigVersion.cmake.in
@@ -0,0 +1,12 @@
+set(PACKAGE_VERSION "@PACKAGE_VERSION@")
+
+set(PACKAGE_VERSION_COMPATIBLE FALSE)
+
+string(REPLACE "." "\\." ESCAPED_API_HEADER_VERSION "@COMMONAPI_API_HEADER_VERSION@")
+if("${PACKAGE_FIND_VERSION}" MATCHES "^@ESCAPED_API_HEADER_VERSION@($|\\.)")
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+endif()
+
+if("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "${PACKAGE_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+endif()
diff --git a/commonapi.spec.in b/commonapi.spec.in
new file mode 100644
index 0000000..56c9e75
--- /dev/null
+++ b/commonapi.spec.in
@@ -0,0 +1,123 @@
+Name: @PROJECT_NAME@
+Version: @COMPONENT_VERSION@
+Release: @RPM_PACKAGE_VERSION@
+Summary: CommonAPI
+Group: libs
+License: @LICENSE@
+Vendor: BMW Group
+URL: http://www.bmw.de
+Source: @PROJECT_NAME@-@COMPONENT_VERSION@.tar.gz
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
+#Requires: libcommonapi
+
+%description
+CAPI middleware for IPC
+
+%package dev
+Summary: CommonAPI header files
+Group: Development/Libraries
+Requires: libcommonapi3
+
+%package staticdev
+Summary: CommonAPI header files
+Group: Development/Libraries
+Requires: libcommonapi3
+
+
+%description dev
+CAPI middleware headers for IPC development
+
+%prep
+mkdir -p %{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI
+%setup
+
+
+
+%build
+mkdir -p build
+cd build
+cmake ..
+make
+
+%install
+rm -rf $RPM_BUILD_ROOT
+cd build
+cmake ..
+make install DESTDIR=$RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT%{_bindir}
+mkdir -p %{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI
+
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root,-)
+%{_libdir}/libCommonAPI.so.@LIBCOMMONAPI_MAJOR_VERSION@
+%{_libdir}/libCommonAPI.so.@LIBCOMMONAPI_MAJOR_VERSION@.@LIBCOMMONAPI_MINOR_VERSION@.@LIBCOMMONAPI_PATCH_VERSION@
+%{_libdir}/libCommonAPI.so
+
+%files staticdev
+#%{_libdir}/libCommonAPI.la
+
+%files dev
+%defattr(-,root,root,-)
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Address.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Attribute.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/AttributeExtension.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/ByteBuffer.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/CommonAPI.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/ContainerUtils.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Deployable.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Deployment.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Enumeration.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Event.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Factory.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/IniFileReader.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/InputStream.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Logger.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/MainLoopContext.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/OutputStream.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Proxy.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/ProxyManager.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Runtime.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/SelectiveEvent.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/SerializableArguments.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Struct.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Stub.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/TypeOutputStream.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Types.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Utils.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Variant.hpp
+%{_includedir}/CommonAPI-@COMMONAPI_API_HEADER_VERSION@/CommonAPI/Version.hpp
+%{_libdir}/cmake/CommonAPI-@COMPONENT_VERSION@/CommonAPIConfig.cmake
+%{_libdir}/cmake/CommonAPI-@COMPONENT_VERSION@/CommonAPIConfigVersion.cmake
+%{_libdir}/cmake/CommonAPI-@COMPONENT_VERSION@/CommonAPITargets.cmake
+%{_libdir}/cmake/CommonAPI-@COMPONENT_VERSION@/CommonAPITargets-@CMAKE_BUILD_TYPE_FOR_SPEC_IN@.cmake
+
+%changelog dev
+* Fri Mar 20 2015 Markus Freutsmiedl <Markus.Freutsmiedl@partner.bmw.de> @GENIVI_PROJECT_VERSION@
+- LIB_MAJOR_VERSION changed to LIBCOMMONAPI_MAJOR_VERSION
+- LIB_MINOR_VERSION changed to LIBCOMMONAPI_MINOR_VERSION
+- LIB_PATCH_VERSION changed to LIBCOMMONAPI_PATCH_VERSION
+- files dev reworked
+
+%changelog dev
+* Tue Sep 2 2014 Markus Freutsmiedl <Markus.Freutsmiedl@partner.bmw.de> @GENIVI_PROJECT_VERSION@
+- files dev reworked
+
+%changelog dev
+* Tue July 1 2014 Markus Freutsmiedl <Markus.Freutsmiedl@partner.bmw.de> @GENIVI_PROJECT_VERSION@
+- LIB_MAJOR_VERSION, LIB_MINOR_VERSION and LIB_PATCH_VERSION introduced
+
+%changelog dev
+* Wed Jan 29 2014 Gernot Wirschal <Gernot.Wirschal@bmw.de> @GENIVI_PROJECT_VERSION@
+- Add dev packet configuration
+
+%changelog
+* Wed Jan 29 2014 Gernot Wirschal <Gernot.Wirschal@bmw.de> @GENIVI_PROJECT_VERSION@
+- Add dev packet configuration
+* Mon Jan 27 2014 Gernot Wirschal <Gernot.Wirschal@bmw.de> @GENIVI_PROJECT_VERSION@
+- Initial packaging for GPT
+
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index 0e75664..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,96 +0,0 @@
-AC_PREREQ(2.61)
-AC_INIT([GENIVI IPC Common API C++],
- [2.1.6],
- [],
- [CommonAPI])
-
-AC_CONFIG_MACRO_DIR([m4])
-m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
-AC_CONFIG_AUX_DIR([build-aux])
-AC_CONFIG_HEADERS([build-aux/config.h])
-AC_CONFIG_FILES([
- Makefile
- CommonAPI.pc
- CommonAPI-uninstalled.pc])
-
-AC_CANONICAL_SYSTEM
-
-AM_INIT_AUTOMAKE([foreign 1.11 silent-rules subdir-objects -Wall -Werror])
-AM_SILENT_RULES
-AM_MAINTAINER_MODE
-
-AS_IF([test -z "${CXXFLAGS}"], [CXXFLAGS='-O0'], [])
-
-AC_PROG_CXX
-AC_LANG([C++])
-AX_CXX_COMPILE_STDCXX_11([noext])
-
-LT_PREREQ(2.2)
-LT_INIT
-
-COMMONAPI_API_HEADER_VERSION="2.1"
-AC_SUBST(COMMONAPI_API_HEADER_VERSION)
-
-GTEST_MIN_VERSION="1.6.0"
-GTEST_URL="http://code.google.com/p/googletest"
-
-
-AC_ARG_VAR([GTEST_CONFIG], [The exact path of Google Test's 'gtest-config' script.])
-AC_ARG_VAR([GTEST_CPPFLAGS], [C-like preprocessor flags for Google Test.])
-AC_ARG_VAR([GTEST_CXXFLAGS], [C++ compile flags for Google Test.])
-AC_ARG_VAR([GTEST_LDFLAGS], [Linker path and option flags for Google Test.])
-AC_ARG_VAR([GTEST_LIBS], [Library linking flags for Google Test.])
-AC_ARG_VAR([GTEST_VERSION], [The available version of Google Test.])
-
-AS_IF([test -f "${GTEST_CONFIG}"],
- [AS_IF([${GTEST_CONFIG} --min-version=${GTEST_MIN_VERSION}],
- [],
- [AC_MSG_ERROR([dnl
- Found Google Test Version ${GTEST_VERSION}. However ${GTEST_MIN_VERSION} is
- required. Please refer to ${GTEST_URL} for a more recent version.])])
- [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`]
- [GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`]
- [GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`]
- [GTEST_LIBS=`${GTEST_CONFIG} --libs`]
- [GTEST_VERSION=`${GTEST_CONFIG} --version`]
- ]
- []
-)
-
-AM_CONDITIONAL(ENABLE_TESTS, [test -f "${GTEST_CONFIG}"])
-
-# Doxygen support
-DX_HTML_FEATURE(ON)
-DX_CHM_FEATURE(OFF)
-DX_CHI_FEATURE(OFF)
-DX_MAN_FEATURE(OFF)
-DX_RTF_FEATURE(OFF)
-DX_XML_FEATURE(OFF)
-DX_PDF_FEATURE(OFF)
-DX_PS_FEATURE(OFF)
-DX_INIT_DOXYGEN(${PACKAGE_NAME}, doxygen.cfg, doc)
-
-AC_MSG_RESULT([
- $PACKAGE_NAME v$VERSION
-
- enable docs: ${ENABLE_DOCS}
-
- GTEST_CONFIG: ${GTEST_CONFIG}
- GTEST_CPPFLAGS: ${GTEST_CPPFLAGS}
- GTEST_CXXFLAGS: ${GTEST_CXXFLAGS}
- GTEST_LDFLAGS: ${GTEST_LDFLAGS}
- GTEST_LIBS: ${GTEST_LIBS}
- GTEST_VERSION: ${GTEST_VERSION}
-
- prefix: ${prefix}
- CXXFLAGS: ${CXXFLAGS}
- LDFLAGS: ${LDFLAGS}
-])
-
-
-
-
-
-
-
-AC_OUTPUT
diff --git a/docx/01_mainpage.dox b/docx/01_mainpage.dox
index 65515b1..3a4940b 100644
--- a/docx/01_mainpage.dox
+++ b/docx/01_mainpage.dox
@@ -1,37 +1,23 @@
/**
- * Copyright (C) 2013 BMW AG
- *
+ * \copyright
+ *
+ * Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This file is part of GENIVI project IPC CommonAPI C++.
*
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * 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/.
- *
- * \author Juergen Gehring (juergen.gehring@bmw.de)
- * \author Manfred Bathelt (manfred.bathelt@bmw.de)
+ * Contributions are licensed to the GENIVI Alliance under one or more Contribution License Agreements.
*
*/
/*!
\mainpage
-\par Usage information
-can be found in the <a href="README.html">README file</a>.
-
-\par About IPC CommonAPI C++
-IPC CommonAPI C++ is a C++ based abstraction API for communication stacks, which enables applications to
-use different communication middleware - so called language bindings - as backend without any changes to the application code.
+\par License
+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/.
-\par More information
-can be found at the <a href="http://projects.genivi.org/commonapi/">project homepage</a> \n
-Please see the <a href="http://projects.genivi.org/commonapi/download">project download section</a> for available language bindings.
+\par CommonAPI C++ Specification and User Guide
+The specification and the user guide can be found in the CommonAPI documentation directory of the CommonAPI Tools project.
-\par IPC CommonAPI C++ Specification
-The specification IPC CommonAPI C++ is maintained within the GENIVI System Infrastructure Expert Group (EG-SI).
-The specification document can be found inside the CommonAPI-Tools project.
+\par Build instructions
+can be found in the README file of this project.
*/
diff --git a/doxygen.cfg b/doxygen.in
index bd426c3..dd571fd 100644
--- a/doxygen.cfg
+++ b/doxygen.in
@@ -26,7 +26,7 @@ DOXYFILE_ENCODING = UTF-8
# identify the project. Note that if you do not use Doxywizard you need
# to put quotes around the project name if it contains spaces.
-PROJECT_NAME = $(PROJECT)-$(VERSION)
+PROJECT_NAME = "@PROJECT@-@PACKAGE_VERSION@"
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
@@ -52,7 +52,7 @@ PROJECT_LOGO =
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
-OUTPUT_DIRECTORY = $(DOCDIR)
+OUTPUT_DIRECTORY = @PROJECT_BINARY_DIR@/@DOCDIR@
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
# 4096 sub-directories (in 2 levels) under the output directory of each output
@@ -128,7 +128,7 @@ FULL_PATH_NAMES = YES
# If left blank the directory from which doxygen is run is used as the
# path to strip.
-STRIP_FROM_PATH = $(SRCDIR)
+STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@/@SRCDIR@
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
# the path mentioned in the documentation of a class, which tells
@@ -319,22 +319,6 @@ INLINE_SIMPLE_STRUCTS = NO
TYPEDEF_HIDES_STRUCT = NO
-# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
-# determine which symbols to keep in memory and which to flush to disk.
-# When the cache is full, less often used symbols will be written to disk.
-# For small to medium size projects (<1000 input files) the default value is
-# probably good enough. For larger projects a too small cache size can cause
-# doxygen to be busy swapping symbols to and from disk most of the time
-# causing a significant performance penalty.
-# If the system has enough physical memory increasing the cache will improve the
-# performance by keeping more symbols in memory. Note that the value works on
-# a logarithmic scale so increasing the size by one will roughly double the
-# memory usage. The cache size is given by this formula:
-# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
-# corresponding to a cache size of 2^16 = 65536 symbols.
-
-SYMBOL_CACHE_SIZE = 0
-
# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be
# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given
# their name and scope. Since this can be an expensive process and often the
@@ -655,7 +639,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
-INPUT = $(SRCDIR) docx
+INPUT = @PROJECT_SOURCE_DIR@/@SRCDIR@ @PROJECT_SOURCE_DIR@/docx
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
@@ -687,7 +671,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.
-EXCLUDE = src/test build-aux src/murmurhash
+EXCLUDE = @PROJECT_SOURCE_DIR@/src/test @PROJECT_SOURCE_DIR@/src/murmurhash
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
@@ -859,7 +843,7 @@ IGNORE_PREFIX =
# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
# generate HTML output.
-GENERATE_HTML = $(GENERATE_HTML)
+GENERATE_HTML = @GENERATE_HTML@
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
@@ -1000,27 +984,27 @@ DOCSET_PUBLISHER_NAME = Publisher
# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
# of the generated HTML documentation.
-GENERATE_HTMLHELP = $(GENERATE_HTMLHELP)
+GENERATE_HTMLHELP = @GENERATE_HTMLHELP@
# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
# be used to specify the file name of the resulting .chm file. You
# can add a path in front of the file if the result should not be
# written to the html output directory.
-CHM_FILE = ../$(PROJECT).chm
+CHM_FILE = ../@PROJECT@.chm
# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
# be used to specify the location (absolute path including file name) of
# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
# the HTML help compiler on the generated index.hhp.
-HHC_LOCATION = $(HHC_PATH)
+HHC_LOCATION = @HHC_PATH@
# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
# controls if a separate .chi index file is generated (YES) or that
# it should be included in the master .chm file (NO).
-GENERATE_CHI = $(GENERATE_CHI)
+GENERATE_CHI = @GENERATE_CHI@
# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
# is used to encode HtmlHelp index (hhk), content (hhc) and project file
@@ -1216,7 +1200,7 @@ SERVER_BASED_SEARCH = NO
# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
# generate Latex output.
-GENERATE_LATEX = $(GENERATE_LATEX)
+GENERATE_LATEX = @GENERATE_LATEX@
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
@@ -1248,7 +1232,7 @@ COMPACT_LATEX = YES
# by the printer. Possible values are: a4, letter, legal and
# executive. If left blank a4wide will be used.
-PAPER_TYPE = $(PAPER_SIZE)
+PAPER_TYPE = @PAPER_SIZE@
# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
# packages that should be included in the LaTeX output.
@@ -1280,7 +1264,7 @@ PDF_HYPERLINKS = NO
# plain latex in the generated Makefile. Set this option to YES to get a
# higher quality PDF documentation.
-USE_PDFLATEX = $(GENERATE_PDF)
+USE_PDFLATEX = @GENERATE_PDF@
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
# command to the generated LaTeX files. This will instruct LaTeX to keep
@@ -1316,7 +1300,7 @@ LATEX_BIB_STYLE = plain
# The RTF output is optimized for Word 97 and may not look very pretty with
# other RTF readers or editors.
-GENERATE_RTF = $(GENERATE_RTF)
+GENERATE_RTF = @GENERATE_RTF@
# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
@@ -1357,7 +1341,7 @@ RTF_EXTENSIONS_FILE =
# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
# generate man pages
-GENERATE_MAN = $(GENERATE_MAN)
+GENERATE_MAN = @GENERATE_MAN@
# The MAN_OUTPUT tag is used to specify where the man pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
@@ -1386,7 +1370,7 @@ MAN_LINKS = NO
# generate an XML file that captures the structure of
# the code including all documentation.
-GENERATE_XML = $(GENERATE_XML)
+GENERATE_XML = @GENERATE_XML@
# The XML_OUTPUT tag is used to specify where the XML pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
@@ -1550,7 +1534,7 @@ TAGFILES =
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
# a tag file that is based on the input files it reads.
-GENERATE_TAGFILE = $(DOCDIR)/$(PROJECT).tag
+GENERATE_TAGFILE = @DOCDIR@/@PROJECT@.tag
# If the ALLEXTERNALS tag is set to YES all external classes will be listed
# in the class index. If set to NO only the inherited external classes
@@ -1601,7 +1585,7 @@ HIDE_UNDOC_RELATIONS = YES
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
-HAVE_DOT = $(HAVE_DOT)
+HAVE_DOT = @HAVE_DOT@
# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
# allowed to run in parallel. When set to 0 (the default) doxygen will
@@ -1732,7 +1716,7 @@ INTERACTIVE_SVG = NO
# The tag DOT_PATH can be used to specify the path where the dot tool can be
# found. If left blank, it is assumed the dot tool can be found in the path.
-DOT_PATH = $(DOT_PATH)
+DOT_PATH = @DOT_PATH@
# The DOTFILE_DIRS tag can be used to specify one or more directories that
# contain dot files that are included in the documentation (see the
diff --git a/include/CommonAPI/Address.hpp b/include/CommonAPI/Address.hpp
new file mode 100644
index 0000000..0826a8f
--- /dev/null
+++ b/include/CommonAPI/Address.hpp
@@ -0,0 +1,52 @@
+// 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/.
+
+#ifndef COMMONAPI_ADDRESS_HPP_
+#define COMMONAPI_ADDRESS_HPP_
+
+#include <iostream>
+#include <string>
+
+#include <CommonAPI/Export.hpp>
+
+namespace CommonAPI {
+
+class Address {
+public:
+ COMMONAPI_EXPORT Address() = default;
+ COMMONAPI_EXPORT Address(const std::string &_address);
+ COMMONAPI_EXPORT Address(const std::string &_domain,
+ const std::string &_interface,
+ const std::string &_instance);
+ COMMONAPI_EXPORT Address(const Address &_source);
+ COMMONAPI_EXPORT virtual ~Address();
+
+ COMMONAPI_EXPORT bool operator==(const Address &_other) const;
+ COMMONAPI_EXPORT bool operator!=(const Address &_other) const;
+ COMMONAPI_EXPORT bool operator<(const Address &_other) const;
+
+ COMMONAPI_EXPORT std::string getAddress() const;
+ COMMONAPI_EXPORT void setAddress(const std::string &_address);
+
+ COMMONAPI_EXPORT const std::string &getDomain() const;
+ COMMONAPI_EXPORT void setDomain(const std::string &_domain);
+
+ COMMONAPI_EXPORT const std::string &getInterface() const;
+ COMMONAPI_EXPORT void setInterface(const std::string &_interface);
+
+ COMMONAPI_EXPORT const std::string &getInstance() const;
+ COMMONAPI_EXPORT void setInstance(const std::string &_instance);
+
+private:
+ std::string domain_;
+ std::string interface_;
+ std::string instance_;
+
+ friend COMMONAPI_EXPORT std::ostream &operator<<(std::ostream &_out, const Address &_address);
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_ADDRESS_HPP_
diff --git a/src/CommonAPI/Attribute.h b/include/CommonAPI/Attribute.hpp
index 51990c3..200d3bb 100644
--- a/src/CommonAPI/Attribute.h
+++ b/include/CommonAPI/Attribute.hpp
@@ -1,25 +1,23 @@
-/* Copyright (C) 2013 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/. */
+// Copyright (C) 2013-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/.
#if !defined (COMMONAPI_INTERNAL_COMPILATION)
#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef COMMONAPI_ATTRIBUTE_H_
-#define COMMONAPI_ATTRIBUTE_H_
-
-#include "types.h"
-#include "Event.h"
+#ifndef COMMONAPI_ATTRIBUTE_HPP_
+#define COMMONAPI_ATTRIBUTE_HPP_
#include <cstdint>
#include <functional>
#include <future>
#include <memory>
+#include <CommonAPI/CallInfo.hpp>
+#include <CommonAPI/Event.hpp>
+#include <CommonAPI/Types.hpp>
namespace CommonAPI {
@@ -32,7 +30,8 @@ template <typename _ValueType>
class ReadonlyAttribute {
public:
typedef _ValueType ValueType;
- typedef std::function<void(const CallStatus&, _ValueType)> AttributeAsyncCallback;
+
+ typedef std::function<void(const CallStatus &, _ValueType)> AttributeAsyncCallback;
virtual ~ReadonlyAttribute() { }
@@ -42,9 +41,11 @@ class ReadonlyAttribute {
* Get value of attribute, usually from remote. Synchronous call.
*
* @param value Reference to be filled with value.
- * @return Call status of the operation.
+ * @param callStatus call status reference will be filled with status of the operation
*/
- virtual void getValue(CallStatus& callStaus, _ValueType& value) const = 0;
+ virtual void getValue(CallStatus &_status,
+ _ValueType &_value,
+ const CallInfo *_info = nullptr) const = 0;
/**
* \brief Get value of attribute, usually from remote. Asynchronous call.
@@ -54,7 +55,8 @@ class ReadonlyAttribute {
* @param attributeAsyncCallback std::function object for the callback to be invoked.
* @return std::future containing the call status of the operation.
*/
- virtual std::future<CallStatus> getValueAsync(AttributeAsyncCallback attributeAsyncCallback) = 0;
+ virtual std::future<CallStatus> getValueAsync(AttributeAsyncCallback attributeAsyncCallback,
+ const CallInfo *_info = nullptr) = 0;
};
/**
@@ -79,7 +81,10 @@ class Attribute: public ReadonlyAttribute<_ValueType> {
* @param callStatus call status reference will be filled with status of the operation
* @param responseValue Reference which will contain the actuall value set by the remote.
*/
- virtual void setValue(const _ValueType& requestValue, CallStatus& callStatus, _ValueType& responseValue) = 0;
+ virtual void setValue(const _ValueType& requestValue,
+ CallStatus& callStatus,
+ _ValueType& responseValue,
+ const CallInfo *_info = nullptr) = 0;
/**
* \brief Set value of attribute, usually to remote. Asynchronous call.
@@ -91,7 +96,8 @@ class Attribute: public ReadonlyAttribute<_ValueType> {
* @return std::future containing the call status of the operation.
*/
virtual std::future<CallStatus> setValueAsync(const _ValueType& requestValue,
- AttributeAsyncCallback attributeAsyncCallback) = 0;
+ AttributeAsyncCallback attributeAsyncCallback,
+ const CallInfo *_info = nullptr) = 0;
};
/**
@@ -109,9 +115,9 @@ class _ObservableAttributeImpl: public _AttributeBaseClass {
virtual ~_ObservableAttributeImpl() { }
/**
- * \brief Returns the event handler for the remote change notifiaction event
+ * \brief Returns the event handler for the remote change notification event
*
- * Returns the event handler for the remote change notifiaction event
+ * Returns the event handler for the remote change notification event
*
* @return The event handler object
*/
@@ -134,4 +140,4 @@ struct WINDummyAttribute {
} // namespace CommonAPI
-#endif // COMMONAPI_ATTRIBUTE_H_
+#endif // COMMONAPI_ATTRIBUTE_HPP_
diff --git a/src/CommonAPI/AttributeExtension.h b/include/CommonAPI/AttributeExtension.hpp
index 4cea9b1..5135924 100644
--- a/src/CommonAPI/AttributeExtension.h
+++ b/include/CommonAPI/AttributeExtension.hpp
@@ -1,24 +1,25 @@
-/* Copyright (C) 2013 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/. */
+// Copyright (C) 2013-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/.
#if !defined (COMMONAPI_INTERNAL_COMPILATION)
#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef COMMON_API_DBUS_ATTRIBUTE_EXTENSION_H_
-#define COMMON_API_DBUS_ATTRIBUTE_EXTENSION_H_
-
-#include "types.h"
-#include "Event.h"
+#ifndef COMMON_API_DBUS_ATTRIBUTE_EXTENSION_HPP_
+#define COMMON_API_DBUS_ATTRIBUTE_EXTENSION_HPP_
#include <cstdint>
#include <functional>
#include <memory>
+#include <CommonAPI/Event.hpp>
+#include <CommonAPI/Types.hpp>
+
+#ifdef WIN32
+#include "Attribute.hpp"
+#endif
namespace CommonAPI {
@@ -44,13 +45,10 @@ class WINDummyAttributeExtension : public CommonAPI::AttributeExtension<_Attribu
WINDummyAttribute dummyAttribute;
public:
WINDummyAttributeExtension() {};
- WINDummyAttributeExtension(Proxy& proxy) :
- AttributeExtension<_AttributeType>(dummyAttribute) {}
-
~WINDummyAttributeExtension() {}
};
#endif
} // namespace CommonAPI
-#endif // COMMON_API_DBUS_ATTRIBUTE_EXTENSION_H_
+#endif // COMMON_API_DBUS_ATTRIBUTE_EXTENSION_HPP_
diff --git a/include/CommonAPI/ByteBuffer.hpp b/include/CommonAPI/ByteBuffer.hpp
new file mode 100644
index 0000000..5d3ad39
--- /dev/null
+++ b/include/CommonAPI/ByteBuffer.hpp
@@ -0,0 +1,18 @@
+// Copyright (C) 2013-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/.
+
+#ifndef COMMONAPI_BYTE_BUFFER_HPP_
+#define COMMONAPI_BYTE_BUFFER_HPP_
+
+#include <vector>
+#include <cstdint>
+
+namespace CommonAPI {
+
+typedef std::vector<uint8_t> ByteBuffer;
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_BYTE_BUFFER_HPP_
diff --git a/include/CommonAPI/CallInfo.hpp b/include/CommonAPI/CallInfo.hpp
new file mode 100644
index 0000000..a6f43bd
--- /dev/null
+++ b/include/CommonAPI/CallInfo.hpp
@@ -0,0 +1,31 @@
+// 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/.
+
+#ifndef COMMONAPI_CALLINFO_HPP_
+#define COMMONAPI_CALLINFO_HPP_
+
+#include <CommonAPI/Config.hpp>
+#include <CommonAPI/Types.hpp>
+
+namespace CommonAPI {
+
+struct COMMONAPI_EXPORT CallInfo {
+ CallInfo()
+ : timeout_(DEFAULT_SEND_TIMEOUT_MS), sender_(0) {
+ }
+ CallInfo(Timeout_t _timeout)
+ : timeout_(_timeout), sender_(0) {
+ }
+ CallInfo(Timeout_t _timeout, Sender_t _sender)
+ : timeout_(_timeout), sender_(_sender) {
+ }
+
+ Timeout_t timeout_;
+ Sender_t sender_;
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_ADDRESS_HPP_
diff --git a/include/CommonAPI/CommonAPI.hpp b/include/CommonAPI/CommonAPI.hpp
new file mode 100644
index 0000000..5568330
--- /dev/null
+++ b/include/CommonAPI/CommonAPI.hpp
@@ -0,0 +1,22 @@
+// Copyright (C) 2013-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/.
+
+#ifndef COMMONAPI_HPP_
+#define COMMONAPI_HPP_
+
+#ifndef COMMONAPI_INTERNAL_COMPILATION
+#define COMMONAPI_INTERNAL_COMPILATION
+#endif
+
+#include "Address.hpp"
+#include "AttributeExtension.hpp"
+#include "ByteBuffer.hpp"
+#include "MainLoopContext.hpp"
+#include "Runtime.hpp"
+#include "Types.hpp"
+
+#undef COMMONAPI_INTERNAL_COMPILATION
+
+#endif // COMMONAPI_HPP_
diff --git a/include/CommonAPI/Config.hpp b/include/CommonAPI/Config.hpp
new file mode 100644
index 0000000..fb99bf3
--- /dev/null
+++ b/include/CommonAPI/Config.hpp
@@ -0,0 +1,17 @@
+// 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/.
+
+#ifndef COMMONAPI_CONFIG_HPP_
+#define COMMONAPI_CONFIG_HPP_
+
+#include <CommonAPI/Types.hpp>
+
+namespace CommonAPI {
+
+static const Timeout_t DEFAULT_SEND_TIMEOUT_MS = 5000;
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_CONFIG_HPP_
diff --git a/include/CommonAPI/ContainerUtils.hpp b/include/CommonAPI/ContainerUtils.hpp
new file mode 100644
index 0000000..9fddc08
--- /dev/null
+++ b/include/CommonAPI/ContainerUtils.hpp
@@ -0,0 +1,33 @@
+// Copyright (C) 2013-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/.
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef COMMONAPI_CONTAINERUTILS_HPP_
+#define COMMONAPI_CONTAINERUTILS_HPP_
+
+#include <functional>
+#include <memory>
+
+#include <CommonAPI/Export.hpp>
+
+namespace CommonAPI {
+class ClientId;
+
+struct COMMONAPI_EXPORT SharedPointerClientIdContentHash : public std::unary_function<std::shared_ptr<ClientId>, size_t> {
+ size_t operator()(const std::shared_ptr<ClientId>& t) const;
+};
+
+struct COMMONAPI_EXPORT SharedPointerClientIdContentEqual : public std::binary_function<std::shared_ptr<ClientId>, std::shared_ptr<ClientId>, bool> {
+ bool operator()(const std::shared_ptr<ClientId>& a, const std::shared_ptr<ClientId>& b) const;
+};
+
+
+} // namespace std
+
+
+#endif // COMMONAPI_CONTAINERUTILS_HPP_
diff --git a/include/CommonAPI/Deployable.hpp b/include/CommonAPI/Deployable.hpp
new file mode 100644
index 0000000..7a9002c
--- /dev/null
+++ b/include/CommonAPI/Deployable.hpp
@@ -0,0 +1,59 @@
+// Copyright (C) 2014-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/.
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef COMMONAPI_DEPLOYABLE_HPP_
+#define COMMONAPI_DEPLOYABLE_HPP_
+
+namespace CommonAPI {
+
+struct DeployableBase {
+};
+
+template<typename _Type, typename _TypeDepl>
+struct Deployable : DeployableBase
+{
+ Deployable(const _TypeDepl *_depl = nullptr)
+ : depl_(const_cast<_TypeDepl *>(_depl)) {
+ }
+
+ Deployable(const _Type &_value, const _TypeDepl *_depl)
+ : value_(_value),
+ depl_(const_cast<_TypeDepl *>(_depl)) {
+ };
+
+ Deployable<_Type, _TypeDepl>& operator=(const Deployable<_Type, _TypeDepl> &_source) {
+ value_ = _source.value_;
+ depl_ = _source.depl_;
+ return (*this);
+ }
+
+ operator _Type() const {
+ return value_;
+ }
+
+ const _Type &getValue() const {
+ return value_;
+ }
+
+ _Type &getValue() {
+ return value_;
+ }
+
+ const _TypeDepl *getDepl() const {
+ return depl_;
+ }
+
+ protected:
+ _Type value_;
+ _TypeDepl *depl_;
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_DEPLOYABLE_HPP_
diff --git a/include/CommonAPI/Deployment.hpp b/include/CommonAPI/Deployment.hpp
new file mode 100644
index 0000000..db2a914
--- /dev/null
+++ b/include/CommonAPI/Deployment.hpp
@@ -0,0 +1,75 @@
+// Copyright (C) 2014-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/.
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef COMMONAPI_DEPLOYMENT_HPP_
+#define COMMONAPI_DEPLOYMENT_HPP_
+
+#include <tuple>
+
+namespace CommonAPI {
+// The binding-specific deployment parameters should be
+// defined like this:
+//
+// struct BindingUInt16Deployment : CommonAPI::Deployment<> {
+// // Binding-specific bool deployment parameters
+// };
+//
+// struct BindingStringDeployment : CommonAPI::Deployment<> {
+// // Binding-specific String deployment parameters
+// };
+//
+// template<typename... _Types>
+// struct BindingStructDeployment
+// : CommonAPI::Deployment<_Types...> {
+// BindingStructDeployment(<SPECIFIC PARAMETERS>, _Types... t)
+// : CommonAPI::Deployment<_Types...>(t),
+// <SPECIFIC INITIALIZERS> {};
+//
+// // Binding-specific struct deployment parameters
+// };
+//
+// The generated code needs to use these definitions to
+// provide the deployment informations for the actual data.
+// E.g., for struct consisting of a boolean and a string
+// value, it needs to generate:
+//
+// CommonAPI::BindingStructDeployment<
+// CommonAPI::BindingBoolDeployment,
+// CommonAPI::BindingStringDeployment
+// > itsDeployment(<PARAMS);
+
+struct EmptyDeployment {};
+
+template<typename _ElementDepl>
+struct ArrayDeployment {
+ ArrayDeployment(_ElementDepl *_elementDepl)
+ : elementDepl_(_elementDepl) {}
+
+ _ElementDepl *elementDepl_;
+};
+
+template<typename _KeyDepl, typename _ValueDepl>
+struct MapDeployment {
+ MapDeployment(_KeyDepl *_key, _ValueDepl *_value)
+ : key_(_key), value_(_value) {}
+
+ const _KeyDepl *key_;
+ const _ValueDepl *value_;
+};
+
+// The following shall be used as a base for structure/variant deployments.
+template<typename... _Types>
+struct Deployment {
+ Deployment(_Types*... _values) : values_(_values...) {}
+ std::tuple<_Types*...> values_;
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_DEPLOYABLE_HPP_
diff --git a/include/CommonAPI/Enumeration.hpp b/include/CommonAPI/Enumeration.hpp
new file mode 100644
index 0000000..1a4d5f4
--- /dev/null
+++ b/include/CommonAPI/Enumeration.hpp
@@ -0,0 +1,40 @@
+// 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/.
+
+#ifndef COMMONAPI_ENUMERATION_HPP_
+#define COMMONAPI_ENUMERATION_HPP_
+
+namespace CommonAPI {
+
+template <typename _Base>
+struct Enumeration {
+ Enumeration() = default;
+ Enumeration(const _Base &_value)
+ : value_(_value) {
+ }
+
+ inline Enumeration &operator=(const _Base &_value) {
+ value_ = _value;
+ return (*this);
+ }
+
+ inline operator const _Base() const {
+ return value_;
+ }
+
+ inline bool operator == (const Enumeration<_Base> &_other) const {
+ return value_ == _other.value_;
+ }
+
+ inline bool operator != (const Enumeration<_Base> &_other) const {
+ return value_ != _other.value_;
+ }
+
+ _Base value_;
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_ENUMERATION_HPP_
diff --git a/include/CommonAPI/Event.hpp b/include/CommonAPI/Event.hpp
new file mode 100644
index 0000000..90971f5
--- /dev/null
+++ b/include/CommonAPI/Event.hpp
@@ -0,0 +1,158 @@
+// Copyright (C) 2013-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/.
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef COMMONAPI_EVENT_HPP_
+#define COMMONAPI_EVENT_HPP_
+
+#include <functional>
+#include <mutex>
+#include <map>
+#include <set>
+#include <tuple>
+
+namespace CommonAPI {
+
+/**
+ * \brief Class representing an event
+ *
+ * Class representing an event
+ */
+template<typename... _Arguments>
+class Event {
+public:
+ typedef std::tuple<_Arguments...> ArgumentsTuple;
+ typedef std::function<void(const _Arguments&...)> Listener;
+ typedef uint32_t Subscription;
+ typedef std::set<Subscription> SubscriptionsSet;
+ typedef std::map<Subscription, Listener> ListenersMap;
+
+ /**
+ * \brief Constructor
+ */
+ Event() : nextSubscription_(0) {};
+
+ /**
+ * \brief Subscribe a listener to this event
+ *
+ * Subscribe a listener to this event.
+ * ATTENTION: You should not build new proxies or register services in callbacks
+ * from events. This can cause a deadlock or assert. Instead, you should set a
+ * trigger for your application to do this on the next iteration of your event loop
+ * if needed. The preferred solution is to build all proxies you need at the
+ * beginning and react to events appropriatly for each.
+ *
+ * @param listener A listener to be added
+ * @return key of the new subscription
+ */
+ Subscription subscribe(Listener listener);
+
+ /**
+ * \brief Remove a listener from this event
+ *
+ * Remove a listener from this event
+ * Note: Do not call this inside a listener notification callback it will deadlock! Use cancellable listeners instead.
+ *
+ * @param subscription A listener token to be removed
+ */
+ void unsubscribe(Subscription subscription);
+
+ virtual ~Event() {}
+
+protected:
+ void notifyListeners(const _Arguments&... eventArguments);
+
+ virtual void onFirstListenerAdded(const Listener& listener) {}
+ virtual void onListenerAdded(const Listener& listener) {}
+
+ virtual void onListenerRemoved(const Listener& listener) {}
+ virtual void onLastListenerRemoved(const Listener& listener) {}
+
+//private:
+ ListenersMap subscriptions_;
+ Subscription nextSubscription_;
+
+ ListenersMap pendingSubscriptions_;
+ SubscriptionsSet pendingUnsubscriptions_;
+
+ std::mutex notificationMutex_;
+ std::mutex subscriptionMutex_;
+};
+
+template<typename ... _Arguments>
+typename Event<_Arguments...>::Subscription Event<_Arguments...>::subscribe(Listener listener) {
+ Subscription subscription;
+ bool isFirstListener;
+
+ subscriptionMutex_.lock();
+ subscription = nextSubscription_++;
+ // TODO?: check for key/subscription overrun
+ listener = pendingSubscriptions_[subscription] = std::move(listener);
+ isFirstListener = (0 == subscriptions_.size());
+ subscriptionMutex_.unlock();
+
+ if (isFirstListener)
+ onFirstListenerAdded(listener);
+ onListenerAdded(listener);
+
+ return subscription;
+}
+
+template<typename ... _Arguments>
+void Event<_Arguments...>::unsubscribe(Subscription subscription) {
+ bool isLastListener(false);
+
+ subscriptionMutex_.lock();
+ auto listener = subscriptions_.find(subscription);
+ if (subscriptions_.end() != listener
+ && pendingUnsubscriptions_.end() == pendingUnsubscriptions_.find(subscription)) {
+ if (0 == pendingSubscriptions_.erase(subscription)) {
+ pendingUnsubscriptions_.insert(subscription);
+ isLastListener = (1 == subscriptions_.size());
+ } else {
+ isLastListener = (0 == subscriptions_.size());
+ }
+ }
+ subscriptionMutex_.unlock();
+
+ if (subscriptions_.end() != listener) {
+ onListenerRemoved(listener->second);
+ if (isLastListener)
+ onLastListenerRemoved(listener->second);
+ }
+}
+
+template<typename ... _Arguments>
+void Event<_Arguments...>::notifyListeners(const _Arguments&... eventArguments) {
+ subscriptionMutex_.lock();
+ notificationMutex_.lock();
+ for (auto iterator = pendingUnsubscriptions_.begin();
+ iterator != pendingUnsubscriptions_.end();
+ iterator++) {
+ subscriptions_.erase(*iterator);
+ }
+ pendingUnsubscriptions_.clear();
+
+ for (auto iterator = pendingSubscriptions_.begin();
+ iterator != pendingSubscriptions_.end();
+ iterator++) {
+ subscriptions_.insert(*iterator);
+ }
+ pendingSubscriptions_.clear();
+
+ subscriptionMutex_.unlock();
+ for (auto iterator = subscriptions_.begin(); iterator != subscriptions_.end(); iterator++) {
+ iterator->second(eventArguments...);
+ }
+
+ notificationMutex_.unlock();
+}
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_EVENT_HPP_
diff --git a/include/CommonAPI/Export.hpp b/include/CommonAPI/Export.hpp
new file mode 100644
index 0000000..1fe9734
--- /dev/null
+++ b/include/CommonAPI/Export.hpp
@@ -0,0 +1,22 @@
+// 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/.
+
+#ifndef COMMONAPI_EXPORT_HPP_
+#define COMMONAPI_EXPORT_HPP_
+
+#ifdef WIN32
+ #define COMMONAPI_EXPORT __declspec(dllexport)
+
+ #if COMMONAPI_DLL_COMPILATION
+ #define COMMONAPI_IMPORT_EXPORT __declspec(dllexport)
+ #else
+ #define COMMONAPI_IMPORT_EXPORT __declspec(dllimport)
+ #endif
+#else
+ #define COMMONAPI_EXPORT
+ #define COMMONAPI_IMPORT_EXPORT
+#endif
+
+#endif // COMMONAPI_EXPORT_HPP_
diff --git a/include/CommonAPI/Factory.hpp b/include/CommonAPI/Factory.hpp
new file mode 100644
index 0000000..df8354d
--- /dev/null
+++ b/include/CommonAPI/Factory.hpp
@@ -0,0 +1,58 @@
+// Copyright (C) 2013-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/.
+
+#ifndef COMMONAPI_FACTORY_HPP_
+#define COMMONAPI_FACTORY_HPP_
+
+#include <functional>
+#include <memory>
+#include <vector>
+
+#include <CommonAPI/Export.hpp>
+#include <CommonAPI/Types.hpp>
+
+namespace CommonAPI {
+
+class MainLoopContext;
+class Proxy;
+class StubBase;
+
+class COMMONAPI_EXPORT Factory {
+public:
+ typedef std::function<void(std::vector<std::string> &)> AvailableInstancesCbk_t;
+ typedef std::function<void(bool)> InstanceAliveCbk_t;
+
+ virtual ~Factory() {};
+
+ virtual std::shared_ptr<Proxy> createProxy(const std::string &_domain,
+ const std::string &_interface,
+ const std::string &_instance,
+ const ConnectionId_t &_connectionId) = 0;
+
+ virtual std::shared_ptr<Proxy> createProxy(const std::string &_domain,
+ const std::string &_interface,
+ const std::string &_instance,
+ std::shared_ptr<MainLoopContext> mainLoopContext) = 0;
+
+ virtual bool registerStub(const std::string &_domain,
+ const std::string &_interface,
+ const std::string &_instance,
+ std::shared_ptr<StubBase> _stub,
+ const ConnectionId_t &_connectionId) = 0;
+
+ virtual bool registerStub(const std::string &_domain,
+ const std::string &_interface,
+ const std::string &_instance,
+ std::shared_ptr<StubBase> _stub,
+ std::shared_ptr<MainLoopContext> mainLoopContext) = 0;
+
+ virtual bool unregisterStub(const std::string &_domain,
+ const std::string &_interface,
+ const std::string &_instance) = 0;
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_FACTORY_HPP_
diff --git a/include/CommonAPI/IniFileReader.hpp b/include/CommonAPI/IniFileReader.hpp
new file mode 100644
index 0000000..13b64c3
--- /dev/null
+++ b/include/CommonAPI/IniFileReader.hpp
@@ -0,0 +1,40 @@
+// 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/.
+
+#ifndef COMMONAPI_INIFILEREADER_HPP_
+#define COMMONAPI_INIFILEREADER_HPP_
+
+#include <map>
+#include <memory>
+#include <string>
+
+#include <CommonAPI/Export.hpp>
+
+namespace CommonAPI {
+
+class IniFileReader {
+public:
+ class Section {
+ public:
+ COMMONAPI_EXPORT const std::map<std::string, std::string> &getMappings() const;
+ COMMONAPI_EXPORT std::string getValue(const std::string &_key) const;
+ private:
+ std::map<std::string, std::string> mappings_;
+
+ friend class IniFileReader;
+ };
+
+ COMMONAPI_EXPORT bool load(const std::string &_path);
+
+ COMMONAPI_EXPORT const std::map<std::string, std::shared_ptr<Section>> &getSections() const;
+ COMMONAPI_EXPORT std::shared_ptr<Section> getSection(const std::string &_name) const;
+
+private:
+ std::map<std::string, std::shared_ptr<Section>> sections_;
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_INIFILEREADER_HPP_
diff --git a/include/CommonAPI/InputStream.hpp b/include/CommonAPI/InputStream.hpp
new file mode 100644
index 0000000..f5cbc12
--- /dev/null
+++ b/include/CommonAPI/InputStream.hpp
@@ -0,0 +1,241 @@
+// Copyright (C) 2013-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/.
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef COMMONAPI_INPUT_STREAM_HPP_
+#define COMMONAPI_INPUT_STREAM_HPP_
+
+#include <unordered_map>
+
+#include <CommonAPI/ByteBuffer.hpp>
+#include <CommonAPI/Deployable.hpp>
+#include <CommonAPI/Deployment.hpp>
+#include <CommonAPI/Enumeration.hpp>
+#include <CommonAPI/Struct.hpp>
+#include <CommonAPI/Variant.hpp>
+#include <CommonAPI/Version.hpp>
+
+namespace CommonAPI {
+
+template<class _Derived>
+class InputStream {
+public:
+ template<class _Deployment>
+ InputStream &readValue(bool &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ InputStream &readValue(int8_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ InputStream &readValue(int16_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ InputStream &readValue(int32_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ InputStream &readValue(int64_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ InputStream &readValue(uint8_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ InputStream &readValue(uint16_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ InputStream &readValue(uint32_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ InputStream &readValue(uint64_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ InputStream &readValue(float &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ InputStream &readValue(double &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ InputStream &readValue(std::string &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment, typename _Base>
+ InputStream &readValue(Enumeration<_Base> &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment, typename... _Types>
+ InputStream &readValue(Struct<_Types...> &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment, class _PolymorphicStruct>
+ InputStream &readValue(std::shared_ptr<_PolymorphicStruct> &_value,
+ const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment, typename... _Types>
+ InputStream &readValue(Variant<_Types...> &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment, typename _ElementType>
+ InputStream &readValue(std::vector<_ElementType> &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment, typename _KeyType, typename _ValueType, typename _HasherType>
+ InputStream &readValue(std::unordered_map<_KeyType, _ValueType, _HasherType> &_value,
+ const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ InputStream &readValue(Version &_value, const _Deployment *_depl = nullptr) {
+ return get()->readValue(_value, _depl);
+ }
+
+ bool hasError() const {
+ return get()->hasError();
+ }
+
+private:
+ inline _Derived *get() {
+ return static_cast<_Derived *>(this);
+ }
+
+ inline const _Derived *get() const {
+ return static_cast<const _Derived *>(this);
+ }
+};
+
+template<class _Derived>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, bool &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, int8_t &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, int16_t &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, int32_t &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, int64_t &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, uint8_t &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, uint16_t &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, uint32_t &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, uint64_t &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, float &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, double &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, std::string &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, Version &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived, typename _Base>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, Enumeration<_Base> &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived, typename... _Types>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, Struct<_Types...> &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived, class _PolymorphicStruct>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, std::shared_ptr<_PolymorphicStruct> &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived, typename... _Types>
+InputStream<_Derived> & operator>>(InputStream<_Derived> &_input, Variant<_Types...> &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived, typename _ElementType>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, std::vector<_ElementType> &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived, typename _KeyType, typename _ValueType, typename _HasherType>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, std::unordered_map<_KeyType, _ValueType, _HasherType> &_value) {
+ return _input.template readValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived, typename _Type, typename _TypeDeployment>
+InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, Deployable<_Type, _TypeDeployment> &_value) {
+ return _input.template readValue<_TypeDeployment>(_value.getValue(), _value.getDepl());
+}
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_INPUT_STREAM_HPP_
diff --git a/include/CommonAPI/Logger.hpp b/include/CommonAPI/Logger.hpp
new file mode 100644
index 0000000..d2761ac
--- /dev/null
+++ b/include/CommonAPI/Logger.hpp
@@ -0,0 +1,179 @@
+// 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/.
+
+#ifndef COMMONAPI_LOGGER_HPP_
+#define COMMONAPI_LOGGER_HPP_
+
+#ifdef USE_DLT
+#include <dlt.h>
+#endif
+
+#include <cstdint>
+#include <fstream>
+#include <memory>
+#include <mutex>
+#include <sstream>
+
+#include <CommonAPI/Export.hpp>
+
+#define COMMONAPI_LOGLEVEL_FATAL 0
+#define COMMONAPI_LOGLEVEL_ERROR 1
+#define COMMONAPI_LOGLEVEL_WARNING 2
+#define COMMONAPI_LOGLEVEL_INFO 3
+#define COMMONAPI_LOGLEVEL_DEBUG 4
+#define COMMONAPI_LOGLEVEL_VERBOSE 5
+
+#ifndef COMMONAPI_LOGLEVEL
+#define COMMONAPI_LOGLEVEL COMMONAPI_LOGLEVEL_INFO
+#endif
+
+#ifdef WIN32
+
+#define COMMONAPI_FATAL(...) \
+ do { Logger::log(Logger::Level::LL_FATAL, __VA_ARGS__); } while (false);
+
+#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_ERROR
+#define COMMONAPI_ERROR(...) \
+ do { Logger::log(Logger::Level::LL_ERROR, __VA_ARGS__); } while (false);
+#else
+#define COMMONAPI_ERROR(...)
+#endif
+
+#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_WARNING
+#define COMMONAPI_WARNING(...) \
+ do { Logger::log(Logger::Level::LL_WARNING, __VA_ARGS__); } while (false);
+#else
+#define COMMONAPI_WARNING(...)
+#endif
+
+#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_INFO
+#define COMMONAPI_INFO(...) \
+ do { Logger::log(Logger::Level::LL_INFO, __VA_ARGS__); } while (false);
+#else
+#define COMMONAPI_INFO(...)
+#endif
+
+#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_DEBUG
+#define COMMONAPI_DEBUG(...) \
+ do { Logger::log(Logger::Level::LL_DEBUG, __VA_ARGS__); } while (false);
+#else
+#define COMMONAPI_DEBUG(...)
+#endif
+
+#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_VERBOSE
+#define COMMONAPI_VERBOSE(...) \
+ do { Logger::log(Logger::Level::LL_VERBOSE, __VA_ARGS__); } while (false);
+#else
+#define COMMONAPI_VERBOSE(...)
+#endif
+
+#else // !WIN32
+
+#define COMMONAPI_FATAL(params...) \
+ do { Logger::log(Logger::Level::LL_FATAL, params); } while (false);
+
+#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_ERROR
+ #define COMMONAPI_ERROR(params...) \
+ do { Logger::log(Logger::Level::LL_ERROR, params); } while (false);
+#else
+ #define COMMONAPI_ERROR(params...)
+#endif
+
+#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_WARNING
+ #define COMMONAPI_WARNING(params...) \
+ do { Logger::log(Logger::Level::LL_WARNING, params); } while (false);
+#else
+ #define COMMONAPI_WARNING(params...)
+#endif
+
+#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_INFO
+ #define COMMONAPI_INFO(params...) \
+ do { Logger::log(Logger::Level::LL_INFO, params); } while (false);
+#else
+ #define COMMONAPI_INFO(params...)
+#endif
+
+#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_DEBUG
+ #define COMMONAPI_DEBUG(params...) \
+ do { Logger::log(Logger::Level::LL_DEBUG, params); } while (false);
+#else
+ #define COMMONAPI_DEBUG(params...)
+#endif
+
+#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_VERBOSE
+ #define COMMONAPI_VERBOSE(params...) \
+ do { Logger::log(Logger::Level::LL_VERBOSE, params); } while (false);
+#else
+ #define COMMONAPI_VERBOSE(params...)
+#endif
+
+#endif // WIN32
+
+namespace CommonAPI {
+
+class Logger {
+public:
+ COMMONAPI_EXPORT enum class Level : uint8_t {
+ LL_FATAL = 0, LL_ERROR = 1, LL_WARNING = 2, LL_INFO = 3, LL_DEBUG = 4, LL_VERBOSE = 5
+ };
+
+ COMMONAPI_EXPORT Logger();
+
+ template<typename... _LogEntries>
+ COMMONAPI_EXPORT static void log(Level _level, _LogEntries... _entries) {
+ std::stringstream buffer;
+ log_intern(buffer, _entries...);
+ Logger::get()->doLog(_level, buffer.str());
+ }
+
+ COMMONAPI_EXPORT static void init(bool, const std::string &, bool = false, const std::string & = "");
+
+private:
+ COMMONAPI_EXPORT static inline std::shared_ptr<Logger> get() {
+ static std::shared_ptr<Logger> theLogger = std::make_shared<Logger>();
+ return theLogger;
+ }
+
+ COMMONAPI_EXPORT static void log_intern(std::stringstream &_buffer) {
+ }
+
+ template<typename _LogEntry, typename... _MoreLogEntries>
+ COMMONAPI_EXPORT static void log_intern(std::stringstream &_buffer, _LogEntry _entry, _MoreLogEntries... _moreEntries) {
+ _buffer << _entry;
+ log_intern(_buffer, _moreEntries...);
+ }
+
+ COMMONAPI_EXPORT void doLog(Level _level, const std::string &_message);
+
+#if defined(USE_CONSOLE) || defined(USE_FILE) || defined(USE_DLT)
+ static Level stringAsLevel(const std::string &_level);
+#endif
+#if defined(USE_CONSOLE) || defined(USE_FILE)
+ static std::string levelAsString(Level _level);
+#endif
+#ifdef USE_DLT
+ static DltLogLevelType levelAsDlt(Level _level);
+#endif
+#if defined(USE_CONSOLE) || defined(USE_FILE)
+ static std::mutex mutex_;
+#endif
+#if defined(USE_CONSOLE) || defined(USE_FILE) || defined(USE_DLT)
+ static Level maximumLogLevel_;
+#endif
+#ifdef USE_CONSOLE
+ static bool useConsole_;
+#endif
+#ifdef USE_FILE
+ static std::shared_ptr<std::ofstream> file_;
+#endif
+#ifdef USE_DLT
+ static bool useDlt_;
+ DLT_DECLARE_CONTEXT(dlt_);
+#endif
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_LOGGER_HPP_
diff --git a/src/CommonAPI/MainLoopContext.h b/include/CommonAPI/MainLoopContext.hpp
index 3c4e7c1..b2e1056 100644
--- a/src/CommonAPI/MainLoopContext.h
+++ b/include/CommonAPI/MainLoopContext.hpp
@@ -1,19 +1,16 @@
-/* Copyright (C) 2013 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/. */
+// Copyright (C) 2013-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/.
#if !defined (COMMONAPI_INTERNAL_COMPILATION)
#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef COMMONAPI_MAIN_LOOP_CONTEXT_H_
-#define COMMONAPI_MAIN_LOOP_CONTEXT_H_
+#ifndef COMMONAPI_MAINLOOPCONTEXT_HPP_
+#define COMMONAPI_MAINLOOPCONTEXT_HPP_
-
-#include <stdint.h>
+#include <cstdint>
#ifdef WIN32
#include <WinSock2.h>
@@ -30,6 +27,9 @@
#include <chrono>
#include <list>
#include <functional>
+#include <string>
+
+#include <CommonAPI/Export.hpp>
namespace CommonAPI {
@@ -42,7 +42,7 @@ enum class DispatchPriority {
};
-int64_t getCurrentTimeInMs();
+int64_t COMMONAPI_EXPORT getCurrentTimeInMs();
/**
@@ -190,87 +190,92 @@ typedef WakeupListenerList::iterator WakeupListenerSubscription;
*
*/
class MainLoopContext {
- public:
- MainLoopContext() {}
- MainLoopContext(const MainLoopContext&) = delete;
- MainLoopContext& operator=(const MainLoopContext&) = delete;
- MainLoopContext(MainLoopContext&&) = delete;
- MainLoopContext& operator=(MainLoopContext&&) = delete;
+public:
+ COMMONAPI_EXPORT MainLoopContext(const std::string &_name = "COMMONAPI_DEFAULT_MAINLOOP_CONTEXT")
+ : name_(_name){
+ }
+
+ COMMONAPI_EXPORT MainLoopContext(const MainLoopContext&) = delete;
+ COMMONAPI_EXPORT MainLoopContext& operator=(const MainLoopContext&) = delete;
+ COMMONAPI_EXPORT MainLoopContext(MainLoopContext&&) = delete;
+ COMMONAPI_EXPORT MainLoopContext& operator=(MainLoopContext&&) = delete;
+
+ COMMONAPI_EXPORT const std::string &getName() const;
/**
* \brief Registers for all DispatchSources that are added or removed.
*/
- DispatchSourceListenerSubscription subscribeForDispatchSources(DispatchSourceAddedCallback dispatchAddedCallback, DispatchSourceRemovedCallback dispatchRemovedCallback);
+ COMMONAPI_EXPORT DispatchSourceListenerSubscription subscribeForDispatchSources(DispatchSourceAddedCallback dispatchAddedCallback, DispatchSourceRemovedCallback dispatchRemovedCallback);
/**
* \brief Registers for all Watches that are added or removed.
*/
- WatchListenerSubscription subscribeForWatches(WatchAddedCallback watchAddedCallback, WatchRemovedCallback watchRemovedCallback);
+ COMMONAPI_EXPORT WatchListenerSubscription subscribeForWatches(WatchAddedCallback watchAddedCallback, WatchRemovedCallback watchRemovedCallback);
/**
* \brief Registers for all Timeouts that are added or removed.
*/
- TimeoutSourceListenerSubscription subscribeForTimeouts(TimeoutSourceAddedCallback timeoutAddedCallback, TimeoutSourceRemovedCallback timeoutRemovedCallback);
+ COMMONAPI_EXPORT TimeoutSourceListenerSubscription subscribeForTimeouts(TimeoutSourceAddedCallback timeoutAddedCallback, TimeoutSourceRemovedCallback timeoutRemovedCallback);
/**
* \brief Registers for all Wakeup-Events that need to interrupt a call to "poll".
*/
- WakeupListenerSubscription subscribeForWakeupEvents(WakeupCallback wakeupCallback);
+ COMMONAPI_EXPORT WakeupListenerSubscription subscribeForWakeupEvents(WakeupCallback wakeupCallback);
/**
* \brief Unsubscribes your listeners for DispatchSources.
*/
- void unsubscribeForDispatchSources(DispatchSourceListenerSubscription subscription);
+ COMMONAPI_EXPORT void unsubscribeForDispatchSources(DispatchSourceListenerSubscription subscription);
/**
* \brief Unsubscribes your listeners for Watches.
*/
- void unsubscribeForWatches(WatchListenerSubscription subscription);
+ COMMONAPI_EXPORT void unsubscribeForWatches(WatchListenerSubscription subscription);
/**
* \brief Unsubscribes your listeners for Timeouts.
*/
- void unsubscribeForTimeouts(TimeoutSourceListenerSubscription subscription);
+ COMMONAPI_EXPORT void unsubscribeForTimeouts(TimeoutSourceListenerSubscription subscription);
/**
* \brief Unsubscribes your listeners for Wakeup-Events.
*/
- void unsubscribeForWakeupEvents(WakeupListenerSubscription subscription);
+ COMMONAPI_EXPORT void unsubscribeForWakeupEvents(WakeupListenerSubscription subscription);
/**
* \brief Notifies all listeners about a new DispatchSource.
*/
- void registerDispatchSource(DispatchSource* dispatchSource, const DispatchPriority dispatchPriority = DispatchPriority::DEFAULT);
+ COMMONAPI_EXPORT void registerDispatchSource(DispatchSource* dispatchSource, const DispatchPriority dispatchPriority = DispatchPriority::DEFAULT);
/**
* \brief Notifies all listeners about the removal of a DispatchSource.
*/
- void deregisterDispatchSource(DispatchSource* dispatchSource);
+ COMMONAPI_EXPORT void deregisterDispatchSource(DispatchSource* dispatchSource);
/**
* \brief Notifies all listeners about a new Watch.
*/
- void registerWatch(Watch* watch, const DispatchPriority dispatchPriority = DispatchPriority::DEFAULT);
+ COMMONAPI_EXPORT void registerWatch(Watch* watch, const DispatchPriority dispatchPriority = DispatchPriority::DEFAULT);
/**
* \brief Notifies all listeners about the removal of a Watch.
*/
- void deregisterWatch(Watch* watch);
+ COMMONAPI_EXPORT void deregisterWatch(Watch* watch);
/**
* \brief Notifies all listeners about a new Timeout.
*/
- void registerTimeoutSource(Timeout* timeoutEvent, const DispatchPriority dispatchPriority = DispatchPriority::DEFAULT);
+ COMMONAPI_EXPORT void registerTimeoutSource(Timeout* timeoutEvent, const DispatchPriority dispatchPriority = DispatchPriority::DEFAULT);
/**
* \brief Notifies all listeners about the removal of a Timeout.
*/
- void deregisterTimeoutSource(Timeout* timeoutEvent);
+ COMMONAPI_EXPORT void deregisterTimeoutSource(Timeout* timeoutEvent);
/**
* \brief Notifies all listeners about a wakeup event that just happened.
*/
- void wakeup();
+ COMMONAPI_EXPORT void wakeup();
/**
* \brief Will return true if at least one subscribe for DispatchSources or Watches has been called.
@@ -278,17 +283,17 @@ class MainLoopContext {
* This function will be used to prevent creation of a factory if a mainloop context is given, but
* no listeners have been registered. This is done in order to ensure correct use of the mainloop context.
*/
- bool isInitialized();
+ COMMONAPI_EXPORT bool isInitialized();
private:
DispatchSourceListenerList dispatchSourceListeners_;
WatchListenerList watchListeners_;
TimeoutSourceListenerList timeoutSourceListeners_;
WakeupListenerList wakeupListeners_;
-};
+ std::string name_;
+};
} // namespace CommonAPI
-
-#endif /* MAIN_LOOP_CONTEXT_H_ */
+#endif // COMMONAPI_MAINLOOPCONTEXT_HPP_
diff --git a/include/CommonAPI/OutputStream.hpp b/include/CommonAPI/OutputStream.hpp
new file mode 100644
index 0000000..1ca221c
--- /dev/null
+++ b/include/CommonAPI/OutputStream.hpp
@@ -0,0 +1,241 @@
+// Copyright (C) 2013-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/.
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef COMMONAPI_OUTPUTSTREAM_HPP_
+#define COMMONAPI_OUTPUTSTREAM_HPP_
+
+#include <unordered_map>
+
+#include <CommonAPI/ByteBuffer.hpp>
+#include <CommonAPI/Deployable.hpp>
+#include <CommonAPI/Deployment.hpp>
+#include <CommonAPI/Enumeration.hpp>
+#include <CommonAPI/Struct.hpp>
+#include <CommonAPI/Variant.hpp>
+#include <CommonAPI/Version.hpp>
+
+namespace CommonAPI {
+
+template<class _Derived>
+class OutputStream {
+public:
+ template<class _Deployment>
+ OutputStream &writeValue(const bool &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ OutputStream &writeValue(const int8_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ OutputStream &writeValue(const int16_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ OutputStream &writeValue(const int32_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ OutputStream &writeValue(const int64_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ OutputStream &writeValue(const uint8_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ OutputStream &writeValue(const uint16_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ OutputStream &writeValue(const uint32_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ OutputStream &writeValue(const uint64_t &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ OutputStream &writeValue(const float &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ OutputStream &writeValue(const double &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ OutputStream &writeValue(const std::string &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment>
+ OutputStream &writeValue(const Version &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment, typename _Base>
+ OutputStream &writeValue(const Enumeration<_Base> &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment, typename... _Types>
+ OutputStream &writeValue(const Struct<_Types...> &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment, class _PolymorphicStruct>
+ OutputStream &writeValue(const std::shared_ptr<_PolymorphicStruct> &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment, typename... _Types>
+ OutputStream &writeValue(const Variant<_Types...> &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment, typename _ElementType>
+ OutputStream &writeValue(const std::vector<_ElementType> &_value, const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ template<class _Deployment, typename _KeyType, typename _ValueType, typename _HasherType>
+ OutputStream &writeValue(const std::unordered_map<_KeyType, _ValueType, _HasherType> &_value,
+ const _Deployment *_depl = nullptr) {
+ return get()->writeValue(_value, _depl);
+ }
+
+ bool hasError() const {
+ return get()->hasError();
+ }
+
+private:
+ inline _Derived *get() {
+ return static_cast<_Derived *>(this);
+ }
+
+ inline const _Derived *get() const {
+ return static_cast<const _Derived *>(this);
+ }
+};
+
+template<class _Derived>
+inline OutputStream<_Derived> &operator<<(OutputStream<_Derived> &_output, const bool &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+inline OutputStream<_Derived>& operator<<(OutputStream<_Derived> &_output, const int8_t &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+inline OutputStream<_Derived>& operator<<(OutputStream<_Derived> &_output, const int16_t &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+inline OutputStream<_Derived>& operator<<(OutputStream<_Derived> &_output, const int32_t &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+inline OutputStream<_Derived>& operator<<(OutputStream<_Derived> &_output, const int64_t &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+inline OutputStream<_Derived>& operator<<(OutputStream<_Derived> &_output, const uint8_t &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+inline OutputStream<_Derived>& operator<<(OutputStream<_Derived> &_output, const uint16_t &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+inline OutputStream<_Derived>& operator<<(OutputStream<_Derived> &_output, const uint32_t &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+inline OutputStream<_Derived>& operator<<(OutputStream<_Derived> &_output, const uint64_t &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+inline OutputStream<_Derived>& operator<<(OutputStream<_Derived> &_output, const float &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+inline OutputStream<_Derived>& operator<<(OutputStream<_Derived> &_output, const double &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived>
+inline OutputStream<_Derived>& operator<<(OutputStream<_Derived> &_output, const std::string &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived, typename _Type, typename _TypeDepl>
+inline OutputStream<_Derived> &operator<<(OutputStream<_Derived> &_output, const Deployable<_Type, _TypeDepl> &_value) {
+ return _output.template writeValue<_TypeDepl>(_value.getValue(), _value.getDepl());
+}
+
+template<class _Derived>
+inline OutputStream<_Derived>& operator<<(OutputStream<_Derived> &_output, const Version &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived, typename _Base>
+OutputStream<_Derived> &operator<<(OutputStream<_Derived> &_output, const Enumeration<_Base> &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived, typename... _Types>
+OutputStream<_Derived> &operator<<(OutputStream<_Derived> &_output, const Struct<_Types...> &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived, class _PolymorphicStruct>
+OutputStream<_Derived> &operator<<(OutputStream<_Derived> &_output, const std::shared_ptr<_PolymorphicStruct> &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived, typename... _Types>
+OutputStream<_Derived> &operator<<(OutputStream<_Derived> &_output, const Variant<_Types...> &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived, typename _ElementType>
+OutputStream<_Derived> &operator<<(OutputStream<_Derived> &_output, const std::vector<_ElementType> &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+template<class _Derived, typename _KeyType, typename _ValueType, typename _HasherType>
+OutputStream<_Derived> &operator<<(OutputStream<_Derived> &_output,
+ const std::unordered_map<_KeyType, _ValueType, _HasherType> &_value) {
+ return _output.template writeValue<EmptyDeployment>(_value);
+}
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_OUTPUTSTREAM_HPP_
diff --git a/include/CommonAPI/Proxy.hpp b/include/CommonAPI/Proxy.hpp
new file mode 100644
index 0000000..5b7d745
--- /dev/null
+++ b/include/CommonAPI/Proxy.hpp
@@ -0,0 +1,47 @@
+// Copyright (C) 2013-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/.
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef COMMONAPI_PROXY_HPP_
+#define COMMONAPI_PROXY_HPP_
+
+#include <cstdint>
+#include <memory>
+#include <type_traits>
+
+#include <CommonAPI/Address.hpp>
+#include <CommonAPI/Attribute.hpp>
+#include <CommonAPI/Export.hpp>
+#include <CommonAPI/Version.hpp>
+
+namespace CommonAPI {
+
+typedef Event<AvailabilityStatus> ProxyStatusEvent;
+typedef ReadonlyAttribute<Version> InterfaceVersionAttribute;
+
+class Proxy {
+public:
+ COMMONAPI_EXPORT virtual ~Proxy() {}
+
+ COMMONAPI_EXPORT const Address &getAddress() const;
+
+ COMMONAPI_EXPORT virtual bool isAvailable() const = 0;
+
+ COMMONAPI_EXPORT virtual bool isAvailableBlocking() const = 0;
+
+ COMMONAPI_EXPORT virtual ProxyStatusEvent& getProxyStatusEvent() = 0;
+
+ COMMONAPI_EXPORT virtual InterfaceVersionAttribute& getInterfaceVersionAttribute() = 0;
+
+protected:
+ Address address_;
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_PROXY_HPP_
diff --git a/include/CommonAPI/ProxyManager.hpp b/include/CommonAPI/ProxyManager.hpp
new file mode 100644
index 0000000..571eb97
--- /dev/null
+++ b/include/CommonAPI/ProxyManager.hpp
@@ -0,0 +1,73 @@
+// Copyright (C) 2013-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/.
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef COMMONAPI_PROXY_MANAGER_HPP_
+#define COMMONAPI_PROXY_MANAGER_HPP_
+
+#include <functional>
+#include <future>
+#include <string>
+#include <vector>
+
+#include <CommonAPI/Event.hpp>
+#include <CommonAPI/Proxy.hpp>
+#include <CommonAPI/Types.hpp>
+
+namespace CommonAPI {
+
+class ProxyManager {
+public:
+ typedef std::function<void(const CallStatus &, const std::vector<std::string> &)> GetAvailableInstancesCallback;
+ typedef std::function<void(const CallStatus &, const AvailabilityStatus &)> GetInstanceAvailabilityStatusCallback;
+
+ typedef Event<std::string, AvailabilityStatus> InstanceAvailabilityStatusChangedEvent;
+
+ ProxyManager() = default;
+ ProxyManager(ProxyManager &&) = delete;
+ ProxyManager(const ProxyManager &) = delete;
+
+ virtual ~ProxyManager() {}
+
+ virtual const std::string &getDomain() const = 0;
+ virtual const std::string &getInterface() const = 0;
+ virtual const ConnectionId_t &getConnectionId() const = 0;
+
+ virtual void getAvailableInstances(CommonAPI::CallStatus&, std::vector<std::string>& availableInstances) = 0;
+ virtual std::future<CallStatus> getAvailableInstancesAsync(GetAvailableInstancesCallback callback) = 0;
+
+ virtual void getInstanceAvailabilityStatus(const std::string& instanceAddress,
+ CallStatus& callStatus,
+ AvailabilityStatus& availabilityStatus) = 0;
+
+ virtual std::future<CallStatus> getInstanceAvailabilityStatusAsync(const std::string&,
+ GetInstanceAvailabilityStatusCallback callback) = 0;
+
+ virtual InstanceAvailabilityStatusChangedEvent& getInstanceAvailabilityStatusChangedEvent() = 0;
+
+ template<template<typename ...> class _ProxyClass, typename ... _AttributeExtensions>
+ std::shared_ptr<_ProxyClass<_AttributeExtensions...> >
+ buildProxy(const std::string &_instance) {
+ std::shared_ptr<Proxy> proxy = createProxy(getDomain(), getInterface(), _instance, getConnectionId());
+ if (proxy) {
+ return std::make_shared<_ProxyClass<_AttributeExtensions...>>(proxy);
+ }
+ return NULL;
+
+ }
+
+protected:
+ std::shared_ptr<Proxy> createProxy(const std::string &,
+ const std::string &,
+ const std::string &,
+ const ConnectionId_t &_connection) const;
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_PROXY_MANAGER_HPP_
diff --git a/include/CommonAPI/Runtime.hpp b/include/CommonAPI/Runtime.hpp
new file mode 100644
index 0000000..1cb4f94
--- /dev/null
+++ b/include/CommonAPI/Runtime.hpp
@@ -0,0 +1,203 @@
+// Copyright (C) 2013-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/.
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef COMMONAPI_RUNTIME_HPP_
+#define COMMONAPI_RUNTIME_HPP_
+
+#include <map>
+#include <memory>
+#include <mutex>
+#include <set>
+
+#include <CommonAPI/Export.hpp>
+#include <CommonAPI/Factory.hpp>
+#include <CommonAPI/Types.hpp>
+
+namespace CommonAPI {
+
+static const ConnectionId_t DEFAULT_CONNECTION_ID = "";
+
+class MainLoopContext;
+class Proxy;
+class ProxyManager;
+class StubBase;
+
+template<template<typename ...> class _ProxyType, template<typename> class _AttributeExtension>
+struct DefaultAttributeProxyHelper;
+
+template<template<typename ...> class _ProxyClass, template<typename> class _AttributeExtension>
+std::shared_ptr<
+ typename DefaultAttributeProxyHelper<_ProxyClass, _AttributeExtension>::class_t
+> createProxyWithDefaultAttributeExtension(
+ const std::string &_domain, const std::string &_instance);
+
+class Runtime {
+public:
+ COMMONAPI_EXPORT static std::string getProperty(const std::string &_name);
+ COMMONAPI_EXPORT static void setProperty(const std::string &_name, const std::string &_value);
+
+ COMMONAPI_EXPORT static std::shared_ptr<Runtime> get();
+
+ COMMONAPI_EXPORT Runtime();
+ COMMONAPI_EXPORT virtual ~Runtime();
+
+ COMMONAPI_EXPORT void init();
+
+ template<template<typename ...> class _ProxyClass, typename ... _AttributeExtensions>
+ COMMONAPI_EXPORT std::shared_ptr<
+ _ProxyClass<_AttributeExtensions...>
+ >
+ buildProxy(const std::string &_domain,
+ const std::string &_instance,
+ const ConnectionId_t &_connectionId = DEFAULT_CONNECTION_ID) {
+ std::shared_ptr<Proxy> proxy
+ = createProxy(_domain,
+ _ProxyClass<_AttributeExtensions...>::getInterface(),
+ _instance,
+ _connectionId);
+
+ if (proxy) {
+ return std::make_shared<_ProxyClass<_AttributeExtensions...>>(proxy);
+ }
+ else {
+ return nullptr;
+ }
+ }
+
+ template<template<typename ...> class _ProxyClass, typename ... _AttributeExtensions>
+ COMMONAPI_EXPORT std::shared_ptr<
+ _ProxyClass<_AttributeExtensions...>
+ >
+ buildProxy(const std::string &_domain,
+ const std::string &_instance,
+ std::shared_ptr<MainLoopContext> _context) {
+ std::shared_ptr<Proxy> proxy
+ = createProxy(_domain,
+ _ProxyClass<_AttributeExtensions...>::getInterface(),
+ _instance,
+ _context);
+ if (proxy) {
+ return std::make_shared<_ProxyClass<_AttributeExtensions...>>(proxy);
+ }
+ else {
+ return nullptr;
+ }
+ }
+
+ template <template<typename ...> class _ProxyClass, template<typename> class _AttributeExtension>
+ COMMONAPI_EXPORT std::shared_ptr<typename DefaultAttributeProxyHelper<_ProxyClass, _AttributeExtension>::class_t>
+ buildProxyWithDefaultAttributeExtension(const std::string &_domain,
+ const std::string &_instance,
+ const ConnectionId_t &_connectionId = DEFAULT_CONNECTION_ID) {
+ std::shared_ptr<Proxy> proxy
+ = createProxy(_domain,
+ DefaultAttributeProxyHelper<_ProxyClass, _AttributeExtension>::class_t::getInterface(),
+ _instance,
+ _connectionId);
+ if (proxy) {
+ return std::make_shared<typename DefaultAttributeProxyHelper<_ProxyClass, _AttributeExtension>::class_t>(proxy);
+ }
+ return nullptr;
+ }
+
+ template <template<typename ...> class _ProxyClass, template<typename> class _AttributeExtension>
+ COMMONAPI_EXPORT std::shared_ptr<typename DefaultAttributeProxyHelper<_ProxyClass, _AttributeExtension>::class_t>
+ buildProxyWithDefaultAttributeExtension(const std::string &_domain,
+ const std::string &_instance,
+ std::shared_ptr<MainLoopContext> _context) {
+ std::shared_ptr<Proxy> proxy
+ = createProxy(_domain,
+ DefaultAttributeProxyHelper<_ProxyClass, _AttributeExtension>::class_t::getInterface(),
+ _instance,
+ _context);
+ if (proxy) {
+ return std::make_shared<typename DefaultAttributeProxyHelper<_ProxyClass, _AttributeExtension>::class_t>(proxy);
+ }
+ return nullptr;
+ }
+
+ template<typename _Stub>
+ COMMONAPI_EXPORT bool registerService(const std::string &_domain,
+ const std::string &_instance,
+ std::shared_ptr<_Stub> _service,
+ const ConnectionId_t &_connectionId = DEFAULT_CONNECTION_ID) {
+ return registerStub(_domain, _Stub::StubInterface::getInterface(), _instance, _service, _connectionId);
+ }
+
+ template<typename _Stub>
+ COMMONAPI_EXPORT bool registerService(const std::string &_domain,
+ const std::string &_instance,
+ std::shared_ptr<_Stub> _service,
+ std::shared_ptr<MainLoopContext> _context) {
+ return registerStub(_domain, _Stub::StubInterface::getInterface(), _instance, _service, _context);
+ }
+
+ COMMONAPI_EXPORT bool unregisterService(const std::string &_domain,
+ const std::string &_interface,
+ const std::string &_instance) {
+ return unregisterStub(_domain, _interface, _instance);
+ }
+
+ COMMONAPI_EXPORT bool registerFactory(const std::string &_ipc, std::shared_ptr<Factory> _factory);
+ COMMONAPI_EXPORT bool unregisterFactory(const std::string &_ipc);
+
+ inline const std::string &getDefaultBinding() const { return defaultBinding_; };
+
+private:
+ COMMONAPI_EXPORT bool readConfiguration();
+ COMMONAPI_EXPORT bool splitAddress(const std::string &, std::string &, std::string &, std::string &);
+
+ COMMONAPI_EXPORT std::shared_ptr<Proxy> createProxy(const std::string &, const std::string &, const std::string &,
+ const ConnectionId_t &);
+ COMMONAPI_EXPORT std::shared_ptr<Proxy> createProxy(const std::string &, const std::string &, const std::string &,
+ std::shared_ptr<MainLoopContext>);
+
+ COMMONAPI_EXPORT std::shared_ptr<Proxy> createProxyHelper(const std::string &, const std::string &, const std::string &,
+ const ConnectionId_t &);
+ COMMONAPI_EXPORT std::shared_ptr<Proxy> createProxyHelper(const std::string &, const std::string &, const std::string &,
+ std::shared_ptr<MainLoopContext>);
+
+
+ COMMONAPI_EXPORT bool registerStub(const std::string &, const std::string &, const std::string &,
+ std::shared_ptr<StubBase>, const ConnectionId_t &);
+ COMMONAPI_EXPORT bool registerStub(const std::string &, const std::string &, const std::string &,
+ std::shared_ptr<StubBase>, std::shared_ptr<MainLoopContext>);
+ COMMONAPI_EXPORT bool registerStubHelper(const std::string &, const std::string &, const std::string &,
+ std::shared_ptr<StubBase>, const ConnectionId_t &);
+ COMMONAPI_EXPORT bool registerStubHelper(const std::string &, const std::string &, const std::string &,
+ std::shared_ptr<StubBase>, std::shared_ptr<MainLoopContext>);
+
+ COMMONAPI_EXPORT bool unregisterStub(const std::string &, const std::string &, const std::string &);
+
+ COMMONAPI_EXPORT std::string getLibrary(const std::string &, const std::string &, const std::string &, bool);
+ COMMONAPI_EXPORT bool loadLibrary(const std::string &);
+
+private:
+ std::string defaultBinding_;
+ std::string defaultFolder_;
+ std::string defaultConfig_;
+
+ std::map<std::string, std::shared_ptr<Factory>> factories_;
+ std::shared_ptr<Factory> defaultFactory_;
+ std::map<std::string, std::map<bool, std::string>> libraries_;
+ std::set<std::string> loadedLibraries_; // Library name
+
+ std::mutex mutex_;
+ std::mutex factoriesMutex_;
+ std::mutex loadMutex_;
+
+ static std::map<std::string, std::string> properties_;
+ static std::shared_ptr<Runtime> theRuntime__;
+
+friend class ProxyManager;
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_RUNTIME_HPP_
diff --git a/include/CommonAPI/SelectiveEvent.hpp b/include/CommonAPI/SelectiveEvent.hpp
new file mode 100644
index 0000000..ffae1bf
--- /dev/null
+++ b/include/CommonAPI/SelectiveEvent.hpp
@@ -0,0 +1,28 @@
+// Copyright (C) 2013-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/.
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef COMMONAPI_SELECTIVEEVENT_HPP_
+#define COMMONAPI_SELECTIVEEVENT_HPP_
+
+#include <CommonAPI/Event.hpp>
+
+namespace CommonAPI {
+
+template<typename ... _Arguments>
+class SelectiveEvent: public Event<_Arguments...> {
+public:
+ typedef typename Event<_Arguments...>::Listener Listener;
+ typedef typename Event<_Arguments...>::Subscription Subscription;
+
+ virtual ~SelectiveEvent() {}
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_SELECTIVEEVENT_HPP_
diff --git a/include/CommonAPI/SerializableArguments.hpp b/include/CommonAPI/SerializableArguments.hpp
new file mode 100644
index 0000000..1f2af63
--- /dev/null
+++ b/include/CommonAPI/SerializableArguments.hpp
@@ -0,0 +1,62 @@
+// Copyright (C) 2014-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/.
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef COMMONAPI_SERIALIZABLEARGUMENTS_HPP_
+#define COMMONAPI_SERIALIZABLEARGUMENTS_HPP_
+
+#include <CommonAPI/InputStream.hpp>
+#include <CommonAPI/OutputStream.hpp>
+
+namespace CommonAPI {
+
+template<class _In, class _Out, typename... _Arguments>
+struct SerializableArguments;
+
+template<class _In, class _Out>
+struct SerializableArguments<_In, _Out> {
+ static bool serialize(OutputStream<_Out> &_output) {
+ return true;
+ }
+
+ static bool deserialize(InputStream<_In> &_input) {
+ return true;
+ }
+};
+
+template<class _In, class _Out, typename _ArgumentType>
+struct SerializableArguments<_In, _Out, _ArgumentType> {
+ static bool serialize(OutputStream<_Out> &_output, const _ArgumentType &_argument) {
+ _output << _argument;
+ return !_output.hasError();
+ }
+
+ static bool deserialize(InputStream<_In> &_input, _ArgumentType &_argument) {
+ _input >> _argument;
+ return !_input.hasError();
+ }
+};
+
+template <class _In, class _Out, typename _ArgumentType, typename ... _Rest>
+struct SerializableArguments<_In, _Out, _ArgumentType, _Rest...> {
+ static bool serialize(OutputStream<_Out> &_output, const _ArgumentType &_argument, const _Rest&... _rest) {
+ _output << _argument;
+ return !_output.hasError() ?
+ SerializableArguments<_In, _Out, _Rest...>::serialize(_output, _rest...) : false;
+ }
+
+ static bool deserialize(InputStream<_In> &_input, _ArgumentType &_argument, _Rest&... _rest) {
+ _input >> _argument;
+ return !_input.hasError() ?
+ SerializableArguments<_In, _Out, _Rest...>::deserialize(_input, _rest...) : false;
+ }
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_SERIALIZABLE_ARGUMENTS_HPP_
diff --git a/include/CommonAPI/Struct.hpp b/include/CommonAPI/Struct.hpp
new file mode 100644
index 0000000..c98b09e
--- /dev/null
+++ b/include/CommonAPI/Struct.hpp
@@ -0,0 +1,174 @@
+// Copyright (C) 2014-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/.
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef COMMONAPI_STRUCT_HPP_
+#define COMMONAPI_STRUCT_HPP_
+
+#include <iostream>
+#include <tuple>
+
+namespace CommonAPI {
+
+typedef uint32_t Serial;
+
+template<class _Derived>
+class InputStream;
+
+template<class _Derived>
+class OutputStream;
+
+template<class _Derived>
+class TypeOutputStream;
+
+template<int, class, class, class>
+struct StructReader;
+
+template<
+ int _Index, class _Input,
+ template<class...> class _V, class... _Values,
+ template<class...> class _D, class... _Depls>
+struct StructReader<_Index, _Input, _V<_Values...>, _D<_Depls...>> {
+ void operator()(InputStream<_Input> &_input,
+ _V<_Values...> &_values,
+ const _D<_Depls...> *_depls) {
+ StructReader<_Index-1, _Input, _V<_Values...>, _D<_Depls...>>{}(_input, _values, _depls);
+ _input.template readValue<>(std::get<_Index>(_values.values_),
+ (_depls ? std::get<_Index>(_depls->values_) : nullptr));
+ }
+};
+
+template<
+ int _Index, class _Input,
+ template<class...> class _V, class... _Values,
+ class _D>
+struct StructReader<_Index, _Input, _V<_Values...>, _D> {
+ void operator()(InputStream<_Input> &_input,
+ _V<_Values...> &_values,
+ const _D *_depls) {
+ StructReader<_Index-1, _Input, _V<_Values...>, _D>{}(_input, _values, _depls);
+ _input.template readValue<_D>(std::get<_Index>(_values.values_));
+ }
+};
+
+template<class _Input,
+ template<class...> class _V, class... _Values,
+ template<class...> class _D, class... _Depls>
+struct StructReader<0, _Input, _V<_Values...>, _D<_Depls...>> {
+ void operator()(InputStream<_Input> &_input,
+ _V<_Values...> &_values,
+ const _D<_Depls...> *_depls) {
+ _input.template readValue<>(std::get<0>(_values.values_),
+ (_depls ? std::get<0>(_depls->values_) : nullptr));
+ }
+};
+
+template<class _Input,
+ template<class...> class _V, class... _Values,
+ class _D>
+struct StructReader<0, _Input, _V<_Values...>, _D> {
+ void operator()(InputStream<_Input> &_input,
+ _V<_Values...> &_values,
+ const _D *_depls) {
+ _input.template readValue<_D>(std::get<0>(_values.values_));
+ }
+};
+
+
+template< int, class, class, class >
+struct StructWriter;
+
+template<
+ int _Index, class _Output,
+ template<class ...> class _V, class... _Values,
+ template <class...> class _D, class... _Depls>
+struct StructWriter<_Index, _Output, _V<_Values...>, _D<_Depls...>> {
+ void operator()(OutputStream<_Output> &_output,
+ const _V<_Values...> &_values,
+ const _D<_Depls...> *_depls) {
+ StructWriter<_Index-1, _Output, _V<_Values...>, _D<_Depls...>>{}(_output, _values, _depls);
+ _output.template writeValue<>(std::get<_Index>(_values.values_),
+ (_depls ? std::get<_Index>(_depls->values_) : nullptr));
+ }
+};
+
+template<
+ int _Index, class _Output,
+ template<class...> class _V, class... _Values,
+ class _D>
+struct StructWriter<_Index, _Output, _V<_Values...>, _D> {
+ void operator()(OutputStream<_Output> &_output,
+ const _V<_Values...> &_values,
+ const _D *_depls) {
+ StructWriter<_Index-1, _Output, _V<_Values...>, _D>{}(_output, _values, _depls);
+ _output.template writeValue<_D>(std::get<_Index>(_values.values_));
+ }
+};
+
+template<class _Output,
+ template<class...> class _V, class... _Values,
+ template<class...> class _D, class... _Depls>
+struct StructWriter<0, _Output, _V<_Values...>, _D<_Depls...>> {
+ void operator()(OutputStream<_Output> &_output,
+ const _V<_Values...> &_values,
+ const _D<_Depls...> *_depls) {
+ _output.template writeValue<>(std::get<0>(_values.values_),
+ (_depls ? std::get<0>(_depls->values_) : nullptr));
+ }
+};
+
+template<class _Output,
+ template<class...> class _V, class... _Values,
+ class _D>
+struct StructWriter<0, _Output, _V<_Values...>, _D> {
+ void operator()(OutputStream<_Output> &_output,
+ const _V<_Values...> &_values,
+ const _D *_depls) {
+ _output.template writeValue<_D>(std::get<0>(_values.values_));
+ }
+};
+
+template<int, class, class>
+struct StructTypeWriter;
+
+template<int _Index, class _TypeOutput,
+ template<class...> class _V, class... _Values>
+struct StructTypeWriter<_Index, _TypeOutput, _V<_Values...>> {
+ void operator()(TypeOutputStream<_TypeOutput> &_output,
+ const _V<_Values...> &_values) {
+ StructTypeWriter<_Index-1, _TypeOutput, _V<_Values...>>{}(_output, _values);
+ _output.template writeType(std::get<_Index>(_values.values_));
+ }
+};
+
+template<class _TypeOutput,
+ template<class...> class _V, class... _Values>
+struct StructTypeWriter<0, _TypeOutput, _V<_Values...>> {
+ void operator()(TypeOutputStream<_TypeOutput> &_output,
+ const _V<_Values...> &_values) {
+ _output.template writeType(std::get<0>(_values.values_));
+ }
+};
+
+// Structures are mapped to a (generated) struct which inherits from CommonAPI::Struct.
+// CommonAPI::Struct holds the structured data in a tuple. The generated class provides
+// getter- and setter-methods for the structure members.
+template<typename... _Types>
+struct Struct {
+ std::tuple<_Types...> values_;
+};
+
+// Polymorphic structs are mapped to an interface that is derived from the base class
+// PolymorphicStruct and contain their parameter in a Struct.
+struct PolymorphicStruct {
+ virtual const Serial getSerial() const = 0;
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_STRUCT_HPP_
diff --git a/src/CommonAPI/Stub.h b/include/CommonAPI/Stub.hpp
index a22ae3c..75ee4e0 100644
--- a/src/CommonAPI/Stub.h
+++ b/include/CommonAPI/Stub.hpp
@@ -1,38 +1,36 @@
-/* Copyright (C) 2013 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/. */
+// Copyright (C) 2014-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/.
#if !defined (COMMONAPI_INTERNAL_COMPILATION)
#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef COMMONAPI_STUB_H_
-#define COMMONAPI_STUB_H_
+#ifndef COMMONAPI_STUB_HPP_
+#define COMMONAPI_STUB_HPP_
#include <memory>
#include <string>
#include <type_traits>
+#include <CommonAPI/Address.hpp>
+#include <CommonAPI/Types.hpp>
+
namespace CommonAPI {
class StubAdapter {
public:
- virtual ~StubAdapter() {
- }
+ virtual ~StubAdapter() {}
+ inline const Address &getAddress() const { return address_; }
- virtual const std::string getAddress() const = 0;
- virtual const std::string& getDomain() const = 0;
- virtual const std::string& getServiceId() const = 0;
- virtual const std::string& getInstanceId() const = 0;
+protected:
+ Address address_;
};
class StubBase {
public:
- virtual ~StubBase() {
- }
+ virtual ~StubBase() {}
};
template<typename _StubAdapter, typename _StubRemoteEventHandler>
@@ -42,13 +40,11 @@ public:
typedef _StubAdapter StubAdapterType;
typedef _StubRemoteEventHandler RemoteEventHandlerType;
- virtual ~Stub() {
- }
+ virtual ~Stub() {}
+
+ virtual _StubRemoteEventHandler* initStubAdapter(const std::shared_ptr<_StubAdapter> &_stubAdapter) = 0;
- virtual _StubRemoteEventHandler* initStubAdapter(const std::shared_ptr<_StubAdapter>& stubAdapter) = 0;
- virtual const std::shared_ptr<_StubAdapter> getStubAdapter() {
- return stubAdapter_;
- }
+ inline const std::shared_ptr<_StubAdapter> getStubAdapter() const { return stubAdapter_; }
protected:
std::shared_ptr<_StubAdapter> stubAdapter_;
@@ -61,4 +57,4 @@ enum SelectiveBroadcastSubscriptionEvent {
} // namespace CommonAPI
-#endif // COMMONAPI_STUB_H_
+#endif // COMMONAPI_STUB_HPP_
diff --git a/include/CommonAPI/TypeOutputStream.hpp b/include/CommonAPI/TypeOutputStream.hpp
new file mode 100644
index 0000000..ec44864
--- /dev/null
+++ b/include/CommonAPI/TypeOutputStream.hpp
@@ -0,0 +1,197 @@
+// Copyright (C) 2014-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/.
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef COMMONAPI_TYPEOUTPUTSTREAM_HPP_
+#define COMMONAPI_TYPEOUTPUTSTREAM_HPP_
+
+#include <unordered_map>
+
+#include <CommonAPI/Struct.hpp>
+#include <CommonAPI/Variant.hpp>
+#include <CommonAPI/Types.hpp>
+
+namespace CommonAPI {
+
+template<class _Derived>
+class TypeOutputStream {
+public:
+ inline TypeOutputStream &writeType(const bool &_value) {
+ return get()->writeType(_value);
+ }
+
+ inline TypeOutputStream &writeType(const int8_t &_value) {
+ return get()->writeType(_value);
+ }
+
+ inline TypeOutputStream &writeType(const int16_t &_value) {
+ return get()->writeType(_value);
+ }
+
+ inline TypeOutputStream &writeType(const int32_t &_value) {
+ return get()->writeType(_value);
+ }
+
+ inline TypeOutputStream &writeType(const int64_t &_value) {
+ return get()->writeType(_value);
+ }
+
+ inline TypeOutputStream &writeType(const uint8_t &_value) {
+ return get()->writeType(_value);
+ }
+
+ inline TypeOutputStream &writeType(const uint16_t &_value) {
+ return get()->writeType(_value);
+ }
+
+ inline TypeOutputStream &writeType(const uint32_t &_value) {
+ return get()->writeType(_value);
+ }
+
+ inline TypeOutputStream &writeType(const uint64_t &_value) {
+ return get()->writeType(_value);
+ }
+
+ inline TypeOutputStream &writeType(const float &_value) {
+ return get()->writeType(_value);
+ }
+
+ inline TypeOutputStream &writeType(const double &_value) {
+ return get()->writeType(_value);
+ }
+
+ inline TypeOutputStream &writeType(const std::string &_value) {
+ return get()->writeType(_value);
+ }
+
+ template<typename _Type>
+ TypeOutputStream &writeType(const Enumeration<_Type> &_value) {
+ _Type tmpValue;
+ return get()->writeType(tmpValue);
+ }
+
+ template<typename... _Types>
+ TypeOutputStream &writeType(const Struct<_Types...> &_value) {
+ return get()->writeType(_value);
+ }
+
+ template<typename... _Types>
+ TypeOutputStream &writeType(const Variant<_Types...> &_value) {
+ return get()->writeType(_value);
+ }
+
+ template<typename _ElementType>
+ TypeOutputStream &writeType(const std::vector<_ElementType> &_value) {
+ return get()->writeType(_value);
+ }
+
+ template<typename _KeyType, typename _ValueType, typename _HasherType>
+ TypeOutputStream &writeType(const std::unordered_map<_KeyType, _ValueType, _HasherType> &_value) {
+ return get()->writeType(_value);
+ }
+
+private:
+ inline _Derived *get() {
+ return static_cast<_Derived *>(this);
+ }
+};
+
+template<class _Derived>
+inline TypeOutputStream<_Derived> &operator<<(TypeOutputStream<_Derived> &_output, const bool &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived>
+inline TypeOutputStream<_Derived>& operator<<(TypeOutputStream<_Derived> &_output, const int8_t &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived>
+inline TypeOutputStream<_Derived>& operator<<(TypeOutputStream<_Derived> &_output, const int16_t &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived>
+inline TypeOutputStream<_Derived>& operator<<(TypeOutputStream<_Derived> &_output, const int32_t &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived>
+inline TypeOutputStream<_Derived>& operator<<(TypeOutputStream<_Derived> &_output, const int64_t &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived>
+inline TypeOutputStream<_Derived>& operator<<(TypeOutputStream<_Derived> &_output, const uint8_t &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived>
+inline TypeOutputStream<_Derived>& operator<<(TypeOutputStream<_Derived> &_output, const uint16_t &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived>
+inline TypeOutputStream<_Derived>& operator<<(TypeOutputStream<_Derived> &_output, const uint32_t &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived>
+inline TypeOutputStream<_Derived>& operator<<(TypeOutputStream<_Derived> &_output, const uint64_t &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived>
+inline TypeOutputStream<_Derived>& operator<<(TypeOutputStream<_Derived> &_output, const float &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived>
+inline TypeOutputStream<_Derived>& operator<<(TypeOutputStream<_Derived> &_output, const double &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived>
+inline TypeOutputStream<_Derived>& operator<<(TypeOutputStream<_Derived> &_output, const std::string &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived, typename _Type, typename _TypeDepl>
+inline TypeOutputStream<_Derived> &operator<<(TypeOutputStream<_Derived> &_output, const Deployable<_Type, _TypeDepl> &_value) {
+ return _output.writeType(_value.getValue());
+}
+
+template<class _Derived>
+inline TypeOutputStream<_Derived>& operator<<(TypeOutputStream<_Derived> &_output, const Version &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived, typename... _Types>
+TypeOutputStream<_Derived> &operator<<(TypeOutputStream<_Derived> &_output, const Struct<_Types...> &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived, typename... _Types>
+TypeOutputStream<_Derived> &operator<<(TypeOutputStream<_Derived> &_output, const Variant<_Types...> &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived, typename _ElementType>
+TypeOutputStream<_Derived> &operator<<(TypeOutputStream<_Derived> &_output, const std::vector<_ElementType> &_value) {
+ return _output.writeType(_value);
+}
+
+template<class _Derived, typename _KeyType, typename _ValueType, typename _HasherType>
+TypeOutputStream<_Derived> &operator<<(TypeOutputStream<_Derived> &_output,
+ const std::unordered_map<_KeyType, _ValueType, _HasherType> &_value) {
+ return _output.writeType(_value);
+}
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_TYPEOUTPUTSTREAM_HPP_
diff --git a/src/CommonAPI/types.h b/include/CommonAPI/Types.hpp
index eb2aaf8..de1d85a 100644
--- a/src/CommonAPI/types.h
+++ b/include/CommonAPI/Types.hpp
@@ -1,24 +1,26 @@
-/* Copyright (C) 2013 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/. */
+// Copyright (C) 2013-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/.
#if !defined (COMMONAPI_INTERNAL_COMPILATION)
#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
#endif
-#ifndef COMMONAPI_TYPES_H_
-#define COMMONAPI_TYPES_H_
+#ifndef COMMONAPI_TYPES_HPP_
+#define COMMONAPI_TYPES_HPP_
#include <cstdint>
#include <functional>
#include <unordered_set>
#include <memory>
#include <tuple>
-#include "ContainerUtils.h"
-#include "Event.h"
+
+#include <CommonAPI/ByteBuffer.hpp>
+#include <CommonAPI/ContainerUtils.hpp>
+#include <CommonAPI/Event.hpp>
+#include <CommonAPI/Export.hpp>
+#include <CommonAPI/Version.hpp>
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
# define COMMONAPI_DEPRECATED __attribute__ ((__deprecated__))
@@ -61,20 +63,14 @@ enum class CallStatus {
OUT_OF_MEMORY,
NOT_AVAILABLE,
CONNECTION_FAILED,
- REMOTE_ERROR
+ REMOTE_ERROR,
+ UNKNOWN
};
-
-struct Version {
- Version() = default;
-
- Version(const uint32_t& majorValue, const uint32_t& minorValue):
- Major(majorValue),
- Minor(minorValue) {}
-
- uint32_t Major;
- uint32_t Minor;
-};
+typedef uint32_t CallId_t;
+typedef std::string ConnectionId_t;
+typedef int Timeout_t; // in ms, -1 means "forever"
+typedef uint32_t Sender_t;
/**
* \brief Identifies a client sending a call to a stub.
@@ -91,16 +87,14 @@ public:
template <typename ... Args>
struct SelectiveBroadcastFunctorHelper {
- typedef std::function<SubscriptionStatus(Args...)> SelectiveBroadcastFunctor;
+ typedef std::function<void(Args...)> SelectiveBroadcastFunctor;
};
-
-typedef std::unordered_set<std::shared_ptr<CommonAPI::ClientId>, SharedPointerClientIdContentHash, SharedPointerClientIdContentEqual> ClientIdList;
-template <typename ... Args>
-struct SelectiveBroadcastSubscriptionResult {
- typedef std::tuple<bool, typename CommonAPI::Event<Args...>::Subscription> SubscriptionResult;
-
-};
+typedef std::unordered_set<
+ std::shared_ptr<CommonAPI::ClientId>,
+ SharedPointerClientIdContentHash,
+ SharedPointerClientIdContentEqual
+> ClientIdList;
template<typename _EnumType>
class EnumHasher {
@@ -108,9 +102,15 @@ public:
size_t operator()(const _EnumType& testEnum) const {
return static_cast<int32_t>(testEnum);
}
-
};
+// Type identifier for polymorphic structs
+typedef uint32_t Serial;
+
} // namespace CommonAPI
-#endif // COMMONAPI_TYPES_H_
+#endif // COMMONAPI_TYPES_HPP_
+
+#if defined(COMMONAPI_TYPES_LOCAL_INCLUDE)
+#include COMMONAPI_TYPES_LOCAL_INCLUDE
+#endif
diff --git a/include/CommonAPI/Utils.hpp b/include/CommonAPI/Utils.hpp
new file mode 100644
index 0000000..94891d5
--- /dev/null
+++ b/include/CommonAPI/Utils.hpp
@@ -0,0 +1,22 @@
+// Copyright (C) 2014-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/.
+
+#ifndef COMMONAPI_UTILS_HPP_
+#define COMMONAPI_UTILS_HPP_
+
+#include <string>
+#include <vector>
+
+#include <CommonAPI/Export.hpp>
+
+namespace CommonAPI {
+
+std::vector<std::string> COMMONAPI_EXPORT split(const std::string& s, char delim);
+void COMMONAPI_EXPORT trim(std::string &_s);
+
+
+} //namespace CommonAPI
+
+#endif /* COMMONAPI_UTILS_HPP_ */
diff --git a/include/CommonAPI/Variant.hpp b/include/CommonAPI/Variant.hpp
new file mode 100644
index 0000000..d7b1088
--- /dev/null
+++ b/include/CommonAPI/Variant.hpp
@@ -0,0 +1,746 @@
+// Copyright (C) 2013-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 <cassert>
+#include <cstdint>
+#include <iostream>
+#include <memory>
+#include <string>
+#include <tuple>
+#include <type_traits>
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#include <CommonAPI/Deployable.hpp>
+#include <CommonAPI/Deployment.hpp>
+
+#ifndef COMMONAPI_VARIANT_HPP_
+#define COMMONAPI_VARIANT_HPP_
+
+namespace CommonAPI {
+
+template<class _Derived>
+class InputStream;
+
+template<class _Derived>
+class OutputStream;
+
+template<typename... _Types>
+struct MaxSize;
+
+template<>
+struct MaxSize<> {
+ static const unsigned int value = 0;
+};
+
+template<typename _Type, typename... _Types>
+struct MaxSize<_Type, _Types...> {
+ static const unsigned int current_type_size = sizeof(_Type);
+ static const unsigned int next_type_size = MaxSize<_Types...>::value;
+ static const unsigned int value =
+ current_type_size > next_type_size ?
+ current_type_size : next_type_size;
+};
+
+template<typename _SearchType, typename... _RestTypes>
+struct VariantTypeSelector;
+
+template<typename _SearchType, typename... _RestTypes>
+struct VariantTypeSelector<_SearchType, _SearchType, _RestTypes...> {
+ typedef _SearchType type;
+};
+
+/**
+ * \brief A templated generic variant class which provides type safe access and operators
+ *
+ * A templated generic variant class which provides type safe access and operators
+ */
+template<typename... _Types>
+class Variant {
+private:
+ typedef std::tuple_size<std::tuple<_Types...>> TypesTupleSize;
+
+public:
+
+ static const unsigned int maxSize = MaxSize<_Types...>::value;
+
+ /**
+ * \brief Construct an empty variant
+ *
+ * Construct an empty variant
+ */
+ Variant();
+
+
+ /**
+ * \brief Copy constructor. Must have identical templates.
+ *
+ * Copy constructor. Must have identical templates.
+ *
+ * @param _source Variant to copy
+ */
+ Variant(const Variant &_source);
+
+ /**
+ * \brief Copy constructor. Must have identical templates.
+ *
+ * Copy constructor. Must have identical templates.
+ *
+ * @param _source Variant to copy
+ */
+ Variant(Variant &&_source);
+
+ ~Variant();
+
+ /**
+ * \brief Assignment of another variant. Must have identical templates.
+ *
+ * Assignment of another variant. Must have identical templates.
+ *
+ * @param _source Variant to assign
+ */
+ Variant &operator=(const Variant &_source);
+ /**
+ * \brief Assignment of another variant. Must have identical templates.
+ *
+ * Assignment of another variant. Must have identical templates.
+ *
+ * @param _source Variant to assign
+ */
+ Variant &operator=(Variant &&_source);
+
+ /**
+ * \brief Assignment of a contained type. Must be one of the valid templated types.
+ *
+ * Assignment of a contained type. Must be one of the valid templated types.
+ *
+ * @param _value Value to assign
+ */
+ template<typename _Type>
+ typename std::enable_if<!std::is_same<_Type, Variant<_Types...>>::value, Variant<_Types...>&>::type
+ operator=(const _Type &_value);
+
+ /**
+ * \brief Equality of another variant. Must have identical template list and content.
+ *
+ * Equality of another variant. Must have identical template list and content.
+ *
+ * @param _other Variant to compare
+ */
+ bool operator==(const Variant<_Types...> &_other) const;
+
+ /**
+ * \brief Not-Equality of another variant. Must have identical template list and content.
+ *
+ * Not-Equality of another variant. Must have identical template list and content.
+ *
+ * @param _other Variant to compare
+ */
+ bool operator!=(const Variant<_Types...> &_other) const;
+
+ /**
+ * \brief Testif the contained type is the same as the template on this method.
+ *
+ * Testif the contained type is the same as the template on this method.
+ *
+ * @return Is same type
+ */
+ template<typename _Type>
+ const bool isType() const;
+
+ /**
+ * \brief Construct variant with content type set to value.
+ *
+ * Construct variant with content type set to value.
+ *
+ * @param _value Value to place
+ */
+ template<typename _Type>
+ Variant(const _Type &_value,
+ typename std::enable_if<!std::is_const<_Type>::value>::type* = 0,
+ typename std::enable_if<!std::is_reference<_Type>::value>::type* = 0,
+ typename std::enable_if<!std::is_same<_Type, Variant>::value>::type* = 0);
+
+ /**
+ * \brief Construct variant with content type set to value.
+ *
+ * Construct variant with content type set to value.
+ *
+ * @param _value Value to place
+ */
+ template<typename _Type>
+ Variant(_Type &&_value,
+ typename std::enable_if<!std::is_const<_Type>::value>::type* = 0,
+ typename std::enable_if<!std::is_reference<_Type>::value>::type* = 0,
+ typename std::enable_if<!std::is_same<_Type, Variant>::value>::type* = 0);
+
+ /**
+ * \brief Get value of variant, template to content type. Throws exception if type is not contained.
+ *
+ * Get value of variant, template to content type. Throws exception if type is not contained.
+ */
+ template<typename _Type>
+ const _Type &get() const;
+
+ /**
+ * \brief Get index in template list of type actually contained, starting at 1 at the end of the template list
+ *
+ * Get index in template list of type actually contained, starting at 1 at the end of the template list
+ *
+ * @return Index of contained type
+ */
+ uint8_t getValueType() const {
+ return valueType_;
+ }
+
+private:
+ template<typename _Type>
+ void set(const _Type &_value, const bool clear);
+
+ template<typename _Type>
+ void set(_Type &&_value, const bool clear);
+
+ template<typename _FriendType>
+ friend struct TypeWriter;
+ template<typename ... _FriendTypes>
+ friend struct AssignmentVisitor;
+ template<typename _FriendType>
+ friend struct TypeEqualsVisitor;
+ template<typename ... _FriendTypes>
+ friend struct PartialEqualsVisitor;
+ template<class _Derived, typename ... _FriendTypes>
+ friend struct InputStreamReadVisitor;
+ template<class Variant, typename ... _FTypes>
+ friend struct ApplyVoidIndexVisitor;
+
+public:
+ inline bool hasValue() const {
+ return (valueType_ < TypesTupleSize::value);
+ }
+ typename std::aligned_storage<maxSize>::type valueStorage_;
+
+ uint8_t valueType_;
+};
+
+template<class _Variant, typename... _Types>
+struct ApplyVoidIndexVisitor;
+
+template<class _Variant>
+struct ApplyVoidIndexVisitor<_Variant> {
+ static const uint8_t index = 0;
+
+ static
+ void visit(_Variant &, uint8_t &) {
+ assert(false);
+ }
+};
+
+template<class _Variant, typename _Type, typename... _Types>
+struct ApplyVoidIndexVisitor<_Variant, _Type, _Types...> {
+ static const uint8_t index
+ = ApplyVoidIndexVisitor<_Variant, _Types...>::index + 1;
+
+ static void visit(_Variant &_variant, uint8_t &_index) {
+ if (index == _index) {
+ new (&_variant.valueStorage_) _Type();
+ _variant.valueType_ = index;
+ } else {
+ ApplyVoidIndexVisitor<
+ _Variant, _Types...
+ >::visit(_variant, _index);
+ }
+ }
+};
+
+template<class _Visitor, class _Variant, typename... _Types>
+struct ApplyVoidVisitor;
+
+template<class _Visitor, class _Variant>
+struct ApplyVoidVisitor<_Visitor, _Variant> {
+ static const uint8_t index = 0;
+
+ static
+ void visit(_Visitor &, _Variant &) {
+ assert(false);
+ }
+
+ static
+ void visit(_Visitor &, const _Variant &) {
+ assert(false);
+ }
+};
+
+template<class _Visitor, class _Variant, typename _Type, typename ... _Types>
+struct ApplyVoidVisitor<_Visitor, _Variant, _Type, _Types...> {
+ static const uint8_t index
+ = ApplyVoidVisitor<_Visitor, _Variant, _Types...>::index + 1;
+
+ static void visit(_Visitor &_visitor, _Variant &_variant) {
+ if (_variant.getValueType() == index) {
+ _visitor(_variant.template get<_Type>());
+ } else {
+ ApplyVoidVisitor<
+ _Visitor, _Variant, _Types...
+ >::visit(_visitor, _variant);
+ }
+ }
+
+ static void visit(_Visitor &_visitor, const _Variant &_variant) {
+ if (_variant.getValueType() == index) {
+ _visitor(_variant.template get<_Type>());
+ } else {
+ ApplyVoidVisitor<
+ _Visitor, _Variant, _Types...
+ >::visit(_visitor, _variant);
+ }
+ }
+};
+
+template<class _Visitor, class _Variant, typename ... _Types>
+struct ApplyBoolVisitor;
+
+template<class _Visitor, class _Variant>
+struct ApplyBoolVisitor<_Visitor, _Variant> {
+ static const uint8_t index = 0;
+
+ static bool visit(_Visitor &, _Variant &) {
+ assert(false);
+ return false;
+ }
+};
+
+template<class _Visitor, class _Variant, typename _Type, typename ... _Types>
+struct ApplyBoolVisitor<_Visitor, _Variant, _Type, _Types...> {
+ static const uint8_t index
+ = ApplyBoolVisitor<_Visitor, _Variant, _Types...>::index + 1;
+
+ static bool visit(_Visitor &_visitor, _Variant &_variant) {
+ if (_variant.getValueType() == index) {
+ return _visitor(_variant.template get<_Type>());
+ } else {
+ return ApplyBoolVisitor<
+ _Visitor, _Variant, _Types...
+ >::visit(_visitor, _variant);
+ }
+ }
+};
+
+template<class _Visitor, class _Variant, class _Deployment, typename ... _Types>
+struct ApplyStreamVisitor;
+
+template<class _Visitor, class _Variant, class _Deployment>
+struct ApplyStreamVisitor<_Visitor, _Variant, _Deployment> {
+ static const uint8_t index = 0;
+
+ static
+ void visit(_Visitor &, _Variant &, const _Deployment *) {
+ assert(false);
+ }
+
+ static
+ void visit(_Visitor &, const _Variant &, const _Deployment *) {
+ assert(false);
+ }
+};
+
+template<class _Visitor, class _Variant, class _Deployment, typename _Type, typename ... _Types>
+struct ApplyStreamVisitor<_Visitor, _Variant, _Deployment, _Type, _Types...> {
+ static const uint8_t index
+ = ApplyStreamVisitor<_Visitor, _Variant, _Deployment, _Types...>::index + 1;
+
+ static void visit(_Visitor &_visitor, _Variant &_variant, const _Deployment *_depl) {
+ if (_variant.getValueType() == index) {
+ _visitor(_variant.template get<_Type>(),
+ (_depl ? std::get<std::tuple_size<decltype(_depl->values_)>::value-index>(_depl->values_)
+ : nullptr));
+ } else {
+ ApplyStreamVisitor<
+ _Visitor, _Variant, _Deployment, _Types...
+ >::visit(_visitor, _variant, _depl);
+ }
+ }
+
+ static void visit(_Visitor &_visitor, const _Variant &_variant, const _Deployment *_depl) {
+ if (_variant.getValueType() == index) {
+ _visitor(_variant.template get<_Type>(),
+ (_depl ? std::get<std::tuple_size<decltype(_depl->values_)>::value-index>(_depl->values_)
+ : nullptr));
+ } else {
+ ApplyStreamVisitor<
+ _Visitor, _Variant, _Deployment, _Types...
+ >::visit(_visitor, _variant, _depl);
+ }
+ }
+};
+
+template<uint32_t _Size>
+struct DeleteVisitor {
+public:
+ DeleteVisitor(typename std::aligned_storage<_Size>::type &_storage)
+ : storage_(_storage) {
+ }
+
+ template<typename _Type>
+ void operator()(const _Type &) const {
+ (reinterpret_cast<const _Type *>(&storage_))->~_Type();
+ }
+
+private:
+ typename std::aligned_storage<_Size>::type &storage_;
+};
+
+template<class _Derived>
+struct OutputStreamWriteVisitor {
+public:
+ OutputStreamWriteVisitor(OutputStream<_Derived> &_output)
+ : output_(_output) {
+ }
+
+ template<typename _Type, typename _Deployment = EmptyDeployment>
+ void operator()(const _Type &_value, const _Deployment *_depl = nullptr) const {
+ Deployable<_Type, _Deployment> itsValue(_value, _depl);
+ output_ << itsValue;
+ }
+
+private:
+ OutputStream<_Derived> &output_;
+};
+
+template<class _Derived, typename ... _Types>
+struct InputStreamReadVisitor {
+public:
+ InputStreamReadVisitor(InputStream<_Derived> &_input, Variant<_Types...> &_target)
+ : input_(_input), target_(_target) {
+ }
+
+ template<typename _Type, typename _Deployment = EmptyDeployment>
+ void operator()(const _Type &_value, const _Deployment *_depl = nullptr) {
+ Deployable<_Type, _Deployment> itsValue(_depl);
+ input_ >> itsValue;
+ target_.Variant<_Types...>::template set<_Type>(std::move(itsValue.getValue()), false);
+ }
+
+private:
+ InputStream<_Derived> &input_;
+ Variant<_Types...> &target_;
+};
+
+template<class _Derived>
+struct TypeOutputStreamWriteVisitor {
+public:
+ TypeOutputStreamWriteVisitor(_Derived &_output)
+ : output_(_output) {
+ }
+
+ template<typename _Type>
+ void operator()(const _Type &_value) const {
+ output_ << _value;
+ }
+
+private:
+ _Derived &output_;
+};
+
+template<typename _Type>
+struct TypeEqualsVisitor
+{
+public:
+ TypeEqualsVisitor(const _Type &_me)
+ : me_(_me) {
+ }
+
+ bool operator()(const _Type &_other) const {
+ return (me_ == _other);
+ }
+
+ template<typename _OtherType>
+ bool operator()(const _OtherType &) const {
+ return false;
+ }
+
+private:
+ const _Type& me_;
+};
+
+template<typename ... _Types>
+struct PartialEqualsVisitor
+{
+public:
+ PartialEqualsVisitor(const Variant<_Types...> &_me)
+ : me_(_me) {
+ }
+
+ template<typename _Type>
+ bool operator()(const _Type &_other) const {
+ TypeEqualsVisitor<_Type> visitor(_other);
+ return ApplyBoolVisitor<
+ TypeEqualsVisitor<_Type>, const Variant<_Types...>, _Types...
+ >::visit(visitor, me_);
+ }
+
+private:
+ const Variant<_Types...> &me_;
+};
+
+template<typename ... _Types>
+struct AssignmentVisitor {
+public:
+ AssignmentVisitor(Variant<_Types...> &_me, const bool _clear = true)
+ : me_(_me), clear_(_clear) {
+ }
+
+ template<typename _Type>
+ void operator()(const _Type &_value) const {
+ me_.Variant<_Types...>::template set<_Type>(_value, clear_);
+ }
+
+ template<typename _Type>
+ void operator()(_Type &_value) const {
+ me_.Variant<_Types...>::template set<_Type>(_value, clear_);
+ }
+
+private:
+ Variant<_Types...> &me_;
+ const bool clear_;
+};
+
+template<typename... _Types>
+struct TypeSelector;
+
+template<typename _Type>
+struct TypeSelector<_Type> {
+};
+
+template<typename _Type, typename... _Types>
+struct TypeSelector<_Type, _Type, _Types...> {
+ typedef _Type type;
+};
+
+template<typename _Type, typename... _Types>
+struct TypeSelector<_Type, _Type &, _Types...> {
+ typedef _Type& type;
+};
+
+template<typename _Type, typename... _Types>
+struct TypeSelector<_Type &, _Type, _Types...> {
+ typedef _Type type;
+};
+
+template<typename _Type, typename... _Types>
+struct TypeSelector<_Type, const _Type &, _Types...> {
+ typedef const _Type &type;
+};
+
+template<typename _Type, typename... _Types>
+struct TypeSelector<const _Type&, _Type, _Types...> {
+ typedef _Type type;
+};
+
+template<typename _Type, typename... _Types>
+struct TypeSelector<_Type*, const _Type*, _Types...> {
+ typedef const _Type *type;
+};
+
+template<typename _Type, typename... _Types>
+struct TypeSelector<_Type &, const _Type &, _Types...> {
+ typedef const _Type &type;
+};
+
+template<typename _U, typename _Type, typename... _Types>
+struct TypeSelector<_U, _Type, _Types...> {
+ typedef typename TypeSelector<_U, _Types...>::type type;
+};
+
+template<typename... _Types>
+struct TypeIndex;
+
+template<>
+struct TypeIndex<> {
+ static const uint8_t index = 0;
+
+ template<typename _U>
+ static uint8_t get() {
+ return 0;
+ }
+};
+
+template<typename _Type, typename ... _Types>
+struct TypeIndex<_Type, _Types...> {
+ static const uint8_t index = TypeIndex<_Types...>::index + 1;
+
+ template<typename _U>
+ static uint8_t get(typename std::enable_if<std::is_same<_Type, _U>::value>::type* = 0) {
+ return index;
+ }
+
+ template<typename _U>
+ static uint8_t get(typename std::enable_if<!std::is_same<_Type, _U>::value>::type* = 0) {
+ return TypeIndex<_Types...>::template get<_U>();
+ }
+};
+
+template<typename... _Types>
+Variant<_Types...>::Variant()
+ : valueType_(TypesTupleSize::value) {
+ ApplyVoidIndexVisitor<Variant<_Types...>, _Types...>::visit(*this, valueType_);
+}
+
+template<typename... _Types>
+Variant<_Types...>::Variant(const Variant &_source) {
+ AssignmentVisitor<_Types...> visitor(*this, false);
+ ApplyVoidVisitor<
+ AssignmentVisitor<_Types...> , Variant<_Types...>, _Types...
+ >::visit(visitor, _source);
+}
+
+template<typename... _Types>
+Variant<_Types...>::Variant(Variant &&_source)
+{
+ AssignmentVisitor<_Types...> visitor(*this, false);
+ ApplyVoidVisitor<
+ AssignmentVisitor<_Types...> , Variant<_Types...>, _Types...
+ >::visit(visitor, _source);
+}
+
+template<typename... _Types>
+Variant<_Types...>::~Variant() {
+ if (hasValue()) {
+ DeleteVisitor<maxSize> visitor(valueStorage_);
+ ApplyVoidVisitor<
+ DeleteVisitor<maxSize>, Variant<_Types...>, _Types...
+ >::visit(visitor, *this);
+ }
+}
+
+template<typename... _Types>
+Variant<_Types...>& Variant<_Types...>::operator=(const Variant<_Types...> &_source) {
+ AssignmentVisitor<_Types...> visitor(*this, hasValue());
+ ApplyVoidVisitor<
+ AssignmentVisitor<_Types...>, Variant<_Types...>, _Types...
+ >::visit(visitor, _source);
+ return *this;
+}
+
+template<typename... _Types>
+Variant<_Types...>& Variant<_Types...>::operator=(Variant<_Types...> &&_source) {
+ AssignmentVisitor<_Types...> visitor(*this, hasValue());
+ ApplyVoidVisitor<
+ AssignmentVisitor<_Types...>, Variant<_Types...>, _Types...
+ >::visit(visitor, _source);
+ return *this;
+}
+
+template<typename ... _Types>
+template<typename _Type>
+typename std::enable_if<!std::is_same<_Type, Variant<_Types...>>::value, Variant<_Types...>&>::type
+Variant<_Types...>::operator=(const _Type &_value) {
+ set<typename TypeSelector<_Type, _Types...>::type>(_value, hasValue());
+ return *this;
+}
+
+template<typename ... _Types>
+template<typename _Type>
+const bool Variant<_Types...>::isType() const {
+ typedef typename TypeSelector<_Type, _Types...>::type selected_type_t;
+ uint8_t itsType = TypeIndex<_Types...>::template get<selected_type_t>();
+ if (itsType == valueType_) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+template<typename ... _Types>
+template<typename _Type>
+Variant<_Types...>::Variant(const _Type &_value,
+ typename std::enable_if<!std::is_const<_Type>::value>::type*,
+ typename std::enable_if<!std::is_reference<_Type>::value>::type*,
+ typename std::enable_if<!std::is_same<_Type, Variant<_Types...>>::value>::type*) {
+ set<typename TypeSelector<_Type, _Types...>::type>(_value, false);
+}
+
+template<typename ... _Types>
+template<typename _Type>
+Variant<_Types...>::Variant(_Type &&_value,
+typename std::enable_if<!std::is_const<_Type>::value>::type*,
+typename std::enable_if<!std::is_reference<_Type>::value>::type*,
+typename std::enable_if<!std::is_same<_Type, Variant<_Types...>>::value>::type*) {
+ set<typename TypeSelector<_Type, _Types...>::type>(std::move(_value), false);
+}
+
+
+template<typename ... _Types>
+template<typename _Type>
+const _Type & Variant<_Types...>::get() const {
+ typedef typename TypeSelector<_Type, _Types...>::type selected_type_t;
+ uint8_t itsType = TypeIndex<_Types...>::template get<selected_type_t>();
+ if (itsType == valueType_) {
+ return *(reinterpret_cast<const _Type *>(&valueStorage_));
+ } else {
+#ifdef __EXCEPTIONS
+ std::bad_cast toThrow;
+ throw toThrow;
+#else
+ printf("SerializableVariant.hpp:%i %s: Incorrect access to variant; attempting to get type not currently contained", __LINE__, __FUNCTION__);
+ abort();
+#endif
+ }
+}
+
+
+template<typename ... _Types>
+template<typename _U>
+void Variant<_Types...>::set(const _U &_value, const bool _clear) {
+ typedef typename TypeSelector<_U, _Types...>::type selected_type_t;
+
+ if (_clear) {
+ DeleteVisitor<maxSize> visitor(valueStorage_);
+ ApplyVoidVisitor<
+ DeleteVisitor<maxSize>, Variant<_Types...>, _Types...
+ >::visit(visitor, *this);
+ }
+ new (&valueStorage_) selected_type_t(std::move(_value));
+ valueType_ = TypeIndex<_Types...>::template get<selected_type_t>();
+}
+
+template<typename ... _Types>
+template<typename _U>
+void Variant<_Types...>::set(_U &&_value, const bool _clear) {
+ typedef typename TypeSelector<_U, _Types...>::type selected_type_t;
+
+ selected_type_t&& any_container_value = std::move(_value);
+ if(_clear)
+ {
+ DeleteVisitor<maxSize> visitor(valueStorage_);
+ ApplyVoidVisitor<
+ DeleteVisitor<maxSize>, Variant<_Types...>, _Types...
+ >::visit(visitor, *this);
+ } else {
+ new (&valueStorage_) selected_type_t(std::move(any_container_value));
+ }
+
+ valueType_ = TypeIndex<_Types...>::template get<selected_type_t>();
+}
+
+template<typename ... _Types>
+bool Variant<_Types...>::operator==(const Variant<_Types...> &_other) const
+{
+ PartialEqualsVisitor<_Types...> visitor(*this);
+ return ApplyBoolVisitor<
+ PartialEqualsVisitor<_Types...>, const Variant<_Types...>, _Types...
+ >::visit(visitor, _other);
+}
+
+template<typename ... _Types>
+bool Variant<_Types...>::operator!=(const Variant<_Types...> &_other) const
+{
+ return !(*this == _other);
+}
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_VARIANT_HPP_
diff --git a/include/CommonAPI/Version.hpp b/include/CommonAPI/Version.hpp
new file mode 100644
index 0000000..97534b0
--- /dev/null
+++ b/include/CommonAPI/Version.hpp
@@ -0,0 +1,29 @@
+// Copyright (C) 2014-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/.
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef COMMONAPI_VERSION_HPP_
+#define COMMONAPI_VERSION_HPP_
+
+#include <cstdint>
+
+namespace CommonAPI {
+
+struct Version {
+ Version() = default;
+ Version(const uint32_t &majorValue, const uint32_t &minorValue)
+ : Major(majorValue), Minor(minorValue) {
+ }
+
+ uint32_t Major;
+ uint32_t Minor;
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_STRUCT_HPP_
diff --git a/m4/ax_cxx_compile_stdcxx_11.m4 b/m4/ax_cxx_compile_stdcxx_11.m4
deleted file mode 100644
index 0d96c07..0000000
--- a/m4/ax_cxx_compile_stdcxx_11.m4
+++ /dev/null
@@ -1,107 +0,0 @@
-# ============================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
-# ============================================================================
-#
-# SYNOPSIS
-#
-# AX_CXX_COMPILE_STDCXX_11([ext|noext])
-#
-# DESCRIPTION
-#
-# Check for baseline language coverage in the compiler for the C++11
-# standard; if necessary, add switches to CXXFLAGS to enable support.
-# Errors out if no mode that supports C++11 baseline syntax can be found.
-# The argument, if specified, indicates whether you insist on an extended
-# mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. -std=c++11).
-# If neither is specified, you get whatever works, with preference for an
-# extended mode.
-#
-# LICENSE
-#
-# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
-# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved. This file is offered as-is, without any
-# warranty.
-
-#serial 1
-
-m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
- template <typename T>
- struct check
- {
- static_assert(sizeof(int) <= sizeof(T), "not big enough");
- };
-
- typedef check<check<bool>> right_angle_brackets;
-
- int a;
- decltype(a) b;
-
- typedef check<int> check_type;
- check_type c;
- check_type&& cr = static_cast<check_type&&>(c);
-])
-
-AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
- m4_if([$1], [], [],
- [$1], [ext], [],
- [$1], [noext], [],
- [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
- AC_LANG_ASSERT([C++])dnl
- ac_success=no
- AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
- ax_cv_cxx_compile_cxx11,
- [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
- [ax_cv_cxx_compile_cxx11=yes],
- [ax_cv_cxx_compile_cxx11=no])])
- if test x$ax_cv_cxx_compile_cxx11 = xyes; then
- ac_success=yes
- fi
-
- m4_if([$1], [noext], [], [dnl
- if test x$ac_success = xno; then
- for switch in -std=gnu++11 -std=gnu++0x; do
- cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
- AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
- $cachevar,
- [ac_save_CXXFLAGS="$CXXFLAGS"
- CXXFLAGS="$CXXFLAGS $switch"
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
- [eval $cachevar=yes],
- [eval $cachevar=no])
- CXXFLAGS="$ac_save_CXXFLAGS"])
- if eval test x\$$cachevar = xyes; then
- CXXFLAGS="$CXXFLAGS $switch"
- ac_success=yes
- break
- fi
- done
- fi])
-
- m4_if([$1], [ext], [], [dnl
- if test x$ac_success = xno; then
- for switch in -std=c++11 -std=c++0x; do
- cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
- AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
- $cachevar,
- [ac_save_CXXFLAGS="$CXXFLAGS"
- CXXFLAGS="$CXXFLAGS $switch"
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
- [eval $cachevar=yes],
- [eval $cachevar=no])
- CXXFLAGS="$ac_save_CXXFLAGS"])
- if eval test x\$$cachevar = xyes; then
- CXXFLAGS="$CXXFLAGS $switch"
- ac_success=yes
- break
- fi
- done
- fi])
-
- if test x$ac_success = xno; then
- AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
- fi
-])
diff --git a/m4/ax_prog_doxygen.m4 b/m4/ax_prog_doxygen.m4
deleted file mode 100644
index 44b22b0..0000000
--- a/m4/ax_prog_doxygen.m4
+++ /dev/null
@@ -1,532 +0,0 @@
-# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_prog_doxygen.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# DX_INIT_DOXYGEN(PROJECT-NAME, DOXYFILE-PATH, [OUTPUT-DIR])
-# DX_DOXYGEN_FEATURE(ON|OFF)
-# DX_DOT_FEATURE(ON|OFF)
-# DX_HTML_FEATURE(ON|OFF)
-# DX_CHM_FEATURE(ON|OFF)
-# DX_CHI_FEATURE(ON|OFF)
-# DX_MAN_FEATURE(ON|OFF)
-# DX_RTF_FEATURE(ON|OFF)
-# DX_XML_FEATURE(ON|OFF)
-# DX_PDF_FEATURE(ON|OFF)
-# DX_PS_FEATURE(ON|OFF)
-#
-# DESCRIPTION
-#
-# The DX_*_FEATURE macros control the default setting for the given
-# Doxygen feature. Supported features are 'DOXYGEN' itself, 'DOT' for
-# generating graphics, 'HTML' for plain HTML, 'CHM' for compressed HTML
-# help (for MS users), 'CHI' for generating a seperate .chi file by the
-# .chm file, and 'MAN', 'RTF', 'XML', 'PDF' and 'PS' for the appropriate
-# output formats. The environment variable DOXYGEN_PAPER_SIZE may be
-# specified to override the default 'a4wide' paper size.
-#
-# By default, HTML, PDF and PS documentation is generated as this seems to
-# be the most popular and portable combination. MAN pages created by
-# Doxygen are usually problematic, though by picking an appropriate subset
-# and doing some massaging they might be better than nothing. CHM and RTF
-# are specific for MS (note that you can't generate both HTML and CHM at
-# the same time). The XML is rather useless unless you apply specialized
-# post-processing to it.
-#
-# The macros mainly control the default state of the feature. The use can
-# override the default by specifying --enable or --disable. The macros
-# ensure that contradictory flags are not given (e.g.,
-# --enable-doxygen-html and --enable-doxygen-chm,
-# --enable-doxygen-anything with --disable-doxygen, etc.) Finally, each
-# feature will be automatically disabled (with a warning) if the required
-# programs are missing.
-#
-# Once all the feature defaults have been specified, call DX_INIT_DOXYGEN
-# with the following parameters: a one-word name for the project for use
-# as a filename base etc., an optional configuration file name (the
-# default is 'Doxyfile', the same as Doxygen's default), and an optional
-# output directory name (the default is 'doxygen-doc').
-#
-# Automake Support
-#
-# The following is a template aminclude.am file for use with Automake.
-# Make targets and variables values are controlled by the various
-# DX_COND_* conditionals set by autoconf.
-#
-# The provided targets are:
-#
-# doxygen-doc: Generate all doxygen documentation.
-#
-# doxygen-run: Run doxygen, which will generate some of the
-# documentation (HTML, CHM, CHI, MAN, RTF, XML)
-# but will not do the post processing required
-# for the rest of it (PS, PDF, and some MAN).
-#
-# doxygen-man: Rename some doxygen generated man pages.
-#
-# doxygen-ps: Generate doxygen PostScript documentation.
-#
-# doxygen-pdf: Generate doxygen PDF documentation.
-#
-# Note that by default these are not integrated into the automake targets.
-# If doxygen is used to generate man pages, you can achieve this
-# integration by setting man3_MANS to the list of man pages generated and
-# then adding the dependency:
-#
-# $(man3_MANS): doxygen-doc
-#
-# This will cause make to run doxygen and generate all the documentation.
-#
-# The following variable is intended for use in Makefile.am:
-#
-# DX_CLEANFILES = everything to clean.
-#
-# Then add this variable to MOSTLYCLEANFILES.
-#
-# ----- begin aminclude.am -------------------------------------
-#
-# ## --------------------------------- ##
-# ## Format-independent Doxygen rules. ##
-# ## --------------------------------- ##
-#
-# if DX_COND_doc
-#
-# ## ------------------------------- ##
-# ## Rules specific for HTML output. ##
-# ## ------------------------------- ##
-#
-# if DX_COND_html
-#
-# DX_CLEAN_HTML = @DX_DOCDIR@/html
-#
-# endif DX_COND_html
-#
-# ## ------------------------------ ##
-# ## Rules specific for CHM output. ##
-# ## ------------------------------ ##
-#
-# if DX_COND_chm
-#
-# DX_CLEAN_CHM = @DX_DOCDIR@/chm
-#
-# if DX_COND_chi
-#
-# DX_CLEAN_CHI = @DX_DOCDIR@/@PACKAGE@.chi
-#
-# endif DX_COND_chi
-#
-# endif DX_COND_chm
-#
-# ## ------------------------------ ##
-# ## Rules specific for MAN output. ##
-# ## ------------------------------ ##
-#
-# if DX_COND_man
-#
-# DX_CLEAN_MAN = @DX_DOCDIR@/man
-#
-# endif DX_COND_man
-#
-# ## ------------------------------ ##
-# ## Rules specific for RTF output. ##
-# ## ------------------------------ ##
-#
-# if DX_COND_rtf
-#
-# DX_CLEAN_RTF = @DX_DOCDIR@/rtf
-#
-# endif DX_COND_rtf
-#
-# ## ------------------------------ ##
-# ## Rules specific for XML output. ##
-# ## ------------------------------ ##
-#
-# if DX_COND_xml
-#
-# DX_CLEAN_XML = @DX_DOCDIR@/xml
-#
-# endif DX_COND_xml
-#
-# ## ----------------------------- ##
-# ## Rules specific for PS output. ##
-# ## ----------------------------- ##
-#
-# if DX_COND_ps
-#
-# DX_CLEAN_PS = @DX_DOCDIR@/@PACKAGE@.ps
-#
-# DX_PS_GOAL = doxygen-ps
-#
-# doxygen-ps: @DX_DOCDIR@/@PACKAGE@.ps
-#
-# @DX_DOCDIR@/@PACKAGE@.ps: @DX_DOCDIR@/@PACKAGE@.tag
-# cd @DX_DOCDIR@/latex; \
-# rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \
-# $(DX_LATEX) refman.tex; \
-# $(MAKEINDEX_PATH) refman.idx; \
-# $(DX_LATEX) refman.tex; \
-# countdown=5; \
-# while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \
-# refman.log > /dev/null 2>&1 \
-# && test $$countdown -gt 0; do \
-# $(DX_LATEX) refman.tex; \
-# countdown=`expr $$countdown - 1`; \
-# done; \
-# $(DX_DVIPS) -o ../@PACKAGE@.ps refman.dvi
-#
-# endif DX_COND_ps
-#
-# ## ------------------------------ ##
-# ## Rules specific for PDF output. ##
-# ## ------------------------------ ##
-#
-# if DX_COND_pdf
-#
-# DX_CLEAN_PDF = @DX_DOCDIR@/@PACKAGE@.pdf
-#
-# DX_PDF_GOAL = doxygen-pdf
-#
-# doxygen-pdf: @DX_DOCDIR@/@PACKAGE@.pdf
-#
-# @DX_DOCDIR@/@PACKAGE@.pdf: @DX_DOCDIR@/@PACKAGE@.tag
-# cd @DX_DOCDIR@/latex; \
-# rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \
-# $(DX_PDFLATEX) refman.tex; \
-# $(DX_MAKEINDEX) refman.idx; \
-# $(DX_PDFLATEX) refman.tex; \
-# countdown=5; \
-# while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \
-# refman.log > /dev/null 2>&1 \
-# && test $$countdown -gt 0; do \
-# $(DX_PDFLATEX) refman.tex; \
-# countdown=`expr $$countdown - 1`; \
-# done; \
-# mv refman.pdf ../@PACKAGE@.pdf
-#
-# endif DX_COND_pdf
-#
-# ## ------------------------------------------------- ##
-# ## Rules specific for LaTeX (shared for PS and PDF). ##
-# ## ------------------------------------------------- ##
-#
-# if DX_COND_latex
-#
-# DX_CLEAN_LATEX = @DX_DOCDIR@/latex
-#
-# endif DX_COND_latex
-#
-# .PHONY: doxygen-run doxygen-doc $(DX_PS_GOAL) $(DX_PDF_GOAL)
-#
-# .INTERMEDIATE: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL)
-#
-# doxygen-run: @DX_DOCDIR@/@PACKAGE@.tag
-#
-# doxygen-doc: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL)
-#
-# @DX_DOCDIR@/@PACKAGE@.tag: $(DX_CONFIG) $(pkginclude_HEADERS)
-# rm -rf @DX_DOCDIR@
-# $(DX_ENV) $(DX_DOXYGEN) $(srcdir)/$(DX_CONFIG)
-#
-# DX_CLEANFILES = \
-# @DX_DOCDIR@/@PACKAGE@.tag \
-# -r \
-# $(DX_CLEAN_HTML) \
-# $(DX_CLEAN_CHM) \
-# $(DX_CLEAN_CHI) \
-# $(DX_CLEAN_MAN) \
-# $(DX_CLEAN_RTF) \
-# $(DX_CLEAN_XML) \
-# $(DX_CLEAN_PS) \
-# $(DX_CLEAN_PDF) \
-# $(DX_CLEAN_LATEX)
-#
-# endif DX_COND_doc
-#
-# ----- end aminclude.am ---------------------------------------
-#
-# LICENSE
-#
-# Copyright (c) 2009 Oren Ben-Kiki <oren@ben-kiki.org>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved. This file is offered as-is, without any
-# warranty.
-
-#serial 12
-
-## ----------##
-## Defaults. ##
-## ----------##
-
-DX_ENV=""
-AC_DEFUN([DX_FEATURE_doc], ON)
-AC_DEFUN([DX_FEATURE_dot], OFF)
-AC_DEFUN([DX_FEATURE_man], OFF)
-AC_DEFUN([DX_FEATURE_html], ON)
-AC_DEFUN([DX_FEATURE_chm], OFF)
-AC_DEFUN([DX_FEATURE_chi], OFF)
-AC_DEFUN([DX_FEATURE_rtf], OFF)
-AC_DEFUN([DX_FEATURE_xml], OFF)
-AC_DEFUN([DX_FEATURE_pdf], ON)
-AC_DEFUN([DX_FEATURE_ps], ON)
-
-## --------------- ##
-## Private macros. ##
-## --------------- ##
-
-# DX_ENV_APPEND(VARIABLE, VALUE)
-# ------------------------------
-# Append VARIABLE="VALUE" to DX_ENV for invoking doxygen.
-AC_DEFUN([DX_ENV_APPEND], [AC_SUBST([DX_ENV], ["$DX_ENV $1='$2'"])])
-
-# DX_DIRNAME_EXPR
-# ---------------
-# Expand into a shell expression prints the directory part of a path.
-AC_DEFUN([DX_DIRNAME_EXPR],
- [[expr ".$1" : '\(\.\)[^/]*$' \| "x$1" : 'x\(.*\)/[^/]*$']])
-
-# DX_IF_FEATURE(FEATURE, IF-ON, IF-OFF)
-# -------------------------------------
-# Expands according to the M4 (static) status of the feature.
-AC_DEFUN([DX_IF_FEATURE], [ifelse(DX_FEATURE_$1, ON, [$2], [$3])])
-
-# DX_REQUIRE_PROG(VARIABLE, PROGRAM)
-# ----------------------------------
-# Require the specified program to be found for the DX_CURRENT_FEATURE to work.
-AC_DEFUN([DX_REQUIRE_PROG], [
-AC_PATH_TOOL([$1], [$2])
-if test "$DX_FLAG_[]DX_CURRENT_FEATURE$$1" = 1; then
- AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION])
- AC_SUBST(DX_FLAG_[]DX_CURRENT_FEATURE, 0)
-fi
-])
-
-# DX_TEST_FEATURE(FEATURE)
-# ------------------------
-# Expand to a shell expression testing whether the feature is active.
-AC_DEFUN([DX_TEST_FEATURE], [test "$DX_FLAG_$1" = 1])
-
-# DX_CHECK_DEPEND(REQUIRED_FEATURE, REQUIRED_STATE)
-# -------------------------------------------------
-# Verify that a required features has the right state before trying to turn on
-# the DX_CURRENT_FEATURE.
-AC_DEFUN([DX_CHECK_DEPEND], [
-test "$DX_FLAG_$1" = "$2" \
-|| AC_MSG_ERROR([doxygen-DX_CURRENT_FEATURE ifelse([$2], 1,
- requires, contradicts) doxygen-DX_CURRENT_FEATURE])
-])
-
-# DX_CLEAR_DEPEND(FEATURE, REQUIRED_FEATURE, REQUIRED_STATE)
-# ----------------------------------------------------------
-# Turn off the DX_CURRENT_FEATURE if the required feature is off.
-AC_DEFUN([DX_CLEAR_DEPEND], [
-test "$DX_FLAG_$1" = "$2" || AC_SUBST(DX_FLAG_[]DX_CURRENT_FEATURE, 0)
-])
-
-# DX_FEATURE_ARG(FEATURE, DESCRIPTION,
-# CHECK_DEPEND, CLEAR_DEPEND,
-# REQUIRE, DO-IF-ON, DO-IF-OFF)
-# --------------------------------------------
-# Parse the command-line option controlling a feature. CHECK_DEPEND is called
-# if the user explicitly turns the feature on (and invokes DX_CHECK_DEPEND),
-# otherwise CLEAR_DEPEND is called to turn off the default state if a required
-# feature is disabled (using DX_CLEAR_DEPEND). REQUIRE performs additional
-# requirement tests (DX_REQUIRE_PROG). Finally, an automake flag is set and
-# DO-IF-ON or DO-IF-OFF are called according to the final state of the feature.
-AC_DEFUN([DX_ARG_ABLE], [
- AC_DEFUN([DX_CURRENT_FEATURE], [$1])
- AC_DEFUN([DX_CURRENT_DESCRIPTION], [$2])
- AC_ARG_ENABLE(doxygen-$1,
- [AS_HELP_STRING(DX_IF_FEATURE([$1], [--disable-doxygen-$1],
- [--enable-doxygen-$1]),
- DX_IF_FEATURE([$1], [don't $2], [$2]))],
- [
-case "$enableval" in
-#(
-y|Y|yes|Yes|YES)
- AC_SUBST([DX_FLAG_$1], 1)
- $3
-;; #(
-n|N|no|No|NO)
- AC_SUBST([DX_FLAG_$1], 0)
-;; #(
-*)
- AC_MSG_ERROR([invalid value '$enableval' given to doxygen-$1])
-;;
-esac
-], [
-AC_SUBST([DX_FLAG_$1], [DX_IF_FEATURE([$1], 1, 0)])
-$4
-])
-if DX_TEST_FEATURE([$1]); then
- $5
- :
-fi
-AM_CONDITIONAL(DX_COND_$1, DX_TEST_FEATURE([$1]))
-if DX_TEST_FEATURE([$1]); then
- $6
- :
-else
- $7
- :
-fi
-])
-
-## -------------- ##
-## Public macros. ##
-## -------------- ##
-
-# DX_XXX_FEATURE(DEFAULT_STATE)
-# -----------------------------
-AC_DEFUN([DX_DOXYGEN_FEATURE], [AC_DEFUN([DX_FEATURE_doc], [$1])])
-AC_DEFUN([DX_DOT_FEATURE], [AC_DEFUN([DX_FEATURE_dot], [$1])])
-AC_DEFUN([DX_MAN_FEATURE], [AC_DEFUN([DX_FEATURE_man], [$1])])
-AC_DEFUN([DX_HTML_FEATURE], [AC_DEFUN([DX_FEATURE_html], [$1])])
-AC_DEFUN([DX_CHM_FEATURE], [AC_DEFUN([DX_FEATURE_chm], [$1])])
-AC_DEFUN([DX_CHI_FEATURE], [AC_DEFUN([DX_FEATURE_chi], [$1])])
-AC_DEFUN([DX_RTF_FEATURE], [AC_DEFUN([DX_FEATURE_rtf], [$1])])
-AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])])
-AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])])
-AC_DEFUN([DX_PDF_FEATURE], [AC_DEFUN([DX_FEATURE_pdf], [$1])])
-AC_DEFUN([DX_PS_FEATURE], [AC_DEFUN([DX_FEATURE_ps], [$1])])
-
-# DX_INIT_DOXYGEN(PROJECT, [CONFIG-FILE], [OUTPUT-DOC-DIR])
-# ---------------------------------------------------------
-# PROJECT also serves as the base name for the documentation files.
-# The default CONFIG-FILE is "Doxyfile" and OUTPUT-DOC-DIR is "doxygen-doc".
-AC_DEFUN([DX_INIT_DOXYGEN], [
-
-# Files:
-AC_SUBST([DX_PROJECT], [$1])
-AC_SUBST([DX_CONFIG], [ifelse([$2], [], Doxyfile, [$2])])
-AC_SUBST([DX_DOCDIR], [ifelse([$3], [], doxygen-doc, [$3])])
-
-# Environment variables used inside doxygen.cfg:
-DX_ENV_APPEND(SRCDIR, $srcdir)
-DX_ENV_APPEND(PROJECT, $DX_PROJECT)
-DX_ENV_APPEND(DOCDIR, $DX_DOCDIR)
-DX_ENV_APPEND(VERSION, $PACKAGE_VERSION)
-
-# Doxygen itself:
-DX_ARG_ABLE(doc, [generate any doxygen documentation],
- [],
- [],
- [DX_REQUIRE_PROG([DX_DOXYGEN], doxygen)
- DX_REQUIRE_PROG([DX_PERL], perl)],
- [DX_ENV_APPEND(PERL_PATH, $DX_PERL)])
-
-# Dot for graphics:
-DX_ARG_ABLE(dot, [generate graphics for doxygen documentation],
- [DX_CHECK_DEPEND(doc, 1)],
- [DX_CLEAR_DEPEND(doc, 1)],
- [DX_REQUIRE_PROG([DX_DOT], dot)],
- [DX_ENV_APPEND(HAVE_DOT, YES)
- DX_ENV_APPEND(DOT_PATH, [`DX_DIRNAME_EXPR($DX_DOT)`])],
- [DX_ENV_APPEND(HAVE_DOT, NO)])
-
-# Man pages generation:
-DX_ARG_ABLE(man, [generate doxygen manual pages],
- [DX_CHECK_DEPEND(doc, 1)],
- [DX_CLEAR_DEPEND(doc, 1)],
- [],
- [DX_ENV_APPEND(GENERATE_MAN, YES)],
- [DX_ENV_APPEND(GENERATE_MAN, NO)])
-
-# RTF file generation:
-DX_ARG_ABLE(rtf, [generate doxygen RTF documentation],
- [DX_CHECK_DEPEND(doc, 1)],
- [DX_CLEAR_DEPEND(doc, 1)],
- [],
- [DX_ENV_APPEND(GENERATE_RTF, YES)],
- [DX_ENV_APPEND(GENERATE_RTF, NO)])
-
-# XML file generation:
-DX_ARG_ABLE(xml, [generate doxygen XML documentation],
- [DX_CHECK_DEPEND(doc, 1)],
- [DX_CLEAR_DEPEND(doc, 1)],
- [],
- [DX_ENV_APPEND(GENERATE_XML, YES)],
- [DX_ENV_APPEND(GENERATE_XML, NO)])
-
-# (Compressed) HTML help generation:
-DX_ARG_ABLE(chm, [generate doxygen compressed HTML help documentation],
- [DX_CHECK_DEPEND(doc, 1)],
- [DX_CLEAR_DEPEND(doc, 1)],
- [DX_REQUIRE_PROG([DX_HHC], hhc)],
- [DX_ENV_APPEND(HHC_PATH, $DX_HHC)
- DX_ENV_APPEND(GENERATE_HTML, YES)
- DX_ENV_APPEND(GENERATE_HTMLHELP, YES)],
- [DX_ENV_APPEND(GENERATE_HTMLHELP, NO)])
-
-# Seperate CHI file generation.
-DX_ARG_ABLE(chi, [generate doxygen seperate compressed HTML help index file],
- [DX_CHECK_DEPEND(chm, 1)],
- [DX_CLEAR_DEPEND(chm, 1)],
- [],
- [DX_ENV_APPEND(GENERATE_CHI, YES)],
- [DX_ENV_APPEND(GENERATE_CHI, NO)])
-
-# Plain HTML pages generation:
-DX_ARG_ABLE(html, [generate doxygen plain HTML documentation],
- [DX_CHECK_DEPEND(doc, 1) DX_CHECK_DEPEND(chm, 0)],
- [DX_CLEAR_DEPEND(doc, 1) DX_CLEAR_DEPEND(chm, 0)],
- [],
- [DX_ENV_APPEND(GENERATE_HTML, YES)],
- [DX_TEST_FEATURE(chm) || DX_ENV_APPEND(GENERATE_HTML, NO)])
-
-# PostScript file generation:
-DX_ARG_ABLE(ps, [generate doxygen PostScript documentation],
- [DX_CHECK_DEPEND(doc, 1)],
- [DX_CLEAR_DEPEND(doc, 1)],
- [DX_REQUIRE_PROG([DX_LATEX], latex)
- DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex)
- DX_REQUIRE_PROG([DX_DVIPS], dvips)
- DX_REQUIRE_PROG([DX_EGREP], egrep)])
-
-# PDF file generation:
-DX_ARG_ABLE(pdf, [generate doxygen PDF documentation],
- [DX_CHECK_DEPEND(doc, 1)],
- [DX_CLEAR_DEPEND(doc, 1)],
- [DX_REQUIRE_PROG([DX_PDFLATEX], pdflatex)
- DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex)
- DX_REQUIRE_PROG([DX_EGREP], egrep)])
-
-# LaTeX generation for PS and/or PDF:
-AM_CONDITIONAL(DX_COND_latex, DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf))
-if DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf); then
- DX_ENV_APPEND(GENERATE_LATEX, YES)
-else
- DX_ENV_APPEND(GENERATE_LATEX, NO)
-fi
-
-# Paper size for PS and/or PDF:
-AC_ARG_VAR(DOXYGEN_PAPER_SIZE,
- [a4wide (default), a4, letter, legal or executive])
-case "$DOXYGEN_PAPER_SIZE" in
-#(
-"")
- AC_SUBST(DOXYGEN_PAPER_SIZE, "")
-;; #(
-a4wide|a4|letter|legal|executive)
- DX_ENV_APPEND(PAPER_SIZE, $DOXYGEN_PAPER_SIZE)
-;; #(
-*)
- AC_MSG_ERROR([unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE'])
-;;
-esac
-
-#For debugging:
-#echo DX_FLAG_doc=$DX_FLAG_doc
-#echo DX_FLAG_dot=$DX_FLAG_dot
-#echo DX_FLAG_man=$DX_FLAG_man
-#echo DX_FLAG_html=$DX_FLAG_html
-#echo DX_FLAG_chm=$DX_FLAG_chm
-#echo DX_FLAG_chi=$DX_FLAG_chi
-#echo DX_FLAG_rtf=$DX_FLAG_rtf
-#echo DX_FLAG_xml=$DX_FLAG_xml
-#echo DX_FLAG_pdf=$DX_FLAG_pdf
-#echo DX_FLAG_ps=$DX_FLAG_ps
-#echo DX_ENV=$DX_ENV
-])
diff --git a/src/CommonAPI/Address.cpp b/src/CommonAPI/Address.cpp
new file mode 100644
index 0000000..2315a9c
--- /dev/null
+++ b/src/CommonAPI/Address.cpp
@@ -0,0 +1,122 @@
+// 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 <sstream>
+
+#include <CommonAPI/Address.hpp>
+
+namespace CommonAPI {
+
+Address::Address(const std::string &_address) {
+ // TODO: handle error situation (_address is no valid CommonAPI address)
+ setAddress(_address);
+}
+
+Address::Address(const std::string &_domain,
+ const std::string &_interface,
+ const std::string &_instance)
+ : domain_(_domain),
+ interface_(_interface),
+ instance_(_instance) {
+}
+
+Address::Address(const Address &_source)
+ : domain_(_source.domain_),
+ interface_(_source.interface_),
+ instance_(_source.instance_) {
+}
+
+Address::~Address() {
+}
+
+bool
+Address::operator ==(const Address &_other) const {
+ return (domain_ == _other.domain_ &&
+ interface_ == _other.interface_ &&
+ instance_ == _other.instance_);
+}
+
+bool
+Address::operator !=(const Address &_other) const {
+ return (domain_ != _other.domain_ ||
+ interface_ != _other.interface_ ||
+ instance_ != _other.instance_);
+}
+
+bool
+Address::operator<(const Address &_other) const {
+ if (domain_ < _other.domain_)
+ return true;
+
+ if (domain_ == _other.domain_) {
+ if (interface_ < _other.interface_)
+ return true;
+
+ if (interface_ == _other.interface_) {
+ if (instance_ < _other.instance_)
+ return true;
+ }
+ }
+
+ return false;
+}
+
+std::string
+Address::getAddress() const {
+ return (domain_ + ":" + interface_ + ":" + instance_);
+}
+
+void
+Address::setAddress(const std::string &_address) {
+ std::istringstream addressStream(_address);
+ if (std::getline(addressStream, domain_, ':')) {
+ if (std::getline(addressStream, interface_, ':')) {
+ if(!std::getline(addressStream, instance_, ':')) {
+ if(std::getline(addressStream, instance_)) {
+ }
+ }
+ }
+ }
+}
+
+const std::string &
+Address::getDomain() const {
+ return domain_;
+}
+
+void
+Address::setDomain(const std::string &_domain) {
+ domain_ = _domain;
+}
+
+const std::string &
+Address::getInterface() const {
+ return interface_;
+}
+
+void
+Address::setInterface(const std::string &_interface) {
+ interface_ = _interface;
+}
+
+const std::string &
+Address::getInstance() const {
+ return instance_;
+}
+
+void
+Address::setInstance(const std::string &_instance) {
+ instance_ = _instance;
+}
+
+std::ostream &
+operator<<(std::ostream &_out, const Address &_address) {
+ _out << _address.domain_
+ << ":" << _address.interface_
+ << ":" << _address.instance_;
+ return _out;
+}
+
+} // namespace CommonAPI
diff --git a/src/CommonAPI/ByteBuffer.h b/src/CommonAPI/ByteBuffer.h
deleted file mode 100644
index e92b157..0000000
--- a/src/CommonAPI/ByteBuffer.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright (C) 2013 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/. */
-#ifndef COMMONAPI_BYTE_BUFFER_H_
-#define COMMONAPI_BYTE_BUFFER_H_
-
-#include <vector>
-#include <cstdint>
-
-namespace CommonAPI {
-
-typedef std::vector<uint8_t> ByteBuffer;
-
-} // namespace CommonAPI
-
-#endif // COMMONAPI_BYTE_BUFFER_H_
diff --git a/src/CommonAPI/CommonAPI.h b/src/CommonAPI/CommonAPI.h
deleted file mode 100644
index 27c0767..0000000
--- a/src/CommonAPI/CommonAPI.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#ifndef COMMONAPI_H_
-#define COMMONAPI_H_
-
-
-#ifndef COMMONAPI_INTERNAL_COMPILATION
-#define COMMONAPI_INTERNAL_COMPILATION
-#endif
-
-#include "Runtime.h"
-#include "Factory.h"
-#include "AttributeExtension.h"
-#include "ByteBuffer.h"
-#include "types.h"
-
-#undef COMMONAPI_INTERNAL_COMPILATION
-
-
-#endif /* COMMONAPI_H_ */
diff --git a/src/CommonAPI/Configuration.cpp b/src/CommonAPI/Configuration.cpp
deleted file mode 100644
index d15a75a..0000000
--- a/src/CommonAPI/Configuration.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/* Copyright (C) 2013 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 <fstream>
-
-#include "Configuration.h"
-#include "utils.h"
-
-
-namespace CommonAPI {
-
-std::unordered_map<std::string, std::string> knownMiddlewareAliases_;
-std::unordered_map<std::string, std::string> knownMiddlewarePaths_;
-std::unordered_map<std::string, std::vector<std::string> > knownGeneratedPaths_;
-std::vector<std::string> librarySearchPaths_;
-std::string defaultBindingIdentifier_ = "";
-
-
-const Configuration& Configuration::getInstance() {
- static Configuration* instance = NULL;
- if (!instance) {
- instance = new Configuration();
- instance->retrieveCommonApiConfiguration();
- }
- return *instance;
-}
-
-const std::vector<std::string>& Configuration::getLibrarySearchPaths() const {
- return librarySearchPaths_;
-}
-
-const std::string& Configuration::getMiddlewareNameForAlias(const std::string& alias) const {
- auto foundMiddlewareName = knownMiddlewareAliases_.find(alias);
- if (foundMiddlewareName != knownMiddlewareAliases_.end()) {
- return foundMiddlewareName->second;
- } else {
- return alias;
- }
-}
-
-const std::string& Configuration::getMiddlewareLibraryPath(const std::string& middlewareIdentifier) const {
- auto foundMiddlewarePath = knownMiddlewarePaths_.find(middlewareIdentifier);
- if (foundMiddlewarePath == knownMiddlewarePaths_.end()) {
- static const std::string emptyReturn = "";
- return emptyReturn;
- }
- return foundMiddlewarePath->second;
-}
-
-const std::vector<std::string>& Configuration::getGenericLibraryPaths(const std::string& middlewareIdentifier) const {
- const auto& generatedPathsForMiddleware = knownGeneratedPaths_.find(middlewareIdentifier);
- if (generatedPathsForMiddleware != knownGeneratedPaths_.end()) {
- return generatedPathsForMiddleware->second;
- }
- static const std::vector<std::string> emptyReturn;
- return emptyReturn;
-}
-
-const std::string& Configuration::getDefaultMiddlewareIdentifier() const {
- return defaultBindingIdentifier_;
-}
-
-void Configuration::readConfigFile(std::ifstream& addressConfigFile) {
- std::string currentlyParsedBindingIdentifier = "";
-
- std::string readLine;
-
- while (addressConfigFile.good()) {
- getline(addressConfigFile, readLine);
- const size_t readLineLength = readLine.length();
-
- if (strncmp(readLine.c_str(), CATEGORY_IDENTIFIER_BINDING, strlen(CATEGORY_IDENTIFIER_BINDING)) == 0
- && readLine[readLineLength - 1] == CATEGORY_ENDING) {
-
- std::string newBindingIdentifier = readLine.substr(
- strlen(CATEGORY_IDENTIFIER_BINDING),
- readLineLength - (strlen(CATEGORY_IDENTIFIER_BINDING) + 1));
-
- trim(newBindingIdentifier);
- if (containsOnlyAlphanumericCharacters(newBindingIdentifier)) {
- currentlyParsedBindingIdentifier = newBindingIdentifier;
- }
-
- } else if (currentlyParsedBindingIdentifier != "") {
- std::vector<std::string> parameterElements = split(readLine, '=');
- if (parameterElements.size() == 2) {
-
- if (parameterElements.at(0) == BINDING_PARAMETER_ALIAS) {
- std::vector<std::string> aliases = split(parameterElements.at(1), ':');
- for (const std::string& singleAlias: aliases) {
- knownMiddlewareAliases_.insert( {singleAlias, currentlyParsedBindingIdentifier});
- }
-
- } else if (parameterElements.at(0) == BINDING_PARAMETER_LIBPATH) {
- knownMiddlewarePaths_.insert( {currentlyParsedBindingIdentifier, parameterElements.at(1)});
-
- } else if (parameterElements.at(0) == BINDING_PARAMETER_GENPATH) {
- std::vector<std::string> paths = split(parameterElements.at(1), ':');
- auto alreadyKnownPaths = knownGeneratedPaths_.find(currentlyParsedBindingIdentifier);
-
- if (alreadyKnownPaths == knownGeneratedPaths_.end()) {
- const std::vector<std::string> pathSet(paths.begin(), paths.end());
- knownGeneratedPaths_.insert( {currentlyParsedBindingIdentifier, std::move(pathSet)} );
- } else {
- alreadyKnownPaths->second.insert(alreadyKnownPaths->second.end(), paths.begin(), paths.end());
- }
- }
-
- } else if (parameterElements.size() == 1) {
- if (parameterElements.at(0) == BINDING_PARAMETER_DEFAULT && defaultBindingIdentifier_ == "") {
- defaultBindingIdentifier_ = currentlyParsedBindingIdentifier;
- }
- }
- }
- }
-}
-
-
-void Configuration::readEnvironmentVariables() {
- librarySearchPaths_ = split(COMMONAPI_STD_LIB_PATH, ':');
-
- bool errorOccured = false;
-#ifdef WIN32
- char* environmentBindingPath;
- size_t len;
- errno_t err = _dupenv_s(&environmentBindingPath, &len, COMMONAPI_ENVIRONMENT_BINDING_PATH);
- if (err != 0 || environmentBindingPath == NULL) {
- errorOccured = true;
- }
-#else
- const char* environmentBindingPath = getenv(COMMONAPI_ENVIRONMENT_BINDING_PATH);
- if (!environmentBindingPath) {
- errorOccured = true;
- }
-#endif
-
- if (!errorOccured) {
- std::vector<std::string> environmentPaths = split(environmentBindingPath, ':');
- librarySearchPaths_.insert(librarySearchPaths_.begin(), environmentPaths.begin(), environmentPaths.end());
- }
-}
-
-
-void Configuration::retrieveCommonApiConfiguration() {
- readEnvironmentVariables();
-
- std::string fqnOfConfigFile = getCurrentBinaryFileFQN();
- fqnOfConfigFile += COMMONAPI_CONFIG_SUFFIX;
-
- std::ifstream commonapiConfigFile;
- commonapiConfigFile.open(fqnOfConfigFile.c_str());
-
- if (commonapiConfigFile.is_open()) {
- readConfigFile(commonapiConfigFile);
- commonapiConfigFile.close();
- }
-
- commonapiConfigFile.clear();
- std::vector<std::string> splittedConfigFQN = split(fqnOfConfigFile, '/');
- std::string globalConfigFQN = COMMONAPI_GLOBAL_CONFIG_ROOT + splittedConfigFQN.at(splittedConfigFQN.size() - 1);
- commonapiConfigFile.open(globalConfigFQN);
- if (commonapiConfigFile.is_open()) {
- readConfigFile(commonapiConfigFile);
- commonapiConfigFile.close();
- }
- commonapiConfigFile.clear();
-
- commonapiConfigFile.open(COMMONAPI_GLOBAL_CONFIG_FQN);
- if (commonapiConfigFile.is_open()) {
- readConfigFile(commonapiConfigFile);
- commonapiConfigFile.close();
- }
-}
-
-
-} // namespace CommonAPI
diff --git a/src/CommonAPI/Configuration.h b/src/CommonAPI/Configuration.h
deleted file mode 100644
index 554518e..0000000
--- a/src/CommonAPI/Configuration.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#ifndef COMMONAPI_CONFIGURATION_H_
-#define COMMONAPI_CONFIGURATION_H_
-
-
-#include <unordered_map>
-#include <vector>
-#include <string>
-#include <cstring>
-
-
-namespace CommonAPI {
-
-
-static const char COMMONAPI_CONFIG_SUFFIX[] = ".conf";
-static const char COMMONAPI_GLOBAL_CONFIG_ROOT[] = "/etc/CommonAPI/";
-static const char COMMONAPI_GLOBAL_CONFIG_FQN[] = "/etc/CommonAPI/CommonAPI.conf";
-
-static const char COMMONAPI_STD_LIB_PATH[] = "/usr/lib:/usr/local/lib/";
-static const char COMMONAPI_ENVIRONMENT_BINDING_PATH[] = "COMMONAPI_BINDING_PATH";
-
-static const char CATEGORY_ENDING = '}';
-
-static const char CATEGORY_IDENTIFIER_BINDING[] = "{binding:";
-
-static const char BINDING_PARAMETER_ALIAS[] = "alias";
-static const char BINDING_PARAMETER_LIBPATH[] = "libpath";
-static const char BINDING_PARAMETER_GENPATH[] = "genpath";
-static const char BINDING_PARAMETER_DEFAULT[] = "default";
-
-
-/**
- * Represents the contents of all parsed CommonAPI Configuration files.
- *
- * For more information on how to configure CommonAPI, see attached documentation.
- */
-class Configuration {
- public:
- /**
- * Returns the instance of the Configuration.
- *
- * When first calling this method, all configuration files that are found are parsed and
- * the values are stored within this class.
- *
- * @return The singleton instance of the CommonAPI Configuration.
- */
- static const Configuration& getInstance();
-
- Configuration(const Configuration&) = delete;
- Configuration& operator=(const Configuration&) = delete;
- Configuration(Configuration&&) = delete;
- Configuration& operator=(Configuration&&) = delete;
-
- /**
- * Returns the search paths on which binding specific libraries may be found.
- *
- * Default search paths are /usr/lib and /usr/local/lib, those two will always be returned.
- * If additional search paths have been configured, those will also be returned.
- *
- * @return
- */
- const std::vector<std::string>& getLibrarySearchPaths() const;
-
- /**
- * Returns the actual middleware identifier for the given alias.
- *
- * If no such alias has been configured, the given alias itself will be returned.
- *
- * @return The middleware identifier or the given alias itself, if no mapping to a middleware identifier was found.
- */
- const std::string& getMiddlewareNameForAlias(const std::string& alias) const;
-
- /**
- * Returns the specified library path for the given middleware identifier.
- *
- * If a path to a specific library has been configured for the given middleware identifier, this path will be returned.
- * If no such path has been configured, the empty string will be returned.
- *
- * @return The path to the middleware library, if any is known, the empty string "" otherwise.
- */
- const std::string& getMiddlewareLibraryPath(const std::string& middlewareIdentifier) const;
-
- /**
- * Returns the paths to other generic libraries configured for a specific binding.
- *
- * This function is meant to be called by middleware libraries. Will return all configured paths to
- * generic libraries. You likely wil want to use the utility functions provided in <CommonAPI/utils.h>
- * to do the loading. To arrange and time the loading is responsibility of the middleware only.
- *
- * @return A vector containing all generic libraries associated with the given middlewareIdentifier.
- */
- const std::vector<std::string>& getGenericLibraryPaths(const std::string& middlewareIdentifier) const;
-
- /**
- * Returns the configured default middleware identifier.
- *
- * If no default has been configured, the empty string "" will be returned.
- *
- * @return The configured default middleware identifier.
- */
- const std::string& getDefaultMiddlewareIdentifier() const;
-
- private:
- Configuration() = default;
-
- void readConfigFile(std::ifstream& addressConfigFile);
- void retrieveCommonApiConfiguration();
- void readEnvironmentVariables();
-};
-
-
-
-} // namespace CommonAPI
-
-#endif /* COMMONAPI_CONFIGURATION_H_ */
diff --git a/src/CommonAPI/ContainerUtils.cpp b/src/CommonAPI/ContainerUtils.cpp
index 08fe2bc..887ac91 100644
--- a/src/CommonAPI/ContainerUtils.cpp
+++ b/src/CommonAPI/ContainerUtils.cpp
@@ -1,12 +1,10 @@
-/* Copyright (C) 2013 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/. */
+// Copyright (C) 2014-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 "ContainerUtils.h"
-#include "types.h"
+#include <CommonAPI/ContainerUtils.hpp>
+#include <CommonAPI/Types.hpp>
namespace CommonAPI {
@@ -26,4 +24,4 @@ bool SharedPointerClientIdContentEqual::operator()(const std::shared_ptr<ClientI
}
}
-} // namespace std
+} // namespace std
diff --git a/src/CommonAPI/ContainerUtils.h b/src/CommonAPI/ContainerUtils.h
deleted file mode 100644
index a4423ab..0000000
--- a/src/CommonAPI/ContainerUtils.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#if !defined (COMMONAPI_INTERNAL_COMPILATION)
-#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef FUNCTIONALHASH_H_
-#define FUNCTIONALHASH_H_
-
-#include <functional>
-#include <memory>
-
-namespace CommonAPI {
-class ClientId;
-
-struct SharedPointerClientIdContentHash : public std::unary_function<std::shared_ptr<ClientId>, size_t> {
- size_t operator()(const std::shared_ptr<ClientId>& t) const;
-};
-
-struct SharedPointerClientIdContentEqual : public std::binary_function<std::shared_ptr<ClientId>, std::shared_ptr<ClientId>, bool> {
- bool operator()(const std::shared_ptr<ClientId>& a, const std::shared_ptr<ClientId>& b) const;
-};
-
-
-} // namespace std
-
-
-#endif /* FUNCTIONALHASH_H_ */
diff --git a/src/CommonAPI/Event.h b/src/CommonAPI/Event.h
deleted file mode 100644
index 3d059b2..0000000
--- a/src/CommonAPI/Event.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#if !defined (COMMONAPI_INTERNAL_COMPILATION)
-#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef COMMONAPI_EVENT_H_
-#define COMMONAPI_EVENT_H_
-
-#include <functional>
-#include <list>
-#include <tuple>
-#include <mutex>
-
-namespace CommonAPI {
-
-enum class SubscriptionStatus {
- RETAIN,
- CANCEL
-};
-
-/**
- * \brief Class representing an event
- *
- * Class representing an event
- */
-template<typename ... _Arguments>
-class Event {
-public:
- typedef std::tuple<_Arguments...> ArgumentsTuple;
- typedef std::function<void(const _Arguments&...)> Listener;
- typedef std::function<SubscriptionStatus(const _Arguments&...)> CancellableListener;
- typedef std::list<CancellableListener> ListenersList;
- typedef typename ListenersList::iterator Subscription;
-
- class CancellableListenerWrapper;
-
- /**
- * \brief Subscribe a listener to this event
- *
- * Subscribe a listener to this event.
- * ATTENTION: You should not build new proxies or register services in callbacks
- * from events. This can cause a deadlock or assert. Instead, you should set a
- * trigger for your application to do this on the next iteration of your event loop
- * if needed. The preferred solution is to build all proxies you need at the
- * beginning and react to events appropriatly for each.
- *
- * @param listener A listener to be added
- * @return A token identifying this subscription
- */
- virtual Subscription subscribe(Listener listener);
-
- /**
- * \brief Subscribe a cancellable listener to this event
- *
- * Subscribe a cancellable listener to this event
- * ATTENTION: You should not build new proxies or register services in callbacks
- * from events. This can cause a deadlock or assert. Instead, you should set a
- * trigger for your application to do this on the next iteration of your event loop
- * if needed. The preferred solution is to build all proxies you need at the
- * beginning and react to events appropriatly for each.
- *
- * @param listener A cancellable listener to be added
- * @return A token identifying this subscription
- */
- Subscription subscribeCancellableListener(CancellableListener listener);
-
- /**
- * \brief Remove a listener from this event
- *
- * Remove a listener from this event
- * Note: Do not call this inside a listener notification callback it will deadlock! Use cancellable listeners instead.
- *
- * @param listenerSubscription A listener token to be removed
- * @return true, if the removed subscription was the last one
- */
- void unsubscribe(Subscription listenerSubscription);
-
- virtual ~Event() {
- }
-
-protected:
- // Returns false if all subscriptions were cancelled
- // Does not send *Removed events!
- SubscriptionStatus notifyListeners(const _Arguments&... eventArguments);
-
- // Events sent during subscribe()
- virtual void onFirstListenerAdded(const CancellableListener& listener) {
- }
- virtual void onListenerAdded(const CancellableListener& listener) {
- }
-
- // Events sent during unsubscribe()
- virtual void onListenerRemoved(const CancellableListener& listener) { }
- virtual void onLastListenerRemoved(const CancellableListener& listener) { }
-
- inline bool hasListeners() const;
-
-//private:
- ListenersList listenersList_;
- std::mutex listenerListMutex_;
-};
-
-template<typename ... _Arguments>
-class Event<_Arguments...>::CancellableListenerWrapper {
-public:
- CancellableListenerWrapper(Listener&& listener) :
- listener_(std::move(listener)) {
- }
-
- SubscriptionStatus operator()(const _Arguments&... eventArguments) {
- listener_(eventArguments...);
- return SubscriptionStatus::RETAIN;
- }
-
-private:
- Listener listener_;
-};
-
-template<typename ... _Arguments>
-typename Event<_Arguments...>::Subscription Event<_Arguments...>::subscribe(Listener listener) {
- return subscribeCancellableListener(CancellableListenerWrapper(std::move(listener)));
-}
-
-template<typename ... _Arguments>
-typename Event<_Arguments...>::Subscription Event<_Arguments...>::subscribeCancellableListener(CancellableListener listener) {
- listenerListMutex_.lock();
- const bool firstListenerAdded = listenersList_.empty();
-
- listenersList_.emplace_front(std::move(listener));
- Subscription listenerSubscription = listenersList_.begin();
- listenerListMutex_.unlock();
-
- if (firstListenerAdded) {
- onFirstListenerAdded(*listenerSubscription);
- }
-
- onListenerAdded(*listenerSubscription);
-
- return listenerSubscription;
-}
-
-template<typename ... _Arguments>
-void Event<_Arguments...>::unsubscribe(Subscription listenerSubscription) {
- const CancellableListener cancellableListener = *listenerSubscription;
-
- listenerListMutex_.lock();
- listenersList_.erase(listenerSubscription);
- const bool lastListenerRemoved = listenersList_.empty();
- listenerListMutex_.unlock();
-
- onListenerRemoved(cancellableListener);
-
- if (lastListenerRemoved) {
- onLastListenerRemoved(cancellableListener);
- }
-}
-
-template<typename ... _Arguments>
-SubscriptionStatus Event<_Arguments...>::notifyListeners(const _Arguments&... eventArguments) {
- listenerListMutex_.lock();
- for (auto iterator = listenersList_.begin(); iterator != listenersList_.end();) {
- const CancellableListener& cancellableListener = *iterator;
- const SubscriptionStatus listenerSubscriptionStatus = cancellableListener(eventArguments...);
-
- if (listenerSubscriptionStatus == SubscriptionStatus::CANCEL) {
- auto listenerIterator = iterator;
- iterator++;
- listenersList_.erase(listenerIterator);
- } else
- iterator++;
- }
-
- const bool lEmpty = listenersList_.empty();
-
- listenerListMutex_.unlock();
-
- return lEmpty ? SubscriptionStatus::CANCEL : SubscriptionStatus::RETAIN;
-}
-
-template<typename ... _Arguments>
-bool Event<_Arguments...>::hasListeners() const {
- return !listenersList_.empty();
-}
-
-} // namespace CommonAPI
-
-#endif // COMMONAPI_EVENT_H_
diff --git a/src/CommonAPI/Factory.cpp b/src/CommonAPI/Factory.cpp
deleted file mode 100644
index bc1d696..0000000
--- a/src/CommonAPI/Factory.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright (C) 2013 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 "Factory.h"
-
-namespace CommonAPI {
-
-std::shared_ptr<Runtime> Factory::getRuntime() {
- return runtime_;
-}
-
-} // namespace CommonAPI
diff --git a/src/CommonAPI/Factory.h b/src/CommonAPI/Factory.h
deleted file mode 100644
index 3760953..0000000
--- a/src/CommonAPI/Factory.h
+++ /dev/null
@@ -1,369 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#if !defined (COMMONAPI_INTERNAL_COMPILATION)
-#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef COMMONAPI_FACTORY_H_
-#define COMMONAPI_FACTORY_H_
-
-#include <cassert>
-#include <memory>
-#include <sstream>
-#include <string>
-#include <unordered_map>
-#include <vector>
-
-#include "MiddlewareInfo.h"
-#include "Proxy.h"
-#include "Stub.h"
-#include "types.h"
-#include "utils.h"
-#include "AttributeExtension.h"
-
-
-namespace CommonAPI {
-
-
-class Factory;
-class ServicePublisher;
-
-
-template<template<typename ...> class _ProxyType, template<typename> class _AttributeExtension>
-struct DefaultAttributeProxyFactoryHelper;
-
-
-template<template<typename ...> class _ProxyClass, template<typename> class _AttributeExtension>
-std::shared_ptr<typename DefaultAttributeProxyFactoryHelper<_ProxyClass, _AttributeExtension>::class_t> createProxyWithDefaultAttributeExtension(Factory* specificFactory, const std::string& participantId, const std::string& domain);
-
-
-/**
- * \brief The main CommonAPI access class. A factory is responsible for creation and destruction of service objects.
- *
- * The main CommonAPI access class. A factory is responsible for creation and destruction of service objects.
- * This includes proxies and stubs. It also provides service discovery methods.
- */
-class Factory {
- public:
- typedef std::function<void(std::vector<std::string>&) > GetAvailableServiceInstancesCallback;
- typedef std::function<void(bool)> IsServiceInstanceAliveCallback;
-
-
- /**
- * \brief Creates factory. Don't call manually.
- *
- * Creates factory. Don't call manually.
- */
- Factory(const std::shared_ptr<Runtime> runtime,
- const MiddlewareInfo* middlewareInfo):
- runtime_(runtime),
- middlewareInfo_(middlewareInfo) {
- }
-
- /**
- * \brief Creates factory. Don't call manually.
- *
- * Creates factory. Don't call manually.
- */
- Factory(const std::shared_ptr<Runtime> runtime,
- const MiddlewareInfo* middlewareInfo,
- const std::string factoryName,
- const bool nullOnInvalidName) :
- runtime_(runtime),
- middlewareInfo_(middlewareInfo) {
- }
-
- virtual ~Factory() {}
-
- /**
- * \brief Build a proxy for the specified address
- *
- * Build a proxy for the specified address.
- * Template this method call for the desired proxy type and attribute extension.
- *
- * @param participantId The participant ID of the common API address (last part)
- * @param serviceName The service name of the common API address (middle part)
- * @param domain The domain of the common API address (first part)
- * @return a shared pointer to the constructed proxy
- */
- template<template<typename ...> class _ProxyClass, typename ... _AttributeExtensions>
- std::shared_ptr<
- _ProxyClass<
-#ifdef WIN32
- CommonAPI::WINDummyAttributeExtension<WINDummyAttribute>,
-#endif
- _AttributeExtensions...>
- >
- buildProxy(const std::string& participantId,
- const std::string& serviceName,
- const std::string& domain) {
- std::shared_ptr<Proxy> abstractMiddlewareProxy = createProxy(_ProxyClass<_AttributeExtensions...>::getInterfaceId(), participantId, serviceName, domain);
-
- if(abstractMiddlewareProxy) {
- auto returnProxy = std::make_shared<
- _ProxyClass<
-#ifdef WIN32
- CommonAPI::WINDummyAttributeExtension<WINDummyAttribute>,
-#endif
- _AttributeExtensions...>
- >(abstractMiddlewareProxy);
-
- return returnProxy;
- }
- else {
- return NULL;
- }
- }
-
- /**
- * \brief Build a proxy for the specified address
- *
- * Build a proxy for the specified address.
- * Template this method call for the desired proxy type and attribute extensions.
- *
- * @param serviceAddress The common API address
- * @return a shared pointer to the constructed proxy
- */
- template<template<typename ...> class _ProxyClass, typename ... _AttributeExtensions >
- std::shared_ptr<
- _ProxyClass<
-#ifdef WIN32
- CommonAPI::WINDummyAttributeExtension<WINDummyAttribute>,
-#endif
- _AttributeExtensions...>
- >
- buildProxy(const std::string& serviceAddress) {
- std::string domain;
- std::string serviceName;
- std::string participantId;
- if (!splitValidAddress(serviceAddress, domain, serviceName, participantId)) {
- return false;
- }
-
- return buildProxy<_ProxyClass, _AttributeExtensions...>(participantId, serviceName, domain);
- }
-
- /**
- * \brief Build a proxy for the specified address with one extension for all attributes
- *
- * Build a proxy for the specified address with one extension for all attributes
- * Template this method call for the desired proxy type and attribute extensions.
- *
- * @param participantId The participant ID of the common API address (last part)
- * @param serviceName The service name of the common API address (middle part)
- * @param domain The domain of the common API address (first part)
- * @return a shared pointer to the constructed proxy
- */
- template <template<typename ...> class _ProxyClass, template<typename> class _AttributeExtension>
- std::shared_ptr<typename DefaultAttributeProxyFactoryHelper<_ProxyClass, _AttributeExtension>::class_t>
- buildProxyWithDefaultAttributeExtension(const std::string& participantId,
- const std::string& serviceName,
- const std::string& domain);
-
- /**
- * \brief Build a proxy for the specified address with one extension for all attributes
- *
- * Build a proxy for the specified address with one extension for all attributes
- * Template this method call for the desired proxy type attribute extension.
- *
- * @param serviceAddress The common API address
- * @return a shared pointer to the constructed proxy
- */
- template <template<typename ...> class _ProxyClass, template<typename> class _AttributeExtension>
- std::shared_ptr<typename DefaultAttributeProxyFactoryHelper<_ProxyClass, _AttributeExtension>::class_t>
- buildProxyWithDefaultAttributeExtension(const std::string& serviceAddress);
-
- /**
- * \brief Get a pointer to the runtime of this factory.
- *
- * Get a pointer to the runtime of this factory.
- *
- * @return the Runtime
- */
- std::shared_ptr<Runtime> getRuntime();
-
- /**
- * \brief Register a service stub under a specified address
- *
- * Register a service stub under a specified address. The service will be registered
- * with the ServicePublisher that is provided by the runtime which you also retrieved
- * this factory from. It is recommended to use the ServicePublisher for registering
- * and unregistering purposes.
- *
- * @param stub The stub pointer
- * @param participantId The participant ID of the common API address (last part)
- * @param serviceName The service name of the common API address (middle part)
- * @param domain The domain of the common API address (first part)
- * @return Was the registration successful
- *
- * @deprecated Use CommonAPI::Runtime->getServicePublisher()->registerService() instead.
- * Purpose for this change is to make service management (esp. deregistering) independent
- * from factory instances.
- */
- template<typename _Stub>
- COMMONAPI_DEPRECATED bool registerService(std::shared_ptr<_Stub> stub,
- const std::string& participantId,
- const std::string& serviceName,
- const std::string& domain);
-
- /**
- * \brief Register a service stub under a specified address
- *
- * Register a service stub under a specified address. The service will be registered
- * with the ServicePublisher that is provided by the runtime which you also retrieved
- * this factory from. It is recommended to use the ServicePublisher for registering
- * and unregistering purposes.
- *
- * @param stub The stub pointer
- * @param serviceAddress The common API address
- * @return Was the registration successful
- *
- * @deprecated Use CommonAPI::Runtime->getServicePublisher()->registerService() instead.
- * Purpose for this change is to make service management (esp. deregistering) independent
- * from factory instances.
- */
- template<typename _Stub>
- COMMONAPI_DEPRECATED bool registerService(std::shared_ptr<_Stub> stub, const std::string& serviceAddress);
-
- /**
- * \brief Unregister a service stub associated with a specified address
- *
- * Unregister a service stub associated with a specified address.
- *
- * @param participantId The participant ID of the common API address (last part)
- * @param serviceName The service name of the common API address (middle part)
- * @param domain The domain of the common API address (first part)
- * @return Was the deregistration successful
- *
- * @deprecated Use CommonAPI::Runtime->getServicePublisher()->unregisterService() instead.
- * Purpose for this change is to make service management (esp. deregistering) independent
- * from factory instances.
- */
- COMMONAPI_DEPRECATED virtual bool unregisterService(const std::string& participantId, const std::string& serviceName, const std::string& domain) = 0;
-
- /**
- * \brief Unregister a service stub associated with a specified address
- *
- * Unregister a service stub associated with a specified address
- *
- * @param serviceAddress The common API address
- * @return Was the deregistration successful
- *
- * @deprecated Use CommonAPI::Runtime->getServicePublisher()->unregisterService() instead.
- * Purpose for this change is to make service management (esp. deregistering) independent
- * from factory instances.
- */
- COMMONAPI_DEPRECATED bool unregisterService(const std::string& serviceAddress);
-
- /**
- * \brief Get all instances of a specific service name available. Synchronous call.
- *
- * Get all instances of a specific service name available. Synchronous call.
- *
- * @param serviceName The service name of the common API address (middle part)
- * @param serviceDomainName The domain of the common API address (first part)
- * @return A vector of strings containing the available complete common api addresses.
- */
- virtual std::vector<std::string> getAvailableServiceInstances(const std::string& serviceName, const std::string& serviceDomainName = "local") = 0;
-
- /**
- * \brief Is a particular complete common api address available. Synchronous call.
- *
- * Is a particular complete common api address available. Synchronous call.
- *
- * @param serviceAddress The common API address
- * @return Is alive
- */
- virtual bool isServiceInstanceAlive(const std::string& serviceAddress) = 0;
-
- /**
- * \brief Is a particular complete common api address available. Synchronous call.
- *
- * Is a particular complete common api address available. Synchronous call.
- *
- * @param serviceInstanceID The participant ID of the common API address (last part)
- * @param serviceName The service name of the common API address (middle part)
- * @param serviceDomainName The domain of the common API address (first part)
- * @return Is alive
- */
- virtual bool isServiceInstanceAlive(const std::string& serviceInstanceID, const std::string& serviceName, const std::string& serviceDomainName = "local") = 0;
-
- /**
- * \brief Get all instances of a specific service name available. Asynchronous call.
- *
- * Get all instances of a specific service name available. Asynchronous call.
- *
- * @param serviceName The service name of the common API address (middle part)
- * @param serviceDomainName The domain of the common API address (first part)
- */
- virtual void getAvailableServiceInstancesAsync(GetAvailableServiceInstancesCallback callback, const std::string& serviceName, const std::string& serviceDomainName = "local") = 0;
-
- /**
- * \brief Tells whether a particular service instance is available. Asynchronous call.
- *
- * Tells whether a particular service instance is available. Asynchronous call.
- *
- * @param serviceAddress The common API address of the service
- */
- virtual void isServiceInstanceAliveAsync(IsServiceInstanceAliveCallback callback, const std::string& serviceAddress) = 0;
-
- /**
- * \brief Tells whether a particular service instance is available. Asynchronous call.
- *
- * Tells whether a particular service instance is available. Asynchronous call.
- *
- * @param serviceInstanceID The participant ID of the common API address (last part) of the service
- * @param serviceName The service name of the common API address (middle part) of the service
- * @param serviceDomainName The domain of the common API address (first part) of the service
- */
- virtual void isServiceInstanceAliveAsync(IsServiceInstanceAliveCallback callback, const std::string& serviceInstanceID, const std::string& serviceName, const std::string& serviceDomainName = "local") = 0;
-
- protected:
- virtual std::shared_ptr<Proxy> createProxy(const char* interfaceId, const std::string& participantId, const std::string& serviceName, const std::string& domain) = 0;
-
- /**
- * @deprecated Use CommonAPI::ServicePublisher::registerService() instead.
- */
- COMMONAPI_DEPRECATED virtual bool registerAdapter(std::shared_ptr<StubBase> stubBase,
- const char* interfaceId,
- const std::string& participantId,
- const std::string& serviceName,
- const std::string& domain) {
- return false;
- }
- std::shared_ptr<Runtime> runtime_;
- private:
-
- const MiddlewareInfo* middlewareInfo_;
-
- inline bool splitValidAddress(const std::string& serviceAddress, std::string& domain, std::string& serviceName, std::string& participantId) {
- std::istringstream addressStream(serviceAddress);
- if(!std::getline(addressStream, domain, ':')) {
- return false;
- }
- if(!std::getline(addressStream, serviceName, ':')) {
- return false;
- }
- if(!std::getline(addressStream, participantId, ':')) {
- return false;
- }
- if(std::getline(addressStream, participantId)) {
- return false;
- }
- return true;
- }
-
- friend class ServicePublisher;
-};
-
-
-} // namespace CommonAPI
-
-#include "Factory.hpp"
-
-#endif // COMMONAPI_FACTORY_H_
diff --git a/src/CommonAPI/Factory.hpp b/src/CommonAPI/Factory.hpp
deleted file mode 100644
index 0804996..0000000
--- a/src/CommonAPI/Factory.hpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Copyright (C) 2013 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/. */
-#ifndef COMMONAPI_FACTORY_IMPL_H_
-#define COMMONAPI_FACTORY_IMPL_H_
-
-#include "Runtime.h"
-#include "ServicePublisher.h"
-
-namespace CommonAPI {
-
-template <template<typename ...> class _ProxyClass, template<typename> class _AttributeExtension>
-std::shared_ptr<typename DefaultAttributeProxyFactoryHelper<_ProxyClass, _AttributeExtension>::class_t>
-Factory::buildProxyWithDefaultAttributeExtension(const std::string& participantId,
- const std::string& serviceName,
- const std::string& domain) {
-
- std::shared_ptr<Proxy> abstractMiddlewareProxy = createProxy(DefaultAttributeProxyFactoryHelper<_ProxyClass, _AttributeExtension>::class_t::getInterfaceId(), participantId, serviceName, domain);
- if (abstractMiddlewareProxy) {
- return std::make_shared<typename DefaultAttributeProxyFactoryHelper<_ProxyClass, _AttributeExtension>::class_t>(abstractMiddlewareProxy);
- }
- return NULL;
-}
-
-template <template<typename ...> class _ProxyClass, template<typename> class _AttributeExtension>
-std::shared_ptr<typename DefaultAttributeProxyFactoryHelper<_ProxyClass, _AttributeExtension>::class_t>
-Factory::buildProxyWithDefaultAttributeExtension(const std::string& serviceAddress) {
-
- std::string domain;
- std::string serviceName;
- std::string participantId;
- if(!splitValidAddress(serviceAddress, domain, serviceName, participantId)) {
- return std::shared_ptr<typename DefaultAttributeProxyFactoryHelper<_ProxyClass, _AttributeExtension>::class_t>();
- }
-
- return buildProxyWithDefaultAttributeExtension<_ProxyClass, _AttributeExtension>(participantId, serviceName, domain);
-}
-
-template<typename _Stub>
-COMMONAPI_DEPRECATED bool Factory::registerService(std::shared_ptr<_Stub> stub,
- const std::string& participantId,
- const std::string& serviceName,
- const std::string& domain) {
-
- std::shared_ptr<StubBase> stubBase = std::dynamic_pointer_cast<StubBase>(stub);
- return registerAdapter(stubBase, _Stub::StubAdapterType::getInterfaceId(), participantId, serviceName, domain);
-}
-
-template<typename _Stub>
-COMMONAPI_DEPRECATED bool Factory::registerService(std::shared_ptr<_Stub> stub, const std::string& serviceAddress) {
- std::string domain;
- std::string serviceName;
- std::string participantId;
- if(!splitValidAddress(serviceAddress, domain, serviceName, participantId)) {
- return false;
- }
-
- std::shared_ptr<StubBase> stubBase = std::dynamic_pointer_cast<StubBase>(stub);
- return registerAdapter(stubBase, _Stub::StubAdapterType::getInterfaceId(), participantId, serviceName, domain);
-}
-
-COMMONAPI_DEPRECATED inline bool Factory::unregisterService(const std::string& serviceAddress) {
- return runtime_->getServicePublisher()->unregisterService(serviceAddress);
-}
-
-} //namespace CommonAPI
-
-#endif // COMMONAPI_FACTORY_IMPL_H_
diff --git a/src/CommonAPI/IniFileReader.cpp b/src/CommonAPI/IniFileReader.cpp
new file mode 100644
index 0000000..1637591
--- /dev/null
+++ b/src/CommonAPI/IniFileReader.cpp
@@ -0,0 +1,114 @@
+// 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 <fstream>
+#include <sstream>
+
+#include <CommonAPI/IniFileReader.hpp>
+#include <CommonAPI/Logger.hpp>
+#include <CommonAPI/Utils.hpp>
+
+namespace CommonAPI {
+
+const std::map<std::string, std::string> &
+IniFileReader::Section::getMappings() const {
+ return mappings_;
+}
+
+std::string
+IniFileReader::Section::getValue(const std::string &_key) const {
+ auto it = mappings_.find(_key);
+ if (it != mappings_.end()) {
+ return it->second;
+ }
+ return ("");
+}
+
+bool
+IniFileReader::load(const std::string &_path) {
+ std::ifstream configStream(_path);
+ if (configStream.is_open()) {
+ COMMONAPI_INFO("Loading ini file from ", _path);
+
+ int lineCounter(0);
+ std::string currentSectionName;
+ std::shared_ptr<Section> currentSection;
+
+ while (!configStream.eof()) {
+ std::string line;
+ std::getline(configStream, line);
+ lineCounter++;
+
+ trim(line);
+
+ std::size_t start = line.find('[');
+ if (start == 0) {
+ std::size_t end = line.find(']');
+ if (end != line.npos) {
+ currentSectionName = line.substr(++start, --end);
+ if (sections_.end() == sections_.find(currentSectionName)) {
+ currentSection = std::make_shared<Section>();
+ if (currentSection) {
+ sections_[currentSectionName] = currentSection;
+ }
+ } else {
+ COMMONAPI_ERROR("Double definition of section \'",
+ currentSectionName,
+ "\' ignoring definition (line ",
+ lineCounter,
+ ")");
+ currentSection = nullptr;
+ }
+ } else {
+ COMMONAPI_ERROR("Missing \']\' in section definition (line ",
+ lineCounter, ")");
+ }
+ } else if (currentSection) {
+ std::size_t pos = line.find('=');
+ if (pos != line.npos) {
+ std::string key = line.substr(0, pos);
+ trim(key);
+ if (currentSection->mappings_.end()
+ != currentSection->mappings_.find(key)) {
+ COMMONAPI_ERROR("Double definition for key \'",
+ key,
+ "'\' in section \'",
+ currentSectionName,
+ "\' (line ",
+ lineCounter,
+ ")");
+ } else {
+ std::string value = line.substr(pos+1);
+ trim(value);
+ currentSection->mappings_[key] = value;
+ }
+ } else if (line.size() > 0) {
+ COMMONAPI_ERROR("Missing \'=\' in key=value definition (line ",
+ lineCounter, ")");
+ }
+ }
+ }
+ }
+ return true;
+}
+
+const std::map<std::string, std::shared_ptr<IniFileReader::Section>> &
+IniFileReader::getSections() const {
+ return sections_;
+}
+
+std::shared_ptr<IniFileReader::Section>
+IniFileReader::getSection(const std::string &_name) const {
+ std::shared_ptr<IniFileReader::Section> section;
+
+ auto sectionIterator = sections_.find(_name);
+ if (sectionIterator != sections_.end()) {
+ section = sectionIterator->second;
+ }
+
+ return section;
+}
+
+} // namespace CommonAPI
diff --git a/src/CommonAPI/InputStream.cpp b/src/CommonAPI/InputStream.cpp
deleted file mode 100644
index 42dbec8..0000000
--- a/src/CommonAPI/InputStream.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Copyright (C) 2013 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 "InputStream.h"
-
-namespace CommonAPI {
-
-InputStream& operator>>(InputStream& inputStream, bool& boolValue) {
- return inputStream.readValue(boolValue);
-}
-
-InputStream& operator>>(InputStream& inputStream, int8_t& int8Value) {
- return inputStream.readValue(int8Value);
-}
-
-InputStream& operator>>(InputStream& inputStream, int16_t& int16Value) {
- return inputStream.readValue(int16Value);
-}
-
-InputStream& operator>>(InputStream& inputStream, int32_t& int32Value) {
- return inputStream.readValue(int32Value);
-}
-
-InputStream& operator>>(InputStream& inputStream, int64_t& int64Value) {
- return inputStream.readValue(int64Value);
-}
-
-InputStream& operator>>(InputStream& inputStream, uint8_t& uint8Value) {
- return inputStream.readValue(uint8Value);
-}
-
-InputStream& operator>>(InputStream& inputStream, uint16_t& uint16Value) {
- return inputStream.readValue(uint16Value);
-}
-
-InputStream& operator>>(InputStream& inputStream, uint32_t& uint32Value) {
- return inputStream.readValue(uint32Value);
-}
-
-InputStream& operator>>(InputStream& inputStream, uint64_t& uint64Value) {
- return inputStream.readValue(uint64Value);
-}
-
-InputStream& operator>>(InputStream& inputStream, float& floatValue) {
- return inputStream.readValue(floatValue);
-}
-
-InputStream& operator>>(InputStream& inputStream, double& doubleValue) {
- return inputStream.readValue(doubleValue);
-}
-
-InputStream& operator>>(InputStream& inputStream, std::string& stringValue) {
- return inputStream.readValue(stringValue);
-}
-
-InputStream& operator>>(InputStream& inputStream, Version& versionValue) {
- return inputStream.readVersionValue(versionValue);
-}
-
-InputStream& operator>>(InputStream& inputStream, SerializableStruct& serializableStruct) {
- inputStream.beginReadSerializableStruct(serializableStruct);
- serializableStruct.readFromInputStream(inputStream);
- inputStream.endReadSerializableStruct(serializableStruct);
-
- return inputStream;
-}
-
-InputStream& operator>>(InputStream& inputStream, SerializableVariant& serializableVariant) {
- inputStream.readSerializableVariant(serializableVariant);
- return inputStream;
-}
-
-}
diff --git a/src/CommonAPI/InputStream.h b/src/CommonAPI/InputStream.h
deleted file mode 100644
index 786a991..0000000
--- a/src/CommonAPI/InputStream.h
+++ /dev/null
@@ -1,341 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#if !defined (COMMONAPI_INTERNAL_COMPILATION)
-#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef COMMONAPI_INPUT_STREAM_H_
-#define COMMONAPI_INPUT_STREAM_H_
-
-#include "ByteBuffer.h"
-#include "SerializableStruct.h"
-#include "SerializableVariant.h"
-#include "types.h"
-
-#include <cstdint>
-#include <functional>
-#include <memory>
-#include <string>
-#include <unordered_map>
-#include <vector>
-#include <type_traits>
-
-namespace CommonAPI {
-
-class InputStream {
-public:
- virtual ~InputStream() {}
- virtual bool hasError() const = 0;
-
- virtual InputStream& readValue(bool& boolValue) = 0;
-
- virtual InputStream& readValue(int8_t& int8Value) = 0;
- virtual InputStream& readValue(int16_t& int16Value) = 0;
- virtual InputStream& readValue(int32_t& int32Value) = 0;
- virtual InputStream& readValue(int64_t& int64Value) = 0;
-
- virtual InputStream& readValue(uint8_t& uint8Value) = 0;
- virtual InputStream& readValue(uint16_t& uint16Value) = 0;
- virtual InputStream& readValue(uint32_t& uint32Value) = 0;
- virtual InputStream& readValue(uint64_t& uint64Value) = 0;
-
- virtual InputStream& readValue(float& floatValue) = 0;
- virtual InputStream& readValue(double& doubleValue) = 0;
-
- virtual InputStream& readValue(std::string& stringValue) = 0;
-
- virtual InputStream& readValue(ByteBuffer& byteBufferValue) = 0;
-
- virtual InputStream& readEnumValue(int8_t& int8BackingTypeValue) = 0;
- virtual InputStream& readEnumValue(int16_t& int16BackingTypeValue) = 0;
- virtual InputStream& readEnumValue(int32_t& int32BackingTypeValue) = 0;
- virtual InputStream& readEnumValue(int64_t& int64BackingTypeValue) = 0;
- virtual InputStream& readEnumValue(uint8_t& uint8BackingTypeValue) = 0;
- virtual InputStream& readEnumValue(uint16_t& uint16BackingTypeValue) = 0;
- virtual InputStream& readEnumValue(uint32_t& uint32BackingTypeValue) = 0;
- virtual InputStream& readEnumValue(uint64_t& uint64BackingTypeValue) = 0;
-
- template<typename _EnumBackingType, typename _EnumType>
- InputStream& readEnumValue(_EnumType& enumValue);
-
- virtual InputStream& readVersionValue(Version& versionValue) = 0;
-
- virtual void beginReadSerializableStruct(const SerializableStruct& serializableStruct) = 0;
- virtual void endReadSerializableStruct(const SerializableStruct& serializableStruct) = 0;
-
- virtual void beginReadSerializablePolymorphicStruct(uint32_t& serialId) = 0;
- virtual void endReadSerializablePolymorphicStruct(const uint32_t& serialId) = 0;
-
- virtual void readSerializableVariant(SerializableVariant& serializableVariant) = 0;
-
- virtual char* readRawData(const size_t numBytesToRead) = 0;
-
- virtual void beginReadBoolVector() = 0;
- virtual void beginReadInt8Vector() = 0;
- virtual void beginReadInt16Vector() = 0;
- virtual void beginReadInt32Vector() = 0;
- virtual void beginReadInt64Vector() = 0;
- virtual void beginReadUInt8Vector() = 0;
- virtual void beginReadUInt16Vector() = 0;
- virtual void beginReadUInt32Vector() = 0;
- virtual void beginReadUInt64Vector() = 0;
- virtual void beginReadFloatVector() = 0;
- virtual void beginReadDoubleVector() = 0;
- virtual void beginReadStringVector() = 0;
- virtual void beginReadByteBufferVector() = 0;
- virtual void beginReadVersionVector() = 0;
-
- virtual void beginReadInt8EnumVector() = 0;
- virtual void beginReadInt16EnumVector() = 0;
- virtual void beginReadInt32EnumVector() = 0;
- virtual void beginReadInt64EnumVector() = 0;
- virtual void beginReadUInt8EnumVector() = 0;
- virtual void beginReadUInt16EnumVector() = 0;
- virtual void beginReadUInt32EnumVector() = 0;
- virtual void beginReadUInt64EnumVector() = 0;
-
- virtual void beginReadVectorOfSerializableStructs() = 0;
- virtual void beginReadVectorOfSerializableVariants() = 0;
- virtual void beginReadVectorOfVectors() = 0;
- virtual void beginReadVectorOfMaps() = 0;
-
- virtual void beginReadVectorOfSerializablePolymorphicStructs() = 0;
-
- virtual bool hasMoreVectorElements() = 0;
- virtual void endReadVector() = 0;
-
- virtual void beginReadMap() = 0;
- virtual bool hasMoreMapElements() = 0;
- virtual void endReadMap() = 0;
- virtual void beginReadMapElement() = 0;
- virtual void endReadMapElement() = 0;
-};
-
-template<typename _EnumBackingType, typename _EnumType>
-InputStream& InputStream::readEnumValue(_EnumType& enumValue) {
- _EnumBackingType enumBackingValue;
-
- readEnumValue(enumBackingValue);
- enumValue = static_cast<_EnumType>(enumBackingValue);
-
- return *this;
-}
-
-InputStream& operator>>(InputStream& inputStream, bool& boolValue);
-
-InputStream& operator>>(InputStream& inputStream, int8_t& int8Value);
-
-InputStream& operator>>(InputStream& inputStream, int16_t& int16Value);
-
-InputStream& operator>>(InputStream& inputStream, int32_t& int32Value);
-
-InputStream& operator>>(InputStream& inputStream, int64_t& int64Value);
-
-InputStream& operator>>(InputStream& inputStream, uint8_t& uint8Value);
-
-InputStream& operator>>(InputStream& inputStream, uint16_t& uint16Value);
-
-InputStream& operator>>(InputStream& inputStream, uint32_t& uint32Value);
-
-InputStream& operator>>(InputStream& inputStream, uint64_t& uint64Value);
-
-InputStream& operator>>(InputStream& inputStream, float& floatValue);
-
-InputStream& operator>>(InputStream& inputStream, double& doubleValue);
-
-InputStream& operator>>(InputStream& inputStream, std::string& stringValue);
-
-InputStream& operator>>(InputStream& inputStream, Version& versionValue);
-
-InputStream& operator>>(InputStream& inputStream, SerializableStruct& serializableStruct);
-
-template<typename _SerializablePolymorphicStructType>
-typename std::enable_if<std::is_base_of<SerializablePolymorphicStruct, _SerializablePolymorphicStructType>::value,
- InputStream>::type&
-operator>>(InputStream& inputStream,
- std::shared_ptr<_SerializablePolymorphicStructType>& serializablePolymorphicStruct) {
- uint32_t serialId;
-
- inputStream.beginReadSerializablePolymorphicStruct(serialId);
- if (!inputStream.hasError()) {
- _SerializablePolymorphicStructType* instancePtr = _SerializablePolymorphicStructType::createInstance(serialId);
- serializablePolymorphicStruct.reset(instancePtr);
- if (instancePtr != NULL) {
- instancePtr->readFromInputStream(inputStream);
- }
-
- inputStream.endReadSerializablePolymorphicStruct(serialId);
- }
-
- return inputStream;
-}
-
-InputStream& operator>>(InputStream& inputStream, SerializableVariant& serializableVariant);
-
-template<typename _VectorElementType>
-class InputStreamGenericTypeVectorHelper {
-public:
- static void beginReadVector(InputStream& inputStream, const std::vector<_VectorElementType>& vectorValue) {
- doBeginReadVector(inputStream, vectorValue);
- }
-
-private:
- static inline void doBeginReadVector(InputStream& inputStream, const std::vector<bool>& vectorValue) {
- inputStream.beginReadBoolVector();
- }
- static inline void doBeginReadVector(InputStream& inputStream, const std::vector<int8_t>& vectorValue) {
- inputStream.beginReadInt8Vector();
- }
- static inline void doBeginReadVector(InputStream& inputStream, const std::vector<int16_t>& vectorValue) {
- inputStream.beginReadInt16Vector();
- }
- static inline void doBeginReadVector(InputStream& inputStream, const std::vector<int32_t>& vectorValue) {
- inputStream.beginReadInt32Vector();
- }
- static inline void doBeginReadVector(InputStream& inputStream, const std::vector<int64_t>& vectorValue) {
- inputStream.beginReadInt64Vector();
- }
- static inline void doBeginReadVector(InputStream& inputStream, const std::vector<uint8_t>& vectorValue) {
- inputStream.beginReadUInt8Vector();
- }
- static inline void doBeginReadVector(InputStream& inputStream, const std::vector<uint16_t>& vectorValue) {
- inputStream.beginReadUInt16Vector();
- }
- static inline void doBeginReadVector(InputStream& inputStream, const std::vector<uint32_t>& vectorValue) {
- inputStream.beginReadUInt32Vector();
- }
- static inline void doBeginReadVector(InputStream& inputStream, const std::vector<uint64_t>& vectorValue) {
- inputStream.beginReadUInt64Vector();
- }
- static inline void doBeginReadVector(InputStream& inputStream, const std::vector<float>& vectorValue) {
- inputStream.beginReadFloatVector();
- }
- static inline void doBeginReadVector(InputStream& inputStream, const std::vector<double>& vectorValue) {
- inputStream.beginReadDoubleVector();
- }
- static inline void doBeginReadVector(InputStream& inputStream, const std::vector<std::string>& vectorValue) {
- inputStream.beginReadStringVector();
- }
- static inline void doBeginReadVector(InputStream& inputStream, const std::vector<ByteBuffer>& vectorValue) {
- inputStream.beginReadByteBufferVector();
- }
- static inline void doBeginReadVector(InputStream& inputStream, const std::vector<Version>& vectorValue) {
- inputStream.beginReadVersionVector();
- }
-
- template<typename _PointerType,
- typename = typename std::enable_if<
- std::is_base_of<SerializablePolymorphicStruct, _PointerType>::value>::type>
- static inline void doBeginReadVector(InputStream& inputStream,
- const std::vector<std::shared_ptr<_PointerType>>& vectorValue) {
- inputStream.beginReadVectorOfSerializablePolymorphicStructs();
- }
-
- template<typename _InnerVectorElementType>
- static inline void doBeginReadVector(InputStream& inputStream,
- const std::vector<std::vector<_InnerVectorElementType>>& vectorValue) {
- inputStream.beginReadVectorOfVectors();
- }
-
- template<typename _InnerKeyType, typename _InnerValueType, typename _InnerHashType>
- static inline void doBeginReadVector(InputStream& inputStream,
- const std::vector<std::unordered_map<_InnerKeyType, _InnerValueType, _InnerHashType>>& vectorValue) {
- inputStream.beginReadVectorOfMaps();
- }
-
- template<typename _InnerKeyType, typename _InnerValueType>
- static inline void doBeginReadVector(InputStream& inputStream,
- const std::vector<std::unordered_map<_InnerKeyType, _InnerValueType>>& vectorValue) {
- inputStream.beginReadVectorOfMaps();
- }
-};
-
-template<typename _VectorElementType, bool _IsSerializableStruct = false>
-struct InputStreamSerializableStructVectorHelper: InputStreamGenericTypeVectorHelper<_VectorElementType> {
-};
-
-template<typename _VectorElementType>
-struct InputStreamSerializableStructVectorHelper<_VectorElementType, true> {
- static void beginReadVector(InputStream& inputStream, const std::vector<_VectorElementType>& vectorValue) {
- inputStream.beginReadVectorOfSerializableStructs();
- }
-};
-
-template<typename _VectorElementType, bool _IsSerializableVariant = false>
-struct InputStreamSerializableVariantVectorHelper: InputStreamSerializableStructVectorHelper<_VectorElementType,
- std::is_base_of<SerializableStruct, _VectorElementType>::value> {
-};
-
-template<typename _VectorElementType>
-struct InputStreamSerializableVariantVectorHelper<_VectorElementType, true> {
- static void beginReadVector(InputStream& inputStream, const std::vector<_VectorElementType>& vectorValue) {
- inputStream.beginReadVectorOfSerializableVariants();
- }
-};
-
-template<typename _VectorElementType>
-struct InputStreamVectorHelper: InputStreamSerializableVariantVectorHelper<_VectorElementType,
- std::is_base_of<SerializableVariant, _VectorElementType>::value> {
-};
-
-/**
- * Handles all reading of vectors from a given #InputStream. The given vector may contain any types for which a
- * (specialized) operator>>() is provided. For basic types, such an operator already is provided as a templated operator.
- * The vector does not need to be initialized in any way.
- *
- * @tparam _ElementType The type of the values that are contained in the vector that is to be read from the given stream.
- * @param val The vector in which the retrieved values are to be stored
- * @param inputStream The stream which the vector is to be read from
- * @return The given inputStream to allow for successive reading
- */
-template<typename _VectorElementType>
-InputStream& operator>>(InputStream& inputStream, std::vector<_VectorElementType>& vectorValue) {
- InputStreamVectorHelper<_VectorElementType>::beginReadVector(inputStream, vectorValue);
-
- while (inputStream.hasMoreVectorElements()) {
- _VectorElementType element;
-
- inputStream >> element;
-
- if (inputStream.hasError())
- break;
-
- vectorValue.push_back(std::move(element));
- }
-
- inputStream.endReadVector();
- return inputStream;
-}
-
-template<typename _KeyType, typename _ValueType, typename _HasherType>
-InputStream& operator>>(InputStream& inputStream, std::unordered_map<_KeyType, _ValueType, _HasherType>& mapValue) {
- typedef typename std::unordered_map<_KeyType, _ValueType, _HasherType>::value_type MapValueType;
-
- inputStream.beginReadMap();
-
- while (inputStream.hasMoreMapElements()) {
- _KeyType elementKey;
- _ValueType elementValue;
-
- inputStream.beginReadMapElement();
- inputStream >> elementKey >> elementValue;
- inputStream.endReadMapElement();
-
- if (inputStream.hasError())
- break;
-
- mapValue.insert(MapValueType(std::move(elementKey), std::move(elementValue)));
- }
-
- inputStream.endReadMap();
- return inputStream;
-}
-
-} // namespace CommonAPI
-
-#endif // COMMONAPI_INPUT_STREAM_H_
diff --git a/src/CommonAPI/Logger.cpp b/src/CommonAPI/Logger.cpp
new file mode 100644
index 0000000..4514bd7
--- /dev/null
+++ b/src/CommonAPI/Logger.cpp
@@ -0,0 +1,152 @@
+// 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 <CommonAPI/Logger.hpp>
+#include <CommonAPI/Runtime.hpp>
+
+namespace CommonAPI {
+
+#if defined(USE_CONSOLE) || defined(USE_FILE)
+std::mutex Logger::mutex_;
+#endif
+
+#ifdef USE_CONSOLE
+bool Logger::useConsole_(true);
+#endif
+
+#ifdef USE_FILE
+std::shared_ptr<std::ofstream> Logger::file_;
+#endif
+
+#ifdef USE_DLT
+bool Logger::useDlt_(false);
+#endif
+
+#if defined(USE_CONSOLE) || defined(USE_FILE) || defined(USE_DLT)
+Logger::Level Logger::maximumLogLevel_(Logger::Level::LL_INFO);
+#endif
+
+Logger::Logger() {
+#ifdef USE_DLT
+ DLT_REGISTER_APP("CAPI", "CAPI");
+ std::string context = Runtime::getProperty("LogContext");
+ if (context == "") context = "CAPI";
+ DLT_REGISTER_CONTEXT(dlt_, context.c_str(), "CAPI");
+#endif
+}
+
+void
+Logger::init(bool _useConsole, const std::string &_fileName, bool _useDlt, const std::string &_level) {
+#ifdef USE_CONSOLE
+ useConsole_ = _useConsole;
+#endif
+#ifdef USE_FILE
+ if (_fileName != "") {
+ file_ = std::make_shared<std::ofstream>();
+ if (file_)
+ file_->open(_fileName.c_str(), std::ofstream::out | std::ofstream::app);
+ }
+#endif
+#ifdef USE_DLT
+ useDlt_ = _useDlt;
+#endif
+#if defined(USE_CONSOLE) || defined(USE_FILE) || defined(USE_DLT)
+ maximumLogLevel_ = stringAsLevel(_level);
+#endif
+}
+
+void
+Logger::doLog(Level _level, const std::string &_message) {
+#ifdef USE_CONSOLE
+ if (useConsole_) {
+ std::lock_guard<std::mutex> consoleGuard(mutex_);
+ std::cout << "[CAPI][" << levelAsString(_level) << "] " << _message << std::endl;
+ }
+#endif
+#ifdef USE_FILE
+ if (file_ && file_->is_open()) {
+ std::lock_guard<std::mutex> consoleGuard(mutex_);
+ (*(file_.get())) << "[CAPI][" << levelAsString(_level) << "] " << _message << std::endl;
+ }
+#endif
+#ifdef USE_DLT
+ if (useDlt_) {
+ DLT_LOG_STRING(dlt_, levelAsDlt(_level), _message.c_str());
+ }
+#endif
+}
+
+#if defined(USE_CONSOLE) || defined(USE_FILE) || defined(USE_DLT)
+Logger::Level
+Logger::stringAsLevel(const std::string &_level) {
+ if (_level == "fatal")
+ return Level::LL_FATAL;
+
+ if (_level == "error")
+ return Level::LL_ERROR;
+
+ if (_level == "warning")
+ return Level::LL_WARNING;
+
+ if (_level == "info")
+ return Level::LL_INFO;
+
+ if (_level == "debug")
+ return Level::LL_DEBUG;
+
+ if (_level == "verbose")
+ return Level::LL_VERBOSE;
+
+ return Level::LL_INFO;
+}
+#endif
+
+#if defined(USE_CONSOLE) || defined(USE_FILE)
+std::string
+Logger::levelAsString(Logger::Level _level) {
+ switch (_level) {
+ case Level::LL_FATAL:
+ return "FATAL";
+ case Level::LL_ERROR:
+ return "ERROR";
+ case Level::LL_WARNING:
+ return "WARNING";
+ case Level::LL_INFO:
+ return "INFO";
+ case Level::LL_DEBUG:
+ return "DEBUG";
+ case Level::LL_VERBOSE:
+ return "VERBOSE";
+ default:
+ return "";
+ }
+}
+#endif
+
+#ifdef USE_DLT
+DltLogLevelType
+Logger::levelAsDlt(Logger::Level _level) {
+ switch (_level) {
+ case Level::LL_FATAL:
+ return DLT_LOG_FATAL;
+ case Level::LL_ERROR:
+ return DLT_LOG_ERROR;
+ case Level::LL_WARNING:
+ return DLT_LOG_WARN;
+ case Level::LL_INFO:
+ return DLT_LOG_INFO;
+ case Level::LL_DEBUG:
+ return DLT_LOG_DEBUG;
+ case Level::LL_VERBOSE:
+ return DLT_LOG_VERBOSE;
+ default:
+ return DLT_LOG_DEFAULT;
+ }
+}
+#endif
+
+} //namespace CommonAPI
diff --git a/src/CommonAPI/MainLoopContext.cpp b/src/CommonAPI/MainLoopContext.cpp
index b13cd89..c8bcb41 100644
--- a/src/CommonAPI/MainLoopContext.cpp
+++ b/src/CommonAPI/MainLoopContext.cpp
@@ -1,12 +1,9 @@
-/* Copyright (C) 2013 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 "MainLoopContext.h"
+// Copyright (C) 2013-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/MainLoopContext.hpp>
namespace CommonAPI {
@@ -14,6 +11,10 @@ int64_t getCurrentTimeInMs() {
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
}
+const std::string &MainLoopContext::getName() const {
+ return name_;
+}
+
DispatchSourceListenerSubscription MainLoopContext::subscribeForDispatchSources(DispatchSourceAddedCallback dispatchAddedCallback, DispatchSourceRemovedCallback dispatchRemovedCallback) {
dispatchSourceListeners_.emplace_front(dispatchAddedCallback, dispatchRemovedCallback);
return dispatchSourceListeners_.begin();
@@ -96,4 +97,4 @@ bool MainLoopContext::isInitialized() {
return dispatchSourceListeners_.size() > 0 || watchListeners_.size() > 0;
}
-} //Namespace CommonAPI
+} // namespace CommonAPI
diff --git a/src/CommonAPI/MiddlewareInfo.h b/src/CommonAPI/MiddlewareInfo.h
deleted file mode 100644
index 7a138b3..0000000
--- a/src/CommonAPI/MiddlewareInfo.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#if !defined (COMMONAPI_INTERNAL_COMPILATION)
-#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef MIDDLEWAREINFO_H_
-#define MIDDLEWAREINFO_H_
-
-
-#include <memory>
-#include <cstring>
-#include "types.h"
-
-
-namespace CommonAPI {
-
-
-class Runtime;
-
-
-typedef std::shared_ptr<Runtime> (*MiddlewareRuntimeLoadFunction) ();
-
-
-struct MiddlewareInfo {
- const char* middlewareName_;
- MiddlewareRuntimeLoadFunction getInstance_;
- Version version_;
-
- MiddlewareInfo(const char* middlewareName,
- MiddlewareRuntimeLoadFunction middlewareRuntimeLoadFunction,
- Version version):
- middlewareName_(middlewareName),
- getInstance_(middlewareRuntimeLoadFunction),
- version_(version) {}
-};
-
-
-} // namespace CommonAPI
-
-
-#endif /* MIDDLEWAREINFO_H_ */
diff --git a/src/CommonAPI/OutputStream.h b/src/CommonAPI/OutputStream.h
deleted file mode 100644
index 3cedf27..0000000
--- a/src/CommonAPI/OutputStream.h
+++ /dev/null
@@ -1,555 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#if !defined (COMMONAPI_INTERNAL_COMPILATION)
-#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef COMMONAPI_OUTPUT_STREAM_H_
-#define COMMONAPI_OUTPUT_STREAM_H_
-
-#include "ByteBuffer.h"
-#include "SerializableStruct.h"
-#include "SerializableVariant.h"
-#include "types.h"
-#include <iostream>
-
-#include <cstdint>
-#include <functional>
-#include <memory>
-#include <string>
-#include <unordered_map>
-#include <vector>
-#include <type_traits>
-
-namespace CommonAPI {
-
-class SerializableVariant;
-
-class TypeOutputStream {
-public:
- virtual ~TypeOutputStream() {}
-
- virtual void writeBoolType() = 0;
-
- virtual void writeInt8Type() = 0;
- virtual void writeInt16Type() = 0;
- virtual void writeInt32Type() = 0;
- virtual void writeInt64Type() = 0;
-
- virtual void writeUInt8Type() = 0;
- virtual void writeUInt16Type() = 0;
- virtual void writeUInt32Type() = 0;
- virtual void writeUInt64Type() = 0;
-
- virtual void writeInt8EnumType() = 0;
- virtual void writeInt16EnumType() = 0;
- virtual void writeInt32EnumType() = 0;
- virtual void writeInt64EnumType() = 0;
-
- virtual void writeUInt8EnumType() = 0;
- virtual void writeUInt16EnumType() = 0;
- virtual void writeUInt32EnumType() = 0;
- virtual void writeUInt64EnumType() = 0;
-
- virtual void writeFloatType() = 0;
- virtual void writeDoubleType() = 0;
-
- virtual void writeStringType() = 0;
- virtual void writeByteBufferType() = 0;
- virtual void writeVersionType() = 0;
-
- virtual void beginWriteVectorType() = 0;
- virtual void endWriteVectorType() = 0;
-
- virtual void beginWriteMapType() = 0;
- virtual void endWriteMapType() = 0;
-
- virtual void beginWriteStructType() = 0;
- virtual void endWriteStructType() = 0;
-
- virtual void writeVariantType() = 0;
-
- virtual std::string retrieveSignature() = 0;
-};
-
-template<typename _Type>
-struct TypeWriter;
-
-template<typename _Type>
-struct BasicTypeWriter;
-
-template<>
-struct BasicTypeWriter<bool> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.writeBoolType();
- }
-};
-
-template<>
-struct BasicTypeWriter<int8_t> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.writeInt8Type();
- }
-};
-
-template<>
-struct BasicTypeWriter<int16_t> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.writeInt16Type();
- }
-};
-
-template<>
-struct BasicTypeWriter<int32_t> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.writeInt32Type();
- }
-};
-
-template<>
-struct BasicTypeWriter<int64_t> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.writeInt64Type();
- }
-};
-
-template<>
-struct BasicTypeWriter<uint8_t> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.writeUInt8Type();
- }
-};
-
-template<>
-struct BasicTypeWriter<uint16_t> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.writeUInt16Type();
- }
-};
-
-template<>
-struct BasicTypeWriter<uint32_t> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.writeUInt32Type();
- }
-};
-
-template<>
-struct BasicTypeWriter<uint64_t> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.writeUInt64Type();
- }
-};
-
-template<>
-struct BasicTypeWriter<float> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.writeFloatType();
- }
-};
-
-template<>
-struct BasicTypeWriter<double> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.writeDoubleType();
- }
-};
-
-template<>
-struct BasicTypeWriter<std::string> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.writeStringType();
- }
-};
-
-template<>
-struct BasicTypeWriter<CommonAPI::ByteBuffer> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.writeByteBufferType();
- }
-};
-
-template<>
-struct BasicTypeWriter<CommonAPI::Version> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.writeVersionType();
- }
-};
-
-template<typename _VectorElementType>
-struct BasicTypeWriter<std::vector<_VectorElementType>> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.beginWriteVectorType();
- TypeWriter<_VectorElementType>::writeType(typeStream);
- }
-};
-
-template<typename _KeyType, typename _ValueType>
-struct BasicTypeWriter<std::unordered_map<_KeyType, _ValueType>> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.beginWriteMapType();
-
- BasicTypeWriter<_KeyType>::writeType(typeStream);
- BasicTypeWriter<_ValueType>::writeType(typeStream);
-
- typeStream.endWriteMapType();
- }
-};
-
-template<typename _Type, bool _IsStructType = false>
-struct StructTypeWriter: public BasicTypeWriter<_Type> {
-};
-
-template<typename _Type>
-struct StructTypeWriter<_Type, true> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.beginWriteStructType();
- _Type::writeToTypeOutputStream(typeStream);
- typeStream.endWriteStructType();
- }
-};
-
-template<typename _Type, bool _IsVariantType = false>
-struct VariantTypeWriter: public StructTypeWriter<_Type, std::is_base_of<SerializableStruct, _Type>::value> {
-};
-
-template<typename _Type>
-struct VariantTypeWriter<_Type, true> {
- inline static void writeType(TypeOutputStream& typeStream) {
- typeStream.writeVariantType();
- }
-};
-
-template<typename _Type>
-struct TypeWriter: public VariantTypeWriter<_Type, std::is_base_of<SerializableVariant, _Type>::value> {
-};
-
-class OutputStream {
-public:
- virtual ~OutputStream() {
- }
- virtual bool hasError() const = 0;
-
- virtual OutputStream& writeValue(const bool& boolValue) = 0;
-
- virtual OutputStream& writeValue(const int8_t& int8Value) = 0;
- virtual OutputStream& writeValue(const int16_t& int16Value) = 0;
- virtual OutputStream& writeValue(const int32_t& int32Value) = 0;
- virtual OutputStream& writeValue(const int64_t& int64Value) = 0;
-
- virtual OutputStream& writeValue(const uint8_t& uint8Value) = 0;
- virtual OutputStream& writeValue(const uint16_t& uint16Value) = 0;
- virtual OutputStream& writeValue(const uint32_t& uint32Value) = 0;
- virtual OutputStream& writeValue(const uint64_t& uint64Value) = 0;
-
- virtual OutputStream& writeValue(const float& floatValue) = 0;
- virtual OutputStream& writeValue(const double& doubleValue) = 0;
-
- virtual OutputStream& writeValue(const std::string& stringValue) = 0;
-
- virtual OutputStream& writeValue(const ByteBuffer& byteBufferValue) = 0;
-
- virtual OutputStream& writeEnumValue(const int8_t& int8BackingTypeValue) = 0;
- virtual OutputStream& writeEnumValue(const int16_t& int16BackingTypeValue) = 0;
- virtual OutputStream& writeEnumValue(const int32_t& int32BackingTypeValue) = 0;
- virtual OutputStream& writeEnumValue(const int64_t& int64BackingTypeValue) = 0;
- virtual OutputStream& writeEnumValue(const uint8_t& uint8BackingTypeValue) = 0;
- virtual OutputStream& writeEnumValue(const uint16_t& uint16BackingTypeValue) = 0;
- virtual OutputStream& writeEnumValue(const uint32_t& uint32BackingTypeValue) = 0;
- virtual OutputStream& writeEnumValue(const uint64_t& uint64BackingTypeValue) = 0;
-
- virtual OutputStream& writeVersionValue(const Version& versionValue) = 0;
-
- virtual void beginWriteSerializableStruct(const SerializableStruct& serializableStruct) = 0;
- virtual void endWriteSerializableStruct(const SerializableStruct& serializableStruct) = 0;
-
- virtual void beginWriteSerializablePolymorphicStruct(const std::shared_ptr<SerializablePolymorphicStruct>& serializableStruct) = 0;
- virtual void endWriteSerializablePolymorphicStruct(const std::shared_ptr<SerializablePolymorphicStruct>& serializableStruct) = 0;
-
- virtual void beginWriteSerializableVariant(const SerializableVariant& serializableVariant) = 0;
- virtual void endWriteSerializableVariant(const SerializableVariant& serializableVariant) = 0;
-
- virtual void beginWriteBoolVector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteInt8Vector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteInt16Vector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteInt32Vector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteInt64Vector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteUInt8Vector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteUInt16Vector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteUInt32Vector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteUInt64Vector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteFloatVector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteDoubleVector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteStringVector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteByteBufferVector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteVersionVector(uint32_t sizeOfVector) = 0;
-
- virtual void beginWriteInt8EnumVector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteInt16EnumVector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteInt32EnumVector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteInt64EnumVector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteUInt8EnumVector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteUInt16EnumVector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteUInt32EnumVector(uint32_t sizeOfVector) = 0;
- virtual void beginWriteUInt64EnumVector(uint32_t sizeOfVector) = 0;
-
- virtual void beginWriteVectorOfSerializableStructs(uint32_t sizeOfVector) = 0;
- virtual void beginWriteVectorOfSerializableVariants(uint32_t sizeOfVector) = 0;
- virtual void beginWriteVectorOfVectors(uint32_t sizeOfVector) = 0;
- virtual void beginWriteVectorOfMaps(uint32_t sizeOfVector) = 0;
-
- virtual void beginWriteVectorOfSerializablePolymorphicStructs(uint32_t sizeOfVector) = 0;
-
- virtual void endWriteVector() = 0;
-
- virtual void beginWriteMap(size_t elementCount) = 0;
- virtual void endWriteMap() = 0;
- virtual void beginWriteMapElement() = 0;
- virtual void endWriteMapElement() = 0;
-
- virtual bool writeRawData(const char* rawDataPtr, const size_t sizeInByte) = 0;
-};
-
-inline OutputStream& operator<<(OutputStream& outputStream, const bool& boolValue) {
- return outputStream.writeValue(boolValue);
-}
-
-inline OutputStream& operator<<(OutputStream& outputStream, const int8_t& int8Value) {
- return outputStream.writeValue(int8Value);
-}
-
-inline OutputStream& operator<<(OutputStream& outputStream, const int16_t& int16Value) {
- return outputStream.writeValue(int16Value);
-}
-
-inline OutputStream& operator<<(OutputStream& outputStream, const int32_t& int32Value) {
- return outputStream.writeValue(int32Value);
-}
-
-inline OutputStream& operator<<(OutputStream& outputStream, const int64_t& int64Value) {
- return outputStream.writeValue(int64Value);
-}
-
-inline OutputStream& operator<<(OutputStream& outputStream, const uint8_t& uint8Value) {
- return outputStream.writeValue(uint8Value);
-}
-
-inline OutputStream& operator<<(OutputStream& outputStream, const uint16_t& uint16Value) {
- return outputStream.writeValue(uint16Value);
-}
-
-inline OutputStream& operator<<(OutputStream& outputStream, const uint32_t& uint32Value) {
- return outputStream.writeValue(uint32Value);
-}
-
-inline OutputStream& operator<<(OutputStream& outputStream, const uint64_t& uint64Value) {
- return outputStream.writeValue(uint64Value);
-}
-
-inline OutputStream& operator<<(OutputStream& outputStream, const float& floatValue) {
- return outputStream.writeValue(floatValue);
-}
-
-inline OutputStream& operator<<(OutputStream& outputStream, const double& doubleValue) {
- return outputStream.writeValue(doubleValue);
-}
-
-inline OutputStream& operator<<(OutputStream& outputStream, const std::string& stringValue) {
- return outputStream.writeValue(stringValue);
-}
-
-inline OutputStream& operator<<(OutputStream& outputStream, const Version& versionValue) {
- return outputStream.writeVersionValue(versionValue);
-}
-
-template<typename _SerializablePolymorphicStructType>
-typename std::enable_if<std::is_base_of<SerializablePolymorphicStruct, _SerializablePolymorphicStructType>::value,
- OutputStream>::type&
-operator<<(OutputStream& outputStream,
- const std::shared_ptr<_SerializablePolymorphicStructType>& serializablePolymorphicStruct) {
- outputStream.beginWriteSerializablePolymorphicStruct(serializablePolymorphicStruct);
- serializablePolymorphicStruct->writeToOutputStream(outputStream);
- outputStream.endWriteSerializablePolymorphicStruct(serializablePolymorphicStruct);
-
- return outputStream;
-}
-
-inline OutputStream& operator<<(OutputStream& outputStream, const SerializableStruct& serializableStruct) {
- outputStream.beginWriteSerializableStruct(serializableStruct);
- serializableStruct.writeToOutputStream(outputStream);
- outputStream.endWriteSerializableStruct(serializableStruct);
-
- return outputStream;
-}
-
-inline OutputStream& operator<<(OutputStream& outputStream, const SerializableVariant& serializableVariant) {
- outputStream.beginWriteSerializableVariant(serializableVariant);
- serializableVariant.writeToOutputStream(outputStream);
- outputStream.endWriteSerializableVariant(serializableVariant);
-
- return outputStream;
-}
-
-template<typename _VectorElementType>
-class OutStreamGenericVectorHelper {
-public:
- static void beginWriteVector(OutputStream& outputStream, const std::vector<_VectorElementType>& vectorValue) {
- doBeginWriteVector(outputStream, vectorValue);
- }
-
-private:
- static inline void doBeginWriteVector(OutputStream& outputStream, const std::vector<bool>& vectorValue) {
- outputStream.beginWriteBoolVector(vectorValue.size());
- }
- static inline void doBeginWriteVector(OutputStream& outputStream, const std::vector<int8_t>& vectorValue) {
- outputStream.beginWriteInt8Vector(vectorValue.size());
- }
- static inline void doBeginWriteVector(OutputStream& outputStream, const std::vector<int16_t>& vectorValue) {
- outputStream.beginWriteInt16Vector(vectorValue.size());
- }
- static inline void doBeginWriteVector(OutputStream& outputStream, const std::vector<int32_t>& vectorValue) {
- outputStream.beginWriteInt32Vector(vectorValue.size());
- }
- static inline void doBeginWriteVector(OutputStream& outputStream, const std::vector<int64_t>& vectorValue) {
- outputStream.beginWriteInt64Vector(vectorValue.size());
- }
- static inline void doBeginWriteVector(OutputStream& outputStream, const std::vector<uint8_t>& vectorValue) {
- outputStream.beginWriteUInt8Vector(vectorValue.size());
- }
- static inline void doBeginWriteVector(OutputStream& outputStream, const std::vector<uint16_t>& vectorValue) {
- outputStream.beginWriteUInt16Vector(vectorValue.size());
- }
- static inline void doBeginWriteVector(OutputStream& outputStream, const std::vector<uint32_t>& vectorValue) {
- outputStream.beginWriteUInt32Vector(vectorValue.size());
- }
- static inline void doBeginWriteVector(OutputStream& outputStream, const std::vector<uint64_t>& vectorValue) {
- outputStream.beginWriteUInt64Vector(vectorValue.size());
- }
- static inline void doBeginWriteVector(OutputStream& outputStream, const std::vector<float>& vectorValue) {
- outputStream.beginWriteFloatVector(vectorValue.size());
- }
- static inline void doBeginWriteVector(OutputStream& outputStream, const std::vector<double>& vectorValue) {
- outputStream.beginWriteDoubleVector(vectorValue.size());
- }
- static inline void doBeginWriteVector(OutputStream& outputStream, const std::vector<std::string>& vectorValue) {
- outputStream.beginWriteStringVector(vectorValue.size());
- }
- static inline void doBeginWriteVector(OutputStream& outputStream, const std::vector<ByteBuffer>& vectorValue) {
- outputStream.beginWriteByteBufferVector(vectorValue.size());
- }
- static inline void doBeginWriteVector(OutputStream& outputStream, const std::vector<Version>& vectorValue) {
- outputStream.beginWriteVersionVector(vectorValue.size());
- }
-
- template<typename _PointerType,
- typename = typename std::enable_if<
- std::is_base_of<SerializablePolymorphicStruct, _PointerType>::value>::type>
- static inline void doBeginWriteVector(OutputStream& outputStream,
- const std::vector<std::shared_ptr<_PointerType>>& vectorValue) {
- outputStream.beginWriteVectorOfSerializablePolymorphicStructs(vectorValue.size());
- }
-
- template<typename _InnerVectorElementType>
- static inline void doBeginWriteVector(OutputStream& outputStream,
- const std::vector<std::vector<_InnerVectorElementType>>& vectorValue) {
- outputStream.beginWriteVectorOfVectors(vectorValue.size());
- }
-
- template<typename _InnerKeyType, typename _InnerValueType, typename _InnerHashType>
- static inline void doBeginWriteVector(OutputStream& outputStream,
- const std::vector<std::unordered_map<_InnerKeyType, _InnerValueType, _InnerHashType>>& vectorValue) {
- outputStream.beginWriteVectorOfMaps(vectorValue.size());
- }
-
- template<typename _InnerKeyType, typename _InnerValueType>
- static inline void doBeginWriteVector(OutputStream& outputStream,
- const std::vector<std::unordered_map<_InnerKeyType, _InnerValueType>>& vectorValue) {
- outputStream.beginWriteVectorOfMaps(vectorValue.size());
- }
-};
-
-template<typename _VectorElementType, bool _IsSerializableStruct = false>
-struct OutputStreamSerializableStructVectorHelper: public OutStreamGenericVectorHelper<_VectorElementType> {
-};
-
-template<typename _VectorElementType>
-struct OutputStreamSerializableStructVectorHelper<_VectorElementType, true> {
- static void beginWriteVector(OutputStream& outputStream, const std::vector<_VectorElementType>& vectorValue) {
- outputStream.beginWriteVectorOfSerializableStructs(vectorValue.size());
- }
-};
-
-template<typename _VectorElementType, bool _IsSerializableVariant = false>
-struct OutputStreamSerializableVariantVectorHelper: public OutputStreamSerializableStructVectorHelper<
- _VectorElementType,
- std::is_base_of<SerializableStruct, _VectorElementType>::value> {
-};
-
-template<typename _VectorElementType>
-struct OutputStreamSerializableVariantVectorHelper<_VectorElementType, true> {
- static void beginWriteVector(OutputStream& outputStream, const std::vector<_VectorElementType>& vectorValue) {
- outputStream.beginWriteVectorOfSerializableVariants(vectorValue.size());
- }
-};
-
-template<typename _VectorElementType>
-struct OutputStreamVectorHelper: OutputStreamSerializableVariantVectorHelper<_VectorElementType,
- std::is_base_of<SerializableVariant, _VectorElementType>::value> {
-};
-
-/**
- * Handles all writing of vectors to a given #OutputStream. The given vector may contain any types that are
- * defined as basic types within the context of CommonAPI, as well as any types derived from those basic types.
- *
- * @tparam _ElementType The type of the elements that are contained in the given vector.
- * @param val The vector that is to be written into the given stream
- * @param outputStream The stream which is to be written into
- * @return The given outputStream to allow for successive writing.
- * @see operator<<(OutputStream&, const _BasicType&)
- * @see SerializableStruct
- * @see SerializableVariant
- */
-template<typename _VectorElementType>
-OutputStream& operator<<(OutputStream& outputStream, const std::vector<_VectorElementType>& vectorValue) {
- OutputStreamVectorHelper<_VectorElementType>::beginWriteVector(outputStream, vectorValue);
- const size_t elementCount = vectorValue.size();
-
- for (size_t i = 0; i < elementCount; i++) {
- outputStream << vectorValue[i];
-
- if (outputStream.hasError())
- break;
- }
-
- outputStream.endWriteVector();
- return outputStream;
-}
-
-template<typename _KeyType, typename _ValueType, typename _HasherType>
-OutputStream& operator<<(OutputStream& outputStream,
- const std::unordered_map<_KeyType, _ValueType, _HasherType>& mapValue) {
- typedef typename std::unordered_map<_KeyType, _ValueType, _HasherType>::const_iterator MapConstIterator;
-
- const size_t elementCount = mapValue.size();
- outputStream.beginWriteMap(elementCount);
-
- for (MapConstIterator iter = mapValue.cbegin(); iter != mapValue.cend(); iter++) {
- outputStream.beginWriteMapElement();
- outputStream << iter->first << iter->second;
- if (outputStream.hasError())
- return outputStream;
- outputStream.endWriteMapElement();
- }
-
- outputStream.endWriteMap();
- return outputStream;
-}
-
-} // namespace CommonAPI
-
-#endif // COMMONAPI_OUTPUT_STREAM_H_
diff --git a/src/CommonAPI/Proxy.cpp b/src/CommonAPI/Proxy.cpp
new file mode 100644
index 0000000..072fc30
--- /dev/null
+++ b/src/CommonAPI/Proxy.cpp
@@ -0,0 +1,15 @@
+// Copyright (C) 2013-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/Proxy.hpp>
+
+namespace CommonAPI {
+
+const Address &
+Proxy::getAddress() const {
+ return address_;
+}
+
+} // namespace CommonAPI
diff --git a/src/CommonAPI/Proxy.h b/src/CommonAPI/Proxy.h
deleted file mode 100644
index b427824..0000000
--- a/src/CommonAPI/Proxy.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#if !defined (COMMONAPI_INTERNAL_COMPILATION)
-#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef COMMONAPI_PROXY_H_
-#define COMMONAPI_PROXY_H_
-
-#include "Attribute.h"
-
-#include <cstdint>
-#include <memory>
-#include <type_traits>
-
-namespace CommonAPI {
-
-typedef Event<AvailabilityStatus> ProxyStatusEvent;
-typedef ReadonlyAttribute<Version> InterfaceVersionAttribute;
-
-
-class Proxy {
- public:
- virtual ~Proxy() { }
-
- // The addressing scheme has the following format: "domain:service:instance"
- virtual std::string getAddress() const = 0;
-
- // i.e. "local"
- virtual const std::string& getDomain() const = 0;
-
- // i.e. "com.bmw.infotainment"
- virtual const std::string& getServiceId() const = 0;
-
- // i.e. "com.bmw.infotainment.low"
- virtual const std::string& getInstanceId() const = 0;
-
- virtual bool isAvailable() const = 0;
-
- virtual bool isAvailableBlocking() const = 0;
-
- virtual ProxyStatusEvent& getProxyStatusEvent() = 0;
-
- virtual InterfaceVersionAttribute& getInterfaceVersionAttribute() = 0;
-};
-
-} // namespace CommonAPI
-
-#endif // COMMONAPI_PROXY_H_
diff --git a/src/CommonAPI/ProxyManager.cpp b/src/CommonAPI/ProxyManager.cpp
new file mode 100644
index 0000000..ac3b263
--- /dev/null
+++ b/src/CommonAPI/ProxyManager.cpp
@@ -0,0 +1,18 @@
+// Copyright (C) 2013-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/ProxyManager.hpp>
+#include <CommonAPI/Runtime.hpp>
+
+namespace CommonAPI {
+
+std::shared_ptr<Proxy>
+ProxyManager::createProxy(
+ const std::string &_domain, const std::string &_interface, const std::string &_instance,
+ const ConnectionId_t &_connection) const {
+ return Runtime::get()->createProxy(_domain, _interface, _instance, _connection);
+}
+
+} // namespace CommonAPI
diff --git a/src/CommonAPI/ProxyManager.h b/src/CommonAPI/ProxyManager.h
deleted file mode 100644
index ecb8799..0000000
--- a/src/CommonAPI/ProxyManager.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#if !defined (COMMONAPI_INTERNAL_COMPILATION)
-#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef COMMONAPI_PROXY_MANAGER_H_
-#define COMMONAPI_PROXY_MANAGER_H_
-
-#include "types.h"
-#include "Event.h"
-#include "Proxy.h"
-#include "Factory.h"
-
-#include <functional>
-#include <future>
-#include <string>
-#include <vector>
-
-
-namespace CommonAPI {
-
-class ProxyManager {
- public:
- typedef std::function<void(const CallStatus&, const std::vector<std::string>&)> GetAvailableInstancesCallback;
- typedef std::function<void(const CallStatus&, const AvailabilityStatus&)> GetInstanceAvailabilityStatusCallback;
-
- typedef Event<std::string, AvailabilityStatus> InstanceAvailabilityStatusChangedEvent;
-
- ProxyManager() { };
- ProxyManager(ProxyManager&&) = delete;
- ProxyManager(const ProxyManager&) = delete;
-
- virtual ~ProxyManager() { }
-
- virtual void getAvailableInstances(CommonAPI::CallStatus&, std::vector<std::string>& availableInstances) = 0;
- virtual std::future<CallStatus> getAvailableInstancesAsync(GetAvailableInstancesCallback callback) = 0;
-
- virtual void getInstanceAvailabilityStatus(const std::string& instanceAddress,
- CallStatus& callStatus,
- AvailabilityStatus& availabilityStatus) = 0;
-
- virtual std::future<CallStatus> getInstanceAvailabilityStatusAsync(const std::string&,
- GetInstanceAvailabilityStatusCallback callback) = 0;
-
- virtual InstanceAvailabilityStatusChangedEvent& getInstanceAvailabilityStatusChangedEvent() = 0;
-
- template<template<typename ...> class _ProxyClass, typename ... _AttributeExtensions>
- std::shared_ptr<
- _ProxyClass<
-#ifdef WIN32
- CommonAPI::WINDummyAttributeExtension<WINDummyAttribute>,
-#endif
- _AttributeExtensions...>
- >
- buildProxy(const std::string& instanceName) {
- std::shared_ptr<Proxy> abstractMiddlewareProxy = createProxy(instanceName);
- if (abstractMiddlewareProxy) {
- auto returnProxy = std::make_shared<
- _ProxyClass<
-#ifdef WIN32
- CommonAPI::WINDummyAttributeExtension<WINDummyAttribute>,
-#endif
- _AttributeExtensions...>
- >(abstractMiddlewareProxy);
- return returnProxy;
- }
- return NULL;
- }
-
- template <template<typename ...> class _ProxyClass, template<typename> class _AttributeExtension>
- std::shared_ptr<typename DefaultAttributeProxyFactoryHelper<_ProxyClass, _AttributeExtension>::class_t>
- buildProxyWithDefaultAttributeExtension(const std::string& instanceName) {
- std::shared_ptr<Proxy> abstractMiddlewareProxy = createProxy(instanceName);
- if (abstractMiddlewareProxy) {
- return std::make_shared<typename DefaultAttributeProxyFactoryHelper<_ProxyClass, _AttributeExtension>::class_t>(abstractMiddlewareProxy);
- }
- return NULL;
- }
-
- protected:
- virtual std::shared_ptr<Proxy> createProxy(const std::string& instanceName) = 0;
-};
-
-} // namespace CommonAPI
-
-#endif // COMMONAPI_PROXY_MANAGER_H_
diff --git a/src/CommonAPI/Runtime.cpp b/src/CommonAPI/Runtime.cpp
index bc5c4dc..95c2832 100644
--- a/src/CommonAPI/Runtime.cpp
+++ b/src/CommonAPI/Runtime.cpp
@@ -1,393 +1,409 @@
-/* Copyright (C) 2013 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 <sys/types.h>
-#include <sys/stat.h>
-#ifndef WIN32
-#include <dirent.h>
+// Copyright (C) 2013-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/.
+
+#ifdef WIN32
+#include <Windows.h>
+#else
#include <dlfcn.h>
+#include <unistd.h>
#endif
-#include <algorithm>
-#include <iostream>
-#include <unordered_map>
-#include <stdexcept>
+#include <sys/stat.h>
-#include "Runtime.h"
-#include "Configuration.h"
-#include "utils.h"
+#include <algorithm>
+#include <CommonAPI/Factory.hpp>
+#include <CommonAPI/IniFileReader.hpp>
+#include <CommonAPI/Logger.hpp>
+#include <CommonAPI/Runtime.hpp>
namespace CommonAPI {
+const char *COMMONAPI_DEFAULT_BINDING = "dbus";
+const char *COMMONAPI_DEFAULT_FOLDER = "/usr/local/lib/commonapi";
+const char *COMMONAPI_DEFAULT_CONFIG_FILE = "commonapi.ini";
+const char *COMMONAPI_DEFAULT_CONFIG_FOLDER = "/etc";
-static std::unordered_map<std::string, MiddlewareRuntimeLoadFunction>* registeredRuntimeLoadFunctions_;
-static bool isDynamic_ = false;
-
-static const char COMMONAPI_LIB_PREFIX[] = "libCommonAPI-";
-static const char MIDDLEWARE_INFO_SYMBOL_NAME[] = "middlewareInfo";
+std::map<std::string, std::string> properties__;
+std::shared_ptr<Runtime> Runtime::theRuntime__ = std::make_shared<Runtime>();
-#ifndef WIN32
-bool Runtime::tryLoadLibrary(const std::string& libraryPath,
- void** sharedLibraryHandle,
- MiddlewareInfo** foundMiddlewareInfo) {
-
- //In case we find an already loaded library again while looking for another one,
- //there is no need to look at it
- if (dlopen(libraryPath.c_str(), RTLD_NOLOAD)) {
- return false;
- }
-
- //In order to place symbols of the newly loaded library ahead of already resolved symbols, we need
- //RTLD_DEEPBIND. This is necessary for this case: A library already is linked at compile time, but while
- //trying to resolve another library dynamically we might find the very same library again.
- //dlopen() doesn't know about the compile time linked library and will close it if dlclose() ever is
- //called, thereby causing memory corruptions. Therefore, we must be able to access the middlewareInfo
- //of the newly dlopened library in order to determine whether it already has been linked.
- *sharedLibraryHandle = dlopen(libraryPath.c_str(), RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND);
- if (*sharedLibraryHandle == NULL) {
- return false;
- }
-
- *foundMiddlewareInfo = static_cast<MiddlewareInfo*>(dlsym(*sharedLibraryHandle, MIDDLEWARE_INFO_SYMBOL_NAME));
-
- //In this context, a resolved value of NULL it is just as invalid as if dlerror() was set additionally.
- if (!*foundMiddlewareInfo) {
- dlclose(*sharedLibraryHandle);
- return false;
- }
-
- if (!(*foundMiddlewareInfo)->middlewareName_ || !(*foundMiddlewareInfo)->getInstance_) {
- dlclose(sharedLibraryHandle);
- return false;
- }
-
- return true;
+std::string
+Runtime::getProperty(const std::string &_name) {
+ auto foundProperty = properties__.find(_name);
+ if (foundProperty != properties__.end())
+ return foundProperty->second;
+ return "";
}
-bool Runtime::checkAndLoadLibrary(const std::string& libraryPath,
- const std::string& requestedBindingIdentifier,
- bool keepLibrary) {
-
- void* sharedLibraryHandle = NULL;
- MiddlewareInfo* foundMiddlewareInfo;
- if (!tryLoadLibrary(libraryPath, &sharedLibraryHandle, &foundMiddlewareInfo)) {
- return false;
- }
-
- if (foundMiddlewareInfo->middlewareName_ != requestedBindingIdentifier) {
- //If library was linked at compile time (and therefore an appropriate runtime loader is registered),
- //the library must not be closed!
- auto foundRegisteredRuntimeLoader = registeredRuntimeLoadFunctions_->find(foundMiddlewareInfo->middlewareName_);
- if (foundRegisteredRuntimeLoader == registeredRuntimeLoadFunctions_->end()) {
- dlclose(sharedLibraryHandle);
- }
- return false;
- }
-
- if (!keepLibrary) {
- dlclose(sharedLibraryHandle);
- } else {
- //Extend visibility to make symbols available to all other libraries that are loaded afterwards,
- //e.g. libraries containing generated binding specific code.
- sharedLibraryHandle = dlopen(libraryPath.c_str(), RTLD_NOW | RTLD_GLOBAL);
- if (!sharedLibraryHandle) {
- return false;
- }
- registeredRuntimeLoadFunctions_->insert( {foundMiddlewareInfo->middlewareName_, foundMiddlewareInfo->getInstance_} );
- }
-
- return true;
+void
+Runtime::setProperty(const std::string &_name, const std::string &_value) {
+ properties__[_name] = _value;
}
-bool Runtime::checkAndLoadDefaultLibrary(std::string& foundBindingIdentifier, const std::string& libraryPath) {
- void* sharedLibraryHandle = NULL;
- MiddlewareInfo* foundMiddlewareInfo;
- if (!tryLoadLibrary(libraryPath, &sharedLibraryHandle, &foundMiddlewareInfo)) {
- return false;
- }
-
- //Extend visibility to make symbols available to all other linked libraries,
- //e.g. libraries containing generated binding specific code
- sharedLibraryHandle = dlopen(libraryPath.c_str(), RTLD_NOW | RTLD_GLOBAL);
- if (!sharedLibraryHandle) {
- return false;
- }
- registeredRuntimeLoadFunctions_->insert( {foundMiddlewareInfo->middlewareName_, foundMiddlewareInfo->getInstance_} );
- foundBindingIdentifier = foundMiddlewareInfo->middlewareName_;
-
- return true;
+std::shared_ptr<Runtime> Runtime::get() {
+ theRuntime__->init();
+ return theRuntime__;
}
-const std::vector<std::string> Runtime::readDirectory(const std::string& path) {
- std::vector<std::string> result;
- struct stat filestat;
-
- DIR *directory = opendir(path.c_str());
-
- if (!directory) {
- return std::vector<std::string>();
- }
-
- struct dirent* entry;
-
- while ((entry = readdir(directory))) {
- const std::string fqnOfEntry = path + entry->d_name;
-
- if (stat(fqnOfEntry.c_str(), &filestat)) {
- continue;
- }
- if (S_ISDIR(filestat.st_mode)) {
- continue;
- }
-
- if (strncmp(COMMONAPI_LIB_PREFIX, entry->d_name, strlen(COMMONAPI_LIB_PREFIX)) != 0) {
- continue;
- }
-
- const char* fileNamePtr = entry->d_name;
- while ((fileNamePtr = strchr(fileNamePtr + 1, '.'))) {
- if (strncmp(".so", fileNamePtr, 3) == 0) {
- break;
- }
- }
-
- if (fileNamePtr) {
- result.push_back(fqnOfEntry);
- }
- }
-
- closedir (directory);
-
- std::sort( result.begin(), result.end() );
-
- return result;
+Runtime::Runtime()
+ : defaultBinding_(COMMONAPI_DEFAULT_BINDING),
+ defaultFolder_(COMMONAPI_DEFAULT_FOLDER) {
}
-#endif
-struct LibraryVersion {
- int32_t major;
- int32_t minor;
- int32_t revision;
-};
-
-bool operator<(LibraryVersion const& lhs, LibraryVersion const& rhs) {
- if (lhs.major == rhs.major) {
- if (lhs.minor == rhs.minor) {
- return lhs.revision < rhs.revision;
- }
- return lhs.minor < rhs.minor;
- }
- return lhs.major < rhs.major;
+Runtime::~Runtime() {
+ // intentionally left empty
}
+bool
+Runtime::registerFactory(const std::string &_binding, std::shared_ptr<Factory> _factory) {
+ COMMONAPI_DEBUG("Registering factory for binding=", _binding);
+ bool isRegistered(false);
#ifndef WIN32
-std::shared_ptr<Runtime> Runtime::checkDynamicLibraries(const std::string& requestedMiddlewareName, LoadState& loadState) {
- const std::string& middlewareLibraryPath = Configuration::getInstance().getMiddlewareLibraryPath(requestedMiddlewareName);
-
- if (middlewareLibraryPath != "") {
- if (!checkAndLoadLibrary(middlewareLibraryPath, requestedMiddlewareName, true)) {
- //A path for requestedMiddlewareName was configured, but no corresponding library was found
- loadState = LoadState::CONFIGURATION_ERROR;
- return std::shared_ptr<Runtime>(NULL);
- } else {
- const std::string currentBinaryFQN = getCurrentBinaryFileFQN();
- const uint32_t lastPathSeparatorPosition = currentBinaryFQN.find_last_of("/\\");
- const std::string currentBinaryPath = currentBinaryFQN.substr(0, lastPathSeparatorPosition + 1);
- auto foundRuntimeLoader = registeredRuntimeLoadFunctions_->find(requestedMiddlewareName);
- if (foundRuntimeLoader != registeredRuntimeLoadFunctions_->end()) {
- return (foundRuntimeLoader->second)();
- }
- //One should not get here
- loadState = LoadState::BINDING_ERROR;
- return std::shared_ptr<Runtime>(NULL);
- }
- }
-
- const std::vector<std::string>& librarySearchPaths = Configuration::getInstance().getLibrarySearchPaths();
-
- LibraryVersion highestVersionFound = {0, 0, 0};
- std::string fqnOfHighestVersion = "";
-
- for (const std::string& singleSearchPath: librarySearchPaths) {
- std::vector<std::string> orderedLibraries = readDirectory(singleSearchPath);
-
- for (const std::string& fqnOfEntry : orderedLibraries) {
- std::string versionString;
- LibraryVersion currentLibraryVersion = {-1, -1, -1};
-
- const char* fileNamePtr = fqnOfEntry.c_str();
- while ((fileNamePtr = strchr(fileNamePtr + 1, '.'))) {
- if (strncmp(".so", fileNamePtr, 3) == 0) {
- break;
- }
- }
-
- const char* positionOfFirstDot = strchr(fileNamePtr + 1, '.');
- if (positionOfFirstDot) {
- versionString = positionOfFirstDot + 1;
- }
-
- std::vector<std::string> versionElements = split(versionString, '.');
- if (versionElements.size() >= 1 && containsOnlyDigits(versionElements[0])) {
- currentLibraryVersion.major = strtol(versionElements[0].c_str(), NULL, 0);
- }
- if (versionElements.size() >= 3 && containsOnlyDigits(versionElements[2])) {
- currentLibraryVersion.minor = strtol(versionElements[1].c_str(), NULL, 0);
- currentLibraryVersion.revision = strtol(versionElements[2].c_str(), NULL, 0);
- }
-
- if (highestVersionFound < currentLibraryVersion) {
- if (!checkAndLoadLibrary(fqnOfEntry, requestedMiddlewareName, false)) {
- continue;
- }
- highestVersionFound = currentLibraryVersion;
- fqnOfHighestVersion = fqnOfEntry;
- }
- }
- }
-
- if (fqnOfHighestVersion != "") {
- checkAndLoadLibrary(fqnOfHighestVersion, requestedMiddlewareName, true);
-
- auto foundRuntimeLoader = registeredRuntimeLoadFunctions_->find(requestedMiddlewareName);
- if (foundRuntimeLoader != registeredRuntimeLoadFunctions_->end()) {
- std::shared_ptr<Runtime> loadedRuntime = foundRuntimeLoader->second();
- if (!loadedRuntime) {
- loadState = LoadState::BINDING_ERROR;
- }
- return loadedRuntime;
- }
- }
-
- loadState = LoadState::NO_LIBRARY_FOUND;
-
- return std::shared_ptr<Runtime>();
+ std::lock_guard<std::mutex> itsLock(factoriesMutex_);
+#endif
+ if (_binding == defaultBinding_) {
+ defaultFactory_ = _factory;
+ } else {
+ auto foundFactory = factories_.find(_binding);
+ if (foundFactory == factories_.end()) {
+ factories_[_binding] = _factory;
+ isRegistered = true;
+ }
+ }
+ return isRegistered;
}
-
-std::shared_ptr<Runtime> Runtime::checkDynamicLibraries(LoadState& loadState) {
- const std::vector<std::string>& librarySearchPaths = Configuration::getInstance().getLibrarySearchPaths();
-
- for (const std::string& singleSearchPath : librarySearchPaths) {
- std::vector<std::string> orderedLibraries = readDirectory(singleSearchPath);
-
- for (const std::string& fqnOfEntry: orderedLibraries) {
- std::string foundBindingName;
- if (!checkAndLoadDefaultLibrary(foundBindingName, fqnOfEntry)) {
- continue;
- }
-
- auto foundRuntimeLoader = registeredRuntimeLoadFunctions_->find(foundBindingName);
- if (foundRuntimeLoader != registeredRuntimeLoadFunctions_->end()) {
- return (foundRuntimeLoader->second)();
- }
- }
- }
-
- loadState = LoadState::NO_LIBRARY_FOUND;
-
- return std::shared_ptr<Runtime>();
-}
+bool
+Runtime::unregisterFactory(const std::string &_binding) {
+ COMMONAPI_DEBUG("Unregistering factory for binding=", _binding);
+#ifndef WIN32
+ std::lock_guard<std::mutex> itsLock(factoriesMutex_);
#endif
-
-void Runtime::registerRuntimeLoader(const std::string& middlewareName, const MiddlewareRuntimeLoadFunction& middlewareRuntimeLoadFunction) {
- if (!registeredRuntimeLoadFunctions_) {
- registeredRuntimeLoadFunctions_ = new std::unordered_map<std::string, MiddlewareRuntimeLoadFunction>();
- }
- if (!isDynamic_) {
- registeredRuntimeLoadFunctions_->insert( {middlewareName, middlewareRuntimeLoadFunction});
- }
+ if (_binding == defaultBinding_) {
+ defaultFactory_.reset();
+ } else {
+ factories_.erase(_binding);
+ }
+ return true;
}
-
-std::shared_ptr<Runtime> Runtime::load() {
- LoadState dummyState;
- return load(dummyState);
+/*
+ * Private
+ */
+void Runtime::init() {
+ static bool isInitialized(false);
+#ifndef WIN32
+ std::lock_guard<std::mutex> itsLock(mutex_);
+#endif
+ if (!isInitialized) {
+ // Determine default configuration file
+ const char *config = getenv("COMMONAPI_CONFIG");
+ if (config) {
+ defaultConfig_ = config;
+ } else {
+ defaultConfig_ = COMMONAPI_DEFAULT_CONFIG_FOLDER;
+ defaultConfig_ += "/";
+ defaultConfig_ += COMMONAPI_DEFAULT_CONFIG_FILE;
+ }
+
+ // TODO: evaluate return parameter and decide what to do
+ (void)readConfiguration();
+
+ // Determine default ipc & shared library folder
+ const char *binding = getenv("COMMONAPI_DEFAULT_BINDING");
+ if (binding)
+ defaultBinding_ = binding;
+
+ const char *folder = getenv("COMMONAPI_DEFAULT_FOLDER");
+ if (folder)
+ defaultFolder_ = folder;
+
+ // Log settings
+ COMMONAPI_INFO("Using default binding \'", defaultBinding_, "\'");
+ COMMONAPI_INFO("Using default shared library folder \'", defaultFolder_, "\'");
+ COMMONAPI_INFO("Using default configuration file \'", defaultConfig_, "\'");
+
+ isInitialized = true;
+ }
}
-
-std::shared_ptr<Runtime> Runtime::load(LoadState& loadState) {
- isDynamic_ = true;
- loadState = LoadState::SUCCESS;
- if(!registeredRuntimeLoadFunctions_) {
- registeredRuntimeLoadFunctions_ = new std::unordered_map<std::string, MiddlewareRuntimeLoadFunction>();
- }
-
- const std::string& defaultBindingIdentifier = Configuration::getInstance().getDefaultMiddlewareIdentifier();
- if (defaultBindingIdentifier != "") {
- const auto defaultRuntimeLoader = registeredRuntimeLoadFunctions_->find(defaultBindingIdentifier);
- if (defaultRuntimeLoader != registeredRuntimeLoadFunctions_->end()) {
- return (defaultRuntimeLoader->second)();
- }
-
+bool
+Runtime::readConfiguration() {
+#define MAX_PATH_LEN 255
+ std::string config;
+ char currentDirectory[MAX_PATH_LEN];
#ifdef WIN32
- return std::shared_ptr<Runtime>();
+ if (GetCurrentDirectory(MAX_PATH_LEN, currentDirectory)) {
#else
- return checkDynamicLibraries(defaultBindingIdentifier, loadState);
+ if (getcwd(currentDirectory, MAX_PATH_LEN)) {
#endif
+ config = currentDirectory;
+ config += "/";
+ config += COMMONAPI_DEFAULT_CONFIG_FILE;
+
+ struct stat s;
+ if (stat(config.c_str(), &s) != 0) {
+ config = defaultConfig_;
+ }
+ }
+
+ IniFileReader reader;
+ if (!reader.load(config))
+ return false;
+
+ std::shared_ptr<IniFileReader::Section> section
+ = reader.getSection("logging");
+ if (section) {
+ std::string itsConsole = section->getValue("console");
+ std::string itsFile = section->getValue("file");
+ std::string itsDlt = section->getValue("dlt");
+ std::string itsLevel = section->getValue("level");
+
+ Logger::init((itsConsole == "true"),
+ itsFile,
+ (itsDlt == "true"),
+ itsLevel);
+ }
+
+ section = reader.getSection("default");
+ if (section) {
+ std::string binding = section->getValue("binding");
+ if ("" != binding)
+ defaultBinding_ = binding;
+
+ std::string folder = section->getValue("folder");
+ if ("" != folder)
+ defaultFolder_ = folder;
+ }
+
+ section = reader.getSection("proxy");
+ if (section) {
+ for (auto m : section->getMappings()) {
+ COMMONAPI_DEBUG("Adding proxy mapping: ", m.first, " --> ", m.second);
+ libraries_[m.first][true] = m.second;
+ }
+ }
+
+ section = reader.getSection("stub");
+ if (section) {
+ for (auto m : section->getMappings()) {
+ COMMONAPI_DEBUG("Adding stub mapping: ", m.first, " --> ", m.second);
+ libraries_[m.first][false] = m.second;
+ }
+ }
+
+ return true;
+}
- } else {
- const auto defaultRuntimeLoader = registeredRuntimeLoadFunctions_->begin();
- if (defaultRuntimeLoader != registeredRuntimeLoadFunctions_->end()) {
- return (defaultRuntimeLoader->second)();
- }
-#ifdef WIN32
- return std::shared_ptr<Runtime>();
-#else
- return checkDynamicLibraries(loadState);
-#endif
- }
+std::shared_ptr<Proxy>
+Runtime::createProxy(
+ const std::string &_domain, const std::string &_interface, const std::string &_instance,
+ const ConnectionId_t &_connectionId) {
+
+ // Check whether we already know how to create such proxies...
+ std::shared_ptr<Proxy> proxy = createProxyHelper(_domain, _interface, _instance, _connectionId);
+ if (!proxy) {
+ // ...it seems do not, lets try to load a library that does...
+ std::lock_guard<std::mutex> itsGuard(loadMutex_);
+ std::string library = getLibrary(_domain, _interface, _instance, true);
+ if (loadLibrary(library)) {
+ proxy = createProxyHelper(_domain, _interface, _instance, _connectionId);
+ }
+ }
+ return proxy;
}
+std::shared_ptr<Proxy>
+Runtime::createProxy(
+ const std::string &_domain, const std::string &_interface, const std::string &_instance,
+ std::shared_ptr<MainLoopContext> _context) {
+
+ // Check whether we already know how to create such proxies...
+ std::shared_ptr<Proxy> proxy = createProxyHelper(_domain, _interface, _instance, _context);
+ if (!proxy) {
+ // ...it seems do not, lets try to load a library that does...
+ std::lock_guard<std::mutex> itsGuard(loadMutex_);
+ std::string library = getLibrary(_domain, _interface, _instance, true);
+ if (loadLibrary(library)) {
+ proxy = createProxyHelper(_domain, _interface, _instance, _context);
+ }
+ }
+ return proxy;
+}
-std::shared_ptr<Runtime> Runtime::load(const std::string& middlewareIdOrAlias) {
- LoadState dummyState;
- return load(middlewareIdOrAlias, dummyState);
+
+bool
+Runtime::registerStub(const std::string &_domain, const std::string &_interface, const std::string &_instance,
+ std::shared_ptr<StubBase> _stub, const ConnectionId_t &_connectionId) {
+
+ bool isRegistered = registerStubHelper(_domain, _interface, _instance, _stub, _connectionId);
+ if (!isRegistered) {
+ std::string library = getLibrary(_domain, _interface, _instance, false);
+ std::lock_guard<std::mutex> itsGuard(loadMutex_);
+ if (loadLibrary(library)) {
+ isRegistered = registerStubHelper(_domain, _interface, _instance, _stub, _connectionId);
+ }
+ }
+ return isRegistered;
}
-std::shared_ptr<Runtime> Runtime::load(const std::string& middlewareIdOrAlias, LoadState& loadState) {
- isDynamic_ = true;
- loadState = LoadState::SUCCESS;
- if (!registeredRuntimeLoadFunctions_) {
- registeredRuntimeLoadFunctions_ = new std::unordered_map<std::string, MiddlewareRuntimeLoadFunction>();
- }
+bool
+Runtime::registerStub(const std::string &_domain, const std::string &_interface, const std::string &_instance,
+ std::shared_ptr<StubBase> _stub, std::shared_ptr<MainLoopContext> _context) {
+
+ bool isRegistered = registerStubHelper(_domain, _interface, _instance, _stub, _context);
+ if (!isRegistered) {
+ std::string library = getLibrary(_domain, _interface, _instance, false);
+ std::lock_guard<std::mutex> itsGuard(loadMutex_);
+ if (loadLibrary(library)) {
+ isRegistered = registerStubHelper(_domain, _interface, _instance, _stub, _context);
+ }
+ }
+ return isRegistered;
+}
- const std::string middlewareName = Configuration::getInstance().getMiddlewareNameForAlias(middlewareIdOrAlias);
+bool
+Runtime::unregisterStub(const std::string &_domain, const std::string &_interface, const std::string &_instance) {
+ for (auto factory : factories_) {
+ if (factory.second->unregisterStub(_domain, _interface, _instance))
+ return true;
+ }
- auto foundRuntimeLoader = registeredRuntimeLoadFunctions_->find(middlewareName);
- if (foundRuntimeLoader != registeredRuntimeLoadFunctions_->end()) {
- return (foundRuntimeLoader->second)();
- }
+ return (defaultFactory_ ? defaultFactory_->unregisterStub(_domain, _interface, _instance) : false);
+}
-#ifdef WIN32
- return std::shared_ptr<Runtime>();
-#else
- return checkDynamicLibraries(middlewareName, loadState);
-#endif
+std::string
+Runtime::getLibrary(
+ const std::string &_domain, const std::string &_interface, const std::string &_instance,
+ bool _isProxy) {
+
+ std::string library;
+ std::string address = _domain + ":" + _interface + ":" + _instance;
+
+ COMMONAPI_DEBUG("Loading library for ", address, (_isProxy ? " proxy." : " stub."));
+
+ auto libraryIterator = libraries_.find(address);
+ if (libraryIterator != libraries_.end()) {
+ auto addressIterator = libraryIterator->second.find(_isProxy);
+ if (addressIterator != libraryIterator->second.end()) {
+ library = addressIterator->second;
+ return library;
+ }
+ }
+
+ // If no library was explicitely configured, check whether property
+ // "LibraryBase" is set. If yes, use it, if not build default library
+ // name.
+ library = getProperty("LibraryBase");
+ if (library != "") {
+ library = "lib" + library + "-" + defaultBinding_;
+ } else {
+ library = "lib" + _domain + "__" + _interface + "__" + _instance;
+ std::replace(library.begin(), library.end(), '.', '_');
+ }
+
+ return library;
}
+bool
+Runtime::loadLibrary(const std::string &_library) {
+ std::string itsLibrary(_library);
+
+ // TODO: decide whether this really is a good idea...
+ #ifdef WIN32
+ if (itsLibrary.rfind(".dll") != itsLibrary.length() - 4) {
+ itsLibrary += ".dll";
+ }
+ #else
+ if (itsLibrary.rfind(".so") != itsLibrary.length() - 3) {
+ itsLibrary += ".so";
+ }
+ #endif
+
+ bool isLoaded(true);
+ if (loadedLibraries_.end() == loadedLibraries_.find(itsLibrary)) {
+ #ifdef WIN32
+ if (LoadLibrary(itsLibrary.c_str()) != 0) {
+ loadedLibraries_.insert(itsLibrary);
+ COMMONAPI_DEBUG("Loading interface library \"", itsLibrary, "\" succeeded.");
+ } else {
+ COMMONAPI_ERROR("Loading interface library \"", itsLibrary, "\" failed (", GetLastError(), ")");
+ isLoaded = false;
+ }
+ #else
+ if (dlopen(itsLibrary.c_str(), RTLD_LAZY | RTLD_GLOBAL) != 0) {
+ loadedLibraries_.insert(itsLibrary);
+ COMMONAPI_DEBUG("Loading interface library \"", itsLibrary, "\" succeeded.");
+ }
+ else {
+ COMMONAPI_ERROR("Loading interface library \"", itsLibrary, "\" failed (", dlerror(), ")");
+ isLoaded = false;
+ }
+ #endif
+ }
+ return isLoaded;
+}
-std::shared_ptr<MainLoopContext> Runtime::getNewMainLoopContext() const {
- return std::make_shared<MainLoopContext>();
+std::shared_ptr<Proxy>
+Runtime::createProxyHelper(const std::string &_domain, const std::string &_interface, const std::string &_instance,
+ const std::string &_connectionId) {
+ std::lock_guard<std::mutex> itsLock(factoriesMutex_);
+ for (auto factory : factories_) {
+ std::shared_ptr<Proxy> proxy
+ = factory.second->createProxy(_domain, _interface, _instance, _connectionId);
+ if (proxy)
+ return proxy;
+ }
+ return (defaultFactory_ ?
+ defaultFactory_->createProxy(_domain, _interface, _instance, _connectionId)
+ : nullptr);
}
-std::shared_ptr<Factory> Runtime::createFactory(const std::string factoryName,
- const bool nullOnInvalidName) {
- return createFactory(std::shared_ptr<MainLoopContext>(NULL), factoryName, nullOnInvalidName);
+std::shared_ptr<Proxy>
+Runtime::createProxyHelper(const std::string &_domain, const std::string &_interface, const std::string &_instance,
+ std::shared_ptr<MainLoopContext> _context ) {
+ std::lock_guard<std::mutex> itsLock(factoriesMutex_);
+ for (auto factory : factories_) {
+ std::shared_ptr<Proxy> proxy
+ = factory.second->createProxy(_domain, _interface, _instance, _context);
+ if (proxy)
+ return proxy;
+ }
+ return (defaultFactory_ ?
+ defaultFactory_->createProxy(_domain, _interface, _instance, _context) :
+ nullptr);
}
-std::shared_ptr<Factory> Runtime::createFactory(std::shared_ptr<MainLoopContext> mainLoopContext,
- const std::string factoryName,
- const bool nullOnInvalidName) {
- if(mainLoopContext && !mainLoopContext->isInitialized()) {
- return std::shared_ptr<Factory>(NULL);
- }
- return doCreateFactory(mainLoopContext, factoryName, nullOnInvalidName);
+bool
+Runtime::registerStubHelper(const std::string &_domain, const std::string &_interface, const std::string &_instance,
+ std::shared_ptr<StubBase> _stub, const std::string &_connectionId) {
+ bool isRegistered(false);
+ std::lock_guard<std::mutex> itsLock(factoriesMutex_);
+ for (auto factory : factories_) {
+ isRegistered = factory.second->registerStub(_domain, _interface, _instance, _stub, _connectionId);
+ if (isRegistered)
+ return isRegistered;
+ }
+ return (defaultFactory_ ?
+ defaultFactory_->registerStub(_domain, _interface, _instance, _stub, _connectionId) :
+ false);
}
+bool
+Runtime::registerStubHelper(const std::string &_domain, const std::string &_interface, const std::string &_instance,
+ std::shared_ptr<StubBase> _stub, std::shared_ptr<MainLoopContext> _context) {
+ bool isRegistered(false);
+ std::lock_guard<std::mutex> itsLock(factoriesMutex_);
+ for (auto factory : factories_) {
+ isRegistered = factory.second->registerStub(_domain, _interface, _instance, _stub, _context);
+ if (isRegistered)
+ return isRegistered;
+ }
+ return (defaultFactory_ ?
+ defaultFactory_->registerStub(_domain, _interface, _instance, _stub, _context) :
+ false);
+}
-} // namespace CommonAPI
+} //Namespace CommonAPI
diff --git a/src/CommonAPI/Runtime.h b/src/CommonAPI/Runtime.h
deleted file mode 100644
index 15fc05c..0000000
--- a/src/CommonAPI/Runtime.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#if !defined (COMMONAPI_INTERNAL_COMPILATION)
-#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef COMMONAPI_RUNTIME_H_
-#define COMMONAPI_RUNTIME_H_
-
-
-#include "MiddlewareInfo.h"
-#include "MainLoopContext.h"
-
-#include <memory>
-#include <unordered_map>
-#include <string>
-#include <cassert>
-#include <cstring>
-#include <mutex>
-
-
-namespace CommonAPI {
-
-
-class Factory;
-class Runtime;
-class MainLoopContext;
-class ServicePublisher;
-
-/**
- * \brief Represents the CommonAPI runtime bindings available.
- *
- * Represents the CommonAPI runtime bindings available.
- */
-class Runtime {
- public:
- enum class LoadState {
- SUCCESS,
- NO_LIBRARY_FOUND,
- CONFIGURATION_ERROR,
- BINDING_ERROR
- };
-
- virtual ~Runtime() {}
-
- /**
- * \brief Loads the default runtime.
- *
- * Loads the runtime for the default middleware binding. This can be
- * * One of the middleware bindings that were linked at compile time
- * * The first middleware binding that is encountered when resolving bindings at runtime
- * * The middleware binding that was configured as default in the corresponding configuration
- * file (throws an error if no such binding exists)
- *
- * @return The runtime object for the default binding, or null if any error occurred
- */
- static std::shared_ptr<Runtime> load();
-
- /**
- * \brief Loads the default runtime and notifies the caller of any errors.
- *
- * Loads the runtime for the default middleware binding. This can be
- * * One of the middleware bindings that were linked at compile time
- * * The first middleware binding that is encountered when resolving bindings at runtime
- * * The middleware binding that was configured as default in the corresponding configuration
- * file (throws an error if no such binding exists)
- *
- * @param loadState: An enumeration that will be set appropriately after loading has finished or
- * aborted. May be used for debugging purposes.
- *
- * @return The runtime object for the default binding, or null if any error occurred. In the latter
- * case, loadState will be set to an appropriate value.
- */
- static std::shared_ptr<Runtime> load(LoadState& loadState);
-
- /**
- * \brief Loads specified runtime.
- *
- * Loads the runtime for the specified middleware binding. The given well known name can be either
- * the well known name defined by a binding, or a configured alias for a binding.
- *
- * @param middlewareIdOrAlias A well known name or an alias for a binding
- *
- * @return The runtime object for specified binding, or null if any error occurred.
- */
- static std::shared_ptr<Runtime> load(const std::string& middlewareIdOrAlias);
-
- /**
- * \brief Loads specified runtime.
- *
- * Loads the runtime for the specified middleware binding. The given well known name can be either
- * the well known name defined by a binding, or a configured alias for a binding.
- *
- * @param middlewareIdOrAlias A well known name or an alias for a binding.
- * @param loadState: An enumeration that will be set appropriately after loading has finished or
- * aborted. May be used for debugging purposes.
- *
- * @return The runtime object for specified binding, or null if any error occurred. In the latter
- * case, loadState will be set to an appropriate value.
- */
- static std::shared_ptr<Runtime> load(const std::string& middlewareIdOrAlias, LoadState& loadState);
-
- /**
- * \brief Called by bindings to register their runtime loaders. Do not call from applications.
- *
- * Called by bindings to register their runtime loaders. Do not call from applications.
- */
- static void registerRuntimeLoader(const std::string& middlewareName, const MiddlewareRuntimeLoadFunction& middlewareRuntimeLoadFunction);
-
- /**
- * \brief Returns new MainLoopContext.
- *
- * Creates and returns a new MainLoopContext object. This context can be used to take
- * complete control over the order and time of execution of the abstract middleware
- * dispatching mechanism. Make sure to register all callback functions before subsequently
- * handing it to createFactory(), as during creation of the factory object the callbacks may
- * already be called.
- *
- * @return A new MainLoopContext object
- */
- std::shared_ptr<MainLoopContext> getNewMainLoopContext() const;
-
- /**
- * \brief Create a factory for the loaded runtime.
- *
- * Create a factory for the loaded runtime
- *
- * @param mainLoopContext: In case mainloop integration shall be used, a std::shared_ptr<MainLoopContext> can be passed in.
- * If no parameter is given, internal threading will handle sending and receiving of messages automatically.
- * If the mainloop context is not initialized, no factory will be returned. See documentation of
- * MainLoopContext::isInitialized().
- *
- * @param factoryName: If additional configuration parameters for the specific middleware factory shall be provided,
- * the appropriate set of parameters may be identified by this name. See accompanying documentation for
- * usage of configuration files.
- *
- * @param nullOnInvalidName: If a factoryName is provided, this parameter determines whether the standard configuration
- * for factories shall be used if the specific parameter set cannot be found, or if instead no factory
- * shall be returned in this case.
- *
- * @return Factory object for this runtime
- */
- std::shared_ptr<Factory> createFactory(std::shared_ptr<MainLoopContext> mainLoopContext = std::shared_ptr<MainLoopContext>(NULL),
- const std::string factoryName = "",
- const bool nullOnInvalidName = false);
-
- /**
- * \brief Create a factory for the loaded runtime.
- *
- * Create a factory for the loaded runtime
- *
- * @param factoryName: If additional configuration parameters for the specific middleware factory shall be provided,
- * the appropriate set of parameters may be identified by this name. See accompanying documentation for
- * usage of configuration files.
- *
- * @param nullOnInvalidName: If a factoryName is provided, this parameter determines whether the standard configuration
- * for factories shall be used if the specific parameter set cannot be found, or if instead no factory
- * shall be returned in this case.
- *
- * @return Factory object for this runtime
- */
- std::shared_ptr<Factory> createFactory(const std::string factoryNamey,
- const bool nullOnInvalidName = false);
-
- /**
- * \brief Returns the ServicePublisher object for this runtime.
- *
- * Returns the ServicePublisher object for this runtime. Use the interface
- * provided by the ServicePublisher to publish and de-publish the services that
- * your application will provide to the outside world over the middleware
- * represented by this runtime. A ServicePublisher exists once per middleware.
- *
- * @return The ServicePublisher object for this runtime
- */
- virtual std::shared_ptr<ServicePublisher> getServicePublisher() = 0;
-
- protected:
- virtual std::shared_ptr<Factory> doCreateFactory(std::shared_ptr<MainLoopContext> mainLoopContext,
- const std::string& factoryName,
- const bool nullOnInvalidName = false) = 0;
-
- private:
- static const std::vector<std::string> readDirectory(const std::string& path);
-
- static std::shared_ptr<Runtime> checkDynamicLibraries(LoadState& loadState);
- static std::shared_ptr<Runtime> checkDynamicLibraries(const std::string& middlewareName, LoadState& loadState);
-
- static bool tryLoadLibrary(const std::string& libraryPath, void** sharedLibraryHandle, MiddlewareInfo** foundMiddlewareInfo);
- static bool checkAndLoadLibrary(const std::string& libraryPath, const std::string& requestedMiddlewareName, bool keepLibrary);
- static bool checkAndLoadDefaultLibrary(std::string& foundBindingName, const std::string& libraryPath);
-
- static void closeHandle(void* libraryHandle);
-};
-
-
-} // namespace CommonAPI
-
-#endif // COMMONAPI_RUNTIME_H_
diff --git a/src/CommonAPI/SelectiveEvent.h b/src/CommonAPI/SelectiveEvent.h
deleted file mode 100644
index c430e8d..0000000
--- a/src/CommonAPI/SelectiveEvent.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#if !defined (COMMONAPI_INTERNAL_COMPILATION)
-#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef COMMONAPI_SELECTIVE_EVENT_H_
-#define COMMONAPI_SELECTIVE_EVENT_H_
-
-#include "Event.h"
-
-namespace CommonAPI {
-
-template<typename ... _Arguments>
-class SelectiveEvent: public Event<_Arguments...> {
-public:
- typedef typename Event<_Arguments...>::Listener Listener;
- typedef typename Event<_Arguments...>::Subscription Subscription;
-
- virtual ~SelectiveEvent() {
- }
-
- Subscription subscribe(Listener listener) {
- // just delegate
- bool success;
- return subscribe(listener, success);
- }
-
- /**
- * \brief Subscribe a listener to this event and be notified of success
- *
- * Subscribe a listener to this event and be notified of success via the passed reference.
- * ATTENTION: You should not build new proxies or register services in callbacks
- * from events. This can cause a deadlock or assert. Instead, you should set a
- * trigger for your application to do this on the next iteration of your event loop
- * if needed. The preferred solution is to build all proxies you need at the
- * beginning and react to events appropriatly for each.
- *
- * @param listener A listener to be added
- * @param success Indicates whether subscription was accepted
- * @return A token identifying this subscription
- */
- virtual Subscription subscribe(Listener listener, bool& success) = 0;
-};
-
-} // namespace CommonAPI
-
-#endif
diff --git a/src/CommonAPI/SerializableStruct.h b/src/CommonAPI/SerializableStruct.h
deleted file mode 100644
index c704387..0000000
--- a/src/CommonAPI/SerializableStruct.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#if !defined (COMMONAPI_INTERNAL_COMPILATION)
-#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef COMMONAPI_SERIALIZABLE_STRUCT_H_
-#define COMMONAPI_SERIALIZABLE_STRUCT_H_
-
-#include <cstdint>
-#include <memory>
-
-
-namespace CommonAPI {
-
-class InputStream;
-class OutputStream;
-class TypeOutputStream;
-
-struct SerializableStruct {
- virtual ~SerializableStruct() { }
-
- virtual void readFromInputStream(InputStream& inputStream) = 0;
- virtual void writeToOutputStream(OutputStream& outputStream) const = 0;
-};
-
-struct SerializablePolymorphicStruct: SerializableStruct {
- virtual uint32_t getSerialId() const = 0;
- virtual void createTypeSignature(TypeOutputStream& typeOutputStream) const = 0;
-};
-
-} // namespace CommonAPI
-
-#endif // COMMONAPI_SERIALIZABLE_STRUCT_H_
diff --git a/src/CommonAPI/SerializableVariant.h b/src/CommonAPI/SerializableVariant.h
deleted file mode 100644
index 78daee3..0000000
--- a/src/CommonAPI/SerializableVariant.h
+++ /dev/null
@@ -1,257 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#if !defined (COMMONAPI_INTERNAL_COMPILATION)
-#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef COMMONAPI_SERIALIZABLE_VARIANT_H_
-#define COMMONAPI_SERIALIZABLE_VARIANT_H_
-
-#include <memory>
-#include <cstdint>
-#include <iostream>
-#include <string>
-#include <tuple>
-#include <type_traits>
-#include <cassert>
-
-namespace CommonAPI {
-
-class InputStream;
-class OutputStream;
-
-class TypeOutputStream;
-
-template<typename _Type>
-struct TypeWriter;
-
-/**
- * \brief A variant class which can be serialised by bindings.
- *
- * A variant class which can be serialised by bindings.
- */
-class SerializableVariant {
-public:
- virtual ~SerializableVariant() {
- }
-
- virtual uint8_t getValueType() const = 0;
-
- virtual void readFromInputStream(const uint8_t typeIndex, InputStream& inputStream) = 0;
- virtual void writeToOutputStream(OutputStream& outputStream) const = 0;
-
- virtual void writeToTypeOutputStream(TypeOutputStream& typeOutputStream) const = 0;
-};
-
-template<typename ... _Types>
-struct MaxSize;
-
-template<>
-struct MaxSize<> {
- static const unsigned int value = 0;
-};
-
-template<typename _Type, typename ... _Types>
-struct MaxSize<_Type, _Types...> {
- static const unsigned int current_type_size = sizeof(_Type);
- static const unsigned int next_type_size = MaxSize<_Types...>::value;
- static const unsigned int value =
- current_type_size > next_type_size ?
- current_type_size : next_type_size;
-};
-
-template<typename _SearchType, typename ... _RestTypes>
-struct VariantTypeSelector;
-
-template<typename _SearchType, typename ... _RestTypes>
-struct VariantTypeSelector<_SearchType, _SearchType, _RestTypes...> {
- typedef _SearchType type;
-};
-
-/**
- * \brief A templated generic variant class which provides type safe access and operators
- *
- * A templated generic variant class which provides type safe access and operators
- */
-template<typename ... _Types>
-class Variant: public SerializableVariant {
-private:
- typedef std::tuple_size<std::tuple<_Types...>> TypesTupleSize;
-
-public:
-
- static const unsigned int maxSize = MaxSize<_Types...>::value;
-
- /**
- * \brief Construct an empty variant
- *
- * Construct an empty variant
- */
- Variant();
-
-
- /**
- * \brief Copy constructor. Must have identical templates.
- *
- * Copy constructor. Must have identical templates.
- *
- * @param fromVariant Variant to copy
- */
- Variant(const Variant& fromVariant);
-
- /**
- * \brief Copy constructor. Must have identical templates.
- *
- * Copy constructor. Must have identical templates.
- *
- * @param fromVariant Variant to copy
- */
- Variant(Variant&& fromVariant);
-
- ~Variant();
-
- virtual void readFromInputStream(const uint8_t typeIndex, InputStream& inputStream);
-
- virtual void writeToOutputStream(OutputStream& outputStream) const;
-
- virtual void writeToTypeOutputStream(TypeOutputStream& typeOutputStream) const;
-
- /**
- * \brief Assignment of another variant. Must have identical templates.
- *
- * Assignment of another variant. Must have identical templates.
- *
- * @param rhs Variant to assign
- */
- Variant& operator=(const Variant& rhs);
- /**
- * \brief Assignment of another variant. Must have identical templates.
- *
- * Assignment of another variant. Must have identical templates.
- *
- * @param rhs Variant to assign
- */
- Variant& operator=(Variant&& rhs);
-
- /**
- * \brief Assignment of a contained type. Must be one of the valid templated types.
- *
- * Assignment of a contained type. Must be one of the valid templated types.
- *
- * @param value Value to assign
- */
- template<typename _Type>
- typename std::enable_if<!std::is_same<_Type, Variant<_Types...>>::value, Variant<_Types...>&>::type
- operator=(const _Type& value);
-
- /**
- * \brief Equality of another variant. Must have identical template list and content.
- *
- * Equality of another variant. Must have identical template list and content.
- *
- * @param rhs Variant to compare
- */
- bool operator==(const Variant<_Types...>& rhs) const;
-
- /**
- * \brief Not-Equality of another variant. Must have identical template list and content.
- *
- * Not-Equality of another variant. Must have identical template list and content.
- *
- * @param rhs Variant to compare
- */
- bool operator!=(const Variant<_Types...>& rhs) const;
-
- /**
- * \brief Testif the contained type is the same as the template on this method.
- *
- * Testif the contained type is the same as the template on this method.
- *
- * @return Is same type
- */
- template <typename _Type>
- const bool isType() const;
-
- /**
- * \brief Construct variant with content type set to value.
- *
- * Construct variant with content type set to value.
- *
- * @param value Value to place
- */
- template <typename _Type>
- Variant(const _Type& value,
- typename std::enable_if<!std::is_const<_Type>::value>::type* = 0,
- typename std::enable_if<!std::is_reference<_Type>::value>::type* = 0,
- typename std::enable_if<!std::is_same<_Type, Variant>::value>::type* = 0);
-
- /**
- * \brief Construct variant with content type set to value.
- *
- * Construct variant with content type set to value.
- *
- * @param value Value to place
- */
- template <typename _Type>
- Variant(_Type && value,
- typename std::enable_if<!std::is_const<_Type>::value>::type* = 0,
- typename std::enable_if<!std::is_reference<_Type>::value>::type* = 0,
- typename std::enable_if<!std::is_same<_Type, Variant>::value>::type* = 0);
-
- /**
- * \brief Get value of variant, template to content type. Throws exception if type is not contained.
- *
- * Get value of variant, template to content type. Throws exception if type is not contained.
- */
- template <typename _Type>
- const _Type& get() const;
-
- /**
- * \brief Get index in template list of type actually contained, starting at 1 at the end of the template list
- *
- * Get index in template list of type actually contained, starting at 1 at the end of the template list
- *
- * @return Index of contained type
- */
- uint8_t getValueType() const {
- return valueType_;
- }
-
-private:
-
- template<typename _U>
- void set( const _U& value, const bool clear);
-
- template<typename _U>
- void set( _U&& value, const bool clear);
-
- template<typename _FriendType>
- friend struct TypeWriter;
- template<typename ... _FriendTypes>
- friend struct AssignmentVisitor;
- template<typename _FriendType>
- friend struct TypeEqualsVisitor;
- template<typename ... _FriendTypes>
- friend struct PartialEqualsVisitor;
- template<typename ... _FriendTypes>
- friend struct InputStreamReadVisitor;
- template<class Variant, typename ... _FTypes>
- friend struct ApplyVoidIndexVisitor;
-
-protected:
- inline bool hasValue() const {
- return valueType_ < TypesTupleSize::value;
- }
- uint8_t valueType_;
- typename std::aligned_storage<maxSize>::type valueStorage_;
-};
-} // namespace CommonAPI
-
-#include "SerializableVariant.hpp"
-
-#endif // COMMONAPI_SERIALIZABLE_VARIANT_H_
diff --git a/src/CommonAPI/SerializableVariant.hpp b/src/CommonAPI/SerializableVariant.hpp
deleted file mode 100644
index fe9a53d..0000000
--- a/src/CommonAPI/SerializableVariant.hpp
+++ /dev/null
@@ -1,522 +0,0 @@
-/* Copyright (C) 2013 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/. */
-#ifndef COMMONAPI_SERIALIZABLE_VARIANT_IMPL_
-#define COMMONAPI_SERIALIZABLE_VARIANT_IMPL_
-
-#include "OutputStream.h"
-#include "InputStream.h"
-
-#include <exception>
-
-
-namespace CommonAPI {
-
-template<class Variant, typename ... _Types>
-struct ApplyVoidIndexVisitor;
-
-template<class Variant>
-struct ApplyVoidIndexVisitor<Variant> {
- static const uint8_t index = 0;
-
- static
- void visit(Variant&, uint8_t&) {
- //won't be called
- assert(false);
- }
-};
-
-template<class Variant, typename _Type, typename ... _Types>
-struct ApplyVoidIndexVisitor<Variant, _Type, _Types...> {
- static const uint8_t index = ApplyVoidIndexVisitor<Variant,
- _Types...>::index + 1;
-
- static void visit(Variant& var, uint8_t& ind) {
- if (ind == index) {
- new (&var.valueStorage_) _Type();
- var.valueType_ = index;
- } else {
- ApplyVoidIndexVisitor<Variant, _Types...>::visit(var, ind);
- }
- }
-};
-
-template<class Visitor, class Variant, typename ... _Types>
-struct ApplyVoidVisitor;
-
-template<class Visitor, class Variant>
-struct ApplyVoidVisitor<Visitor, Variant> {
- static const uint8_t index = 0;
-
- static
- void visit(Visitor&, Variant&) {
- //won't be called
- assert(false);
- }
-
- static
- void visit(Visitor&, const Variant&) {
- //won't be called
- assert(false);
- }
-};
-
-template<class Visitor, class Variant, typename _Type, typename ... _Types>
-struct ApplyVoidVisitor<Visitor, Variant, _Type, _Types...> {
- static const uint8_t index = ApplyVoidVisitor<Visitor, Variant,
- _Types...>::index + 1;
-
- static void visit(Visitor& visitor, Variant& var) {
- if (var.getValueType() == index) {
- visitor(var.template get<_Type>());
- } else {
- ApplyVoidVisitor<Visitor, Variant, _Types...>::visit(visitor, var);
- }
- }
-
- static void visit(Visitor& visitor, const Variant& var) {
- if (var.getValueType() == index) {
- visitor(var.template get<_Type>());
- } else {
- ApplyVoidVisitor<Visitor, Variant, _Types...>::visit(visitor, var);
- }
- }
-};
-
-template<class Visitor, class Variant, typename ... _Types>
-struct ApplyBoolVisitor
-;
-
-template<class Visitor, class Variant>
-struct ApplyBoolVisitor<Visitor, Variant> {
- static const uint8_t index = 0;
-
- static bool visit(Visitor&, Variant&) {
- //won't be called
- assert(false);
- return false;
- }
-};
-
-template<class Visitor, class Variant, typename _Type, typename ... _Types>
-struct ApplyBoolVisitor<Visitor, Variant, _Type, _Types...> {
- static const uint8_t index = ApplyBoolVisitor<Visitor, Variant,
- _Types...>::index + 1;
-
- static bool visit(Visitor& visitor, Variant& var) {
- if (var.getValueType() == index) {
- return visitor(var.template get<_Type>());
- } else {
- return ApplyBoolVisitor<Visitor, Variant, _Types...>::visit(visitor,
- var);
- }
- }
-};
-
-template<uint8_t size>
-struct DeleteVisitor {
-public:
- DeleteVisitor(typename std::aligned_storage<size>::type& storage) :
- storage_(storage) {
- }
-
- template<typename _Type>
- void operator()(const _Type&) const {
- (reinterpret_cast<const _Type *>(&storage_))->~_Type();
- }
-
-private:
- typename std::aligned_storage<size>::type& storage_;
-};
-
-struct TypeOutputStreamWriteVisitor {
-public:
- TypeOutputStreamWriteVisitor(TypeOutputStream& typeStream) :
- typeStream_(typeStream) {
- }
-
- template<typename _Type>
- void operator()(const _Type&) const {
- TypeWriter<_Type>::writeType(typeStream_);
- }
-
-private:
- TypeOutputStream& typeStream_;
-};
-
-struct OutputStreamWriteVisitor {
-public:
- OutputStreamWriteVisitor(OutputStream& outputStream) :
- outputStream_(outputStream) {
- }
-
- template<typename _Type>
- void operator()(const _Type& value) const {
- outputStream_ << value;
- }
-
-private:
- OutputStream& outputStream_;
-};
-
-
-template<typename ... _Types>
-struct InputStreamReadVisitor {
-public:
- InputStreamReadVisitor(Variant<_Types...>& lhs, InputStream& inputStream) :
- lhs_(lhs),
- inputStream_(inputStream) {
- }
-
- template<typename _Type>
- void operator()(const _Type&) {
- _Type value;
- inputStream_ >> value;
-#ifdef WIN32
- lhs_.set<_Type>(std::move(value), false);
-#else
- lhs_.Variant<_Types...>::template set<_Type>(std::move(value), false);
-#endif
- }
-
-private:
- Variant<_Types...>& lhs_;
- InputStream& inputStream_;
-};
-
-
-template<typename _Type>
-struct TypeEqualsVisitor
-{
-public:
- TypeEqualsVisitor(const _Type& rhs): rhs_(rhs) {
- }
-
- bool operator()(const _Type& lhs) const {
- return lhs == rhs_;
- }
-
- template<typename _U>
- bool operator()(const _U&) const {
- return false;
- }
-
-private:
- const _Type& rhs_;
-};
-
-template<typename ... _Types>
-struct PartialEqualsVisitor
-{
-public:
- PartialEqualsVisitor(const Variant<_Types...>& lhs) :
- lhs_(lhs) {
- }
-
- template<typename _Type>
- bool
- operator()(const _Type& rhs) const
- {
- TypeEqualsVisitor<_Type> visitor(rhs);
- return ApplyBoolVisitor<TypeEqualsVisitor<_Type>, const Variant<_Types...>, _Types...>::visit(visitor, lhs_);
- }
-
-private:
- const Variant<_Types...>& lhs_;
-};
-
-template<typename ... _Types>
-struct AssignmentVisitor {
-public:
- AssignmentVisitor(Variant<_Types...>& lhs, const bool clear = true) :
- lhs_(lhs), clear_(clear) {
- }
-
- template<typename _Type>
- void operator()(const _Type& value) const {
-#ifdef WIN32
- lhs_.set<_Type>(value, clear_);
-#else
- lhs_.Variant<_Types...>::template set<_Type>(value, clear_);
-#endif
- }
-
- template<typename _Type>
- void operator()(_Type& value) const {
- lhs_.Variant<_Types...>::template set<_Type>(value, clear_);
- }
-
-private:
- Variant<_Types...>& lhs_;
- const bool clear_;
-};
-
-template<typename ... _Types>
-struct TypeSelector;
-
-template<typename _U>
-struct TypeSelector<_U> {
-};
-
-//_U == _Type
-template<typename _Type, typename ... _Types>
-struct TypeSelector<_Type, _Type, _Types...> {
- typedef _Type type;
-};
-
-//_U& == _Type
-template<typename _Type, typename ... _Types>
-struct TypeSelector<_Type, _Type&, _Types...> {
- typedef _Type& type;
-};
-
-//_U == _Type&
-template<typename _Type, typename ... _Types>
-struct TypeSelector<_Type&, _Type, _Types...> {
- typedef _Type type;
-};
-
-//const _U& == _Type
-template<typename _Type, typename ... _Types>
-struct TypeSelector<_Type, const _Type&, _Types...> {
- typedef const _Type& type;
-};
-
-//_U == const _Type&
-template<typename _Type, typename ... _Types>
-struct TypeSelector<const _Type&, _Type, _Types...> {
- typedef _Type type;
-};
-
-//_U == X*
-//_Type == const X*
-template<typename _Type, typename ... _Types>
-struct TypeSelector<_Type*, const _Type*, _Types...> {
- typedef const _Type* type;
-};
-
-//_U == X&
-//_Type == const X&
-template<typename _Type, typename ... _Types>
-struct TypeSelector<_Type&, const _Type&, _Types...> {
- typedef const _Type& type;
-};
-
-//_U != _Type, let's try to find _U among _Types
-template<typename _U, typename _Type, typename ... _Types>
-struct TypeSelector<_U, _Type, _Types...> {
- typedef typename TypeSelector<_U, _Types...>::type type;
-};
-
-template<typename ... _Types>
-struct TypeIndex;
-
-template<>
-struct TypeIndex<> {
- static const uint8_t index = 0;
-
- template<typename _U>
- static uint8_t get() {
- return 0;
- }
-};
-
-template<typename _Type, typename ... _Types>
-struct TypeIndex<_Type, _Types...> {
- static const uint8_t index = TypeIndex<_Types...>::index + 1;
-
- template<typename _U>
- static uint8_t get(
- typename std::enable_if<std::is_same<_Type, _U>::value>::type* = 0) {
- return index;
- }
-
- template<typename _U>
- static uint8_t get(typename std::enable_if<!std::is_same<_Type, _U>::value>::type* = 0) {
- return TypeIndex<_Types...>::template get<_U>();
- }
-};
-
-template<typename ... _Types>
-Variant<_Types...>::Variant() :
- valueType_(TypesTupleSize::value) {
- ApplyVoidIndexVisitor<Variant<_Types...>, _Types...>::visit(*this, valueType_);
-}
-
-template<typename ... _Types>
-Variant<_Types...>::Variant(const Variant& fromVariant) {
- AssignmentVisitor<_Types...> visitor(*this, false);
- ApplyVoidVisitor<AssignmentVisitor<_Types...> , Variant<_Types...>, _Types...>::visit(visitor, fromVariant);
-}
-
-template<typename ... _Types>
-Variant<_Types...>::Variant(Variant&& fromVariant)
-{
- AssignmentVisitor<_Types...> visitor(*this, false);
- ApplyVoidVisitor<AssignmentVisitor<_Types...> , Variant<_Types...>, _Types...>::visit(visitor, fromVariant);
-}
-
-/*template<typename ... _Types>
-Variant<_Types...>::Variant(Variant&& fromVariant) :
- valueType_(std::move(fromVariant.valueType_)),
- valueStorage_(std::move(fromVariant.valueStorage_))
-{
-}*/
-
-template<typename ... _Types>
-Variant<_Types...>::~Variant() {
- if (hasValue()) {
- DeleteVisitor<maxSize> visitor(valueStorage_);
- ApplyVoidVisitor<DeleteVisitor<maxSize>, Variant<_Types...>, _Types...>::visit(visitor, *this);
- }
-}
-
-template<typename ... _Types>
-void Variant<_Types...>::readFromInputStream(const uint8_t typeIndex, InputStream& inputStream) {
- if(hasValue()) {
- DeleteVisitor<maxSize> visitor(valueStorage_);
- ApplyVoidVisitor<DeleteVisitor<maxSize>, Variant<_Types...>, _Types...>::visit(visitor, *this);
- }
- valueType_ = typeIndex;
- InputStreamReadVisitor<_Types...> visitor(*this, inputStream);
- ApplyVoidVisitor<InputStreamReadVisitor<_Types...>, Variant<_Types...>, _Types...>::visit(visitor, *this);
-}
-
-template<typename ... _Types>
-void Variant<_Types...>::writeToOutputStream(OutputStream& outputStream) const {
- OutputStreamWriteVisitor visitor(outputStream);
- ApplyVoidVisitor<OutputStreamWriteVisitor, Variant<_Types...>, _Types...>::visit(
- visitor, *this);
-}
-
-template<typename ... _Types>
-void Variant<_Types...>::writeToTypeOutputStream(TypeOutputStream& typeOutputStream) const {
- TypeOutputStreamWriteVisitor visitor(typeOutputStream);
- ApplyVoidVisitor<TypeOutputStreamWriteVisitor, Variant<_Types...>, _Types...>::visit(
- visitor, *this);
-}
-
-template<typename ... _Types>
-Variant<_Types...>& Variant<_Types...>::operator=(const Variant<_Types...>& rhs) {
- AssignmentVisitor<_Types...> visitor(*this, hasValue());
- ApplyVoidVisitor<AssignmentVisitor<_Types...>, Variant<_Types...>, _Types...>::visit(
- visitor, rhs);
- return *this;
-}
-
-template<typename ... _Types>
-Variant<_Types...>& Variant<_Types...>::operator=(Variant<_Types...>&& rhs) {
- AssignmentVisitor<_Types...> visitor(*this, hasValue());
- ApplyVoidVisitor<AssignmentVisitor<_Types...>, Variant<_Types...>, _Types...>::visit(visitor, rhs);
- return *this;
-}
-
-template<typename ... _Types>
-template<typename _Type>
-typename std::enable_if<!std::is_same<_Type, Variant<_Types...>>::value, Variant<_Types...>&>::type
-Variant<_Types...>::operator=(const _Type& value) {
- set<typename TypeSelector<_Type, _Types...>::type>(value, hasValue());
- return *this;
-}
-
-template<typename ... _Types>
-template<typename _Type>
-const bool Variant<_Types...>::isType() const {
- typedef typename TypeSelector<_Type, _Types...>::type selected_type_t;
- uint8_t cType = TypeIndex<_Types...>::template get<selected_type_t>();
- if (cType == valueType_) {
- return true;
- } else {
- return false;
- }
-}
-
-template<typename ... _Types>
-template<typename _Type>
-Variant<_Types...>::Variant(const _Type& value,
- typename std::enable_if<!std::is_const<_Type>::value>::type*,
- typename std::enable_if<!std::is_reference<_Type>::value>::type*,
- typename std::enable_if<!std::is_same<_Type, Variant<_Types...>>::value>::type*) {
- set<typename TypeSelector<_Type, _Types...>::type>(value, false);
-}
-
-template<typename ... _Types>
-template<typename _Type>
-Variant<_Types...>::Variant(_Type && value,
-typename std::enable_if<!std::is_const<_Type>::value>::type*,
-typename std::enable_if<!std::is_reference<_Type>::value>::type*,
-typename std::enable_if<!std::is_same<_Type, Variant<_Types...>>::value>::type*) {
- set<typename TypeSelector<_Type, _Types...>::type>(std::move(value), false);
-}
-
-
-template<typename ... _Types>
-template<typename _Type>
-const _Type & Variant<_Types...>::get() const {
- typedef typename TypeSelector<_Type, _Types...>::type selected_type_t;
- uint8_t cType = TypeIndex<_Types...>::template get<selected_type_t>();
- if (cType == valueType_) {
- return *(reinterpret_cast<const _Type *>(&valueStorage_));
- } else {
-#if defined(__EXCEPTIONS) || defined(WIN32)
- std::bad_cast toThrow;
- throw toThrow;
-#else
- printf("SerializableVariant.hpp:%i %s: Incorrect access to variant; attempting to get type not currently contained", __LINE__, __FUNCTION__);
- abort();
-#endif
- }
-}
-
-
-template<typename ... _Types>
-template<typename _U>
-void Variant<_Types...>::set(const _U& value, const bool clear) {
- typedef typename TypeSelector<_U, _Types...>::type selected_type_t;
-
- if (clear) {
- DeleteVisitor<maxSize> visitor(valueStorage_);
- ApplyVoidVisitor<DeleteVisitor<maxSize>, Variant<_Types...>, _Types...>::visit(visitor, *this);
- }
- new (&valueStorage_) selected_type_t(std::move(value));
- valueType_ = TypeIndex<_Types...>::template get<selected_type_t>();
-}
-
-template<typename ... _Types>
-template<typename _U>
-void Variant<_Types...>::set(_U&& value, const bool clear) {
- typedef typename TypeSelector<_U, _Types...>::type selected_type_t;
-
- selected_type_t&& any_container_value = std::move(value);
- if(clear)
- {
- DeleteVisitor<maxSize> visitor(valueStorage_);
- ApplyVoidVisitor<DeleteVisitor<maxSize>, Variant<_Types...>, _Types...>::visit(visitor, *this);
- } else {
- new (&valueStorage_) selected_type_t(std::move(any_container_value));
- }
-
- valueType_ = TypeIndex<_Types...>::template get<selected_type_t>();
-}
-
-template<typename ... _Types>
-bool Variant<_Types...>::operator==(const Variant<_Types...>& rhs) const
- {
- PartialEqualsVisitor<_Types...> visitor(*this);
- return ApplyBoolVisitor<PartialEqualsVisitor<_Types...>, const Variant<_Types...>, _Types...>::visit(
- visitor,
- rhs);
-}
-
-template<typename ... _Types>
-bool Variant<_Types...>::operator!=(const Variant<_Types...>& rhs) const
- {
- return !(*this == rhs);
-}
-
-}
-
-#endif //COMMONAPI_SERIALIZABLE_VARIANT_IMPL_
diff --git a/src/CommonAPI/ServicePublisher.cpp b/src/CommonAPI/ServicePublisher.cpp
deleted file mode 100644
index dc89b2b..0000000
--- a/src/CommonAPI/ServicePublisher.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (C) 2013 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 "ServicePublisher.h"
-#include "Stub.h"
-#include "Factory.h"
-
-namespace CommonAPI {
-
-bool ServicePublisher::registerService(const std::shared_ptr<StubBase>& stubBase,
- const char* interfaceId,
- const std::string& participantId,
- const std::string& serviceName,
- const std::string& domain,
- const std::shared_ptr<Factory>& factory) {
- return factory->registerAdapter(stubBase, interfaceId, participantId, serviceName, domain);
-}
-
-} // namespace CommonAPI
diff --git a/src/CommonAPI/ServicePublisher.h b/src/CommonAPI/ServicePublisher.h
deleted file mode 100644
index 3dd6a65..0000000
--- a/src/CommonAPI/ServicePublisher.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#if !defined (COMMONAPI_INTERNAL_COMPILATION)
-#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef COMMONAPI_SERVICE_PUBLISHER_H_
-#define COMMONAPI_SERVICE_PUBLISHER_H_
-
-#include <memory>
-#include <string>
-
-namespace CommonAPI {
-
-class StubBase;
-class Factory;
-
-/**
- * \brief Manages all services that shall be published by the application.
- *
- * Stubs for all services that shall be published will be registered here.
- * This class is defined as singleton per loaded runtime (i.e. per loaded middleware).
- */
-class ServicePublisher {
- public:
- virtual ~ServicePublisher() {}
-
- /**
- * \brief Registers and publishes a service.
- *
- * Registers and publishes a service. Which service is to be published is defined
- * by the stub-pointer that is given as parameter. The given factory will be used
- * to construct all necessary middleware specific objects to do the publishing.
- *
- * \note Note that a call to this method will always result in a registration
- * with the middleware the given factory was instantiated for, not the middleware
- * that matches the runtime this ServicePublisher was retrieved from. Accordingly,
- * unregistering the service will have to be done by using the ServicePublisher
- * that is provided by the runtime matching the middleware that also provided
- * the given factory.
- *
- * @param serviceAddress The CommonAPI address the service shall be reachable at
- * @param stub The stub that provides an implementation for the service
- * @param factory The factory that will be used to construct all necessary middleware specific objects
- *
- * @return 'true' if the service was published successfully, 'false' if not or if another service that uses
- * the exact same address already is registered.
- */
- template<typename _Stub>
- bool registerService(std::shared_ptr<_Stub> stub,
- const std::string& serviceAddress,
- std::shared_ptr<Factory> factory);
-
- /**
- * \brief Registers and publishes a service.
- *
- * Registers and publishes a service. Which service is to be published is defined
- * by the stub-pointer that is given as parameter. The given factory will be used
- * to construct all necessary middleware specific objects to do the publishing.
- *
- * \note Note that a call to this method will always result in a registration
- * with the middleware the given factory was instantiated for, not the middleware
- * that matches the runtime this ServicePublisher was retrieved from. Accordingly,
- * unregistering the service will have to be done by using the ServicePublisher
- * that is provided by the runtime matching the middleware that also provided
- * the given factory.
- *
- * @param participantId The CommonAPI participant ID the service shall be identified with
- * @param serviceName The CommonAPI service name the service shall provide
- * @param domain The CommonAPI domain the service shall be reachable at
- * @param stub The stub that provides an implementation for the service
- * @param factory The factory that will be used to construct all necessary middleware specific objects
- *
- * @return 'true' if the service was published successfully, 'false' if not or if another service that uses
- * the exact same address already is registered.
- */
- template<typename _Stub>
- bool registerService(std::shared_ptr<_Stub> stub,
- const std::string& participantId,
- const std::string& serviceName,
- const std::string& domain,
- std::shared_ptr<Factory> factory);
-
- /**
- * \brief Unregisters and depublishes the service that was published for the given address.
- *
- * Unregisters and depublishes the service that was published for the given CommonAPI address.
- *
- * @param The CommonAPI address the service was registered for
- *
- * @return 'true' if there was a service for the given address and depublishing
- * was successful, 'false' otherwise
- */
- virtual bool unregisterService(const std::string& serviceAddress) = 0;
-
- /**
- * \brief Unregisters and depublishes the service that was published for the given address.
- *
- * Unregisters and depublishes the service that was published for the given CommonAPI address.
- *
- * @param The CommonAPI participant ID the service was identified with
- * @param The CommonAPI service name the service provided
- * @param The CommonAPI domain the service was registered for
- *
- * @return 'true' if there was a service for the given address and depublishing
- * was successful, 'false' otherwise
- */
- bool unregisterService(const std::string& participantId,
- const std::string& serviceName,
- const std::string& domain) {
- std::string serviceAddress(participantId + ":" + serviceName + ":" + domain);
- return unregisterService(serviceAddress);
- }
-
- protected:
- /**
- * Register stubBase service within a factory.
- *
- * This is a new API which deprecates the old Factory::registerAdapter() method.
- * For compatibility reasons a default implementation is provided. New middleware
- * implementations should override this method.
- */
- virtual bool registerService(const std::shared_ptr<StubBase>& stubBase,
- const char* interfaceId,
- const std::string& participantId,
- const std::string& serviceName,
- const std::string& domain,
- const std::shared_ptr<Factory>& factory);
-};
-
-} // namespace CommonAPI
-
-#include "ServicePublisher.hpp"
-
-#endif /* COMMONAPI_SERVICE_PUBLISHER_H_ */
diff --git a/src/CommonAPI/ServicePublisher.hpp b/src/CommonAPI/ServicePublisher.hpp
deleted file mode 100644
index bab75ed..0000000
--- a/src/CommonAPI/ServicePublisher.hpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright (C) 2013 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/. */
-
-#ifndef COMMONAPI_SERVICE_PUBLISHER_IMPL_H_
-#define COMMONAPI_SERVICE_PUBLISHER_IMPL_H_
-
-#include "Factory.h"
-
-namespace CommonAPI {
-
-template<typename _Stub>
-bool ServicePublisher::registerService(std::shared_ptr<_Stub> stub,
- const std::string& participantId,
- const std::string& serviceName,
- const std::string& domain,
- std::shared_ptr<Factory> factory) {
-
- std::shared_ptr<StubBase> stubBase = std::dynamic_pointer_cast<StubBase>(stub);
- return registerService(stubBase, _Stub::StubInterface::getInterfaceId(), participantId, serviceName, domain, factory);
-}
-
-template<typename _Stub>
-bool ServicePublisher::registerService(std::shared_ptr<_Stub> stub,
- const std::string& serviceAddress,
- std::shared_ptr<Factory> factory) {
- std::string domain;
- std::string serviceName;
- std::string participantId;
- if(!factory->splitValidAddress(serviceAddress, domain, serviceName, participantId)) {
- return false;
- }
-
- return registerService<_Stub>(stub, participantId, serviceName, domain, factory);
-}
-
-} // namespace CommonAPI
-
-
-#endif /* COMMONAPI_SERVICE_PUBLISHER_IMPL_H_ */
diff --git a/src/CommonAPI/Utils.cpp b/src/CommonAPI/Utils.cpp
new file mode 100644
index 0000000..2540a86
--- /dev/null
+++ b/src/CommonAPI/Utils.cpp
@@ -0,0 +1,47 @@
+// Copyright (C) 2014-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 <algorithm>
+#include <sstream>
+#include <functional>
+
+#include <CommonAPI/Utils.hpp>
+
+namespace CommonAPI {
+
+std::vector<std::string>& split(const std::string& s, char delim, std::vector<std::string>& elems) {
+ std::istringstream ss(s);
+ std::string item;
+ while (std::getline(ss, item, delim)) {
+ elems.push_back(item);
+ }
+ return elems;
+}
+
+std::vector<std::string> split(const std::string& s, char delim) {
+ std::vector<std::string> elems;
+ return split(s, delim, elems);
+}
+
+void trim(std::string& toTrim) {
+ toTrim.erase(
+ toTrim.begin(),
+ std::find_if(
+ toTrim.begin(),
+ toTrim.end(),
+ std::not1(std::ptr_fun(isspace))
+ )
+ );
+
+ toTrim.erase(
+ std::find_if(
+ toTrim.rbegin(),
+ toTrim.rend(),
+ std::not1(std::ptr_fun(isspace))).base(),
+ toTrim.end()
+ );
+}
+
+}//namespace CommonAPI
diff --git a/src/CommonAPI/utils.cpp b/src/CommonAPI/utils.cpp
deleted file mode 100644
index 303c32a..0000000
--- a/src/CommonAPI/utils.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-/* Copyright (C) 2013 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 "utils.h"
-
-namespace CommonAPI {
-std::string getCurrentBinaryFileFQN() {
- #ifdef WIN32
- TCHAR result[MAX_PATH];
- std::basic_string<TCHAR> resultString(result, GetModuleFileName(NULL, result, MAX_PATH));
- return std::string(resultString.begin(), resultString.end());
- #else
- char fqnOfBinary[FILENAME_MAX];
- char pathToProcessImage[FILENAME_MAX];
-
- sprintf(pathToProcessImage, "/proc/%d/exe", getpid());
- const ssize_t lengthOfFqn = readlink(pathToProcessImage, fqnOfBinary, sizeof(fqnOfBinary) - 1);
-
- if (lengthOfFqn != -1) {
- fqnOfBinary[lengthOfFqn] = '\0';
- return std::string(std::move(fqnOfBinary));
- }
- else {
- return std::string("");
- }
- #endif
- }
-
-std::vector<std::string>& split(const std::string& s, char delim, std::vector<std::string>& elems) {
- std::istringstream ss(s);
- std::string item;
- while (std::getline(ss, item, delim)) {
- elems.push_back(item);
- }
- return elems;
-}
-
-std::vector<std::string> split(const std::string& s, char delim) {
- std::vector<std::string> elems;
- return split(s, delim, elems);
-}
-
-void trim(std::string& toTrim) {
- toTrim.erase(
- toTrim.begin(),
- std::find_if(toTrim.begin(),
- toTrim.end(),
- std::not1(std::ptr_fun(isspace)))
- );
- toTrim.erase(
- std::find_if(toTrim.rbegin(),
- toTrim.rend(),
- std::not1(std::ptr_fun(isspace))).base(),
- toTrim.end()
- );
-}
-
-bool notIsdigit(char c) {
- return !std::isdigit(c, std::locale());
-}
-
-bool containsOnlyDigits(const std::string& toCheck) {
- auto firstNonDigitIt = std::find_if(
- toCheck.begin(),
- toCheck.end(),
- notIsdigit);
-
- return firstNonDigitIt == toCheck.end();
-}
-
-bool notIsalnum(char c) {
- return !std::isalnum(c, std::locale());
-}
-
-bool containsOnlyAlphanumericCharacters(const std::string& toCheck) {
- auto firstNonAlphanumericCharacterIt = std::find_if(
- toCheck.begin(),
- toCheck.end(),
- notIsalnum);
-
- return firstNonAlphanumericCharacterIt == toCheck.end();
-}
-
-bool isValidDomainName(const std::string& domainName) {
- return containsOnlyAlphanumericCharacters(domainName);
-}
-
-bool isValidServiceName(const std::string& serviceName) {
- bool isValid = serviceName[0] != '.' && serviceName[serviceName.size() - 1] != '.';
-
- if (isValid) {
- std::vector<std::string> splittedServiceName = split(serviceName, '.');
-
- for (auto serviceNameElementIt = splittedServiceName.begin();
- serviceNameElementIt != splittedServiceName.end() && isValid;
- ++serviceNameElementIt) {
- isValid &= containsOnlyAlphanumericCharacters(*serviceNameElementIt);
- }
- }
-
- return isValid;
-}
-
-bool isValidInstanceId(const std::string& instanceId) {
- //Validation rules for ServiceName and InstanceID are equivalent
- return isValidServiceName(instanceId);
-}
-
-bool isValidCommonApiAddress(const std::string& commonApiAddress) {
- std::vector<std::string> splittedAddress = split(commonApiAddress, ':');
- if (splittedAddress.size() != 3) {
- return false;
- }
- return isValidDomainName(splittedAddress[0]) && isValidServiceName(splittedAddress[1]) && isValidInstanceId(splittedAddress[2]);
-}
-
-#ifndef WIN32
-bool loadGenericLibrary(const std::string& wellKnownMiddlewareName, const std::string& libraryName, const std::string& path, bool checkStandardNamePattern) {
- std::string fqnOfLibrary = path + libraryName;
- struct stat filestat;
- if (stat(fqnOfLibrary.c_str(), &filestat)) {
- return false;
- }
- if (S_ISDIR(filestat.st_mode)) {
- return false;
- }
-
- if (checkStandardNamePattern) {
- const std::string generatedLibPrefix = "lib" + wellKnownMiddlewareName + "Gen-";
- if (strncmp(generatedLibPrefix.c_str(), libraryName.c_str(), generatedLibPrefix.length()) != 0) {
- return false;
- }
-
- const char* fileNamePtr = libraryName.c_str();
- while ((fileNamePtr = strchr(fileNamePtr + 1, '.'))) {
- if (strncmp(".so\0", fileNamePtr, 4) == 0 || strncmp(".so.", fileNamePtr, 4) == 0) {
- break;
- }
- }
-
- if (!fileNamePtr) {
- return false;
- }
- }
-
- dlopen(fqnOfLibrary.c_str(), RTLD_NOW | RTLD_GLOBAL);
- return true;
-}
-
-bool loadGenericLibrary(const std::string& wellKnownMiddlewareName,
- const std::string& fqnOfLibrary,
- bool checkStandardNamePattern) {
- uint32_t position = fqnOfLibrary.find_last_of("/\\");
- std::string path = fqnOfLibrary.substr(0, position + 1);
- std::string file = fqnOfLibrary.substr(position + 1);
- return loadGenericLibrary(wellKnownMiddlewareName, file, path, checkStandardNamePattern);
-}
-
-void findAndLoadGenericLibraries(const std::string& requestedMiddlewareName, const std::string& singleSearchPath) {
- DIR *directory = opendir(singleSearchPath.c_str());
-
- if (directory != NULL) {
- struct dirent* entry;
-
- while ((entry = readdir(directory))) {
- loadGenericLibrary(requestedMiddlewareName, entry->d_name, singleSearchPath, true);
- }
- }
-}
-
-void findAndLoadGenericLibraries(const std::string& requestedMiddlewareName, const std::vector<std::string>& searchPaths) {
- for (const std::string& singleSearchPath : searchPaths) {
- findAndLoadGenericLibraries(requestedMiddlewareName, singleSearchPath.c_str());
- }
-}
-#endif
-}//namespace CommonAPI
diff --git a/src/CommonAPI/utils.h b/src/CommonAPI/utils.h
deleted file mode 100644
index c0e78eb..0000000
--- a/src/CommonAPI/utils.h
+++ /dev/null
@@ -1,230 +0,0 @@
-/* Copyright (C) 2013 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/. */
-#ifndef COMMONAPI_UTILS_H_
-#define COMMONAPI_UTILS_H_
-
-#ifndef WIN32
-#include <dirent.h>
-#include <dlfcn.h>
-#endif
-#include <sys/stat.h>
-
-#include <cstring>
-#include <string>
-#include <sstream>
-#include <vector>
-#include <algorithm>
-#include <iostream>
-
-#include <locale>
-#include <functional>
-
-#ifdef WIN32
-#include <xfunctional>
-#define WIN32_LEAN_AND_MEAN // this prevents windows.h from including winsock.h, which causes duplicate definitions with winsock2.h
-#include <windows.h>
-#else
-#include <unistd.h>
-#endif
-
-namespace CommonAPI {
-
-
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
-# define COMMONAPI_DEPRECATED __attribute__ ((__deprecated__))
-#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
-# define COMMONAPI_DEPRECATED __declspec(deprecated)
-#else
-# define COMMONAPI_DEPRECATED
-#endif
-
-
-/**
- * \brief Returns the fully qualified name of the binary.
- *
- * @return The name of the currently executing binary.
- */
-std::string getCurrentBinaryFileFQN();
-
-/**
- * \brief Splits a std::string according to the given delim-char.
- *
- * The string will be splitted at each position the delim char is encountered. The delim itself
- * will be removed from the result.
- *
- * @param s: The string that is to be splitted
- * @param delim: The character that separates the resulting string tokens in the original string
- * @param elems: Reference to the vector that shall be filled with the splitted string elements.
- *
- * @return A reference to the vector you passed in (elems)
- */
-std::vector<std::string>& split(const std::string& s, char delim, std::vector<std::string>& elems);
-
-/**
- * \brief Splits a std::string according to the given delim-char.
- *
- * The string will be splitted at each position the delim char is encountered. The delim itself
- * will be removed from the result.
- *
- * @param s: The string that is to be splitted
- * @param delim: The character that separates the resulting string tokens in the original string
- *
- * @return A vector containing the splitted string elements.
- */
-std::vector<std::string> split(const std::string& s, char delim);
-
-inline bool isspace(char c) {
- return std::isspace(c, std::locale());
-}
-
-/**
- * \brief Trims whitespaces from beginning and end of a std::string.
- *
- * @param toTrim: The string that is to be trimmed.
- */
-void trim(std::string& toTrim);
-
-bool notIsdigit(char c);
-
-/**
- * \brief Checks whether the given string contains nothing but digits.
- *
- * @param toCheck: The string that is to be checked on the presence of anything but digits.
- *
- * @return true if toCheck contains nothing but digits, false otherwise.
- */
-bool containsOnlyDigits(const std::string& toCheck);
-
-bool notIsalnum(char c);
-
-/**
- * \brief Checks whether the given string contains nothing but alphanumeric characters.
- *
- * @param toCheck: The string that is to be checked on the presence of anything but alphanumeric characters.
- *
- * @return true if toCheck contains nothing but alphanumeric characters, false otherwise.
- */
-bool containsOnlyAlphanumericCharacters(const std::string& toCheck);
-
-/**
- * \brief Checks whether the given std::string is a valid CommonAPI domain name.
- *
- * @param domainName: The std::string that is to be checked.
- *
- * @return true if domainName is a valid CommonAPI domainName, false otherwise.
- */
-bool isValidDomainName(const std::string& domainName);
-
-/**
- * \brief Checks whether the given std::string is a valid CommonAPI service name.
- *
- * @param serviceName: The std::string that is to be checked.
- *
- * @return true if serviceName is a valid CommonAPI serviceName, false otherwise.
- */
-bool isValidServiceName(const std::string& serviceName);
-
-/**
- * \brief Checks whether the given std::string is a valid CommonAPI instance ID.
- *
- * @param instanceId: The std::string that is to be checked.
- *
- * @return true if instanceId is a valid CommonAPI instance ID, false otherwise.
- */
-bool isValidInstanceId(const std::string& instanceId);
-
-/**
- * \brief Checks whether the given std::string is a valid CommonAPI address.
- *
- * @param commonApiAddressName: The std::string that is to be checked.
- *
- * @return true if commonApiAddress is a valid CommonAPI address, false otherwise.
- */
-bool isValidCommonApiAddress(const std::string& commonApiAddress);
-
-#ifndef WIN32
-/**
- * \brief Loads a specific generic library at runtime.
- *
- * The library will be loaded using dlopen(3) with the flags (RTLD_NOW | RTLD_GLOBAL), if all pre-checks are
- * successful. Pre-checks include the verification that the given parameters actually point to a library and
- * optionally if the library matches the standard name pattern for CommonAPI generic libraries. The standard
- * name pattern is "lib<wellKnownMiddlewareName>Gen-<arbitraryName>.so[.major[.minor.revision]]".
- *
- * @param wellKnownMiddlewareName: The name of the middleware that requests the loading of the library.
- * @param libraryName: The name of the library that shall be loaded.
- * @param path: The path at which the library is to be found. path + library name together make up the fully
- * qualified name of the library.
- * @param checkStandardNamePattern: If set to true, it will be ensured the library matches the CommonAPI
- * standard name pattern for generic libraries. This is meant as a safety measure
- * to prevent the loading of unnecessary or the wrong libraries. Set to false if
- * you are sure about what you are doing.
- * @return true if the library could be loaded successfully, false otherwise.
- *
- * @note The well known middleware name is included as a parameter because the additional libraries normally are needed
- * only by specific middlewares. This name however will only be taken into consideration during name checking
- * if the checkStandardNamePattern flag is set to true.
- */
-bool loadGenericLibrary(const std::string& wellKnownMiddlewareName, const std::string& libraryName, const std::string& path, bool checkStandardNamePattern = true);
-
-/**
- * \brief Loads a specific generic library at runtime.
- *
- * The library will be loaded using dlopen(3) with the flags (RTLD_NOW | RTLD_GLOBAL), if all pre-checks are
- * successful. Pre-checks include the verification that the given parameters actually point to a library and
- * optionally if the library matches the standard name pattern for CommonAPI generic libraries. The standard
- * name pattern is "lib<wellKnownMiddlewareName>Gen-<arbitraryName>.so[.major[.minor.revision]]".
- *
- * @param wellKnownMiddlewareName: The name of the middleware that requests the loading of the library.
- * @param fqnOfLibrary: The fully qualified name of the library.
- * @param checkStandardNamePattern: If set to true, it will be ensured the library matches the CommonAPI
- * standard name pattern for generic libraries. This is meant as a safety measure
- * to prevent the loading of unnecessary or the wrong libraries. Set to false if
- * you are sure about what you are doing.
- * @return true if the library could be loaded successfully, false otherwise.
- *
- * @note The well known middleware name is included as a parameter because the additional libraries normally are needed
- * only by specific middlewares. This name however will only be taken into consideration during name checking
- * if the checkStandardNamePattern flag is set to true.
- */
-bool loadGenericLibrary(const std::string& wellKnownMiddlewareName,
- const std::string& fqnOfLibrary,
- bool checkStandardNamePattern = true);
-
-/**
- * \brief Searches the given path for additional generic CommonAPI libraries and loads them.
- *
- * All libraries for which the pre-checks are successful will be loaded using dlopen(3) with the flags
- * (RTLD_NOW | RTLD_GLOBAL). Pre-checks include the verification that the given parameters actually point
- * to a library and if the library matches the standard name pattern for CommonAPI generic libraries.
- * The standard name pattern is "lib<wellKnownMiddlewareName>Gen-<arbitraryName>.so[.major[.minor.revision]]".
- *
- * @param wellKnownMiddlewareName: The name of the middleware that requests the loading of the library. Will
- * be used to perform the name check.
- * @param singleSearchPath: The directory that is to be searched for libraries.
- */
-void findAndLoadGenericLibraries(const std::string& requestedMiddlewareName, const std::string& singleSearchPath);
-
-/**
- * \brief Searches the given paths for additional generic CommonAPI libraries and loads them.
- *
- * All libraries for which the pre-checks are successful will be loaded using dlopen(3) with the flags
- * (RTLD_NOW | RTLD_GLOBAL). Pre-checks include the verification that the given parameters actually point
- * to a library and if the library matches the standard name pattern for CommonAPI generic libraries.
- * The standard name pattern is "lib<wellKnownMiddlewareName>Gen-<arbitraryName>.so[.major[.minor.revision]]".
- *
- * @param wellKnownMiddlewareName: The name of the middleware that requests the loading of the library. Will
- * be used to perform the name check.
- * @param searchPaths: The directories that are to be searched for libraries.
- */
-void findAndLoadGenericLibraries(const std::string& requestedMiddlewareName, const std::vector<std::string>& searchPaths);
-#endif
-
-} //namespace CommonAPI
-
-
-#endif /* COMMONAPI_UTILS_H_ */
diff --git a/src/test/VariantTest.cpp b/src/test/VariantTest.cpp
deleted file mode 100755
index b565573..0000000
--- a/src/test/VariantTest.cpp
+++ /dev/null
@@ -1,245 +0,0 @@
-/* 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 <gtest/gtest.h>
-#include "../CommonAPI/SerializableVariant.h"
-
-using namespace CommonAPI;
-
-class VariantTest: public ::testing::Test {
-
- void SetUp() {
- }
-
- void TearDown() {
- }
-};
-
-
-struct test1: CommonAPI::SerializableStruct {
- int a;
- std::string b;
-
- test1() = default;
- test1(const int& a, const std::string& b) :
- a(a), b(b) {
- }
-
- void readFromInputStream(CommonAPI::InputStream& inputStream) {
-
- }
-
- void writeToOutputStream(CommonAPI::OutputStream& outputStream) const {
-
- }
-
- static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
- }
-
-};
-
-struct test2: CommonAPI::SerializableStruct {
- int a;
- std::string b;
-
- test2() = default;
- test2(const int& a, const std::string& b) :
- a(a), b(b) {
- }
-
- void readFromInputStream(CommonAPI::InputStream& inputStream) {
-
- }
-
- void writeToOutputStream(CommonAPI::OutputStream& outputStream) const {
-
- }
-
- static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
- }
-
-};
-
-
-TEST_F(VariantTest, VariantTestPack) {
-
- int fromInt = 5;
- double fromDouble = 12.344;
- std::string fromString = "123abcsadfaljkawlöfasklöerklöfjasklfjysklfjaskfjsklösdfdko4jdfasdjioögjopefgip3rtgjiprg!";
- Variant<int, double, std::string> myVariant(fromInt);
-
- Variant<int, double, std::string>* myVariants = new Variant<int, double, std::string>(fromString);
-
- Variant<int, double, std::string> myVariantf(fromDouble);
-
- std::string myString = myVariants->get<std::string>();
- EXPECT_EQ(fromString, myString);
-
-
- const int& myInt = myVariant.get<int>();
- EXPECT_EQ(myInt, fromInt);
-
- int vType = myVariant.getValueType();
- EXPECT_EQ(3, vType);
-
- Variant<int, double, std::string> myVariant2 = myVariant;
- const int& myInt2 = myVariant2.get<int>();
- EXPECT_EQ(myInt2, fromInt);
-
- Variant<int, double, std::string> myVariant3 = fromInt;
- const int& myInt3 = myVariant3.get<int>();
- EXPECT_EQ(myInt3, fromInt);
-
- myString = myVariants->get<std::string>();
- EXPECT_EQ(myString, fromString);
-
- Variant<int, double, std::string> myVariantCopy(myVariant);
- const int& myIntCopy = myVariantCopy.get<int>();
- EXPECT_EQ(myIntCopy, fromInt);
-
- Variant<int, double, std::string> myVariantCopy2;
- myVariantCopy2 = myVariant;
-
- const int& myIntCopy2 = myVariantCopy2.get<int>();
- EXPECT_EQ(myIntCopy2, fromInt);
-
-#ifdef __EXCEPTIONS
- EXPECT_ANY_THROW(myVariant.get<double>());
-#endif
-
- EXPECT_TRUE(myVariant.isType<int>());
-
- EXPECT_FALSE(myVariant.isType<std::string>());
-
- Variant<int, double, std::string> movedVariant = std::move(myVariant);
- EXPECT_TRUE(movedVariant.isType<int>());
- EXPECT_EQ(fromInt, movedVariant.get<int>());
-
- const double& myDouble = myVariantf.get<double>();
- EXPECT_EQ(myDouble, fromDouble);
-
- Variant<int, double, std::string> myVariantsCopy(*myVariants);
- std::string myStringCopy = myVariantsCopy.get<std::string>();
- EXPECT_EQ(myStringCopy, fromString);
-
- *myVariants = std::string("Hello World");
- myString = myVariants->get<std::string>();
- EXPECT_EQ(myString, "Hello World");
-
- myStringCopy = myVariantsCopy.get<std::string>();
- EXPECT_EQ(myStringCopy, fromString);
-
- delete myVariants;
-
- test1 sourceStruct = {1, "a"};
-
- Variant<test1, test2> complexSource = sourceStruct;
-
- Variant<test1, test2> complexTarget = complexSource;
- EXPECT_EQ(1, complexTarget.get<test1>().a);
-}
-
-typedef Variant<test1, test2, std::string, uint8_t> ComplexTestVariant;
-typedef Variant<ComplexTestVariant, test2, std::string, uint8_t> OuterTestVariant;
-
-struct Container: CommonAPI::SerializableStruct {
- ComplexTestVariant a;
- std::string b;
-
- Container() = default;
- Container(const ComplexTestVariant& a, const std::string& b) :
- a(a), b(b) {
- }
-
- void readFromInputStream(CommonAPI::InputStream& inputStream) {
-
- }
-
- void writeToOutputStream(CommonAPI::OutputStream& outputStream) const {
-
- }
-
- static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
- }
-
-};
-
-struct ContainerOuter: CommonAPI::SerializableStruct {
- OuterTestVariant a;
- std::string b;
-
- ContainerOuter() = default;
- ContainerOuter(const OuterTestVariant& a, const std::string& b) :
- a(a), b(b) {
- }
-
- void readFromInputStream(CommonAPI::InputStream& inputStream) {
-
- }
-
- void writeToOutputStream(CommonAPI::OutputStream& outputStream) const {
-
- }
-
- static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
- }
-
-};
-
-TEST_F(VariantTest, VariantMoveTest) {
-
- ComplexTestVariant emptyTest;
- Container cont(std::move(emptyTest), "Hello");
-
- test1 assignStruct(1, "Assign");
- ComplexTestVariant assignTest = assignStruct;
- Container contAss(std::move(assignTest), "Hello");
- EXPECT_EQ("Assign", contAss.a.get<test1>().b);
-
- test1 constructStruct(1, "Construct");
- ComplexTestVariant constructTest(constructStruct);
- Container contCon(std::move(constructTest), "Hello");
- EXPECT_EQ("Construct", contCon.a.get<test1>().b);
-
- ComplexTestVariant rec;
-
- rec = cont.a;
-
- rec = contAss.a;
- EXPECT_EQ("Assign", rec.get<test1>().b);
-
- rec = contCon.a;
- EXPECT_EQ("Construct", rec.get<test1>().b);
-}
-
-TEST_F(VariantTest, VariantInVariantMoveTest) {
-
- OuterTestVariant emptyTest;
- ContainerOuter cont(std::move(emptyTest), "Hello");
-
- test1 assignStruct(1, "Assign");
- ComplexTestVariant assignTest = assignStruct;
- OuterTestVariant assignOuter = assignTest;
- ContainerOuter contAss(std::move(assignOuter), "Hello");
- EXPECT_EQ("Assign", contAss.a.get<ComplexTestVariant>().get<test1>().b);
-
- test1 constructStruct(1, "Construct");
- ComplexTestVariant constructTest(constructStruct);
- OuterTestVariant constructOuter(constructTest);
- ContainerOuter contCon(std::move(constructOuter), "Hello");
- EXPECT_EQ("Construct", contCon.a.get<ComplexTestVariant>().get<test1>().b);
-
- ComplexTestVariant rec;
-
- rec = contAss.a.get<ComplexTestVariant>();
- EXPECT_EQ("Assign", rec.get<test1>().b);
-
-
- rec = contCon.a.get<ComplexTestVariant>();
- EXPECT_EQ("Construct", rec.get<test1>().b);
-}
-
-int main(int argc, char** argv) {
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}