server 0.0.1
basicserverinfrastructure

include/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.

Classes

struct  interface
struct  iface_impl

Defines

#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_IMPL(...)   {NUMARGS(__VA_ARGS__), 0, {__VA_ARGS__}}
#define CREATE_IMPL(...)   static struct iface_impl iface_impl = INIT_IMPL(__VA_ARGS__)
#define METHOD_GET(iface, method)   (iface->method)

Typedefs

typedef struct interfaceiface_ptr
typedef struct iface_impliface_impl_ptr

Functions

struct interfaceinterfaceGet (iface_impl_ptr, const iface_ptr)

Define Documentation

#define CREATE_IMPL (   ...)    static struct iface_impl iface_impl = INIT_IMPL(__VA_ARGS__)

Definition at line 16 of file interface.h.

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

Definition at line 8 of file interface.h.

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

Definition at line 10 of file interface.h.

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

Definition at line 15 of file interface.h.

#define MAX_IFACE   32

Definition at line 6 of file interface.h.

#define METHOD_GET (   iface,
  method 
)    (iface->method)

Definition at line 19 of file interface.h.

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

Definition at line 13 of file interface.h.


Typedef Documentation

typedef struct iface_impl* iface_impl_ptr

Definition at line 33 of file interface.h.

typedef struct interface* iface_ptr

Definition at line 26 of file interface.h.


Function Documentation

struct interface* interfaceGet ( iface_impl_ptr  iface_impl,
const iface_ptr  _iface 
) [read]

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

Definition at line 25 of file interface.c.

{
        const iface_ptr * iface = &_iface;
        void *            dummy;

    if (! iface_impl->simpl) {
        qsort((void**)(iface_impl->impl), iface_impl->nimpl, sizeof(iface_ptr), comp);
        iface_impl->simpl=TRUE;
    }

    dummy = bsearch(
                        &iface,
                        iface_impl->impl,
                        iface_impl->nimpl,
                        sizeof(iface_ptr),
                        comp);

        return dummy? *(struct interface **)dummy : dummy;
}
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines