Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
basic_port.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Roc authors
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 
9 //! @file roc_netio/target_libuv/roc_netio/basic_port.h
10 //! @brief Basic network port.
11 
12 #ifndef ROC_NETIO_BASIC_PORT_H_
13 #define ROC_NETIO_BASIC_PORT_H_
14 
15 #include "roc_core/iallocator.h"
16 #include "roc_core/list_node.h"
17 #include "roc_core/refcnt.h"
18 #include "roc_packet/address.h"
19 
20 namespace roc {
21 namespace netio {
22 
23 //! Basic port interface.
24 class BasicPort : public core::RefCnt<BasicPort>, public core::ListNode {
25 public:
26  //! Initialize.
27  explicit BasicPort(core::IAllocator&);
28 
29  //! Destroy.
30  virtual ~BasicPort();
31 
32  //! Get bind address.
33  virtual const packet::Address& address() const = 0;
34 
35  //! Open port.
36  //!
37  //! @remarks
38  //! Should be called from the event loop thread.
39  virtual bool open() = 0;
40 
41  //! Asynchronous close.
42  //!
43  //! @remarks
44  //! Should be called from the event loop thread.
45  virtual void async_close() = 0;
46 
47 private:
48  friend class core::RefCnt<BasicPort>;
49 
50  void destroy();
51 
52  core::IAllocator& allocator_;
53 };
54 
55 } // namespace netio
56 } // namespace roc
57 
58 #endif // ROC_NETIO_BASIC_PORT_H_
Memory allocator interface.
Definition: iallocator.h:23
virtual ~BasicPort()
Destroy.
Base class for list element.
Definition: list_node.h:26
Root namespace.
Linked list node.
Basic port interface.
Definition: basic_port.h:24
Network address.
Definition: address.h:24
Network address.
virtual const packet::Address & address() const =0
Get bind address.
BasicPort(core::IAllocator &)
Initialize.
Base class for reference countable objects.
Definition: refcnt.h:25
Base class for reference countable objects.
Memory allocator interface.
virtual bool open()=0
Open port.
virtual void async_close()=0
Asynchronous close.