queue_func_proto.h
4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* \file scot/queue_func_proto.h
* \author Georg Steffers <georg@steffers.org>
* \brief Macro that produces function prototypes for handling queues
* based on linked lists.
*
* The macros here create all function prototypes to
* the implementations created by the macros in
* \link scot/queue_impl.h scot/queue_impl.h\endlink.
* These macros are normally not called directly within your code but
* through \link scot/queue_proto.h::GEN_QUEUE_PROTO GEN_QUEUE_PROTO\endlink.
* This is because to use the interface declaration
* provided here one will also need the typedefs and datatype prototypes.
*
* Copyright (C)2006 Georg Steffers <georg@steffers.org>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef QUEUE_FUNC_PROTO_H
#define QUEUE_FUNC_PROTO_H
#ifdef GEN_LOCAL
# define STATIC static
#else
# define STATIC
#endif
/**
* \param type the datatype that this list code should handle.
* \pre Type must be a single word typename. If one wants
* to use e.g. lists of structs one has to use typedef
* to create a single word type name like this:
* typedef struct mystruct_t mystruct_t;
* GEN_LIST_FUNC_PROTO should have bin called previously
* in one or the other way.
* \return Nothing
* \post All function prototypes for a queue of the given
* datatype are created.
*
* \brief This creates the prototypes to all queue functions
*
* This creates all the prototypes to the functions that are created by
* \link scot/queue_impl.h::GEN_QUEUE_IMPL GEN_QUEUE_IMPL\endlink in
* \link scot/queue_impl.h scot/queue_impl.h\endlink.
* This provides one with the complete interface to the queue of the given
* datatype.
*/
#define GEN_QUEUE_FUNC_PROTO(type) \
STATIC \
queue_ ## type ## _node_t * \
queue_ ## type ## _new ( \
queue_ ## type ## _node_t *); \
\
STATIC \
void \
queue_ ## type ## _free ( \
queue_ ## type ## _node_t *); \
\
STATIC \
queue_ ## type ## _node_t * \
queue_ ## type ## _enqueue ( \
queue_ ## type ## _node_t *, \
const type *); \
\
STATIC \
type * \
queue_ ## type ## _dequeue ( \
queue_ ## type ## _node_t *); \
\
STATIC \
type * \
queue_ ## type ## _top ( \
queue_ ## type ## _node_t *);
#endif /* QUEUE_FUNC_PROTO_H */