Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
aligned_storage.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2022 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/aligned_storage.h
10
//! @brief Aligned storage.
11
12
#ifndef ROC_CORE_ALIGNED_STORAGE_H_
13
#define ROC_CORE_ALIGNED_STORAGE_H_
14
15
#include "
roc_core/align_ops.h
"
16
#include "
roc_core/stddefs.h
"
17
18
namespace
roc
{
19
namespace
core {
20
21
//! Fixed-size maximum-aligned storage.
22
template
<
size_t
Size>
class
AlignedStorage
{
23
public
:
24
//! Get storage size.
25
static
size_t
size
() {
26
return
sizeof
(Memory);
27
}
28
29
//! Get storage memory.
30
const
void
*
memory
()
const
{
31
return
memory_.payload;
32
}
33
34
//! Get storage memory.
35
void
*
memory
() {
36
return
memory_.payload;
37
}
38
39
private
:
40
union
Memory {
41
AlignMax
alignment;
42
char
payload[Size != 0 ? Size : 1];
43
};
44
45
Memory memory_;
46
};
47
48
}
// namespace core
49
}
// namespace roc
50
51
#endif
// ROC_CORE_ALIGNED_STORAGE_H_
align_ops.h
Alignment operations.
roc::core::AlignedStorage
Fixed-size maximum-aligned storage.
Definition:
aligned_storage.h:22
roc::core::AlignedStorage::memory
const void * memory() const
Get storage memory.
Definition:
aligned_storage.h:30
roc::core::AlignedStorage::memory
void * memory()
Get storage memory.
Definition:
aligned_storage.h:35
roc::core::AlignedStorage::size
static size_t size()
Get storage size.
Definition:
aligned_storage.h:25
roc
Root namespace.
stddefs.h
Commonly used types and functions.
roc::core::AlignMax
Maximum aligned data unit.
Definition:
align_ops.h:21
roc_core
aligned_storage.h
Generated by
1.9.1