1 // Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) 2 // This Source Code Form is subject to the terms of the Mozilla Public 3 // License, v. 2.0. If a copy of the MPL was not distributed with this 4 // file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 6 #ifndef PAYLOADTESTSERVICE_HPP_ 7 #define PAYLOADTESTSERVICE_HPP_ 8 #include <gtest/gtest.h> 9 10 #include <vsomeip/vsomeip.hpp> 11 12 #include <thread> 13 #include <mutex> 14 #include <condition_variable> 15 #include <functional> 16 17 #include "../someip_test_globals.hpp" 18 19 class payload_test_service 20 { 21 public: 22 payload_test_service(); 23 bool init(); 24 void start(); 25 void stop(); 26 void offer(); 27 void stop_offer(); 28 void join_offer_thread(); 29 void on_state(vsomeip::state_type_e _state); 30 void on_message(const std::shared_ptr<vsomeip::message> &_request); 31 void on_message_shutdown(const std::shared_ptr<vsomeip::message> &_request); 32 void run(); 33 34 private: 35 std::shared_ptr<vsomeip::application> app_; 36 bool is_registered_; 37 38 std::mutex mutex_; 39 std::condition_variable condition_; 40 bool blocked_; 41 std::uint32_t number_of_received_messages_; 42 std::thread offer_thread_; 43 }; 44 45 #endif /* PAYLOADTESTSERVICE_HPP_ */ 46