summaryrefslogtreecommitdiff
path: root/implementation/routing/include/event.hpp
blob: a251d2c96ed90330d2a5ac9291ed3311b739c5c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright (C) 2014 BMW Group
// Author: Lutz Bichler (lutz.bichler@bmw.de)
// 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/.

#ifndef VSOMEIP_EVENT_IMPL_HPP
#define VSOMEIP_EVENT_IMPL_HPP

#include <map>
#include <memory>
#include <mutex>
#include <set>

#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/address.hpp>
#include <boost/asio/system_timer.hpp>

#include <vsomeip/primitive_types.hpp>

namespace vsomeip {

class endpoint;
class endpoint_definition;
class message;
class payload;
class routing_manager;

class event : public std::enable_shared_from_this<event> {
 public:
  event(routing_manager *_routing);

  service_t get_service() const;
  void set_service(service_t _service);

  instance_t get_instance() const;
  void set_instance(instance_t _instance);

  event_t get_event() const;
  void set_event(event_t _event);

  const std::shared_ptr<payload> get_payload() const;
  void set_payload(std::shared_ptr<payload> _payload);

  bool is_field() const;
  void set_field(bool _is_field);

  bool is_reliable() const;
  void set_reliable(bool _is_reliable);

  // SIP_RPC_357
  void set_update_cycle(std::chrono::milliseconds &_cycle);

  // SIP_RPC_358
  void set_update_on_change(bool _is_on);

  // SIP_RPC_359 (epsilon change) is not supported!


  const std::set<eventgroup_t> & get_eventgroups() const;
  void add_eventgroup(eventgroup_t _eventgroup);
  void set_eventgroups(const std::set<eventgroup_t> &_eventgroups);

  void notify_one(const std::shared_ptr<endpoint_definition> &_target);

 private:
  void update_cbk(boost::system::error_code const &_error);
  void notify();

 private:
  routing_manager *routing_;
  std::mutex mutex_;
  std::shared_ptr<message> message_;

  bool is_field_;
  bool is_reliable_;

  boost::asio::system_timer cycle_timer_;
  std::chrono::milliseconds cycle_;

  bool is_updating_on_change_;

  std::set<eventgroup_t> eventgroups_;
};

}  // namespace vsomeip

#endif // VSOMEIP_EVENT_IMPL_HPP