00001 /* EGlib "Efficient General Library" provides some basic structures and 00002 * algorithms commons in many optimization algorithms. 00003 * 00004 * Copyright (C) 2005 Daniel Espinoza and Marcos Goycoolea. 00005 * 00006 * This library is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published by the 00008 * Free Software Foundation; either version 2.1 of the License, or (at your 00009 * option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00013 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00014 * License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this library; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00019 * */ 00020 #ifndef __EG_ELINK_H__ 00021 #define __EG_ELINK_H__ 00022 /* ========================================================================= */ 00023 /** @defgroup EGeLink EGeLink 00024 * This header contains the definition of an embeded link, this simple 00025 * structure can be used to build trees that only have the information of the 00026 * parent, and in many other basic structures. 00027 * @version 0.0.1 00028 * @par History: 00029 * - 2005-05-25 00030 * - First Implementation 00031 * */ 00032 /** @{ */ 00033 /** @file 00034 * */ 00035 /* ========================================================================= */ 00036 00037 /* ========================================================================= */ 00038 /** @brief Define a simple link structure. */ 00039 typedef struct EGeLink_t 00040 { 00041 struct EGeLink_t *link; 00042 } 00043 EGeLink_t; 00044 00045 /* ========================================================================= */ 00046 /** @brief Set to null the given link. 00047 * @param link_pt pointer to the structure to set to NULL. 00048 * @return the given link pointer. */ 00049 #define EGeLinkReset(link_pt) ({\ 00050 EGeLink_t*const __lnk__ = (link_pt);\ 00051 __lnk__->link = 0;\ 00052 __lnk__;}) 00053 00054 /* ========================================================================= */ 00055 /** @brief Set the link to point to itself. 00056 * @param link_pt pointer to the structure to set. 00057 * @return the given pointer. */ 00058 #define EGeLinkSetSelf(link_pt) ({\ 00059 EGeLink_t*const __lnk__ = (link_pt);\ 00060 __lnk__->link = __lnk__;}) 00061 00062 /* ========================================================================= */ 00063 /** @brief test wether the given link point to itself. 00064 * @param link_pt pointer to the link to test. 00065 * @return one if the link point to itself, zero otherwise. */ 00066 #define EGeLinkIsSelf(link_pt) ({\ 00067 EGeLink_t*const __lnk__ = (link_pt);\ 00068 __lnk__->link == __lnk__ ? 1 : 0;}) 00069 00070 /* ========================================================================= */ 00071 /** @brief test wether the given link is null. 00072 * @param link_pt pointer to the link to test. 00073 * @return one if the pointer is null, zero otherwise. */ 00074 #define EGeLinkIsNull(link_pt) ({\ 00075 (link_pt)->link ? 0 : 1;}) 00076 00077 /* ========================================================================= */ 00078 /** @brief Set the given pointer to the given value. 00079 * @param link_pt pointer to the link to set. 00080 * @param info information to store. 00081 * @return pointer to the given link structure. 00082 * @note We don't require the given information to be of type (EGeLink_t)*, 00083 * but to use that information as a link, it should. */ 00084 #define EGeLinkSet(link_pt,info) ({\ 00085 EGeLink_t*const __lnk__ = (link_pt);\ 00086 __lnk__->link = (EGeLink_t*)(info);\ 00087 __lnk__;}) 00088 00089 /* ========================================================================= */ 00090 /** @} 00091 * end of eg_elink.h */ 00092 #endif
1.4.5