MCPcopy Create free account
hub / github.com/COVESA/vsomeip / init

Method init

examples/subscribe-sample.cpp:27–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 client_sample(bool _use_tcp) : app_(vsomeip::runtime::get()->create_application()), use_tcp_(_use_tcp) { }
26
27 bool init() {
28 if (!app_->init()) {
29 std::cerr << "Couldn't initialize application" << std::endl;
30 return false;
31 }
32 std::cout << "Client settings [protocol=" << (use_tcp_ ? "TCP" : "UDP") << "]" << std::endl;
33
34 app_->register_state_handler(std::bind(&client_sample::on_state, this, std::placeholders::_1));
35
36 app_->register_message_handler(vsomeip::ANY_SERVICE, SAMPLE_INSTANCE_ID, vsomeip::ANY_METHOD,
37 std::bind(&client_sample::on_message, this, std::placeholders::_1));
38
39 app_->register_availability_handler(
40 SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID,
41 std::bind(&client_sample::on_availability, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
42
43 std::set<vsomeip::eventgroup_t> its_groups;
44 its_groups.insert(SAMPLE_EVENTGROUP_ID);
45 app_->request_event(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, SAMPLE_EVENT_ID, its_groups, vsomeip::event_type_e::ET_FIELD);
46 app_->subscribe(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, SAMPLE_EVENTGROUP_ID);
47
48 return true;
49 }
50
51 void start() { app_->start(); }
52

Callers 1

mainFunction · 0.45

Calls 6

insertMethod · 0.80
request_eventMethod · 0.80
subscribeMethod · 0.45

Tested by

no test coverage detected