.\" Automatically generated by Pandoc 2.2.1 .\" .TH "POBJ_LAYOUT_BEGIN" "3" "2019-02-19" "PMDK - pmemobj API version 2.3" "PMDK Programmer's Manual" .hy .\" Copyright 2014-2019, Intel Corporation .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in .\" the documentation and/or other materials provided with the .\" distribution. .\" .\" * Neither the name of the copyright holder nor the names of its .\" contributors may be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .SH NAME .PP \f[B]POBJ_LAYOUT_BEGIN\f[](), \f[B]POBJ_LAYOUT_TOID\f[](), \f[B]POBJ_LAYOUT_ROOT\f[](), \f[B]POBJ_LAYOUT_NAME\f[](), \f[B]POBJ_LAYOUT_END\f[](), \f[B]POBJ_LAYOUT_TYPES_NUM\f[]() \- 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[] .fi .SH DESCRIPTION .PP \f[B]libpmemobj\f[](7) defines a set of macros for convenient declaration of a pool'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[](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[]() macro indicates a begin of declaration of layout. The \f[I]LAYOUT\f[] 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[]() macro declares a typed \f[I]OID\f[] for type passed as \f[I]TYPE\f[] 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[]() and \f[B]POBJ_LAYOUT_END\f[]() macros, with the same name passed as \f[I]LAYOUT\f[] argument. .PP The \f[B]POBJ_LAYOUT_ROOT\f[]() macro declares a typed \f[I]OID\f[] for type passed as \f[I]ROOT_TYPE\f[] argument inside the declaration of layout. The typed \f[I]OID\f[] will be assigned with type number for root object \f[B]POBJ_ROOT_TYPE_NUM\f[]. .PP The \f[B]POBJ_LAYOUT_END\f[]() macro ends the declaration of layout. .PP The \f[B]POBJ_LAYOUT_NAME\f[]() macro returns the name of layout as a null\-terminated string. .PP The \f[B]POBJ_LAYOUT_TYPES_NUM\f[]() macro returns number of types declared using the \f[B]POBJ_LAYOUT_TOID\f[]() 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[] .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[] .fi .SH SEE ALSO .PP \f[B]TOID_DECLARE\f[](3), \f[B]libpmemobj\f[](7) and \f[B]\f[]