list_type_proto.h 2.93 KB
/**
 * \file scot/list_type_proto.h
 * \author  Georg Steffers <georg@steffers.org>
 * \brief   Macro that creates the datatype for handling linked lists.
 *
 * The macros here create all datatype prototypes typedefs declarations 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 normally one did not only
 * want the datatypes but also the interface declaration to them.
 * 
 * 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_TYPE_PROTO_H
#define  LIST_TYPE_PROTO_H

/**
 * \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 datatype prototypes for lists of the given 
 *                   datatype are created.
 *
 * \brief Datatype prototypes to lists.
 *
 * This creates the prototypes of the datatypes needed to use the
 * list interface.
 *
 * Normally this is not called directly, but by 
 * \link scot/list_proto.h::GEN_LIST_PROTO GEN_LIST_PROTO()\endlink 
 * because it is also neccesary to create the interface to this 
 * datatypes for working lists.
 */
#define  GEN_LIST_TYPE_PROTO(type)                                   \
   struct list_ ## type ## _node_t;                                  \
   typedef struct list_ ## type ## _node_t                           \
      list_ ## type ## _node_t;                                      \
                                                                     \
   typedef int (*list_ ## type ## _cmp_fptr) (                       \
         const type *,                                               \
         const type *);                                              \
                                                                     \
   typedef void (*list_ ## type ## _elem_free_fptr) (type *);

#endif   /* LIST_TYPE_PROTO_H */