taskrambler  v0.1.8
Web server and task management solution.
class/interface/class.h File Reference
#include <stdarg.h>
#include "class/class.h"
#include "class/interface.h"
+ Include dependency graph for class/interface/class.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  i_Class
 

Macros

#define new(class, ...)   classNew(_##class, ##__VA_ARGS__)
 
#define delete(object)   classDelete((void **)&(object))
 
#define clone(object)   classClone((void *)(object))
 
#define newParams(class, args)   classNewParams(_##class, args)
 

Typedefs

typedef int(* fptr_ctor) (void *, va_list *)
 
typedef void(* fptr_dtor) (void *)
 
typedef void(* fptr_clone) (void *, void *const)
 

Functions

void * classNew (class_ptr,...)
 
void classDelete (void **)
 
void * classClone (void *)
 
void * classNewParams (class_ptr, va_list *)
 

Variables

const struct interface i_Class
 

Detailed Description

Interface for class handling. Defines new, delete and clone selectors which in turn use the ctor, dtor and clone implementation from the class implementation.

Author
Georg Hopp

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 3 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.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file class/interface/class.h.


Data Structure Documentation

struct i_Class

Definition at line 40 of file class/interface/class.h.

+ Collaboration diagram for i_Class:
Data Fields
const struct interface *const _
fptr_clone clone
fptr_ctor ctor
fptr_dtor dtor

Macro Definition Documentation

#define clone (   object)    classClone((void *)(object))

Definition at line 53 of file class/interface/class.h.

Referenced by classClone(), serverHandleAccept(), uuidVersion3(), and uuidVersion5().

#define delete (   object)    classDelete((void **)&(object))

Definition at line 52 of file class/interface/class.h.

#define new (   class,
  ... 
)    classNew(_##class, ##__VA_ARGS__)

Definition at line 51 of file class/interface/class.h.

#define newParams (   class,
  args 
)    classNewParams(_##class, args)

Definition at line 60 of file class/interface/class.h.

Referenced by authCreate().

Typedef Documentation

typedef void(* fptr_clone) (void *, void *const)

Definition at line 36 of file class/interface/class.h.

typedef int(* fptr_ctor) (void *, va_list *)

Definition at line 34 of file class/interface/class.h.

typedef void(* fptr_dtor) (void *)

Definition at line 35 of file class/interface/class.h.

Function Documentation

void* classClone ( void *  )

Definition at line 85 of file i_class.c.

References CALL, clone, memCalloc(), and class_ptr::object_size.

86 {
87  class_ptr class = GET_CLASS(_object);
88  void * object = memCalloc(1, class->object_size + sizeof(void*));
89 
90  * (class_ptr *)object = class;
91  object += sizeof(void*);
92 
93 #undef clone
94  CALL(object, Class, clone, _object);
95 
96  return object;
97 }
#define CALL(object, _iface, method,...)
Definition: class/class.h:106
#define clone(object)
void * memCalloc(size_t, size_t)
Definition: memory.c:818
size_t object_size
Definition: class/class.h:136

+ Here is the call graph for this function:

void classDelete ( void **  )

Definition at line 71 of file i_class.c.

References CALL, and MEM_FREE.

Referenced by classNewParams().

72 {
73  if (NULL != *object) {
74  void * mem;
75 
76  CALL(*object, Class, dtor);
77 
78  mem = *object - sizeof(void*);
79  MEM_FREE(mem);
80  *object = NULL;
81  }
82 }
#define MEM_FREE(seg)
Definition: memory.h:28
#define CALL(object, _iface, method,...)
Definition: class/class.h:106

+ Here is the caller graph for this function:

void* classNew ( class_ptr  ,
  ... 
)

Definition at line 58 of file i_class.c.

References classNewParams().

59 {
60  va_list params;
61  void * object;
62 
63  va_start(params, class);
64  object = classNewParams(class, &params);
65  va_end(params);
66 
67  return object;
68 }
void * classNewParams(class_ptr class, va_list *params)
Definition: i_class.c:40

+ Here is the call graph for this function:

void* classNewParams ( class_ptr  ,
va_list *   
)

With this one we can create a new instance via a intermidiary that gets the arguments.

Definition at line 40 of file i_class.c.

References classDelete(), memCalloc(), class_ptr::object_size, and RETCALL.

Referenced by classNew().

41 {
42  void * object = memCalloc(1, class->object_size + sizeof(void*));
43  int ret;
44 
45  * (class_ptr *)object = class;
46  object += sizeof(void*);
47 
48  RETCALL(object, Class, ctor, ret, params);
49 
50  if (-1 == ret) {
51  classDelete(&object);
52  }
53 
54  return object;
55 }
void classDelete(void **object)
Definition: i_class.c:71
#define RETCALL(object, _iface, method, ret,...)
Definition: class/class.h:113
void * memCalloc(size_t, size_t)
Definition: memory.c:818
size_t object_size
Definition: class/class.h:136

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const struct interface i_Class

Definition at line 34 of file i_class.c.