Initial import to Git
authorJohannes Schanda <schanda@itestra.de>
Fri, 11 Jan 2013 09:07:42 +0000 (10:07 +0100)
committerJohannes Schanda <schanda@itestra.de>
Fri, 11 Jan 2013 09:07:42 +0000 (10:07 +0100)
24 files changed:
CommonAPI/.autotools [new file with mode: 0644]
CommonAPI/.cproject [new file with mode: 0644]
CommonAPI/CommonAPI-uninstalled.pc.in [new file with mode: 0644]
CommonAPI/CommonAPI.pc.in [new file with mode: 0644]
CommonAPI/LICENSE [new file with mode: 0644]
CommonAPI/Makefile.am [new file with mode: 0644]
CommonAPI/configure.ac [new file with mode: 0644]
CommonAPI/m4/ax_cxx_compile_stdcxx_11.m4 [new file with mode: 0644]
CommonAPI/src/CommonAPI/Attribute.h [new file with mode: 0644]
CommonAPI/src/CommonAPI/AttributeExtension.h [new file with mode: 0644]
CommonAPI/src/CommonAPI/ByteBuffer.h [new file with mode: 0644]
CommonAPI/src/CommonAPI/Event.h [new file with mode: 0644]
CommonAPI/src/CommonAPI/Factory.h [new file with mode: 0644]
CommonAPI/src/CommonAPI/InputStream.h [new file with mode: 0644]
CommonAPI/src/CommonAPI/MiddlewareInfo.h [new file with mode: 0644]
CommonAPI/src/CommonAPI/OutputStream.h [new file with mode: 0644]
CommonAPI/src/CommonAPI/Proxy.h [new file with mode: 0644]
CommonAPI/src/CommonAPI/Runtime.cpp [new file with mode: 0644]
CommonAPI/src/CommonAPI/Runtime.h [new file with mode: 0644]
CommonAPI/src/CommonAPI/SerializableStruct.h [new file with mode: 0644]
CommonAPI/src/CommonAPI/SerializableVariant.h [new file with mode: 0644]
CommonAPI/src/CommonAPI/Stub.h [new file with mode: 0644]
CommonAPI/src/CommonAPI/types.h [new file with mode: 0644]
test.txt [deleted file]

