|
Server 0.0.1
HTTP/REST server implementation
|
#include <sys/types.h>

Go to the source code of this file.
Data Structures | |
| 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_IFACE_IMPL(...) {NUMARGS(__VA_ARGS__), 0, {__VA_ARGS__}} |
Typedefs | |
| typedef struct interface * | iface_ptr |
| typedef struct iface_impl * | iface_impl_ptr |
Functions | |
| iface_ptr | interfaceGet (iface_impl_ptr, const iface_ptr) |
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.
Copyright © 2012 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.
| #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 struct iface_impl* iface_impl_ptr |
Definition at line 53 of file interface.h.
Definition at line 46 of file interface.h.
| 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.
{
const iface_ptr * iface = &_iface;
iface_ptr * found;
if (! iface_impl->simpl) {
qsort((void**)(iface_impl->impl), iface_impl->nimpl, sizeof(iface_ptr), comp);
iface_impl->simpl=TRUE;
}
found = bsearch(
&iface,
iface_impl->impl,
iface_impl->nimpl,
sizeof(iface_ptr),
comp);
return found? *found : (iface_ptr)NULL;
}