Instances and serialization


Typedefs

typedef xf_instance_s xf_instance_t
 Instance Class.
typedef xf_buffer_s xf_buffer_t
 Buffer for serializing to memory.

Functions

xf_instance_txf_instance_new (void *pobj, xf_refl_t *prefl)
 Constructor.
void * xf_instance_cloneobj (xf_instance_t *pinst)
 object clone of instance
void * xf_instance_rcloneobj (xf_instance_t *pinst)
 recursive object clone of instance
int xf_instance_cpobj (void *ptarget, xf_instance_t *pinst)
 object copy of instance to memory area
int xf_instance_rcpobj (void *ptarget, xf_instance_t *pinst)
 recursive object copy of instance to memory
int xf_instance_free (xf_instance_t *pinst)
 Destructor.
int xf_instance_rfree (xf_instance_t *pinst)
 Destructor.
int xf_instance_obj_free (xf_instance_t *pinst)
 Destructor.
int xf_instance_obj_ofree (xf_instance_t *pinst)
 Destructor.
int xf_instance_obj_rfree (xf_instance_t *pinst)
 Destructor.
int xf_instance_obj_dfree (xf_instance_t *pinst)
 Destructor.
int xf_instance_obj_drfree (xf_instance_t *pinst)
 Destructor.
int xf_instance_setuserdata (xf_instance_t *pinst, void *userdata)
 set userdata
void * xf_instance_getuserdata (xf_instance_t *pinst)
 get userdata
xf_refl_txf_instance_getrefl (xf_instance_t *pinst)
 get reflection
void * xf_instance_getobj (xf_instance_t *pinst)
 get instance object
void * xf_instance_setobj (xf_instance_t *pinst, void *pobj)
 set instance obj
xf_buffer_txf_buffer_new (char *adr, int size)
 Constructor.
void xf_buffer_free (xf_buffer_t *pb)
 Destructor.
char * xf_buffer_getadr (xf_buffer_t *pb)
 return memory adress of buffer
int xf_buffer_reset (xf_buffer_t *pb)
 get length
int xf_instance_write (xf_instance_t *pinst, int fd, xf_buffer_t *pbuf, int openflag, int closeflag)
 serializes an object according to its reflection to stream or buffer

Typedef Documentation

typedef struct xf_buffer_s xf_buffer_t

Buffer for serializing to memory.

A buffer for serializing an instance to memory

typedef struct xf_instance_s xf_instance_t

Instance Class.

instance of an object consisting of object memory, some arbritrary userdata and class reflection


Function Documentation

void xf_buffer_free ( xf_buffer_t pb  ) 

Destructor.

frees the buffer object

Parameters:
pb handle to buffer object

char* xf_buffer_getadr ( xf_buffer_t pb  ) 

return memory adress of buffer

Parameters:
pb handle to buffer object
Returns:
  • the memory adress of buffer supplied in constructor

xf_buffer_t* xf_buffer_new ( char *  adr,
int  size 
)

Constructor.

Parameters:
adr pointer to memory for buffer size of memory buffer
Returns:
  • handle to buffer object
  • NULL: Error

int xf_buffer_reset ( xf_buffer_t pb  ) 

get length

get the length of used buffer object and resets it to zero for reuse

Parameters:
pb handle to buffer object
Returns:
  • the length of data in buffer

void* xf_instance_cloneobj ( xf_instance_t pinst  ) 

object clone of instance

clones an object and all resources due to reflection given by instance

See also:
Dealing with reflection (members which are instances itself, i.e. of type objcet are not cloned, just referenced,

xf_instance_rcloneobj() )

Parameters:
pinst Instance to clone
Returns:
  • pointer to allocated and cloned object

int xf_instance_cpobj ( void *  ptarget,
xf_instance_t pinst 
)

object copy of instance to memory area

copy an object given by instance to a memory region, references in the instance object are allocated and cloned on heap

See also:
Dealing with reflection
Parameters:
ptarget Memory where instance object is copied
pinst Instance to copy
Returns:
  • 0: OK
  • else: Error

