NAP
udpadapter.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Nap includes
8 #include <nap/device.h>
9 #include <nap/resource.h>
10 #include <nap/resourceptr.h>
11 
12 // STD includes
13 #include <system_error>
14 
15 // local includes
16 #include "udpthread.h"
17 
18 namespace nap
19 {
25  class NAPAPI UDPAdapter : public Device
26  {
27  friend class UDPThread;
28 
29  RTTI_ENABLE(Device)
30  public:
34  UDPAdapter();
35 
39  virtual ~UDPAdapter();
40 
46  virtual bool init(utility::ErrorState& errorState) override final;
47 
51  virtual void onDestroy() override final;
52 
61  virtual bool start(utility::ErrorState& errorState) override final;
62 
68  virtual void stop() override final;
69 
70  // Properties
72  bool mAllowFailure = false;
73  protected:
79  virtual bool onStart(utility::ErrorState& errorState) = 0;
80 
84  virtual void onStop() = 0;
85 
89  virtual void onProcess() = 0;
90 
91  void process();
92 
93  bool handleAsioError(const std::error_code& errorCode, utility::ErrorState& errorState, bool& success);
94 
95  asio::io_context& getIOContext();
96  };
97 }
nap::UDPThread
Definition: udpthread.h:51
nap::rtti::ObjectPtr
Definition: objectptr.h:154
nap::utility::ErrorState
Definition: errorstate.h:19
nap::UDPAdapter
Definition: udpadapter.h:25
nap
Definition: templateapp.h:17
asio
Definition: udpthread.h:19
nap::Device
Definition: device.h:20