list_func_proto.h 11.2 KB
/**
 * \file scot/list_func_proto.h
 * \author  Georg Steffers <georg@steffers.org>
 * \brief   Macro that produce function prototypes for handling 
 *          linked lists.
 *
 * The macros here create all function prototypes to 
 * the implementations created by the macros in 
 * \link scot/list_impl.h scot/list_impl.h\endlink.
 * These macros are normally not called directly within your code but
 * through \link scot/list_proto.h::GEN_LIST_PROTO GEN_LIST_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  LIST_FUNC_PROTO_H
#define  LIST_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;
 * \return           Nothing
 * \post             The function prototypes for manage lists of the given 
 *                   datatype are created.
 *
 * \brief Function prototypes for management.
 *
 * This creates the prototypes to the functions that are created by
 * \link scot/list_man.h::GEN_LIST_MANAGEMENT GEN_LIST_MANAGEMENT\endlink 
 * in \link scot/list_man.h scot/list_man.h\endlink.
 *
 * Normally this is not called directly, but by 
 * \link scot/list_proto.h::GEN_LIST_PROTO GEN_LIST_PROTO()\endlink 
 * because this defined just a subset of all function prototypes neccesarry 
 * to handle typesafe lists.
 */
#define  GEN_LIST_MAN_PROTO(type)                                    \
   STATIC                                                            \
   void                                                              \
   list_ ## type ## _set_cmp        (                                \
         list_ ## type ## _cmp_fptr);                                \
   STATIC                                                            \
   void                                                              \
   list_ ## type ## _set_elem_free  (                                \
         list_ ## type ## _elem_free_fptr);                          \
   STATIC                                                            \
   long                                                              \
   list_ ## type ## _elem_free_is_set  (void);                       \
   STATIC                                                            \
   list_ ## type ## _node_t *                                        \
   list_ ## type ## _new            (                                \
         list_ ## type ## _node_t *);                                \
   STATIC                                                            \
   void                                                              \
   list_ ## type ## _free           (                                \
         list_ ## type ## _node_t *);                                \
   STATIC                                                            \
   int                                                               \
   list_ ## type ## _count          (                                \
         list_ ## type ## _node_t *);                                \
   STATIC                                                            \
   int                                                               \
   list_ ## type ## _bol            (                                \
         list_ ## type ## _node_t *,                                 \
         list_ ## type ## _node_t *);                                \
   STATIC                                                            \
   int                                                               \
   list_ ## type ## _eol            (                                \
         list_ ## type ## _node_t *anchor,                           \
         list_ ## type ## _node_t *node);

/**
 * \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;
 * \return           Nothing
 * \post             The function prototypes to navigate lists of the given 
 *                   datatype are created.
 *
 * \brief Function prototypes for navigation.
 *
 * This creates the prototypes to the functions that are created by
 * \link scot/list_nav.h::GEN_LIST_NAVIGATION GEN_LIST_NAVIGATION\endlink 
 * in \link scot/list_nav.h scot/list_nav.h\endlink.
 *
 * Normally this is not called directly, but by 
 * \link scot/list_proto.h::GEN_LIST_PROTO GEN_LIST_PROTO()\endlink 
 * because this defined just a subset of all function prototypes neccesarry 
 * to handle typesafe lists.
 */
#define  GEN_LIST_NAV_PROTO(type)                                    \
   STATIC                                                            \
   list_ ## type ## _node_t *                                        \
   list_ ## type ## _front          (                                \
         list_ ## type ## _node_t *);                                \
   STATIC                                                            \
   list_ ## type ## _node_t *                                        \
   list_ ## type ## _last           (                                \
         list_ ## type ## _node_t *);                                \
   STATIC                                                            \
   list_ ## type ## _node_t *                                        \
   list_ ## type ## _next           (                                \
         list_ ## type ## _node_t *);                                \
   STATIC                                                            \
   list_ ## type ## _node_t *                                        \
   list_ ## type ## _prev           (                                \
         list_ ## type ## _node_t *);                                \
   STATIC                                                            \
   list_ ## type ## _node_t *                                        \
   list_ ## type ## _find           (                                \
         list_ ## type ## _node_t *,                                 \
         const type               *);                                \
   STATIC                                                            \
   list_ ## type ## _node_t *                                        \
   list_ ## type ## _find_anchor    (                                \
         list_ ## type ## _node_t *);

/**
 * \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;
 * \return           Nothing
 * \post             The function prototypes to modify lists of the given 
 *                   datatype are created.
 *
 * \brief Function prototypes for modification.
 *
 * This creates the prototypes to the functions that are created by
 * \link scot/list_mod.h::GEN_LIST_MODIFY GEN_LIST_MODIFY\endlink 
 * in \link scot/list_mod.h scot/list_mod.h\endlink.
 *
 * Normally this is not called directly, but by 
 * \link scot/list_proto.h::GEN_LIST_PROTO GEN_LIST_PROTO()\endlink 
 * because this defined just a subset of all function prototypes neccesarry 
 * to handle typesafe lists.
 */
#define  GEN_LIST_MOD_PROTO(type)                                    \
   STATIC                                                            \
   type *                                                            \
   list_ ## type ## _retrive        (                                \
         list_ ## type ## _node_t *);                                \
   STATIC                                                            \
   void                                                              \
   list_ ## type ## _set            (                                \
         list_ ## type ## _node_t *,                                 \
         const type               *);                                \
   STATIC                                                            \
   list_ ## type ## _node_t *                                        \
   list_ ## type ## _insert         (                                \
         list_ ## type ## _node_t *,                                 \
         const type               *);                                \
   STATIC                                                            \
   list_ ## type ## _node_t *                                        \
   list_ ## type ## _delete         (                                \
         list_ ## type ## _node_t *);                                \
   STATIC                                                            \
   list_ ## type ## _node_t *                                        \
   list_ ## type ## _concat         (                                \
         list_ ## type ## _node_t *,                                 \
         list_ ## type ## _node_t *);


/**
 * \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;
 * \return           Nothing
 * \post             All function prototypes for a lists of the given 
 *                   datatype are created.
 *
 * \brief Calls GEN_LIST_MAN_PROTO, GEN_LIST_NAV_PROTO and GEN_LIST_MOD_PROTO.
 *
 * This creates all the prototypes to the functions that are created by
 * \link scot/list_impl.h::GEN_LIST_IMPL GEN_LIST_IMPL\endlink in 
 * \link scot/list_impl.h scot/list_impl.h\endlink.
 * This provides one with the complete interface to the list of the given
 * datatype.
 */
#define  GEN_LIST_FUNC_PROTO(type)                                   \
   GEN_LIST_MAN_PROTO   (type);                                      \
   GEN_LIST_NAV_PROTO   (type);                                      \
   GEN_LIST_MOD_PROTO   (type);

#endif   /* LIST_FUNC_PROTO_H */