int xf_instance_free ( xf_instance_t pinst  ) 

Destructor.

frees only memory of instance, not of object

Parameters:
pinst Instance to free
Returns:
  • 0: OK
  • else: Error

void* xf_instance_getobj ( xf_instance_t pinst  ) 

get instance object

Parameters:
pinst Instance to get Object from
Returns:
  • Object of instance
  • NULL: Error

xf_refl_t* xf_instance_getrefl ( xf_instance_t pinst  ) 

get reflection

Parameters:
pinst Instance to get the reflection from
Returns:
  • Reflection
  • NULL: Error

void* xf_instance_getuserdata ( xf_instance_t pinst  ) 

get userdata

Parameters:
pinst Instance to get Userdata from
Returns:
Userdata

xf_instance_t* xf_instance_new ( void *  pobj,
xf_refl_t prefl 
)

Constructor.

creates an instance of object pobj and its reflection

See also:
Dealing with reflection
Parameters:
pobj Object of instance
prefl Reflection of instantiated class
Returns:
  • Instance
  • NULL: Error

int xf_instance_obj_dfree ( xf_instance_t pinst  ) 

Destructor.

frees all resources depending on object according to its reflection but not the given instance or object itself

Parameters:
pinst Instance to free

int xf_instance_obj_drfree ( xf_instance_t pinst  ) 

Destructor.

frees all resources depending on object according to its reflection and recursively all depending object instances and their resources but not the given instance or object itself

Parameters:
pinst Instance to free

int xf_instance_obj_free ( xf_instance_t pinst  ) 

Destructor.

frees object and all object resources according to its reflection but not the instance itself

Parameters:
pinst Instance to free

int xf_instance_obj_ofree ( xf_instance_t pinst  ) 

Destructor.

frees object of instance without depending resources or instances

Parameters:
pinst Instance to free

int xf_instance_obj_rfree ( xf_instance_t pinst  ) 

Destructor.

frees object and all object resources according to its reflection and recursively all depending object instances and their resources but not the given instance itself

Parameters:
pinst Instance to free

void* xf_instance_rcloneobj ( xf_instance_t pinst  ) 

recursive object clone of instance

clones an object and all resources due to reflection and recursively all members which are instances itself, i.e. of type object given by instance

See also:
Dealing with reflection
Parameters:
pinst Instance to clone
Returns:
  • pointer to allocated and cloned object

int xf_instance_rcpobj ( void *  ptarget,
xf_instance_t pinst 
)

recursive object copy of instance to memory

copy an object given by instance to a memory region, references in the instance object are allocated and cloned on heap

See also:
Dealing with reflection, members which are instances itself, i.e. of type object will be recursively cloned
Parameters:
ptarget Memory where instance object is copied
pinst Instance to copy
Returns:
  • 0: OK
  • else: Error

int xf_instance_rfree ( xf_instance_t pinst  ) 

Destructor.

frees all memory related to instance, object and recursively depending other instances

Parameters:
pinst Instance to free
Returns:
  • 0: OK
  • else: Error

void* xf_instance_setobj ( xf_instance_t pinst,
void *  pobj 
)

set instance obj

Parameters:
pinst Instance to set object for
pobject pointer to object
Returns:
  • previously associated instance Object (you can free it ;-)
  • NULL: Error

int xf_instance_setuserdata ( xf_instance_t pinst,
void *  userdata 
)

set userdata

Parameters:
pinst Instance to set userdata to
userdata Userdata
Returns:
  • 0: OK
  • else: Error

int xf_instance_write ( xf_instance_t pinst,
int  fd,
xf_buffer_t pbuf,
int  openflag,
int  closeflag 
)

serializes an object according to its reflection to stream or buffer

Parameters:
pinst Instance to serialize
fd Filedescriptor to write to
pbuf Buffer to write to, if equal null write to stream
openflag set true for first object written to stream
closeflag set true for last object written to stream
Returns:
  • 0: OK
  • else: Error


Generated on 4 Mar 2014 for xfer by  doxygen 1.4.7