1POBJ_LAYOUT_BEGIN(3) PMDK Programmer's Manual POBJ_LAYOUT_BEGIN(3)
2
3
4
6 POBJ_LAYOUT_BEGIN(), POBJ_LAYOUT_TOID(), POBJ_LAYOUT_ROOT(), POBJ_LAY‐
7 OUT_NAME(), POBJ_LAYOUT_END(), POBJ_LAYOUT_TYPES_NUM() - persistent
8 memory transactional object store layout
9
11 #include <libpmemobj.h>
12
13 POBJ_LAYOUT_BEGIN(layout)
14 POBJ_LAYOUT_TOID(layout, TYPE)
15 POBJ_LAYOUT_ROOT(layout, ROOT_TYPE)
16 POBJ_LAYOUT_NAME(layout)
17 POBJ_LAYOUT_END(layout)
18 POBJ_LAYOUT_TYPES_NUM(layout)
19
21 libpmemobj(7) defines a set of macros for convenient declaration of a
22 pool's layout. The layout declaration consists of declarations of a
23 number of used types. The declared types will be assigned consecutive
24 type numbers. Declared types may be used in conjunction with type
25 safety macros (see TOID_DECLARE(3)). Once created, the layout declara‐
26 tion must not be changed unless any new types are added at the end of
27 the existing layout declaration. Modifying any existing declaration
28 may lead to changes in the type numbers of declared types, which in
29 consequence may cause data corruption.
30
31 The POBJ_LAYOUT_BEGIN() macro indicates a begin of declaration of lay‐
32 out. The LAYOUT argument is a name of layout. This argument must be
33 passed to all macros related to the declaration of layout.
34
35 The POBJ_LAYOUT_TOID() macro declares a typed OID for type passed as
36 TYPE argument inside the declaration of layout. All types declared us‐
37 ing this macro are assigned with consecutive type numbers. This macro
38 must be used between the POBJ_LAYOUT_BEGIN() and POBJ_LAYOUT_END()
39 macros, with the same name passed as LAYOUT argument.
40
41 The POBJ_LAYOUT_ROOT() macro declares a typed OID for type passed as
42 ROOT_TYPE argument inside the declaration of layout. The typed OID
43 will be assigned with type number for root object POBJ_ROOT_TYPE_NUM.
44
45 The POBJ_LAYOUT_END() macro ends the declaration of layout.
46
47 The POBJ_LAYOUT_NAME() macro returns the name of layout as a null-ter‐
48 minated string.
49
50 The POBJ_LAYOUT_TYPES_NUM() macro returns number of types declared us‐
51 ing the POBJ_LAYOUT_TOID() macro within the layout declaration.
52
54 This is an example of layout declaration:
55
56 POBJ_LAYOUT_BEGIN(mylayout);
57 POBJ_LAYOUT_ROOT(mylayout, struct root);
58 POBJ_LAYOUT_TOID(mylayout, struct node);
59 POBJ_LAYOUT_TOID(mylayout, struct foo);
60 POBJ_LAYOUT_END(mylayout);
61
62 struct root
63 {
64 TOID(struct node) node;
65 };
66
67 struct node
68 {
69 TOID(struct node) next;
70 TOID(struct foo) foo;
71 };
72
73 The name of layout and the number of declared types can be retrieved
74 using the following code:
75
76 const char *layout_name = POBJ_LAYOUT_NAME(mylayout);
77 int num_of_types = POBJ_LAYOUT_TYPES_NUM(mylayout);
78
80 TOID_DECLARE(3), libpmemobj(7) and <http://pmem.io>
81
82
83
84PMDK - pmemobj API version 2.3 2019-03-01 POBJ_LAYOUT_BEGIN(3)