taskrambler  v0.1.8
Web server and task management solution.
class/interface/class.h
Go to the documentation of this file.
1 /**
2  * \file
3  * Interface for class handling. Defines new, delete and clone selectors
4  * which in turn use the ctor, dtor and clone implementation from the
5  * class implementation.
6  *
7  * \author Georg Hopp
8  *
9  * \copyright
10  * Copyright © 2012 Georg Hopp
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 #ifndef __CLASS_INTERFACE_CLASS_H__
27 #define __CLASS_INTERFACE_CLASS_H__
28 
29 #include <stdarg.h>
30 
31 #include "class/class.h"
32 #include "class/interface.h"
33 
34 typedef int (* fptr_ctor)(void *, va_list *);
35 typedef void (* fptr_dtor)(void *);
36 typedef void (* fptr_clone)(void *, void * const);
37 
38 extern const struct interface i_Class;
39 
40 struct i_Class {
41  const struct interface * const _;
45 };
46 
47 extern void * classNew(class_ptr, ...);
48 extern void classDelete(void **);
49 extern void * classClone(void *);
50 
51 #define new(class,...) classNew(_##class, ##__VA_ARGS__)
52 #define delete(object) classDelete((void **)&(object))
53 #define clone(object) classClone((void *)(object))
54 
55 /**
56  * With this one we can create a new instance via a
57  * intermidiary that gets the arguments.
58  */
59 extern void * classNewParams(class_ptr, va_list *);
60 #define newParams(class,args) classNewParams(_##class, args)
61 
62 #endif // __CLASS_INTERFACE_CLASS_H__
63 
64 // vim: set ts=4 sw=4:
fptr_clone clone
fptr_dtor dtor
int(* fptr_ctor)(void *, va_list *)
void(* fptr_clone)(void *, void *const)
void * classClone(void *)
Definition: i_class.c:85
void classDelete(void **)
Definition: i_class.c:71
void * classNewParams(class_ptr, va_list *)
Definition: i_class.c:40
void * classNew(class_ptr,...)
Definition: i_class.c:58
fptr_ctor ctor
const struct interface *const _
void(* fptr_dtor)(void *)