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

Go to the source code of this file.

Data Structures

struct  interface
 
struct  iface_impl_ptr
 

Macros

#define MAX_IFACE   32
 
#define IFACE(name)   ((const struct i_##name const*)&i_##name##_impl)
 
#define INIT_IFACE(name, ...)   static const struct i_##name i_##name##_impl = {&i_##name,__VA_ARGS__}
 
#define NUMARGS(...)   (sizeof((const void*[]){__VA_ARGS__})/sizeof(void*))
 
#define INIT_IFACE_IMPL(...)   {NUMARGS(__VA_ARGS__), 0, {__VA_ARGS__}}
 

Typedefs

typedef const struct interfaceiface_ptr
 

Functions

iface_ptr interfaceGet (iface_impl_ptr, const iface_ptr)
 

Detailed Description

Interface definition code. Each interface is a set of selector functions as well as a data structure where the concrete implementation will be stored. This structure is the intergrated in the class that implements the interface.

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


Data Structure Documentation

struct interface

Definition at line 42 of file interface.h.

+ Collaboration diagram for interface:
Data Fields
const char * name
const size_t nmethods
struct iface_impl

Definition at line 48 of file interface.h.

+ Collaboration diagram for iface_impl_ptr:
Data Fields
const void * impl[MAX_IFACE]
const size_t nimpl
char simpl

Macro Definition Documentation

#define IFACE (   name)    ((const struct i_##name const*)&i_##name##_impl)

Definition at line 34 of file interface.h.

#define INIT_IFACE (   name,
  ... 
)    static const struct i_##name i_##name##_impl = {&i_##name,__VA_ARGS__}

Definition at line 35 of file interface.h.

#define INIT_IFACE_IMPL (   ...)    {NUMARGS(__VA_ARGS__), 0, {__VA_ARGS__}}

Definition at line 39 of file interface.h.

#define MAX_IFACE   32

Definition at line 32 of file interface.h.

#define NUMARGS (   ...)    (sizeof((const void*[]){__VA_ARGS__})/sizeof(void*))

Definition at line 38 of file interface.h.

Typedef Documentation

typedef const struct interface* iface_ptr

Definition at line 46 of file interface.h.

Function Documentation

iface_ptr interfaceGet ( iface_impl_ptr  iface_impl,
const iface_ptr  _iface 
)

this one is important in selector functions to get the correct interface implementation of a class.

Definition at line 44 of file interface.c.

References comp(), and TRUE.

45 {
46  const iface_ptr * iface = &_iface;
47  iface_ptr * found;
48 
49  if (! iface_impl->simpl) {
50  qsort((void**)(iface_impl->impl), iface_impl->nimpl, sizeof(iface_ptr), comp);
52  }
53 
54  found = bsearch(
55  &iface,
58  sizeof(iface_ptr),
59  comp);
60 
61  return found? *found : (iface_ptr)NULL;
62 }
const struct interface * iface_ptr
Definition: interface.h:46
static int comp(const void *_a, const void *_b)
Definition: interface.c:32
const void * impl[MAX_IFACE]
Definition: interface.h:51
const size_t nimpl
Definition: interface.h:49
#define TRUE
Definition: commons.h:27
char simpl
Definition: interface.h:50

+ Here is the call graph for this function: