summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLutz Bichler <Lutz.Bichler@bmw.de>2015-06-17 11:29:46 +0200
committerLutz Bichler <Lutz.Bichler@bmw.de>2015-06-17 11:29:46 +0200
commitc52b2b094ef5844c182f097b14923764758dfe80 (patch)
treef4e0446c1f8411dca5336884e2bc10a820ef8722
parent6c463fcc3dcee619925f08ea09e19a86b9e581cc (diff)
downloadgenivi-common-api-runtime-c52b2b094ef5844c182f097b14923764758dfe80.tar.gz
CommonAPI 3.1.2
-rw-r--r--CMakeLists.txt2
-rw-r--r--CommonAPI.sln31
-rw-r--r--CommonAPI.vcxproj131
-rw-r--r--NEWS15
-rw-r--r--Tests.vcxproj94
-rw-r--r--include/CommonAPI/Enumeration.hpp30
-rw-r--r--include/CommonAPI/Event.hpp19
-rw-r--r--include/CommonAPI/Runtime.hpp174
-rw-r--r--include/CommonAPI/Struct.hpp10
-rw-r--r--include/CommonAPI/TypeOutputStream.hpp14
-rw-r--r--include/CommonAPI/Variant.hpp21
-rw-r--r--src/CommonAPI/Runtime.cpp574
12 files changed, 463 insertions, 652 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 79dd2a9..4711294 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,7 +10,7 @@ PROJECT(libcommonapi)
# version of CommonAPI
SET( LIBCOMMONAPI_MAJOR_VERSION 3 )
SET( LIBCOMMONAPI_MINOR_VERSION 1 )
-SET( LIBCOMMONAPI_PATCH_VERSION 1 )
+SET( LIBCOMMONAPI_PATCH_VERSION 2 )
message(STATUS "Project name: ${PROJECT_NAME}")
diff --git a/CommonAPI.sln b/CommonAPI.sln
deleted file mode 100644
index 025d1c9..0000000
--- a/CommonAPI.sln
+++ /dev/null
@@ -1,31 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Express 2013 for Windows Desktop
-VisualStudioVersion = 12.0.21005.1
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Tests.vcxproj", "{872A0F1D-2EB9-443D-9869-B7F699CC0DE2}"
- ProjectSection(ProjectDependencies) = postProject
- {C18FDEDE-810E-405D-9100-57A1CC5C78A9} = {C18FDEDE-810E-405D-9100-57A1CC5C78A9}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CommonAPI", "CommonAPI.vcxproj", "{C18FDEDE-810E-405D-9100-57A1CC5C78A9}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {872A0F1D-2EB9-443D-9869-B7F699CC0DE2}.Debug|Win32.ActiveCfg = Debug|Win32
- {872A0F1D-2EB9-443D-9869-B7F699CC0DE2}.Debug|Win32.Build.0 = Debug|Win32
- {872A0F1D-2EB9-443D-9869-B7F699CC0DE2}.Release|Win32.ActiveCfg = Release|Win32
- {872A0F1D-2EB9-443D-9869-B7F699CC0DE2}.Release|Win32.Build.0 = Release|Win32
- {C18FDEDE-810E-405D-9100-57A1CC5C78A9}.Debug|Win32.ActiveCfg = Debug|Win32
- {C18FDEDE-810E-405D-9100-57A1CC5C78A9}.Debug|Win32.Build.0 = Debug|Win32
- {C18FDEDE-810E-405D-9100-57A1CC5C78A9}.Release|Win32.ActiveCfg = Release|Win32
- {C18FDEDE-810E-405D-9100-57A1CC5C78A9}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/CommonAPI.vcxproj b/CommonAPI.vcxproj
deleted file mode 100644
index d2061f1..0000000
--- a/CommonAPI.vcxproj
+++ /dev/null
@@ -1,131 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <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>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <IncludePath>$(IncludePath)</IncludePath>
- <LibraryPath>$(LibraryPath)</LibraryPath>
- <TargetName>$(ProjectName)d</TargetName>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <SDLCheck>true</SDLCheck>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <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>
- <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <Lib>
- <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
- </Lib>
- <Lib>
- <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <Verbose>true</Verbose>
- </Lib>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WIN32;COMMONAPI_INTERNAL_COMPILATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
- <DebugInformationFormat>OldStyle</DebugInformationFormat>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- </Link>
- </ItemDefinitionGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/NEWS b/NEWS
index ffe601c..2b61002 100644
--- a/NEWS
+++ b/NEWS
@@ -1 +1,14 @@
-This is CommonAPI 3.1.1
+This is CommonAPI 3.1.0
+
+Changes since 3.0.1
+- Windows support updated
+- CommonAPI logger added
+- Bugfix for ByteBuffers
+- GTEST_ROOT must be set as DEFINE instead of environment variable
+
+Changes since 2.1.6
+- Support for asynchronous stubs
+- Subscribe/Unsubscribe is now thread safe
+- Full support for deployable serialization
+- Dynamic loading of bindings
+- Simplified application interface for building proxies and stubs
diff --git a/Tests.vcxproj b/Tests.vcxproj
deleted file mode 100644
index e2177e7..0000000
--- a/Tests.vcxproj
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{872A0F1D-2EB9-443D-9869-B7F699CC0DE2}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>Tests</RootNamespace>
- <ProjectName>Test</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- <UseOfMfc>false</UseOfMfc>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- <UseOfMfc>false</UseOfMfc>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LinkIncremental>true</LinkIncremental>
- <TargetName>$(ProjectName)d</TargetName>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>$(SolutionDir)\src\test;$(GTEST)\include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;COMMONAPI_INTERNAL_COMPILATION;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <UseFullPaths>true</UseFullPaths>
- <DebugInformationFormat>OldStyle</DebugInformationFormat>
- <MinimalRebuild>false</MinimalRebuild>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalLibraryDirectories>$(GTEST)\msvc\gtest-md\Debug;$(SolutionDir)\Debug;$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>gtestd.lib;CommonAPId.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <AdditionalIncludeDirectories>$(GTEST)\include;$(SolutionDir)\src\test;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;COMMONAPI_INTERNAL_COMPILATION;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <UseFullPaths>true</UseFullPaths>
- <DebugInformationFormat>OldStyle</DebugInformationFormat>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalLibraryDirectories>$(GTEST)\msvc\gtest-md\Release;$(SolutionDir)\Release;$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>gtest.lib;CommonAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="src\test\VariantTest.cpp" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/include/CommonAPI/Enumeration.hpp b/include/CommonAPI/Enumeration.hpp
index 1a4d5f4..da0372d 100644
--- a/include/CommonAPI/Enumeration.hpp
+++ b/include/CommonAPI/Enumeration.hpp
@@ -8,11 +8,11 @@
namespace CommonAPI {
-template <typename _Base>
+template<typename _Base>
struct Enumeration {
Enumeration() = default;
- Enumeration(const _Base &_value)
- : value_(_value) {
+ Enumeration(const _Base &_value) :
+ value_(_value) {
}
inline Enumeration &operator=(const _Base &_value) {
@@ -24,12 +24,28 @@ struct Enumeration {
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_);
}
- inline bool operator != (const Enumeration<_Base> &_other) const {
- return value_ != _other.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_);
+ }
+
+ inline bool operator<=(const Enumeration<_Base> &_other) const {
+ return (value_ <= _other.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_;
diff --git a/include/CommonAPI/Event.hpp b/include/CommonAPI/Event.hpp
index 90971f5..982f9a3 100644
--- a/include/CommonAPI/Event.hpp
+++ b/include/CommonAPI/Event.hpp
@@ -106,24 +106,31 @@ typename Event<_Arguments...>::Subscription Event<_Arguments...>::subscribe(List
template<typename ... _Arguments>
void Event<_Arguments...>::unsubscribe(Subscription subscription) {
bool isLastListener(false);
+ bool hasUnsubscribed(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 {
+ pendingUnsubscriptions_.insert(subscription);
+ isLastListener = (1 == subscriptions_.size());
+ hasUnsubscribed = true;
+ }
+ else {
+ listener = pendingSubscriptions_.find(subscription);
+ if (pendingSubscriptions_.end() != listener) {
+ pendingSubscriptions_.erase(subscription);
isLastListener = (0 == subscriptions_.size());
+ hasUnsubscribed = true;
}
}
subscriptionMutex_.unlock();
- if (subscriptions_.end() != listener) {
+ if (hasUnsubscribed) {
onListenerRemoved(listener->second);
- if (isLastListener)
+ if (isLastListener) {
onLastListenerRemoved(listener->second);
+ }
}
}
diff --git a/include/CommonAPI/Runtime.hpp b/include/CommonAPI/Runtime.hpp
index 1cb4f94..8d33d48 100644
--- a/include/CommonAPI/Runtime.hpp
+++ b/include/CommonAPI/Runtime.hpp
@@ -15,6 +15,7 @@
#include <mutex>
#include <set>
+#include <CommonAPI/AttributeExtension.hpp>
#include <CommonAPI/Export.hpp>
#include <CommonAPI/Factory.hpp>
#include <CommonAPI/Types.hpp>
@@ -28,78 +29,65 @@ 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::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 static std::shared_ptr<Runtime> get();
- COMMONAPI_EXPORT Runtime();
- COMMONAPI_EXPORT virtual ~Runtime();
+ COMMONAPI_EXPORT Runtime();
+ COMMONAPI_EXPORT virtual ~Runtime();
- COMMONAPI_EXPORT void init();
+ COMMONAPI_EXPORT void init();
template<template<typename ...> class _ProxyClass, typename ... _AttributeExtensions>
- COMMONAPI_EXPORT std::shared_ptr<
+ 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);
+ = createProxy(_domain,
+ _ProxyClass<_AttributeExtensions...>::getInterface(),
+ _instance,
+ _connectionId);
if (proxy) {
return std::make_shared<_ProxyClass<_AttributeExtensions...>>(proxy);
}
- else {
- return nullptr;
- }
+ return nullptr;
}
template<template<typename ...> class _ProxyClass, typename ... _AttributeExtensions>
- COMMONAPI_EXPORT std::shared_ptr<
+ 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);
+ = createProxy(_domain,
+ _ProxyClass<_AttributeExtensions...>::getInterface(),
+ _instance,
+ _context);
if (proxy) {
return std::make_shared<_ProxyClass<_AttributeExtensions...>>(proxy);
}
- else {
- return nullptr;
- }
+ return nullptr;
}
template <template<typename ...> class _ProxyClass, template<typename> class _AttributeExtension>
- COMMONAPI_EXPORT std::shared_ptr<typename DefaultAttributeProxyHelper<_ProxyClass, _AttributeExtension>::class_t>
+ 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) {
+ const ConnectionId_t &_connectionId = DEFAULT_CONNECTION_ID) {
std::shared_ptr<Proxy> proxy
- = createProxy(_domain,
- DefaultAttributeProxyHelper<_ProxyClass, _AttributeExtension>::class_t::getInterface(),
- _instance,
- _connectionId);
+ = createProxy(_domain,
+ DefaultAttributeProxyHelper<_ProxyClass, _AttributeExtension>::class_t::getInterface(),
+ _instance,
+ _connectionId);
if (proxy) {
return std::make_shared<typename DefaultAttributeProxyHelper<_ProxyClass, _AttributeExtension>::class_t>(proxy);
}
@@ -107,15 +95,15 @@ public:
}
template <template<typename ...> class _ProxyClass, template<typename> class _AttributeExtension>
- COMMONAPI_EXPORT std::shared_ptr<typename DefaultAttributeProxyHelper<_ProxyClass, _AttributeExtension>::class_t>
+ 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);
+ = createProxy(_domain,
+ DefaultAttributeProxyHelper<_ProxyClass, _AttributeExtension>::class_t::getInterface(),
+ _instance,
+ _context);
if (proxy) {
return std::make_shared<typename DefaultAttributeProxyHelper<_ProxyClass, _AttributeExtension>::class_t>(proxy);
}
@@ -123,77 +111,77 @@ public:
}
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);
- }
+ 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 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 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);
+ 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 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> 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 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 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 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 &);
+ 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::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::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_;
+ std::mutex mutex_;
+ std::mutex factoriesMutex_;
+ std::mutex loadMutex_;
- static std::map<std::string, std::string> properties_;
- static std::shared_ptr<Runtime> theRuntime__;
+ static std::map<std::string, std::string> properties_;
+ static std::shared_ptr<Runtime> theRuntime__;
friend class ProxyManager;
};
diff --git a/include/CommonAPI/Struct.hpp b/include/CommonAPI/Struct.hpp
index c98b09e..b8d748f 100644
--- a/include/CommonAPI/Struct.hpp
+++ b/include/CommonAPI/Struct.hpp
@@ -4,7 +4,7 @@
// 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."
+#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents."
#endif
#ifndef COMMONAPI_STRUCT_HPP_
@@ -142,7 +142,11 @@ struct StructTypeWriter<_Index, _TypeOutput, _V<_Values...>> {
void operator()(TypeOutputStream<_TypeOutput> &_output,
const _V<_Values...> &_values) {
StructTypeWriter<_Index-1, _TypeOutput, _V<_Values...>>{}(_output, _values);
+#ifdef WIN32
+ _output.writeType(std::get<_Index>(_values.values_));
+#else
_output.template writeType(std::get<_Index>(_values.values_));
+#endif
}
};
@@ -151,7 +155,11 @@ template<class _TypeOutput,
struct StructTypeWriter<0, _TypeOutput, _V<_Values...>> {
void operator()(TypeOutputStream<_TypeOutput> &_output,
const _V<_Values...> &_values) {
+#ifdef WIN32
+ _output.writeType(std::get<0>(_values.values_));
+#else
_output.template writeType(std::get<0>(_values.values_));
+#endif
}
};
diff --git a/include/CommonAPI/TypeOutputStream.hpp b/include/CommonAPI/TypeOutputStream.hpp
index ec44864..28f9d01 100644
--- a/include/CommonAPI/TypeOutputStream.hpp
+++ b/include/CommonAPI/TypeOutputStream.hpp
@@ -69,6 +69,10 @@ public:
return get()->writeType(_value);
}
+ inline TypeOutputStream &writeType(const Version &_value) {
+ return get()->writeType(_value);
+ }
+
template<typename _Type>
TypeOutputStream &writeType(const Enumeration<_Type> &_value) {
_Type tmpValue;
@@ -80,6 +84,11 @@ public:
return get()->writeType(_value);
}
+ template<class _PolymorphicStruct>
+ TypeOutputStream &writeType(const std::shared_ptr<_PolymorphicStruct> &_value) {
+ return get()->writeType(_value);
+ }
+
template<typename... _Types>
TypeOutputStream &writeType(const Variant<_Types...> &_value) {
return get()->writeType(_value);
@@ -176,6 +185,11 @@ TypeOutputStream<_Derived> &operator<<(TypeOutputStream<_Derived> &_output, cons
return _output.writeType(_value);
}
+template<class _Derived, class _PolymorphicStruct>
+TypeOutputStream<_Derived> &operator<<(TypeOutputStream<_Derived> &_output, const std::shared_ptr<_PolymorphicStruct> &_value) {
+ return _output.writeType(_value);
+}
+
template<class _Derived, typename... _Types>
TypeOutputStream<_Derived> &operator<<(TypeOutputStream<_Derived> &_output, const Variant<_Types...> &_value) {
return _output.writeType(_value);
diff --git a/include/CommonAPI/Variant.hpp b/include/CommonAPI/Variant.hpp
index d7b1088..7af1b81 100644
--- a/include/CommonAPI/Variant.hpp
+++ b/include/CommonAPI/Variant.hpp
@@ -516,6 +516,27 @@ struct TypeSelector<_Type> {
};
template<typename _Type, typename... _Types>
+struct TypeSelector<typename _Type::Literal, _Type, _Types...> {
+ typedef _Type type;
+};
+
+template<typename _Type, typename... _Types>
+struct TypeSelector<typename _Type::Literal &, _Type, _Types...> {
+ typedef _Type type;
+};
+
+
+template<typename _Type, typename... _Types>
+struct TypeSelector<typename _Type::Literal, const _Type&, _Types...> {
+ typedef _Type type;
+};
+
+template<typename _Type, typename... _Types>
+struct TypeSelector<const typename _Type::Literal &, _Type, _Types...> {
+ typedef _Type type;
+};
+
+template<typename _Type, typename... _Types>
struct TypeSelector<_Type, _Type, _Types...> {
typedef _Type type;
};
diff --git a/src/CommonAPI/Runtime.cpp b/src/CommonAPI/Runtime.cpp
index 95c2832..74c2c0f 100644
--- a/src/CommonAPI/Runtime.cpp
+++ b/src/CommonAPI/Runtime.cpp
@@ -31,379 +31,379 @@ std::shared_ptr<Runtime> Runtime::theRuntime__ = std::make_shared<Runtime>();
std::string
Runtime::getProperty(const std::string &_name) {
- auto foundProperty = properties__.find(_name);
- if (foundProperty != properties__.end())
- return foundProperty->second;
- return "";
+ auto foundProperty = properties__.find(_name);
+ if (foundProperty != properties__.end())
+ return foundProperty->second;
+ return "";
}
void
Runtime::setProperty(const std::string &_name, const std::string &_value) {
- properties__[_name] = _value;
+ properties__[_name] = _value;
}
std::shared_ptr<Runtime> Runtime::get() {
- theRuntime__->init();
- return theRuntime__;
+ theRuntime__->init();
+ return theRuntime__;
}
Runtime::Runtime()
- : defaultBinding_(COMMONAPI_DEFAULT_BINDING),
- defaultFolder_(COMMONAPI_DEFAULT_FOLDER) {
+ : defaultBinding_(COMMONAPI_DEFAULT_BINDING),
+ defaultFolder_(COMMONAPI_DEFAULT_FOLDER) {
}
Runtime::~Runtime() {
- // intentionally left empty
+ // 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);
+ COMMONAPI_DEBUG("Registering factory for binding=", _binding);
+ bool isRegistered(false);
#ifndef WIN32
- std::lock_guard<std::mutex> itsLock(factoriesMutex_);
+ 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;
+ if (_binding == defaultBinding_) {
+ defaultFactory_ = _factory;
+ } else {
+ auto foundFactory = factories_.find(_binding);
+ if (foundFactory == factories_.end()) {
+ factories_[_binding] = _factory;
+ isRegistered = true;
+ }
+ }
+ return isRegistered;
}
bool
Runtime::unregisterFactory(const std::string &_binding) {
- COMMONAPI_DEBUG("Unregistering factory for binding=", _binding);
+ COMMONAPI_DEBUG("Unregistering factory for binding=", _binding);
#ifndef WIN32
- std::lock_guard<std::mutex> itsLock(factoriesMutex_);
+ std::lock_guard<std::mutex> itsLock(factoriesMutex_);
#endif
- if (_binding == defaultBinding_) {
- defaultFactory_.reset();
- } else {
- factories_.erase(_binding);
- }
- return true;
+ if (_binding == defaultBinding_) {
+ defaultFactory_.reset();
+ } else {
+ factories_.erase(_binding);
+ }
+ return true;
}
/*
* Private
*/
void Runtime::init() {
- static bool isInitialized(false);
+ static bool isInitialized(false);
#ifndef WIN32
- std::lock_guard<std::mutex> itsLock(mutex_);
+ 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;
- }
+ 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;
+ }
}
bool
Runtime::readConfiguration() {
#define MAX_PATH_LEN 255
- std::string config;
- char currentDirectory[MAX_PATH_LEN];
+ std::string config;
+ char currentDirectory[MAX_PATH_LEN];
#ifdef WIN32
- if (GetCurrentDirectory(MAX_PATH_LEN, currentDirectory)) {
+ if (GetCurrentDirectory(MAX_PATH_LEN, currentDirectory)) {
#else
- if (getcwd(currentDirectory, MAX_PATH_LEN)) {
+ 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;
+ 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;
}
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;
+ 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;
+ 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;
}
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<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;
}
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;
+ 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;
}
-bool
+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;
- }
+ for (auto factory : factories_) {
+ if (factory.second->unregisterStub(_domain, _interface, _instance))
+ return true;
+ }
- return (defaultFactory_ ? defaultFactory_->unregisterStub(_domain, _interface, _instance) : false);
+ return (defaultFactory_ ? defaultFactory_->unregisterStub(_domain, _interface, _instance) : false);
}
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;
+ 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::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<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);
+ 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<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<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);
}
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);
+ 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);
+ 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