.\" Automatically generated by Pandoc 2.9.2.1 .\" .TH "" "" "2023-05-31" "PMDK - " "PMDK Programmer's Manual" .hy .\" SPDX-License-Identifier: BSD-3-Clause .\" Copyright 2017-2018, Intel Corporation .SH NAME .PP \f[B]POBJ_LAYOUT_BEGIN\f[R](), \f[B]POBJ_LAYOUT_TOID\f[R](), \f[B]POBJ_LAYOUT_ROOT\f[R](), \f[B]POBJ_LAYOUT_NAME\f[R](), \f[B]POBJ_LAYOUT_END\f[R](), \f[B]POBJ_LAYOUT_TYPES_NUM\f[R]() - persistent memory transactional object store layout .SH SYNOPSIS .IP .nf \f[C] #include POBJ_LAYOUT_BEGIN(layout) POBJ_LAYOUT_TOID(layout, TYPE) POBJ_LAYOUT_ROOT(layout, ROOT_TYPE) POBJ_LAYOUT_NAME(layout) POBJ_LAYOUT_END(layout) POBJ_LAYOUT_TYPES_NUM(layout) \f[R] .fi .SH DESCRIPTION .PP \f[B]libpmemobj\f[R](7) defines a set of macros for convenient declaration of a pool\[cq]s layout. The layout declaration consists of declarations of a number of used types. The declared types will be assigned consecutive type numbers. Declared types may be used in conjunction with type safety macros (see \f[B]TOID_DECLARE\f[R](3)). Once created, the layout declaration must not be changed unless any new types are added at the end of the existing layout declaration. Modifying any existing declaration may lead to changes in the type numbers of declared types, which in consequence may cause data corruption. .PP The \f[B]POBJ_LAYOUT_BEGIN\f[R]() macro indicates a begin of declaration of layout. The \f[I]LAYOUT\f[R] argument is a name of layout. This argument must be passed to all macros related to the declaration of layout. .PP The \f[B]POBJ_LAYOUT_TOID\f[R]() macro declares a typed \f[I]OID\f[R] for type passed as \f[I]TYPE\f[R] argument inside the declaration of layout. All types declared using this macro are assigned with consecutive type numbers. This macro must be used between the \f[B]POBJ_LAYOUT_BEGIN\f[R]() and \f[B]POBJ_LAYOUT_END\f[R]() macros, with the same name passed as \f[I]LAYOUT\f[R] argument. .PP The \f[B]POBJ_LAYOUT_ROOT\f[R]() macro declares a typed \f[I]OID\f[R] for type passed as \f[I]ROOT_TYPE\f[R] argument inside the declaration of layout. The typed \f[I]OID\f[R] will be assigned with type number for root object \f[B]POBJ_ROOT_TYPE_NUM\f[R]. .PP The \f[B]POBJ_LAYOUT_END\f[R]() macro ends the declaration of layout. .PP The \f[B]POBJ_LAYOUT_NAME\f[R]() macro returns the name of layout as a null-terminated string. .PP The \f[B]POBJ_LAYOUT_TYPES_NUM\f[R]() macro returns number of types declared using the \f[B]POBJ_LAYOUT_TOID\f[R]() macro within the layout declaration. .SH EXAMPLE .PP This is an example of layout declaration: .IP .nf \f[C] POBJ_LAYOUT_BEGIN(mylayout); POBJ_LAYOUT_ROOT(mylayout, struct root); POBJ_LAYOUT_TOID(mylayout, struct node); POBJ_LAYOUT_TOID(mylayout, struct foo); POBJ_LAYOUT_END(mylayout); struct root { TOID(struct node) node; }; struct node { TOID(struct node) next; TOID(struct foo) foo; }; \f[R] .fi .PP The name of layout and the number of declared types can be retrieved using the following code: .IP .nf \f[C] const char *layout_name = POBJ_LAYOUT_NAME(mylayout); int num_of_types = POBJ_LAYOUT_TYPES_NUM(mylayout); \f[R] .fi .SH SEE ALSO .PP \f[B]TOID_DECLARE\f[R](3), \f[B]libpmemobj\f[R](7) and \f[B]\f[R]