GATE
wrappers.h File Reference

Native data object wrapper interface. More...

#include "gate/gate_core_api.h"
#include "gate/objects.h"
#include "gate/memalloc.h"

Classes

struct  gate_wrapper_type_info_class
 Carries data about a wrapped data type. More...
 

Macros

#define GATE_INTERFACE_NAME_WRAPPER   GATE_INTERFACE_NAME_MEMORYBLOCK GATE_INTERFACE_NAME_SEPARATOR "wrapper"
 
#define gate_wrapper_get_size   gate_memoryblock_get_size
 
#define gate_wrapper_get_content   gate_memoryblock_get_content
 
#define gate_wrapper_get_type(obj)   ((gate_wrapper_t*)(obj))->vtbl->get_type((obj))
 See gate_wrapper_t::get_type.
 
#define gate_wrapper_is_type(obj, cmp_with)   ((gate_wrapper_t*)(obj))->vtbl->is_type((obj), (cmp_with))
 See gate_wrapper_t::is_type.
 
#define GATE_INTERFACE_NAME_VARIANT   GATE_INTERFACE_NAME_WRAPPER GATE_INTERFACE_NAME_SEPARATOR "variant"
 
#define gate_variant_get_size   gate_wrapper_get_size
 
#define gate_variant_get_content   gate_wrapper_get_content
 
#define gate_variant_get_type   gate_wrapper_get_type
 
#define gate_variant_is_type   gate_wrapper_is_type
 
#define gate_variant_set_content(obj, content, size, type)   (obj)->vtbl->set_content((obj), (content), (size), (type))
 

Typedefs

typedef struct gate_wrapper_type_info_class gate_wrapper_type_info_t
 Carries data about a wrapped data type.
 

Functions

 GATE_INTERFACE (gate_wrapper)
 
GATE_CORE_API gate_wrapper_tgate_wrapper_create_new (gate_size_t obj_size, void const *type, gate_mem_dtor_t dtor)
 creates a wrapper for a new allocated raw memory block
 
GATE_CORE_API gate_wrapper_tgate_wrapper_create (void *obj, gate_size_t obj_size, void const *type, gate_mem_dtor_t dtor_obj, gate_mem_dtor_t dtor_mem)
 creates a wrapper to a native pointer and type information
 
GATE_CORE_API gate_wrapper_tgate_wrapper_create_type (gate_wrapper_type_info_t const *type_info, void const *src)
 creates a wrapper for a new allocated copy of a given data type instance
 
 GATE_INTERFACE (gate_variant)
 
GATE_CORE_API gate_variant_tgate_variant_create (gate_wrapper_type_info_t const *ptr_types, gate_size_t types_count)
 creates a variant of different defined types
 

Detailed Description

Native data object wrapper interface.

Puts native data in a gate-object interface including native type information. Can be used to pack and unpack C and C++ constructs to move them between GATE components without directly touching the content or raw pointers.

Function Documentation

◆ gate_variant_create()

GATE_CORE_API gate_variant_t * gate_variant_create ( gate_wrapper_type_info_t const * ptr_types,
gate_size_t types_count )

creates a variant of different defined types

A "variant" can store on instance of a set of defined types

Parameters
[in]ptr_typespointer to first item in array of type-infos
[in]types_countamount of type-info items in array
Returns
pointer variant object interface (ref-count==1)

◆ gate_wrapper_create()

GATE_CORE_API gate_wrapper_t * gate_wrapper_create ( void * obj,
gate_size_t obj_size,
void const * type,
gate_mem_dtor_t dtor_obj,
gate_mem_dtor_t dtor_mem )

creates a wrapper to a native pointer and type information

Parameters
[in]objpointer to object to be embedded
[in]obj_sizesize of object type in bytes
[in]typepointer to native type information (e.g. C++ std::type_info)
[in]dtor_objpointer to object data destructor function (e.g. C++ destructor)
[in]dtor_mempointer to object memory release function (e.g. free() )
Returns
pointer to reference counted wrapper object interface (count==1)

◆ gate_wrapper_create_new()

GATE_CORE_API gate_wrapper_t * gate_wrapper_create_new ( gate_size_t obj_size,
void const * type,
gate_mem_dtor_t dtor )

creates a wrapper for a new allocated raw memory block

Parameters
[in]obj_sizesize of data block for object type in bytes
[in]typepointer to native type information (e.g. C++ std::type_info)
[in]dtorpointer to destructor function
Returns
pointer to reference counted wrapper object interface (count==1)

◆ gate_wrapper_create_type()

GATE_CORE_API gate_wrapper_t * gate_wrapper_create_type ( gate_wrapper_type_info_t const * type_info,
void const * src )

creates a wrapper for a new allocated copy of a given data type instance

Parameters
[in]type_infopointer to type info descriptor
[in]srcpointer to source instance to be copied into the new wrapped content
Returns
pointer to reference counted wrapper object interface (count==1)