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

Go to the source code of this file.

Macros

#define TR_new(class, ...)   TR_classNew(_##class, ##__VA_ARGS__)
 
#define TR_newv(class, args)   TR_classNewv(_##class, args)
 
#define TR_delete(object)   TR_classDelete((void **)&(object))
 
#define TR_clone(object)   TR_classClone((void *)(object))
 

Typedefs

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

Functions

 TR_INTERFACE (TR_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 interface/class.h.

Macro Definition Documentation

#define TR_clone (   object)    TR_classClone((void *)(object))

Create a clone of an instance by calling its clone implementation. A simple memcopy is often not enough because the cloned instance might have to allocate ist own resources or reuse resources in a given way.

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

#define TR_delete (   object)    TR_classDelete((void **)&(object))

Destroy an instance by first calling its destructor and then free all other memory.

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

#define TR_new (   class,
  ... 
)    TR_classNew(_##class, ##__VA_ARGS__)

Interface caller function for i_class::ctor. This one will never be called direcly but only through TR_new.

See also
TR_classNewv
TR_new Create an instance of a class by calling its constructor implementation after initialization and memory allocation of the class itself.

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

#define TR_newv (   class,
  args 
)    TR_classNewv(_##class, args)

Create an instance of a class by calling its constructor implementation but this time with a va_list instead of a variable amount of arguments.

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

Typedef Documentation

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

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

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

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

typedef void(* fptr_dtor) (void *)

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

Function Documentation

TR_INTERFACE ( TR_Class  )

The interface structure for the class interface. Each class that implements this interface (and that should be all classes) need to provide at least a funtion pointer for the fptr_ctor. Else no instances can be created.

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

References TR_IFID.

45  {
46  TR_IFID;
47  fptr_ctor ctor;
48  fptr_dtor dtor;
49  fptr_clone clone;
50 };
int(* fptr_ctor)(void *, va_list *)
void(* fptr_dtor)(void *)
#define TR_IFID
Definition: interface.h:61
void(* fptr_clone)(void *, void *const)