Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
list_node.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 Roc Streaming 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_core/list_node.h
10
//! @brief Linked list node.
11
12
#ifndef ROC_CORE_LIST_NODE_H_
13
#define ROC_CORE_LIST_NODE_H_
14
15
#include "
roc_core/macro_helpers.h
"
16
#include "
roc_core/noncopyable.h
"
17
#include "
roc_core/panic.h
"
18
#include "
roc_core/stddefs.h
"
19
20
namespace
roc
{
21
namespace
core
{
22
23
//! List node internal data.
24
struct
ListData {
25
//! Previous list element.
26
ListData*
prev
;
27
28
//! Next list element.
29
ListData*
next
;
30
31
//! The list this node is member of.
32
//! @remarks
33
//! NULL if node is not member of any list.
34
void
*
list
;
35
36
ListData()
37
:
prev
(NULL)
38
,
next
(NULL)
39
,
list
(NULL) {
40
}
41
};
42
43
//! Base class for List element.
44
//! @remarks
45
//! Object should inherit this class to be able to be a member of List.
46
//! Tag allows to inherit multiple copies of ListNode and include same
47
//! object into multiple lists.
48
template
<
class
Tag =
void
>
class
ListNode
:
public
NonCopyable<ListNode<Tag> > {
49
public
:
50
~ListNode
() {
51
if
(list_data_.list != NULL) {
52
roc_panic
(
"list node: attempt to destroy node while it's still in queue"
);
53
}
54
}
55
56
//! Get pointer to parent node from pointer to internal data.
57
static
ListNode
*
list_node
(
ListData
* data) {
58
return
ROC_CONTAINER_OF
(data,
ListNode
, list_data_);
59
}
60
61
//! Get pointer to internal data.
62
ListData
*
list_data
()
const
{
63
return
&list_data_;
64
}
65
66
private
:
67
mutable
ListData
list_data_;
68
};
69
70
}
// namespace core
71
}
// namespace roc
72
73
#endif
// ROC_CORE_LIST_NODE_H_
roc::core::ListNode
Base class for List element.
Definition
list_node.h:48
roc::core::ListNode::list_node
static ListNode * list_node(ListData *data)
Get pointer to parent node from pointer to internal data.
Definition
list_node.h:57
roc::core::ListNode::list_data
ListData * list_data() const
Get pointer to internal data.
Definition
list_node.h:62
macro_helpers.h
Helper macros.
ROC_CONTAINER_OF
#define ROC_CONTAINER_OF(ptr, type, member)
Cast a member of a structure out to the containing structure.
Definition
macro_helpers.h:37
roc::core
General-purpose building blocks and platform abstraction layer.
roc
Root namespace.
noncopyable.h
Non-copyable object.
panic.h
Panic.
roc_panic
#define roc_panic(...)
Print error message and terminate program gracefully.
Definition
panic.h:50
stddefs.h
Commonly used types and functions.
roc::core::ListData
List node internal data.
Definition
list_node.h:24
roc::core::ListData::next
ListData * next
Next list element.
Definition
list_node.h:29
roc::core::ListData::list
void * list
The list this node is member of.
Definition
list_node.h:34
roc::core::ListData::prev
ListData * prev
Previous list element.
Definition
list_node.h:26
roc_core
list_node.h
Generated by
1.17.0