MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

Page.hxx
Go to the documentation of this file.
1 /*
2 * Copyright 2003-2017 The Music Player Daemon Project
3 * http://www.musicpd.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
25 #ifndef MPD_PAGE_HXX
26 #define MPD_PAGE_HXX
27
28 #include "util/RefCount.hxx"
29
30 #include <stddef.h>
31
37 class Page {
44 RefCount ref;
45
46 public:
50 const size_t size;
51
55 unsigned char data[sizeof(long)];
56
57 protected:
58 Page(size_t _size):size(_size) {}
59 ~Page() = default;
60
65 static Page *Create(size_t size);
66
67 public:
76 static Page *Copy(const void *data, size_t size);
77
84 static Page *Concat(const Page &a, const Page &b);
85
89 void Ref() {
90 ref.Increment();
91 }
92
99 bool Unref();
100 };
101
102 #endif
RefCount::Increment
void Increment()
Definition: RefCount.hxx:52
Page::Page
Page(size_t _size)
Definition: Page.hxx:58
Page::data
unsigned char data[sizeof(long)]
Dynamic array containing the buffer data.
Definition: Page.hxx:55
Page::Copy
static Page * Copy(const void *data, size_t size)
Creates a new #page object, and copies data from the specified buffer.
RefCount.hxx
A very simple reference counting library.
Page::~Page
~Page()=default
Page::Unref
bool Unref()
Decreases the reference counter.
Page::Ref
void Ref()
Increases the reference counter.
Definition: Page.hxx:89
RefCount
Definition: RefCount.hxx:41
Page::Create
static Page * Create(size_t size)
Allocates a new Page object, without filling the data element.
Page::size
const size_t size
The size of this buffer in bytes.
Definition: Page.hxx:50
Page::Concat
static Page * Concat(const Page &a, const Page &b)
Concatenates two pages to a new page.
Page
A dynamically allocated buffer which keeps track of its reference count.
Definition: Page.hxx:37