]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/mem/Page.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / ipc / mem / Page.h
1 /*
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef SQUID_IPC_MEM_PAGE_H
10 #define SQUID_IPC_MEM_PAGE_H
11
12 #include <iosfwd>
13
14 namespace Ipc
15 {
16
17 namespace Mem
18 {
19
20 /// Shared memory page identifier, address, or handler
21 class PageId
22 {
23 public:
24 PageId(): pool(0), number(0), purpose(maxPurpose) {}
25
26 /// true if and only if both critical components have been initialized
27 bool set() const { return pool && number; }
28
29 // safer than bool which would enable silent casts to int
30 typedef const uint32_t PageId::*SaferBool;
31 operator SaferBool() const { return set() ? &PageId::number : NULL; }
32
33 uint32_t pool; ///< page pool ID within Squid
34 // uint32_t segment; ///< memory segment ID within the pool; unused for now
35 uint32_t number; ///< page number within the segment
36
37 enum Purpose { cachePage, ioPage, maxPurpose };
38 Purpose purpose; ///< page purpose
39 };
40
41 /// writes page address (e.g., "sh_page5.3"), for debugging
42 std::ostream &operator <<(std::ostream &os, const PageId &page);
43
44 } // namespace Mem
45
46 } // namespace Ipc
47
48 #endif // SQUID_IPC_MEM_PAGE_H
49