diff options
author | David Wagner <david.wagner@intel.com> | 2015-01-06 18:27:08 +0100 |
---|---|---|
committer | David Wagner <david.wagner@intel.com> | 2015-01-22 12:02:31 +0100 |
commit | d700782e7dae31cbef37ae038b992d2cb0c6f6a4 (patch) | |
tree | 2c67728ffa3830a1fdc4c5ed5798da2b144e85e5 /parameter | |
parent | 70e458c1bb62ad39ea9c59339e74e1f7702910ee (diff) | |
download | external_parameter-framework-d700782e7dae31cbef37ae038b992d2cb0c6f6a4.zip external_parameter-framework-d700782e7dae31cbef37ae038b992d2cb0c6f6a4.tar.gz external_parameter-framework-d700782e7dae31cbef37ae038b992d2cb0c6f6a4.tar.bz2 |
Make ParameterMgrLogger template
This will make it possible to have different kind of ParameterMgr connectors
instead of hardcoding ParameterMgrPlatformConnector in ParameterMgrLogger.
Change-Id: Ia78d9f56c8cc73321e1956856755a56a3569b517
Signed-off-by: David Wagner <david.wagner@intel.com>
Diffstat (limited to 'parameter')
-rw-r--r-- | parameter/Android.mk | 2 | ||||
-rw-r--r-- | parameter/CMakeLists.txt | 3 | ||||
-rw-r--r-- | parameter/ParameterMgrLogger.h | 21 | ||||
-rw-r--r-- | parameter/ParameterMgrPlatformConnector.cpp | 2 | ||||
-rw-r--r-- | parameter/include/ParameterMgrLoggerForward.h (renamed from parameter/ParameterMgrLogger.cpp) | 19 | ||||
-rw-r--r-- | parameter/include/ParameterMgrPlatformConnector.h | 6 |
6 files changed, 24 insertions, 29 deletions
diff --git a/parameter/Android.mk b/parameter/Android.mk index aaa40ea..247c745 100644 --- a/parameter/Android.mk +++ b/parameter/Android.mk @@ -34,6 +34,7 @@ LOCAL_PATH := $(call my-dir) common_copy_headers_to := parameter common_copy_headers := \ + include/ParameterMgrLoggerForward.h \ include/ParameterMgrPlatformConnector.h \ include/SelectionCriterionTypeInterface.h \ include/SelectionCriterionInterface.h \ @@ -92,7 +93,6 @@ common_src_files := \ BitParameterType.cpp \ BitParameter.cpp \ ElementLocator.cpp \ - ParameterMgrLogger.cpp \ AutoLog.cpp \ CompoundRule.cpp \ SelectionCriterionRule.cpp \ diff --git a/parameter/CMakeLists.txt b/parameter/CMakeLists.txt index 50fc15b..590c7b1 100644 --- a/parameter/CMakeLists.txt +++ b/parameter/CMakeLists.txt @@ -79,7 +79,6 @@ add_library(parameter SHARED BitParameterType.cpp BitParameter.cpp ElementLocator.cpp - ParameterMgrLogger.cpp AutoLog.cpp CompoundRule.cpp SelectionCriterionRule.cpp @@ -153,7 +152,6 @@ add_library(parameter SHARED BitParameterType.cpp BitParameter.cpp ElementLocator.cpp - ParameterMgrLogger.cpp AutoLog.cpp CompoundRule.cpp SelectionCriterionRule.cpp @@ -189,6 +187,7 @@ install(TARGETS parameter LIBRARY DESTINATION lib) # Client headers install(FILES include/ParameterHandle.h + include/ParameterMgrLoggerForward.h include/ParameterMgrPlatformConnector.h include/SelectionCriterionInterface.h include/SelectionCriterionTypeInterface.h diff --git a/parameter/ParameterMgrLogger.h b/parameter/ParameterMgrLogger.h index 5a8dd9d..0e42d8a 100644 --- a/parameter/ParameterMgrLogger.h +++ b/parameter/ParameterMgrLogger.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014, Intel Corporation + * Copyright (c) 2011-2015, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -29,22 +29,29 @@ */ #pragma once +#include "ParameterMgrLoggerForward.h" #include "ParameterMgr.h" #include <string> -class CParameterMgrPlatformConnector; - +/* Wrap a class to expose its logging [log(bool, string&)] capabilities + * through ILogger. */ +template<class T> class CParameterMgrLogger : public CParameterMgr::ILogger { public: - CParameterMgrLogger(CParameterMgrPlatformConnector* pParameterMgrPlatformConnector); + CParameterMgrLogger(T& parameterMgrConnector) : + _parameterMgrConnector(parameterMgrConnector) + { + } - // Logging - virtual void log(bool bIsWarning, const std::string& strLog); + virtual void log(bool bIsWarning, const std::string& strLog) + { + _parameterMgrConnector.doLog(bIsWarning, strLog); + } private: // Log destination - CParameterMgrPlatformConnector* _pParameterMgrPlatformConnector; + T& _parameterMgrConnector; }; diff --git a/parameter/ParameterMgrPlatformConnector.cpp b/parameter/ParameterMgrPlatformConnector.cpp index b98692c..7a8511b 100644 --- a/parameter/ParameterMgrPlatformConnector.cpp +++ b/parameter/ParameterMgrPlatformConnector.cpp @@ -40,7 +40,7 @@ CParameterMgrPlatformConnector::CParameterMgrPlatformConnector( _pParameterMgr(new CParameterMgr(strConfigurationFilePath)), _bStarted(false), _pLogger(NULL) { // Logging - _pParameterMgrLogger = new CParameterMgrLogger(this); + _pParameterMgrLogger = new CParameterMgrLogger<CParameterMgrPlatformConnector>(*this); _pParameterMgr->setLogger(_pParameterMgrLogger); } diff --git a/parameter/ParameterMgrLogger.cpp b/parameter/include/ParameterMgrLoggerForward.h index ddd81ef..28b26db 100644 --- a/parameter/ParameterMgrLogger.cpp +++ b/parameter/include/ParameterMgrLoggerForward.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014, Intel Corporation + * Copyright (c) 2015, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -27,18 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "ParameterMgrLogger.h" -#include "ParameterMgrPlatformConnector.h" +#pragma once - -using std::string; - -CParameterMgrLogger::CParameterMgrLogger(CParameterMgrPlatformConnector *pParameterMgrPlatformConnector) : - _pParameterMgrPlatformConnector(pParameterMgrPlatformConnector) -{ -} - -void CParameterMgrLogger::log(bool bIsWarning, const string &strLog) -{ - _pParameterMgrPlatformConnector->doLog(bIsWarning, strLog); -} +// Shared forward declaration, to ensure declaration alignment +template<class T> class CParameterMgrLogger; diff --git a/parameter/include/ParameterMgrPlatformConnector.h b/parameter/include/ParameterMgrPlatformConnector.h index d489545..baa0e7e 100644 --- a/parameter/include/ParameterMgrPlatformConnector.h +++ b/parameter/include/ParameterMgrPlatformConnector.h @@ -32,13 +32,13 @@ #include "SelectionCriterionTypeInterface.h" #include "SelectionCriterionInterface.h" #include "ParameterHandle.h" +#include "ParameterMgrLoggerForward.h" class CParameterMgr; -class CParameterMgrLogger; class CParameterMgrPlatformConnector { - friend class CParameterMgrLogger; + friend class CParameterMgrLogger<CParameterMgrPlatformConnector>; public: // Logger interface class ILogger @@ -144,5 +144,5 @@ private: // Logging ILogger* _pLogger; // Private logging - CParameterMgrLogger* _pParameterMgrLogger; + CParameterMgrLogger<CParameterMgrPlatformConnector>* _pParameterMgrLogger; }; |