From 4c8d43322e89b87288fb5ba12e523237e620481b Mon Sep 17 00:00:00 2001 From: Lutz Helwing Date: Tue, 22 Sep 2015 10:49:29 +0200 Subject: Fixed whitespace and formatting of new code Fixed licence headers Signed-off-by: Alexander Wenzel --- include/dlt/dlt_cpp_extension.hpp | 177 ++++++++++++++++++-------------------- include/dlt/dlt_user.h | 12 +-- 2 files changed, 92 insertions(+), 97 deletions(-) (limited to 'include') diff --git a/include/dlt/dlt_cpp_extension.hpp b/include/dlt/dlt_cpp_extension.hpp index 8949658..1eaf4d2 100644 --- a/include/dlt/dlt_cpp_extension.hpp +++ b/include/dlt/dlt_cpp_extension.hpp @@ -1,22 +1,28 @@ -/** +/* * @licence app begin@ - * Copyright (C) 2015 Intel Corporation + * SPDX license identifier: MPL-2.0 * - * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps. + * Copyright (C) 2015 Intel Corporation * - * Contributions are licensed to the GENIVI Alliance under one or more - * Contribution License Agreements. + * This file is part of GENIVI Project DLT - Diagnostic Log and Trace. * - * \copyright * This Source Code Form is subject to the terms of the - * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with - * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Mozilla Public License (MPL), 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/. * - * \file dlt_cpp_extension.hpp * For further information see http://www.genivi.org/. * @licence end@ */ +/*! + * \author Stefan Vacek Intel Corporation + * + * \copyright Copyright © 2015 Intel Corporation. \n + * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. + * + * \file dlt_cpp_extension.hpp +*/ #ifndef DLT_CPP_EXTENSION_HPP #define DLT_CPP_EXTENSION_HPP @@ -27,170 +33,158 @@ #include #include - template int32_t logToDlt(DltContextData &log, T const &value) = delete; - template<> inline int32_t logToDlt(DltContextData &log, int8_t const &value) { - return dlt_user_log_write_int8(&log, value); + return dlt_user_log_write_int8(&log, value); } template<> inline int32_t logToDlt(DltContextData &log, int16_t const &value) { - return dlt_user_log_write_int16(&log, value); + return dlt_user_log_write_int16(&log, value); } template<> inline int32_t logToDlt(DltContextData &log, int32_t const &value) { - return dlt_user_log_write_int32(&log, value); + return dlt_user_log_write_int32(&log, value); } template<> inline int32_t logToDlt(DltContextData &log, int64_t const &value) { - return dlt_user_log_write_int64(&log, value); + return dlt_user_log_write_int64(&log, value); } template<> inline int32_t logToDlt(DltContextData &log, uint8_t const &value) { - return dlt_user_log_write_uint8(&log, value); + return dlt_user_log_write_uint8(&log, value); } template<> inline int32_t logToDlt(DltContextData &log, uint16_t const &value) { - return dlt_user_log_write_uint16(&log, value); + return dlt_user_log_write_uint16(&log, value); } template<> inline int32_t logToDlt(DltContextData &log, uint32_t const &value) { - return dlt_user_log_write_uint32(&log, value); + return dlt_user_log_write_uint32(&log, value); } template<> inline int32_t logToDlt(DltContextData &log, uint64_t const &value) { - return dlt_user_log_write_uint64(&log, value); + return dlt_user_log_write_uint64(&log, value); } template<> inline int32_t logToDlt(DltContextData &log, float32_t const &value) { - return dlt_user_log_write_float32(&log, value); + return dlt_user_log_write_float32(&log, value); } template<> inline int32_t logToDlt(DltContextData &log, double const &value) { - return dlt_user_log_write_float64(&log, value); + return dlt_user_log_write_float64(&log, value); } template<> inline int32_t logToDlt(DltContextData &log, bool const &value) { - return dlt_user_log_write_bool(&log, value); + return dlt_user_log_write_bool(&log, value); } static inline int32_t logToDlt(DltContextData &log, char const * const value) { - return dlt_user_log_write_utf8_string(&log, value); + return dlt_user_log_write_utf8_string(&log, value); } static inline int32_t logToDlt(DltContextData &log, char * const value) { - return dlt_user_log_write_utf8_string(&log, value); + return dlt_user_log_write_utf8_string(&log, value); } template<> inline int32_t logToDlt(DltContextData &log, std::string const &value) { - return dlt_user_log_write_utf8_string(&log, value.c_str()); + return dlt_user_log_write_utf8_string(&log, value.c_str()); } - /* stl types */ template<> int32_t logToDlt(DltContextData &log, std::string const &value); template> -static inline int32_t logToDlt(DltContextData &log, std::vector<_Tp, _Alloc > const & value) +static inline int32_t logToDlt(DltContextData &log, std::vector<_Tp, _Alloc> const & value) { - int result = 0; + int result = 0; - for (auto elem: value) - { - result += logToDlt(log, elem); - } + for (auto elem : value) + result += logToDlt(log, elem); - if (result != 0) - { - result = -1; - } - return result; + if (result != 0) + result = -1; + + return result; } template> -static inline int32_t logToDlt(DltContextData &log, std::list<_Tp, _Alloc > const & value) +static inline int32_t logToDlt(DltContextData &log, std::list<_Tp, _Alloc> const & value) { - int result = 0; + int result = 0; + + for (auto elem : value) + result += logToDlt(log, elem); - for (auto elem: value) - { - result += logToDlt(log, elem); - } + if (result != 0) + result = -1; - if (result != 0) - { - result = -1; - } - return result; + return result; } template, - typename _Alloc = std::allocator >> -static inline int32_t logToDlt(DltContextData &log, std::map<_Key, _Tp, _Compare, _Alloc > const & value) + typename _Alloc = std::allocator>> +static inline int32_t logToDlt(DltContextData &log, std::map<_Key, _Tp, _Compare, _Alloc> const & value) { - int result = 0; + int result = 0; - for (auto elem: value) - { - result += logToDlt(log, elem.first); - result += logToDlt(log, elem.second); - } + for (auto elem : value) + { + result += logToDlt(log, elem.first); + result += logToDlt(log, elem.second); + } - if (result != 0) - { - result = -1; - } - return result; -} + if (result != 0) + result = -1; + return result; +} //variadic functions using C11 standard template static inline int32_t logToDltVariadic(DltContextData &log, First const &valueA) { - return logToDlt(log, valueA); + return logToDlt(log, valueA); } -template +template static inline int32_t logToDltVariadic(DltContextData &log, First const &valueA, const Rest&... valueB) { - int result = logToDlt(log, valueA) + logToDltVariadic(log, valueB...); - if ( result != 0 ) - { - result = -1; - } - return result; -} + int result = logToDlt(log, valueA) + logToDltVariadic(log, valueB...); + if (result != 0) + result = -1; + + return result; +} /** * @brief macro to write a log message with variable number of arguments and without the need to specify the type of log data @@ -201,14 +195,16 @@ static inline int32_t logToDltVariadic(DltContextData &log, First const &valueA, * DLT_LOG_CXX(dltContext, DLT_LV_X, "text", valueA, valueB, ...) */ #define DLT_LOG_CXX(CONTEXT, LOGLEVEL, ...)\ - do{ \ - DltContextData log; \ - if (dlt_user_log_write_start(&CONTEXT,&log,LOGLEVEL)>0) \ - { \ - logToDltVariadic(log, ##__VA_ARGS__); \ - dlt_user_log_write_finish(&log); \ - } \ - } while(0) + do\ + {\ + DltContextData log;\ + if (dlt_user_log_write_start(&CONTEXT,&log,LOGLEVEL)>0)\ + {\ + logToDltVariadic(log, ##__VA_ARGS__);\ + dlt_user_log_write_finish(&log);\ + }\ + }\ + while(0) /** * @brief macro to write a log message with variable number of arguments and without the need to specify the type of log data. @@ -222,17 +218,16 @@ static inline int32_t logToDltVariadic(DltContextData &log, First const &valueA, * DLT_LOG_FCN_CXX(dltContext, DLT_LV_X, "text", valueA, valueB, ...) */ #define DLT_LOG_FCN_CXX(CONTEXT, LOGLEVEL, ...) \ - do { \ - DltContextData log; \ - if (dlt_user_log_write_start(&CONTEXT, &log, LOGLEVEL) > 0) \ - { \ - dlt_user_log_write_string(&log, __PRETTY_FUNCTION__); \ - logToDltVariadic(log, ##__VA_ARGS__); \ - dlt_user_log_write_finish(&log); \ - } \ - } while(0) - + do\ + {\ + DltContextData log;\ + if (dlt_user_log_write_start(&CONTEXT, &log, LOGLEVEL) > 0)\ + {\ + dlt_user_log_write_string(&log, __PRETTY_FUNCTION__);\ + logToDltVariadic(log, ##__VA_ARGS__);\ + dlt_user_log_write_finish(&log);\ + }\ + }\ + while(0) #endif /* DLT_CPP_EXTENSION_HPP */ - - diff --git a/include/dlt/dlt_user.h b/include/dlt/dlt_user.h index baa5746..05bd6b9 100644 --- a/include/dlt/dlt_user.h +++ b/include/dlt/dlt_user.h @@ -176,11 +176,11 @@ typedef enum */ typedef struct { - char contextID[DLT_ID_SIZE]; /**< context id */ - int32_t log_level_pos; /**< offset in user-application context field */ - int8_t *log_level_ptr; /**< pointer to the log level */ - int8_t *trace_status_ptr; /**< pointer to the trace status */ - uint8_t mcnt; /**< message counter */ + char contextID[DLT_ID_SIZE]; /**< context id */ + int32_t log_level_pos; /**< offset in user-application context field */ + int8_t *log_level_ptr; /**< pointer to the log level */ + int8_t *trace_status_ptr; /**< pointer to the trace status */ + uint8_t mcnt; /**< message counter */ } DltContext; /** @@ -582,7 +582,7 @@ int dlt_register_context(DltContext *handle, const char *contextid, const char * * @param loglevel This is the log level to be pre-set for this context (DLT_LOG_DEFAULT is not allowed here) * @param tracestatus This is the trace status to be pre-set for this context - (DLT_TRACE_STATUS_DEFAULT is not allowed here) + (DLT_TRACE_STATUS_DEFAULT is not allowed here) * @return negative value if there was an error */ int dlt_register_context_ll_ts(DltContext *handle, const char *contextid, const char * description, int loglevel, int tracestatus); -- cgit v1.2.1