diff --git a/CommonAPI/.autotools b/CommonAPI/.autotools
new file mode 100644 (file)
index 0000000..5ca9eb7
--- /dev/null
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configurations>
+<configuration id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.2000865124">
+<option id="configure" value="configure"/>
+<option id="configdir" value=""/>
+<option id="cache-file" value=""/>
+<option id="help" value="false"/>
+<option id="no-create" value="false"/>
+<option id="quiet" value="false"/>
+<option id="version" value="false"/>
+<option id="host" value=""/>
+<option id="build" value=""/>
+<option id="target" value=""/>
+<option id="prefix" value=""/>
+<option id="exec-prefix" value=""/>
+<option id="libdir" value=""/>
+<option id="bindir" value=""/>
+<option id="sbindir" value=""/>
+<option id="includedir" value=""/>
+<option id="datadir" value=""/>
+<option id="sysconfdir" value=""/>
+<option id="infodir" value=""/>
+<option id="mandir" value=""/>
+<option id="srcdir" value=""/>
+<option id="localstatedir" value=""/>
+<option id="sharedstatedir" value=""/>
+<option id="libexecdir" value=""/>
+<option id="oldincludedir" value=""/>
+<option id="program-prefix" value=""/>
+<option id="program-suffix" value=""/>
+<option id="program-transform-name" value=""/>
+<option id="enable-maintainer-mode" value="false"/>
+<flag id="CFLAGS">
+<flagvalue id="cflags-debug" value="false"/>
+<flagvalue id="cflags-gprof" value="false"/>
+<flagvalue id="cflags-gcov" value="false"/>
+</flag>
+<option id="user" value=""/>
+<option id="autogen" value="autogen.sh"/>
+<option id="autogenOpts" value=""/>
+</configuration>
+</configurations>
diff --git a/CommonAPI/.cproject b/CommonAPI/.cproject
new file mode 100644 (file)
index 0000000..10c8d9f
--- /dev/null
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
+<?fileVersion 4.0.0?>\r
+\r
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">\r
+       <storageModule moduleId="org.eclipse.cdt.core.settings">\r
+               <cconfiguration id="cdt.managedbuild.toolchain.gnu.cross.base.1854391134">\r
+                       <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.cross.base.1854391134" moduleId="org.eclipse.cdt.core.settings" name="Default">\r
+                               <externalSettings/>\r
+                               <extensions>\r
+                                       <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>\r
+                                       <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>\r
+                                       <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>\r
+                                       <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>\r
+                                       <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>\r
+                                       <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>\r
+                               </extensions>\r
+                       </storageModule>\r
+                       <storageModule moduleId="cdtBuildSystem" version="4.0.0">\r
+                               <configuration buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.cross.base.1854391134" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">\r
+                                       <folderInfo id="cdt.managedbuild.toolchain.gnu.cross.base.1854391134.2075295936" name="/" resourcePath="">\r
+                                               <toolChain id="cdt.managedbuild.toolchain.gnu.cross.base.829467769" name="cdt.managedbuild.toolchain.gnu.cross.base" superClass="cdt.managedbuild.toolchain.gnu.cross.base">\r
+                                                       <option id="cdt.managedbuild.option.gnu.cross.prefix.43024764" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix"/>\r
+                                                       <option id="cdt.managedbuild.option.gnu.cross.path.1158066037" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path"/>\r
+                                                       <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.1553638191" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>\r
+                                                       <builder id="cdt.managedbuild.builder.gnu.cross.595479512" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.builder.gnu.cross"/>\r
+                                                       <tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.685588221" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">\r
+                                                               <option id="gnu.c.compiler.option.include.paths.707040789" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">\r
+                                                                       <listOptionValue builtIn="false" value="&quot;C:\cygwin\lib\gcc\i686-pc-cygwin\4.5.3\include&quot;"/>\r
+                                                                       <listOptionValue builtIn="false" value="&quot;C:\cygwin\lib\gcc\i686-pc-cygwin\4.5.3\include\c++&quot;"/>\r
+                                                               </option>\r
+                                                               <option id="gnu.c.compiler.option.preprocessor.def.symbols.1405898198" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">\r
+                                                                       <listOptionValue builtIn="false" value="__GXX_EXPERIMENTAL_CXX0X__=1"/>\r
+                                                                       <listOptionValue builtIn="false" value="__GXX_EXPERIMENTAL_CXX0XX__=1"/>\r
+                                                               </option>\r
+                                                               <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1131602988" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>\r
+                                                       </tool>\r
+                                                       <tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.239596601" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">\r
+                                                               <option id="gnu.cpp.compiler.option.include.paths.1009559140" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">\r
+                                                                       <listOptionValue builtIn="false" value="&quot;C:\cygwin\lib\gcc\i686-pc-cygwin\4.5.3\include&quot;"/>\r
+                                                                       <listOptionValue builtIn="false" value="&quot;C:\cygwin\lib\gcc\i686-pc-cygwin\4.5.3\include\c++&quot;"/>\r
+                                                               </option>\r
+                                                               <option id="gnu.cpp.compiler.option.preprocessor.def.1177228206" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">\r
+                                                                       <listOptionValue builtIn="false" value="__GXX_EXPERIMENTAL_CXX0X__=1"/>\r
+                                                                       <listOptionValue builtIn="false" value="__GXX_EXPERIMENTAL_CXX0XX__=1"/>\r
+                                                               </option>\r
+                                                               <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1334227184" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>\r
+                                                       </tool>\r
+                                                       <tool id="cdt.managedbuild.tool.gnu.cross.c.linker.1172540848" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>\r
+                                                       <tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.1145928424" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">\r
+                                                               <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.904664213" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">\r
+                                                                       <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>\r
+                                                                       <additionalInput kind="additionalinput" paths="$(LIBS)"/>\r
+                                                               </inputType>\r
+                                                       </tool>\r
+                                                       <tool id="cdt.managedbuild.tool.gnu.cross.archiver.1345501453" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>\r
+                                                       <tool id="cdt.managedbuild.tool.gnu.cross.assembler.804537221" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">\r
+                                                               <option id="gnu.both.asm.option.include.paths.1161712244" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">\r
+                                                                       <listOptionValue builtIn="false" value="&quot;C:\cygwin\lib\gcc\i686-pc-cygwin\4.5.3\include&quot;"/>\r
+                                                                       <listOptionValue builtIn="false" value="&quot;C:\cygwin\lib\gcc\i686-pc-cygwin\4.5.3\include\c++&quot;"/>\r
+                                                               </option>\r
+                                                               <inputType id="cdt.managedbuild.tool.gnu.assembler.input.448291606" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>\r
+                                                       </tool>\r
+                                               </toolChain>\r
+                                       </folderInfo>\r
+                               </configuration>\r
+                       </storageModule>\r
+                       <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>\r
+               </cconfiguration>\r
+       </storageModule>\r
+       <storageModule moduleId="cdtBuildSystem" version="4.0.0">\r
+               <project id="CommonAPI.null.1443969185" name="CommonAPI"/>\r
+       </storageModule>\r
+       <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>\r
+       <storageModule moduleId="refreshScope"/>\r
+       <storageModule moduleId="scannerConfiguration">\r
+               <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>\r
+               <scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.1854391134;cdt.managedbuild.toolchain.gnu.cross.base.1854391134.2075295936;cdt.managedbuild.tool.gnu.cross.cpp.compiler.239596601;cdt.managedbuild.tool.gnu.cpp.compiler.input.1334227184">\r
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>\r
+               </scannerConfigBuildInfo>\r
+               <scannerConfigBuildInfo instanceId="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.2000865124;org.eclipse.linuxtools.cdt.autotools.core.configuration.build.2000865124.;org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc.697493728;cdt.managedbuild.tool.gnu.c.compiler.input.804999478">\r
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>\r
+               </scannerConfigBuildInfo>\r
+               <scannerConfigBuildInfo instanceId="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.2000865124;org.eclipse.linuxtools.cdt.autotools.core.configuration.build.2000865124.;org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp.744922790;cdt.managedbuild.tool.gnu.cpp.compiler.input.686208857">\r
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>\r
+               </scannerConfigBuildInfo>\r
+               <scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.1854391134;cdt.managedbuild.toolchain.gnu.cross.base.1854391134.2075295936;cdt.managedbuild.tool.gnu.cross.c.compiler.685588221;cdt.managedbuild.tool.gnu.c.compiler.input.1131602988">\r
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>\r
+               </scannerConfigBuildInfo>\r
+       </storageModule>\r
+</cproject>\r
diff --git a/CommonAPI/CommonAPI-uninstalled.pc.in b/CommonAPI/CommonAPI-uninstalled.pc.in
new file mode 100644 (file)
index 0000000..a5253d9
--- /dev/null
@@ -0,0 +1,10 @@
+abs_top_builddir=@abs_top_builddir@
+abs_top_srcdir=@abs_top_srcdir@
+prefix=
+exec_prefix=
+
+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/CommonAPI.pc.in b/CommonAPI/CommonAPI.pc.in
new file mode 100644 (file)
index 0000000..4b47bcf
--- /dev/null
@@ -0,0 +1,10 @@
+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-@PACKAGE_VERSION@
\ No newline at end of file
diff --git a/CommonAPI/LICENSE b/CommonAPI/LICENSE
new file mode 100644 (file)
index 0000000..14e2f77
--- /dev/null
@@ -0,0 +1,373 @@
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+    means each individual or legal entity that creates, contributes to
+    the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+    means the combination of the Contributions of others (if any) used
+    by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+    means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+    means Source Code Form to which the initial Contributor has attached
+    the notice in Exhibit A, the Executable Form of such Source Code
+    Form, and Modifications of such Source Code Form, in each case
+    including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+    means
+
+    (a) that the initial Contributor has attached the notice described
+        in Exhibit B to the Covered Software; or
+
+    (b) that the Covered Software was made available under the terms of
+        version 1.1 or earlier of the License, but not also under the
+        terms of a Secondary License.
+
+1.6. "Executable Form"
+    means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+    means a work that combines Covered Software with other material, in 
+    a separate file or files, that is not Covered Software.
+
+1.8. "License"
+    means this document.
+
+1.9. "Licensable"
+    means having the right to grant, to the maximum extent possible,
+    whether at the time of the initial grant or subsequently, any and
+    all of the rights conveyed by this License.
+
+1.10. "Modifications"
+    means any of the following:
+
+    (a) any file in Source Code Form that results from an addition to,
+        deletion from, or modification of the contents of Covered
+        Software; or
+
+    (b) any new file in Source Code Form that contains any Covered
+        Software.
+
+1.11. "Patent Claims" of a Contributor
+    means any patent claim(s), including without limitation, method,
+    process, and apparatus claims, in any patent Licensable by such
+    Contributor that would be infringed, but for the grant of the
+    License, by the making, using, selling, offering for sale, having
+    made, import, or transfer of either its Contributions or its
+    Contributor Version.
+
+1.12. "Secondary License"
+    means either the GNU General Public License, Version 2.0, the GNU
+    Lesser General Public License, Version 2.1, the GNU Affero General
+    Public License, Version 3.0, or any later versions of those
+    licenses.
+
+1.13. "Source Code Form"
+    means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+    means an individual or a legal entity exercising rights under this
+    License. For legal entities, "You" includes any entity that
+    controls, is controlled by, or is under common control with You. For
+    purposes of this definition, "control" means (a) the power, direct
+    or indirect, to cause the direction or management of such entity,
+    whether by contract or otherwise, or (b) ownership of more than
+    fifty percent (50%) of the outstanding shares or beneficial
+    ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+    Licensable by such Contributor to use, reproduce, make available,
+    modify, display, perform, distribute, and otherwise exploit its
+    Contributions, either on an unmodified basis, with Modifications, or
+    as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+    for sale, have made, import, and otherwise transfer either its
+    Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+    or
+
+(b) for infringements caused by: (i) Your and any other third party's
+    modifications of Covered Software, or (ii) the combination of its
+    Contributions with other software (except as part of its Contributor
+    Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+    its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+    Form, as described in Section 3.1, and You must inform recipients of
+    the Executable Form how they can obtain a copy of such Source Code
+    Form by reasonable means in a timely manner, at a charge no more
+    than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+    License, or sublicense it under different terms, provided that the
+    license for the Executable Form does not attempt to limit or alter
+    the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+*                                                                      *
+*  6. Disclaimer of Warranty                                           *
+*  -------------------------                                           *
+*                                                                      *
+*  Covered Software is provided under this License on an "as is"       *
+*  basis, without warranty of any kind, either expressed, implied, or  *
+*  statutory, including, without limitation, warranties that the       *
+*  Covered Software is free of defects, merchantable, fit for a        *
+*  particular purpose or non-infringing. The entire risk as to the     *
+*  quality and performance of the Covered Software is with You.        *
+*  Should any Covered Software prove defective in any respect, You     *
+*  (not any Contributor) assume the cost of any necessary servicing,   *
+*  repair, or correction. This disclaimer of warranty constitutes an   *
+*  essential part of this License. No use of any Covered Software is   *
+*  authorized under this License except under this disclaimer.         *
+*                                                                      *
+************************************************************************
+
+************************************************************************
+*                                                                      *
+*  7. Limitation of Liability                                          *
+*  --------------------------                                          *
+*                                                                      *
+*  Under no circumstances and under no legal theory, whether tort      *
+*  (including negligence), contract, or otherwise, shall any           *
+*  Contributor, or anyone who distributes Covered Software as          *
+*  permitted above, be liable to You for any direct, indirect,         *
+*  special, incidental, or consequential damages of any character      *
+*  including, without limitation, damages for lost profits, loss of    *
+*  goodwill, work stoppage, computer failure or malfunction, or any    *
+*  and all other commercial damages or losses, even if such party      *
+*  shall have been informed of the possibility of such damages. This   *
+*  limitation of liability shall not apply to liability for death or   *
+*  personal injury resulting from such party's negligence to the       *
+*  extent applicable law prohibits such limitation. Some               *
+*  jurisdictions do not allow the exclusion or limitation of           *
+*  incidental or consequential damages, so this exclusion and          *
+*  limitation may not apply to You.                                    *
+*                                                                      *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+  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 it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+  This Source Code Form is "Incompatible With Secondary Licenses", as
+  defined by the Mozilla Public License, v. 2.0.
diff --git a/CommonAPI/Makefile.am b/CommonAPI/Makefile.am
new file mode 100644 (file)
index 0000000..47afa7a
--- /dev/null
@@ -0,0 +1,43 @@
+ACLOCAL_AMFLAGS = -I m4
+
+# ------------------------------------------------------------------------------
+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
+
+CommonAPI_includedir=$(includedir)/CommonAPI-${VERSION}/CommonAPI
+CommonAPI_include_HEADERS = \
+               src/CommonAPI/Attribute.h \
+        src/CommonAPI/AttributeExtension.h \
+        src/CommonAPI/ByteBuffer.h \
+        src/CommonAPI/Event.h \
+        src/CommonAPI/Factory.h \
+               src/CommonAPI/InputStream.h \
+        src/CommonAPI/MiddlewareInfo.h \
+               src/CommonAPI/OutputStream.h \
+        src/CommonAPI/Proxy.h \
+               src/CommonAPI/Runtime.h \
+               src/CommonAPI/SerializableStruct.h \
+               src/CommonAPI/SerializableVariant.h \
+               src/CommonAPI/types.h
+
+libCommonAPI_la_LIBADD = -ldl
+
+pkgconfigdir = ${libdir}/pkgconfig
+pkgconfig_DATA = CommonAPI.pc
\ No newline at end of file
diff --git a/CommonAPI/configure.ac b/CommonAPI/configure.ac
new file mode 100644 (file)
index 0000000..4e98889
--- /dev/null
@@ -0,0 +1,37 @@
+AC_PREREQ(2.61)
+AC_INIT([GENIVI Common API C++ Library],
+        [0.7],
+        [],
+        [CommonAPI])
+
+AC_CONFIG_MACRO_DIR([m4])
+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
+
+AC_PROG_CXX
+AC_LANG([C++])
+AX_CXX_COMPILE_STDCXX_11([noext])
+
+LT_PREREQ(2.2)
+LT_INIT
+
+AC_MSG_RESULT([
+        $PACKAGE_NAME v$VERSION
+
+        prefix:             ${prefix}
+        CXXFLAGS:           ${CXXFLAGS}
+        LDFLAGS:            ${LDFLAGS}
+])
+
+AC_OUTPUT
+
diff --git a/CommonAPI/m4/ax_cxx_compile_stdcxx_11.m4 b/CommonAPI/m4/ax_cxx_compile_stdcxx_11.m4
new file mode 100644 (file)
index 0000000..0d96c07
--- /dev/null
@@ -0,0 +1,107 @@
+# ============================================================================
+#  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/CommonAPI/src/CommonAPI/Attribute.h b/CommonAPI/src/CommonAPI/Attribute.h
new file mode 100644 (file)
index 0000000..03cc9f4
--- /dev/null
@@ -0,0 +1,65 @@
+/* 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_ATTRIBUTE_H_
+#define COMMONAPI_ATTRIBUTE_H_
+
+#include "types.h"
+#include "Event.h"
+
+#include <cstdint>
+#include <functional>
+#include <future>
+#include <memory>
+
+
+namespace CommonAPI {
+
+template <typename _ValueType>
+class ReadonlyAttribute {
+ public:
+       typedef _ValueType ValueType;
+       typedef std::function<void(const CallStatus&, _ValueType)> AttributeAsyncCallback;
+
+       virtual ~ReadonlyAttribute() { }
+
+       virtual CallStatus getValue(_ValueType& value) const = 0;
+       virtual std::future<CallStatus> getValueAsync(AttributeAsyncCallback attributeAsyncCallback) = 0;
+};
+
+template <typename _ValueType>
+class Attribute: public ReadonlyAttribute<_ValueType> {
+ public:
+       typedef typename ReadonlyAttribute<_ValueType>::ValueType ValueType;
+       typedef typename ReadonlyAttribute<_ValueType>::AttributeAsyncCallback AttributeAsyncCallback;
+
+       virtual ~Attribute() { }
+
+       virtual void setValue(const _ValueType& requestValue, CallStatus& callStatus, _ValueType& responseValue) = 0;
+       virtual std::future<CallStatus> setValueAsync(const _ValueType& requestValue,
+                                                                                                 AttributeAsyncCallback attributeAsyncCallback) = 0;
+};
+
+template <typename _AttributeBaseClass>
+class _ObservableAttributeImpl: public _AttributeBaseClass {
+ public:
+       typedef typename _AttributeBaseClass::ValueType ValueType;
+       typedef typename _AttributeBaseClass::AttributeAsyncCallback AttributeAsyncCallback;
+       typedef Event<ValueType> ChangedEvent;
+
+       virtual ~_ObservableAttributeImpl() { }
+
+       virtual ChangedEvent& getChangedEvent() = 0;
+};
+
+template <typename _ValueType>
+struct ObservableReadonlyAttribute: _ObservableAttributeImpl< ReadonlyAttribute<_ValueType> > {
+};
+
+template <typename _ValueType>
+struct ObservableAttribute: _ObservableAttributeImpl< Attribute<_ValueType> > {
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_ATTRIBUTE_H_
diff --git a/CommonAPI/src/CommonAPI/AttributeExtension.h b/CommonAPI/src/CommonAPI/AttributeExtension.h
new file mode 100644 (file)
index 0000000..0c0071c
--- /dev/null
@@ -0,0 +1,34 @@
+/* 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 COMMON_API_DBUS_ATTRIBUTE_EXTENSION_H_
+#define COMMON_API_DBUS_ATTRIBUTE_EXTENSION_H_
+
+#include "types.h"
+#include "Event.h"
+
+#include <cstdint>
+#include <functional>
+#include <memory>
+
+
+namespace CommonAPI {
+
+template<typename _AttributeType>
+class AttributeExtension {
+ public:
+    inline _AttributeType& getBaseAttribute() {
+        return baseAttribute_;
+    }
+
+ protected:
+    AttributeExtension() = delete;
+    AttributeExtension(_AttributeType& baseAttribute): baseAttribute_(baseAttribute) {
+    }
+
+    _AttributeType& baseAttribute_;
+};
+
+} // namespace CommonAPI
+
+#endif // COMMON_API_DBUS_ATTRIBUTE_EXTENSION_H_
diff --git a/CommonAPI/src/CommonAPI/ByteBuffer.h b/CommonAPI/src/CommonAPI/ByteBuffer.h
new file mode 100644 (file)
index 0000000..4a7e170
--- /dev/null
@@ -0,0 +1,16 @@
+/* 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/CommonAPI/src/CommonAPI/Event.h b/CommonAPI/src/CommonAPI/Event.h
new file mode 100644 (file)
index 0000000..fd5d73d
--- /dev/null
@@ -0,0 +1,127 @@
+/* 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_EVENT_H_
+#define COMMONAPI_EVENT_H_
+
+#include <functional>
+#include <list>
+#include <tuple>
+
+namespace CommonAPI {
+
+enum class SubscriptionStatus {
+       RETAIN,
+       CANCEL
+};
+
+
+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;
+
+       inline Subscription subscribe(Listener listener);
+       Subscription subscribeCancellableListener(CancellableListener listener);
+       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_;
+};
+
+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) {
+       const bool firstListenerAdded = listenersList_.empty();
+
+       listenersList_.emplace_front(std::move(listener));
+       Subscription listenerSubscription = listenersList_.begin();
+
+       if (firstListenerAdded)
+               onFirstListenerAdded(*listenerSubscription);
+
+       onListenerAdded(*listenerSubscription);
+
+       return listenerSubscription;
+}
+
+template <typename... _Arguments>
+void Event<_Arguments...>::unsubscribe(Subscription listenerSubscription) {
+       const CancellableListener cancellableListener = *listenerSubscription;
+
+       listenersList_.erase(listenerSubscription);
+
+       onListenerRemoved(cancellableListener);
+
+       const bool lastListenerRemoved = listenersList_.empty();
+       if (lastListenerRemoved)
+               onLastListenerRemoved(cancellableListener);
+}
+
+template <typename... _Arguments>
+SubscriptionStatus Event<_Arguments...>::notifyListeners(const _Arguments&... eventArguments) {
+       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++;
+       }
+
+       return listenersList_.empty() ? SubscriptionStatus::CANCEL : SubscriptionStatus::RETAIN;
+}
+
+template <typename... _Arguments>
+bool Event<_Arguments...>::hasListeners() const {
+       return !listenersList_.empty();
+}
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_EVENT_H_
diff --git a/CommonAPI/src/CommonAPI/Factory.h b/CommonAPI/src/CommonAPI/Factory.h
new file mode 100644 (file)
index 0000000..f1d6344
--- /dev/null
@@ -0,0 +1,169 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public\r
+ * License, v. 2.0. If a copy of the MPL was not distributed with this\r
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\r
+#ifndef COMMONAPI_FACTORY_H_\r
+#define COMMONAPI_FACTORY_H_\r
+\r
+#include <cassert>\r
+#include <memory>\r
+#include <sstream>\r
+#include <string>\r
+#include <unordered_map>\r
+#include <vector>\r
+\r
+#include "MiddlewareInfo.h"\r
+#include "Proxy.h"\r
+#include "Runtime.h"\r
+#include "Stub.h"\r
+\r
+\r
+namespace CommonAPI {\r
+\r
+\r
+class Factory;\r
+class Runtime;\r
+class MiddlewareInfo;\r
+\r
+\r
+template<template<typename ...> class _ProxyType, template<typename> class _AttributeExtension>\r
+struct DefaultAttributeProxyFactoryHelper;\r
+\r
+\r
+template<template<typename ...> class _ProxyClass, template<typename> class _AttributeExtension>\r
+std::shared_ptr<typename DefaultAttributeProxyFactoryHelper<_ProxyClass, _AttributeExtension>::class_t> createProxyWithDefaultAttributeExtension(Factory* specificFactory, const std::string& participantId, const std::string& domain);\r
+\r
+\r
+class Factory {\r
+ public:\r
+    Factory(const std::shared_ptr<Runtime> runtime,\r
+            const MiddlewareInfo* middlewareInfo):\r
+                runtime_(runtime),\r
+                middlewareInfo_(middlewareInfo) {\r
+    }\r
+\r
+    virtual ~Factory() {}\r
+\r
+    template<template<typename ...> class _ProxyClass, typename ... _AttributeExtensions>\r
+    std::shared_ptr<_ProxyClass<_AttributeExtensions...> >\r
+    buildProxy(const std::string& participantId,\r
+               const std::string& domain) {\r
+\r
+       std::shared_ptr<Proxy> abstractMiddlewareProxy = createProxy(_ProxyClass<_AttributeExtensions...>::getInterfaceName(), participantId, domain);\r
+       return std::make_shared<_ProxyClass<_AttributeExtensions...>>(abstractMiddlewareProxy);\r
+    }\r
+\r
+    template<template<typename ...> class _ProxyClass, typename ... _AttributeExtensions >\r
+    std::shared_ptr<_ProxyClass<_AttributeExtensions...> >\r
+    buildProxy(const std::string& serviceAddress) {\r
+\r
+               std::string domain;\r
+               std::string serviceName;\r
+               std::string participantId;\r
+               if(!splitAddress(serviceAddress, domain, serviceName, participantId)) {\r
+                       return false;\r
+               }\r
+\r
+               return buildProxy<_ProxyClass, _AttributeExtensions...>(participantId, domain);\r
+    }\r
+\r
+    template <template<typename ...> class _ProxyClass, template<typename> class _AttributeExtension>\r
+    std::shared_ptr<typename DefaultAttributeProxyFactoryHelper<_ProxyClass, _AttributeExtension>::class_t>\r
+    buildProxyWithDefaultAttributeExtension(const std::string& participantId,\r
+                                       const std::string& domain) {\r
+\r
+       std::shared_ptr<Proxy> abstractMiddlewareProxy = createProxy(DefaultAttributeProxyFactoryHelper<_ProxyClass, _AttributeExtension>::class_t::getInterfaceName(), participantId, domain);\r
+       return std::make_shared<typename DefaultAttributeProxyFactoryHelper<_ProxyClass, _AttributeExtension>::class_t>(abstractMiddlewareProxy);\r
+    }\r
+\r
+    template <template<typename ...> class _ProxyClass, template<typename> class _AttributeExtension>\r
+    std::shared_ptr<typename DefaultAttributeProxyFactoryHelper<_ProxyClass, _AttributeExtension>::class_t>\r
+    buildProxyWithDefaultAttributeExtension(const std::string& serviceAddress) {\r
+\r
+               std::string domain;\r
+               std::string serviceName;\r
+               std::string participantId;\r
+               if(!splitAddress(serviceAddress, domain, serviceName, participantId)) {\r
+                       return false;\r
+               }\r
+\r
+               return buildProxyWithDefaultAttributeExtension<_ProxyClass, _AttributeExtension>(participantId, domain);\r
+    }\r
+\r
+    inline std::shared_ptr<Runtime> getRuntime() {\r
+        return runtime_;\r
+    }\r
+\r
+    template<typename _Stub>\r
+    bool registerService(std::shared_ptr<_Stub> stub,\r
+                                    const std::string& participantId,\r
+                                const std::string& domain) {\r
+\r
+       std::shared_ptr<StubBase> stubBase = std::dynamic_pointer_cast<StubBase>(stub);\r
+               std::shared_ptr<CommonAPI::StubAdapter> stubAdapter = createAdapter(stubBase, _Stub::StubAdapterType::getInterfaceName(), participantId, domain);\r
+               if(!stubAdapter) {\r
+                       return false;\r
+               }\r
+\r
+               std::string address = domain + ":" + _Stub::StubAdapterType::getInterfaceName() + ":" + participantId;\r
+               registeredServices_.insert( {std::move(address), stubAdapter} );\r
+\r
+               return true;\r
+    }\r
+\r
+    template<typename _Stub>\r
+    bool registerService(std::shared_ptr<_Stub> stub, const std::string& serviceAddress) {\r
+\r
+       if(registeredServices_.find(serviceAddress) != registeredServices_.end()) {\r
+               return false;\r
+       }\r
+\r
+               std::string domain;\r
+               std::string serviceName;\r
+               std::string participantId;\r
+               if(!splitAddress(serviceAddress, domain, serviceName, participantId)) {\r
+                       return false;\r
+               }\r
+\r
+               return registerService<_Stub>(stub, participantId, domain);\r
+    }\r
+\r
+    inline bool unregisterService(const std::string& serviceAddress) {\r
+       return registeredServices_.erase(serviceAddress);\r
+    }\r
+\r
+    virtual std::vector<std::string> getAvailableServiceInstances(const std::string& serviceName, const std::string& serviceDomainName = "local") = 0;\r
+\r
+    virtual bool isServiceInstanceAlive(const std::string& serviceInstanceID, const std::string& serviceName, const std::string& serviceDomainName = "local") = 0;\r
+\r
+ protected:\r
+    virtual std::shared_ptr<Proxy> createProxy(const char* interfaceName, const std::string& participantId, const std::string& domain) = 0;\r
+    virtual std::shared_ptr<StubAdapter> createAdapter(std::shared_ptr<StubBase> stubBase, const char* interfaceName, const std::string& participantId, const std::string& domain) = 0;\r
+\r
+ private:\r
+    std::shared_ptr<Runtime> runtime_;\r
+    std::unordered_map<std::string, std::shared_ptr<CommonAPI::StubAdapter>> registeredServices_;\r
+\r
+    const MiddlewareInfo* middlewareInfo_;\r
+\r
+    inline bool splitAddress(const std::string& serviceAddress, std::string& domain, std::string& serviceName, std::string& participantId) {\r
+       std::istringstream addressStream(serviceAddress);\r
+               if(!std::getline(addressStream, domain, ':')) {\r
+                       return false;\r
+               }\r
+               if(!std::getline(addressStream, serviceName, ':')) {\r
+                       return false;\r
+               }\r
+               if(!std::getline(addressStream, participantId, ':')) {\r
+                       return false;\r
+               }\r
+               if(std::getline(addressStream, participantId)) {\r
+                       return false;\r
+               }\r
+               return true;\r
+    }\r
+};\r
+\r
+\r
+} // namespace CommonAPI\r
+\r
+#endif // COMMONAPI_FACTORY_H_\r
diff --git a/CommonAPI/src/CommonAPI/InputStream.h b/CommonAPI/src/CommonAPI/InputStream.h
new file mode 100644 (file)
index 0000000..908b701
--- /dev/null
@@ -0,0 +1,299 @@
+/* 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_INPUT_STREAM_H_
+#define COMMONAPI_INPUT_STREAM_H_
+
+#include "ByteBuffer.h"
+#include "SerializableStruct.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>
+       inline 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 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 beginReadVectorOfSerializableStructs() = 0;
+    virtual void beginReadVectorOfVectors() = 0;
+    virtual void beginReadVectorOfMaps() = 0;
+
+    virtual bool hasMoreVectorElements() = 0;
+    virtual void endReadVector() = 0;
+
+       virtual void beginReadMap() = 0;
+       virtual bool hasMoreMapElements() = 0;
+       virtual void endReadMap() = 0;
+};
+
+template <typename _EnumBackingType, typename _EnumType>
+InputStream& InputStream::readEnumValue(_EnumType& enumValue) {
+       _EnumBackingType enumBackingValue;
+
+       readEnumValue(enumBackingValue);
+       enumValue = static_cast<_EnumType>(enumBackingValue);
+
+       return *this;
+}
+
+
+inline InputStream& operator>>(InputStream& inputStream, bool& boolValue) {
+       return inputStream.readValue(boolValue);
+}
+
+inline InputStream& operator>>(InputStream& inputStream, int8_t& int8Value) {
+       return inputStream.readValue(int8Value);
+}
+
+inline InputStream& operator>>(InputStream& inputStream, int16_t& int16Value) {
+       return inputStream.readValue(int16Value);
+}
+
+inline InputStream& operator>>(InputStream& inputStream, int32_t& int32Value) {
+       return inputStream.readValue(int32Value);
+}
+
+inline InputStream& operator>>(InputStream& inputStream, int64_t& int64Value) {
+       return inputStream.readValue(int64Value);
+}
+
+inline InputStream& operator>>(InputStream& inputStream, uint8_t& uint8Value) {
+       return inputStream.readValue(uint8Value);
+}
+
+inline InputStream& operator>>(InputStream& inputStream, uint16_t& uint16Value) {
+       return inputStream.readValue(uint16Value);
+}
+
+inline InputStream& operator>>(InputStream& inputStream, uint32_t& uint32Value) {
+       return inputStream.readValue(uint32Value);
+}
+
+inline InputStream& operator>>(InputStream& inputStream, uint64_t& uint64Value) {
+       return inputStream.readValue(uint64Value);
+}
+
+inline InputStream& operator>>(InputStream& inputStream, float& floatValue) {
+       return inputStream.readValue(floatValue);
+}
+
+inline InputStream& operator>>(InputStream& inputStream, double& doubleValue) {
+       return inputStream.readValue(doubleValue);
+}
+
+inline InputStream& operator>>(InputStream& inputStream, std::string& stringValue) {
+       return inputStream.readValue(stringValue);
+}
+
+inline InputStream& operator>>(InputStream& inputStream, ByteBuffer& byteBufferValue) {
+       return inputStream.readValue(byteBufferValue);
+}
+
+inline InputStream& operator>>(InputStream& inputStream, Version& versionValue) {
+       return inputStream.readVersionValue(versionValue);
+}
+
+inline InputStream& operator>>(InputStream& inputStream, SerializableStruct& serializableStruct) {
+    inputStream.beginReadSerializableStruct(serializableStruct);
+    serializableStruct.readFromInputStream(inputStream);
+    inputStream.endReadSerializableStruct(serializableStruct);
+
+    return inputStream;
+}
+
+
+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 _InnerVectorElementType>
+    static inline void doBeginReadVector(InputStream& inputStream, const std::vector<std::vector<_InnerVectorElementType>>& vectorValue) {
+        inputStream.beginReadVectorOfVectors();
+    }
+
+    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>
+struct InputStreamVectorHelper: InputStreamSerializableStructVectorHelper<_VectorElementType,
+                                                                          std::is_base_of<SerializableStruct, _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>
+InputStream& operator>>(InputStream& inputStream, std::unordered_map<_KeyType, _ValueType>& mapValue) {
+       typedef typename std::unordered_map<_KeyType, _ValueType>::value_type MapValueType;
+
+       inputStream.beginReadMap();
+
+       while (inputStream.hasMoreMapElements()) {
+               _KeyType elementKey;
+               _ValueType elementValue;
+
+               inputStream >> elementKey >> elementValue;
+
+               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/CommonAPI/src/CommonAPI/MiddlewareInfo.h b/CommonAPI/src/CommonAPI/MiddlewareInfo.h
new file mode 100644 (file)
index 0000000..1967c10
--- /dev/null
@@ -0,0 +1,49 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public\r
+ * License, v. 2.0. If a copy of the MPL was not distributed with this\r
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\r
+#ifndef MIDDLEWAREINFO_H_\r
+#define MIDDLEWAREINFO_H_\r
+\r
+\r
+#include <memory>\r
+#include <cstring>\r
+\r
+\r
+namespace CommonAPI {\r
+\r
+\r
+class Runtime;\r
+\r
+\r
+inline int FNV1aHash(const char* s) {\r
+    const int FNV_offset_basis = 2166136261;\r
+    const int FNV_prime = 16777619;\r
+\r
+    int hashValue = FNV_offset_basis;\r
+    for (int i = 0; i < strlen(s); i++) {\r
+        hashValue = (hashValue ^ s[i]) * FNV_prime;\r
+    }\r
+    return hashValue;\r
+}\r
+\r
+\r
+typedef std::shared_ptr<Runtime> (*MiddlewareRuntimeLoadFunction) ();\r
+\r
+\r
+struct MiddlewareInfo {\r
+    const int middlewareId;\r
+    const char* middlewareName_;\r
+    MiddlewareRuntimeLoadFunction getInstance;\r
+\r
+    MiddlewareInfo(const char* middlewareName, MiddlewareRuntimeLoadFunction middlewareRuntimeLoadFunction):\r
+        middlewareName_(middlewareName),\r
+        middlewareId(FNV1aHash(middlewareName)),\r
+        getInstance(middlewareRuntimeLoadFunction) {\r
+}\r
+};\r
+\r
+\r
+} // namespace CommonAPI\r
+\r
+\r
+#endif /* MIDDLEWAREINFO_H_ */\r
diff --git a/CommonAPI/src/CommonAPI/OutputStream.h b/CommonAPI/src/CommonAPI/OutputStream.h
new file mode 100644 (file)
index 0000000..1283eff
--- /dev/null
@@ -0,0 +1,282 @@
+/* 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_OUTPUT_STREAM_H_
+#define COMMONAPI_OUTPUT_STREAM_H_
+
+#include "ByteBuffer.h"
+#include "SerializableStruct.h"
+#include "types.h"
+
+#include <cstdint>
+#include <functional>
+#include <memory>
+#include <string>
+#include <unordered_map>
+#include <vector>
+#include <type_traits>
+
+namespace CommonAPI {
+
+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 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 beginWriteVectorOfSerializableStructs(uint32_t sizeOfVector) = 0;
+    virtual void beginWriteVectorOfVectors(uint32_t sizeOfVector) = 0;
+    virtual void beginWriteVectorOfMaps(uint32_t sizeOfVector) = 0;
+
+    virtual void endWriteVector() = 0;
+
+       virtual void beginWriteMap(size_t elementCount) = 0;
+       virtual void endWriteMap() = 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 ByteBuffer& byteBufferValue) {
+       return outputStream.writeValue(byteBufferValue);
+}
+
+inline OutputStream& operator<<(OutputStream& outputStream, const Version& versionValue) {
+       return outputStream.writeVersionValue(versionValue);
+}
+
+inline OutputStream& operator<<(OutputStream& outputStream, const SerializableStruct& serializableStruct) {
+    outputStream.beginWriteSerializableStruct(serializableStruct);
+    serializableStruct.writeToOutputStream(outputStream);
+    outputStream.endWriteSerializableStruct(serializableStruct);
+
+    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 _InnerVectorElementType>
+    static inline void doBeginWriteVector(OutputStream& outputStream, const std::vector<std::vector<_InnerVectorElementType>>& vectorValue) {
+        outputStream.beginWriteVectorOfVectors(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>
+struct OutputStreamVectorHelper: OutputStreamSerializableStructVectorHelper<_VectorElementType,
+                                                                            std::is_base_of<SerializableStruct, _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>
+OutputStream& operator<<(OutputStream& outputStream, const std::unordered_map<_KeyType, _ValueType>& mapValue) {
+       typedef typename std::unordered_map<_KeyType, _ValueType>::const_iterator MapConstIterator;
+
+       const size_t elementCount = mapValue.size();
+
+       outputStream.beginWriteMap(elementCount);
+
+       for (MapConstIterator iter = mapValue.cbegin(); iter != mapValue.cend(); iter++) {
+               outputStream << iter->first << iter->second;
+
+               if (outputStream.hasError())
+                       return outputStream;
+       }
+
+       outputStream.endWriteMap();
+
+       return outputStream;
+}
+
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_OUTPUT_STREAM_H_
diff --git a/CommonAPI/src/CommonAPI/Proxy.h b/CommonAPI/src/CommonAPI/Proxy.h
new file mode 100644 (file)
index 0000000..ad6fd73
--- /dev/null
@@ -0,0 +1,44 @@
+/* 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_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 ProxyStatusEvent& getProxyStatusEvent() = 0;
+
+       virtual InterfaceVersionAttribute& getInterfaceVersionAttribute() = 0;
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_PROXY_H_
diff --git a/CommonAPI/src/CommonAPI/Runtime.cpp b/CommonAPI/src/CommonAPI/Runtime.cpp
new file mode 100644 (file)
index 0000000..ce3eeb0
--- /dev/null
@@ -0,0 +1,53 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public\r
+ * License, v. 2.0. If a copy of the MPL was not distributed with this\r
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\r
+#include "Runtime.h"\r
+\r
+#include <iostream>\r
+\r
+\r
+namespace CommonAPI {\r
+\r
+\r
+std::unordered_map<std::string, MiddlewareRuntimeLoadFunction>* registeredRuntimeLoadFunctions_;\r
+\r
+\r
+void Runtime::registerRuntimeLoader(std::string middlewareName, MiddlewareRuntimeLoadFunction middlewareRuntimeLoadFunction) {\r
+    if(!registeredRuntimeLoadFunctions_) {\r
+        registeredRuntimeLoadFunctions_ = new std::unordered_map<std::string, MiddlewareRuntimeLoadFunction>();\r
+    }\r
+    registeredRuntimeLoadFunctions_->insert({middlewareName, middlewareRuntimeLoadFunction});\r
+}\r
+\r
+\r
+std::shared_ptr<Runtime> Runtime::load() {\r
+    if(!registeredRuntimeLoadFunctions_) {\r
+        registeredRuntimeLoadFunctions_ = new std::unordered_map<std::string, MiddlewareRuntimeLoadFunction> {};\r
+    }\r
+\r
+    auto begin = registeredRuntimeLoadFunctions_->begin();\r
+\r
+    if (begin != registeredRuntimeLoadFunctions_->end()) {\r
+        return (begin->second)();\r
+    }\r
+\r
+    return std::shared_ptr<Runtime>(NULL);\r
+}\r
+\r
+\r
+std::shared_ptr<Runtime> Runtime::load(const std::string& middlewareName) {\r
+    if(!registeredRuntimeLoadFunctions_) {\r
+        registeredRuntimeLoadFunctions_ = new std::unordered_map<std::string, MiddlewareRuntimeLoadFunction> {};\r
+    }\r
+\r
+    for (auto it = registeredRuntimeLoadFunctions_->begin(); it != registeredRuntimeLoadFunctions_->end(); ++it) {\r
+        if(it->first == middlewareName) {\r
+            return (it->second)();\r
+        }\r
+    }\r
+\r
+    return std::shared_ptr<Runtime>(NULL);\r
+}\r
+\r
+\r
+}\r
diff --git a/CommonAPI/src/CommonAPI/Runtime.h b/CommonAPI/src/CommonAPI/Runtime.h
new file mode 100644 (file)
index 0000000..2492c75
--- /dev/null
@@ -0,0 +1,40 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public\r
+ * License, v. 2.0. If a copy of the MPL was not distributed with this\r
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\r
+#ifndef COMMONAPI_RUNTIME_H_\r
+#define COMMONAPI_RUNTIME_H_\r
+\r
+\r
+#include "MiddlewareInfo.h"\r
+#include "Factory.h"\r
+\r
+#include <memory>\r
+#include <fstream>\r
+#include <unordered_map>\r
+#include <dlfcn.h>\r
+#include <string>\r
+#include <cassert>\r
+#include <cstring>\r
+\r
+\r
+namespace CommonAPI {\r
+\r
+\r
+class Factory;\r
+class Runtime;\r
+\r
+\r
+class Runtime {\r
+ public:\r
+    static std::shared_ptr<Runtime> load();\r
+    static std::shared_ptr<Runtime> load(const std::string& middlewareId);\r
+    static void registerRuntimeLoader(std::string middlewareName, MiddlewareRuntimeLoadFunction middlewareRuntimeLoadFunction);\r
+\r
+    virtual ~Runtime() {}\r
+    virtual std::shared_ptr<Factory> createFactory() = 0;\r
+};\r
+\r
+\r
+} // namespace CommonAPI\r
+\r
+#endif // COMMONAPI_RUNTIME_H_\r
diff --git a/CommonAPI/src/CommonAPI/SerializableStruct.h b/CommonAPI/src/CommonAPI/SerializableStruct.h
new file mode 100644 (file)
index 0000000..bc300b3
--- /dev/null
@@ -0,0 +1,25 @@
+/* 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_STRUCT_H_
+#define COMMONAPI_SERIALIZABLE_STRUCT_H_
+
+#include <cstdint>
+#include <memory>
+
+
+namespace CommonAPI {
+
+class InputStream;
+class OutputStream;
+
+struct SerializableStruct {
+       virtual ~SerializableStruct() { }
+
+       virtual void readFromInputStream(InputStream& inputStream) = 0;
+       virtual void writeToOutputStream(OutputStream& outputStream) const = 0;
+};
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_SERIALIZABLE_STRUCT_H_
diff --git a/CommonAPI/src/CommonAPI/SerializableVariant.h b/CommonAPI/src/CommonAPI/SerializableVariant.h
new file mode 100644 (file)
index 0000000..c55f9f4
--- /dev/null
@@ -0,0 +1,38 @@
+/* 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_H_
+#define COMMONAPI_SERIALIZABLE_VARIANT_H_
+
+#include "Stream.h"
+
+#include <memory>
+#include <cstdint>
+
+#ifndef __COMMON_API_EXPERIMENTAL
+#error "Use -D__COMMON_API_EXPERIMENTAL to include experimental variant support"
+#endif
+
+namespace CommonAPI {
+
+class SerializableVariant {
+ public:
+       virtual ~SerializableVariant() { }
+
+       inline uint32_t getType() const;
+
+       virtual void readFromInputStream(InputStream& inputStream) = 0;
+       virtual void writeToOutputStream(OutputStream& outputStream) = 0;
+
+ protected:
+       uint32_t type_;
+       std::shared_ptr<void> value_;
+};
+
+uint32_t SerializableVariant::getType() const {
+       return type_;
+}
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_SERIALIZABLE_VARIANT_H_
diff --git a/CommonAPI/src/CommonAPI/Stub.h b/CommonAPI/src/CommonAPI/Stub.h
new file mode 100644 (file)
index 0000000..e1385bd
--- /dev/null
@@ -0,0 +1,41 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public\r
+ * License, v. 2.0. If a copy of the MPL was not distributed with this\r
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\r
+#ifndef COMMONAPI_STUB_H_\r
+#define COMMONAPI_STUB_H_\r
+\r
+#include <memory>\r
+#include <string>\r
+#include <type_traits>\r
+\r
+namespace CommonAPI {\r
+\r
+class StubAdapter {\r
+ public:\r
+    virtual ~StubAdapter() { }\r
+\r
+    virtual const std::string getAddress() const = 0;\r
+    virtual const std::string& getDomain() const = 0;\r
+    virtual const std::string& getServiceId() const = 0;\r
+    virtual const std::string& getInstanceId() const = 0;\r
+};\r
+\r
+struct StubBase {\r
+       virtual ~StubBase() {}\r
+};\r
+\r
+template <typename _StubAdapter, typename _StubRemoteEventHandler>\r
+class Stub : public StubBase {\r
+       static_assert(std::is_base_of<StubAdapter, _StubAdapter>::value, "Invalid StubAdapter Class!");\r
+ public:\r
+       typedef _StubAdapter StubAdapterType;\r
+       typedef _StubRemoteEventHandler RemoteEventHandlerType;\r
+\r
+       virtual ~Stub() { }\r
+\r
+       virtual _StubRemoteEventHandler* initStubAdapter(const std::shared_ptr<_StubAdapter>& stubAdapter) = 0;\r
+};\r
+\r
+} // namespace CommonAPI\r
+\r
+#endif // COMMONAPI_STUB_H_\r
diff --git a/CommonAPI/src/CommonAPI/types.h b/CommonAPI/src/CommonAPI/types.h
new file mode 100644 (file)
index 0000000..0f07ed3
--- /dev/null
@@ -0,0 +1,41 @@
+/* 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_TYPES_H_
+#define COMMONAPI_TYPES_H_
+
+#include <cstdint>
+
+
+namespace CommonAPI {
+
+enum class AvailabilityStatus {
+       AVAILABLE,
+       NOT_AVAILABLE
+};
+
+
+enum class CallStatus {
+       SUCCESS,
+       OUT_OF_MEMORY,
+       NOT_AVAILABLE,
+       CONNECTION_FAILED,
+       REMOTE_ERROR
+};
+
+
+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_TYPES_H_
diff --git a/test.txt b/test.txt
deleted file mode 100644 (file)
index e69de29..0000000