Implements typeadapt_t lifetime services which can be used for simple types.
1. | Include “C-kern/api/ds/typeadapt.h” |
Typeadapt-Implementation | Implements typeadapt_t lifetime services which can be used for simple types. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file Typeadapt-Implementation. |
C-kern/ | Implementation file Typeadapt-Implementation impl. |
Types | |
struct typeadapt_impl_t | Export typeadapt_impl_t into global namespace. |
Functions | |
test | |
unittest_ds_typeadapt_typeadaptimpl | Test typeadapt_impl_t functionality. |
typeadapt_impl_t | Default implementation of typeadapt_t. |
objectsize | The size of supported structure. |
lifetime | |
typeadapt_impl_FREE | Static initializer. |
typeadapt_impl_INIT | Static initializer. |
init_typeadaptimpl | Initializes implementation to support objectes of size objectsize. |
free_typeadaptimpl | Sets all fields to 0. |
lifetime-service-implementation | |
lifetime_newcopyobj_typeadaptimpl | Implements typeadapt_lifetime_it.newcopy_object. |
lifetime_deleteobj_typeadaptimpl | Implements typeadapt_lifetime_it.delete_object. |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
© 2012 Jörg Seebohn
Header file Typeadapt-Implementation.
Implementation file Typeadapt-Implementation impl.
typedef struct typeadapt_impl_t typeadapt_impl_t
Export typeadapt_impl_t into global namespace.
test | |
unittest_ds_typeadapt_typeadaptimpl | Test typeadapt_impl_t functionality. |
int unittest_ds_typeadapt_typeadaptimpl( void )
Test typeadapt_impl_t functionality.
struct typeadapt_impl_t
Default implementation of typeadapt_t.
1. This implementation assumes that objects can be copied with a simple call to memcpy and no special deep copy semantic is needed. 2. The second one is that objects always have the same size.
Both assumptions are too simple for supporting complex object types. But for complex objects it is considered OK to implement their own typeadapt_t*.
objectsize | The size of supported structure. |
lifetime | |
typeadapt_impl_FREE | Static initializer. |
typeadapt_impl_INIT | Static initializer. |
init_typeadaptimpl | Initializes implementation to support objectes of size objectsize. |
free_typeadaptimpl | Sets all fields to 0. |
lifetime-service-implementation | |
lifetime_newcopyobj_typeadaptimpl | Implements typeadapt_lifetime_it.newcopy_object. |
lifetime_deleteobj_typeadaptimpl | Implements typeadapt_lifetime_it.delete_object. |
int lifetime_newcopyobj_typeadaptimpl( typeadapt_impl_t * typeadp, /*out*/struct typeadapt_object_t ** destobject, const struct typeadapt_object_t * srcobject )
Implements typeadapt_lifetime_it.newcopy_object.
int lifetime_deleteobj_typeadaptimpl( typeadapt_impl_t * typeadp, struct typeadapt_object_t ** object )
Implements typeadapt_lifetime_it.delete_object.
Export typeadapt_impl_t into global namespace.
typedef struct typeadapt_impl_t typeadapt_impl_t
Default implementation of typeadapt_t.
struct typeadapt_impl_t
Test typeadapt_impl_t functionality.
int unittest_ds_typeadapt_typeadaptimpl( void )
The size of supported structure.
size_t objectsize
Static initializer.
#define typeadapt_impl_FREE { typeadapt_FREE, 0 }
Static initializer.
#define typeadapt_impl_INIT( objectsize ) { typeadapt_INIT_LIFETIME(&lifetime_newcopyobj_typeadaptimpl, &lifetime_deleteobj_typeadaptimpl), objectsize }
Initializes implementation to support objectes of size objectsize.
int init_typeadaptimpl( /*out*/typeadapt_impl_t * typeadp, size_t objectsize )
Sets all fields to 0.
int free_typeadaptimpl( typeadapt_impl_t * typeadp )
Implements typeadapt_lifetime_it.newcopy_object.
int lifetime_newcopyobj_typeadaptimpl( typeadapt_impl_t * typeadp, /*out*/struct typeadapt_object_t ** destobject, const struct typeadapt_object_t * srcobject )
Function copies an object.
int ( * newcopy_object ) (struct typeadapt_t * typeadp, /*out*/struct typeadapt_object_t ** destobject, const struct typeadapt_object_t * srcobject)
Implements typeadapt_lifetime_it.delete_object.
int lifetime_deleteobj_typeadaptimpl( typeadapt_impl_t * typeadp, struct typeadapt_object_t ** object )
Function frees memory and associated resources of object.
int ( * delete_object ) (struct typeadapt_t * typeadp, struct typeadapt_object_t ** object)