stack.h 3.1 KB
/**
 * \file scot/stack.h
 * \author  Georg Steffers <georg@steffers.org>
 * \brief   Macro which produce all prototypes and implementations for 
 *          handling stacks based on linked lists by Templates.
 *
 * This is the toplevel template file for stacks based on typesafe lists. 
 * It is quite simple. It just defines one MACRO which in turn calls two 
 * other macros to generate all that is needed for queue-handling of a queue 
 * to a given type.
 *
 * 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  STACK_H
#define  STACK_H

#include <scot/stack_proto.h>
#include <scot/stack_impl.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;
 *                   GEN_LIST(type) has to be called for the list functions,
 *                   as queues depend on these.
 * \return           Nothing
 * \post             The complete framework of functions, types, globals
 *                   prototypes and definitions to handle stacks based on
 *                   typesafe
 *                   lists for the given datatype are generated within the
 *                   calling build file.
 *
 * \brief create complete framework to handle stacks based on typesafe lists.
 *
 * This macro first colls GEN_STACK_PROTO() to create all prototypes
 * neccesary for handling stacks of the given \a type. And then it calls
 * GEN_STACK_IMPL() to also create the neccesary definitions and
 * implementations.\
 * Normally this macro is only called if one only wants to have stacks
 * of the given type in a single c source file and nowhere else. Normally
 * this is then used in conjunction with a previous define of GEN_LOCAL, 
 * that tells GEN_STACK() and the subsequent macros to generate the functions
 * as static.\n
 * If one wants to used queues of the given type in several places of the
 * project one would normally call GEN_STACK_PROTO() in a h file and 
 * GEN_STACK_IMPL() in the c file that does the implementation of that
 * h file (without GEN_LOCAL).
 */
#define  GEN_STACK(type)                                    \
   GEN_STACK_PROTO (type)                                   \
   GEN_STACK_IMPL (type)

#endif   /* STACK_H */