summaryrefslogtreecommitdiff
path: root/test/internal_routing_disabled_acceptance_test/applet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/internal_routing_disabled_acceptance_test/applet.cpp')
-rw-r--r--test/internal_routing_disabled_acceptance_test/applet.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/internal_routing_disabled_acceptance_test/applet.cpp b/test/internal_routing_disabled_acceptance_test/applet.cpp
new file mode 100644
index 0000000..50bf41c
--- /dev/null
+++ b/test/internal_routing_disabled_acceptance_test/applet.cpp
@@ -0,0 +1,44 @@
+#include "applet.hpp"
+
+#include <stdexcept>
+#include <string>
+
+#include <vsomeip/enumeration_types.hpp>
+#include <vsomeip/runtime.hpp>
+
+applet::applet(std::string_view name) : application{vsomeip_v3::runtime::get()->create_application(std::string{name})}
+{
+ if(!this->application->init())
+ {
+ using namespace std::string_literals;
+ throw std::runtime_error{__func__ + "(): vSomeIP application init failure"s};
+ }
+
+ this->async_start = std::async(
+ std::launch::async,
+ &vsomeip_v3::application::start,
+ this->application
+ );
+
+ this->application->register_state_handler(
+ [this](vsomeip_v3::state_type_e state){
+ switch(state)
+ {
+ case vsomeip_v3::state_type_e::ST_REGISTERED:
+ return this->on_state_registered();
+ case vsomeip_v3::state_type_e::ST_DEREGISTERED:
+ return this->on_state_deregistered();
+ }
+ }
+ );
+}
+
+applet::~applet()
+{
+ this->application->clear_all_handler();
+ this->application->stop();
+ this->async_start.wait();
+}
+
+void applet::on_state_registered() {}
+void applet::on_state_deregistered() {}