From d700782e7dae31cbef37ae038b992d2cb0c6f6a4 Mon Sep 17 00:00:00 2001 From: David Wagner Date: Tue, 6 Jan 2015 18:27:08 +0100 Subject: 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 --- parameter/Android.mk | 2 +- parameter/CMakeLists.txt | 3 +- parameter/ParameterMgrLogger.cpp | 44 ----------------------- parameter/ParameterMgrLogger.h | 21 +++++++---- parameter/ParameterMgrPlatformConnector.cpp | 2 +- parameter/include/ParameterMgrLoggerForward.h | 33 +++++++++++++++++ parameter/include/ParameterMgrPlatformConnector.h | 6 ++-- 7 files changed, 53 insertions(+), 58 deletions(-) delete mode 100644 parameter/ParameterMgrLogger.cpp create mode 100644 parameter/include/ParameterMgrLoggerForward.h (limited to 'parameter') 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.cpp b/parameter/ParameterMgrLogger.cpp deleted file mode 100644 index ddd81ef..0000000 --- a/parameter/ParameterMgrLogger.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011-2014, Intel Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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" - - -using std::string; - -CParameterMgrLogger::CParameterMgrLogger(CParameterMgrPlatformConnector *pParameterMgrPlatformConnector) : - _pParameterMgrPlatformConnector(pParameterMgrPlatformConnector) -{ -} - -void CParameterMgrLogger::log(bool bIsWarning, const string &strLog) -{ - _pParameterMgrPlatformConnector->doLog(bIsWarning, strLog); -} 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 -class CParameterMgrPlatformConnector; - +/* Wrap a class to expose its logging [log(bool, string&)] capabilities + * through ILogger. */ +template 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(*this); _pParameterMgr->setLogger(_pParameterMgrLogger); } diff --git a/parameter/include/ParameterMgrLoggerForward.h b/parameter/include/ParameterMgrLoggerForward.h new file mode 100644 index 0000000..28b26db --- /dev/null +++ b/parameter/include/ParameterMgrLoggerForward.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#pragma once + +// Shared forward declaration, to ensure declaration alignment +template 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; public: // Logger interface class ILogger @@ -144,5 +144,5 @@ private: // Logging ILogger* _pLogger; // Private logging - CParameterMgrLogger* _pParameterMgrLogger; + CParameterMgrLogger* _pParameterMgrLogger; }; -- cgit v1.1