diff options
Diffstat (limited to 'implementation/utility/include/utility.hpp')
-rw-r--r-- | implementation/utility/include/utility.hpp | 102 |
1 files changed, 55 insertions, 47 deletions
diff --git a/implementation/utility/include/utility.hpp b/implementation/utility/include/utility.hpp index 186c1ad..000ca9b 100644 --- a/implementation/utility/include/utility.hpp +++ b/implementation/utility/include/utility.hpp @@ -1,5 +1,4 @@ -// Copyright (C) 2014 BMW Group -// Author: Lutz Bichler (lutz.bichler@bmw.de) +// Copyright (C) 2014-2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) // 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/. @@ -16,51 +15,60 @@ namespace vsomeip { class utility { - public: - static void * load_library(const std::string &_path, - const std::string &_symbol); - - static inline bool is_request(std::shared_ptr<message> _message) { - return (_message ? is_request(_message->get_message_type()) : false); - } - - static inline bool is_request(byte_t _type) { - return (is_request(static_cast<message_type_e>(_type))); - } - - static inline bool is_request(message_type_e _type) { - return ((_type < message_type_e::NOTIFICATION) - || (_type >= message_type_e::REQUEST_ACK - && _type <= message_type_e::REQUEST_NO_RETURN_ACK)); - } - - static inline bool is_request_no_return(std::shared_ptr<message> _message) { - return (_message && is_request_no_return(_message->get_message_type())); - } - - static inline bool is_request_no_return(byte_t _type) { - return (is_request_no_return(static_cast<message_type_e>(_type))); - } - - static inline bool is_request_no_return(message_type_e _type) { - return (_type == message_type_e::REQUEST_NO_RETURN - || _type == message_type_e::REQUEST_NO_RETURN_ACK); - } - - static inline bool is_event(byte_t _data) { - return (0 == (0x80 & _data)); - } - - static bool is_notification(const byte_t *_data); - - static uint32_t get_message_size(const byte_t *_data, uint32_t _size); - static inline uint32_t get_message_size(std::vector<byte_t> &_data) { - return (get_message_size(&_data[0], _data.size())); - } - - static uint32_t get_payload_size(const byte_t *_data, uint32_t _size); - - static bool exists(const std::string &_path); +public: + static void * load_library(const std::string &_path, + const std::string &_symbol); + + static inline bool is_request(std::shared_ptr<message> _message) { + return (_message ? is_request(_message->get_message_type()) : false); + } + + static inline bool is_request(byte_t _type) { + return (is_request(static_cast<message_type_e>(_type))); + } + + static inline bool is_request(message_type_e _type) { + return ((_type < message_type_e::MT_NOTIFICATION) + || (_type >= message_type_e::MT_REQUEST_ACK + && _type <= message_type_e::MT_REQUEST_NO_RETURN_ACK)); + } + + static inline bool is_request_no_return(std::shared_ptr<message> _message) { + return (_message && is_request_no_return(_message->get_message_type())); + } + + static inline bool is_request_no_return(byte_t _type) { + return (is_request_no_return(static_cast<message_type_e>(_type))); + } + + static inline bool is_request_no_return(message_type_e _type) { + return (_type == message_type_e::MT_REQUEST_NO_RETURN + || _type == message_type_e::MT_REQUEST_NO_RETURN_ACK); + } + + static inline bool is_event(byte_t _data) { + return (0x80 & _data); + } + + static inline bool is_notification(byte_t _type) { + return (is_notification(static_cast<message_type_e>(_type))); + } + + static inline bool is_notification(message_type_e _type) { + return (_type == message_type_e::MT_NOTIFICATION); + } + + static uint32_t get_message_size(const byte_t *_data, uint32_t _size); + static inline uint32_t get_message_size(std::vector<byte_t> &_data) { + if (_data.size() > 0) { + return (get_message_size(&_data[0], _data.size())); + } + return 0; + } + + static uint32_t get_payload_size(const byte_t *_data, uint32_t _size); + + static bool exists(const std::string &_path); }; } // namespace vsomeip |