The Gnome Chemistry Utils: macros.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories

# macros.h

Go to the documentation of this file.

    00001 // -*- C++ -*-
    00002
    00003 /*
    00004  * Gnome Chemisty Utils
    00005  * macros.h
    00006  *
    00007  * Copyright (C) 2001-2006 Jean Bréfort <jean.brefort@normalesup.org>
    00008  *
    00009  * This program is free software; you can redistribute it and/or
    00010  * modify it under the terms of the GNU General Public License as
    00011  * published by the Free Software Foundation; either version 2 of the
    00012  * License, or (at your option) any later version.
    00013  *
    00014  * This program is distributed in the hope that it will be useful,
    00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00017  * GNU General Public License for more details.
    00018  *
    00019  * You should have received a copy of the GNU General Public License
    00020  * along with this program; if not, write to the Free Software
    00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
    00022  * USA
    00023  */
    00024
    00025 #ifndef GCU_MACROS_H
    00026 #define GCU_MACROS_H
    00027
    00048 #define GCU_PROP(type,member) \
    00049 public: \
    00050         void Set##member (type val) {m_##member = val;} \
    00051         type Get##member (void) {return m_##member;}    \
    00052         type &GetRef##member (void) {return m_##member;}        \
    00053 private:        \
    00054         type m_##member;
    00055
    00069 #define GCU_RO_PROP(type,member) \
    00070 public: \
    00071         type Get##member (void) {return m_##member;}    \
    00072 private:        \
    00073         type m_##member;
    00074
    00088 #define GCU_PROT_PROP(type,member) \
    00089 public: \
    00090         type Get##member (void) {return m_##member;}    \
    00091 protected:      \
    00092         type m_##member;
    00093
    00101 #define GCU_GCONF_GET(key,type,target,defaultval) \
    00102         target = gconf_client_get_##type (m_ConfClient, key, &error); \
    00103         if (error) {    \
    00104                 target = defaultval;    \
    00105                 g_message ("GConf failed: %s", error->message); \
    00106                 g_error_free (error);   \
    00107                 error = NULL;   \
    00108         }       \
    00109         if (target == (type) 0) \
    00110                 target = defaultval;
    00111
    00118 #define GCU_GCONF_GET_NO_CHECK(key,type,target,defaultval) \
    00119         target = gconf_client_get_##type (m_ConfClient, key, &error); \
    00120         if (error) {    \
    00121                 target = defaultval;    \
    00122                 g_message ("GConf failed: %s", error->message); \
    00123                 g_error_free (error);   \
    00124                 error = NULL;   \
    00125         }
    00126
    00135 #define GCU_GCONF_GET_N_TRANSFORM(key,type,target,defaultval,func) \
    00136         {       \
    00137                 type val = gconf_client_get_##type (m_ConfClient, key, &error); \
    00138                 if (error) {    \
    00139                         val = defaultval;       \
    00140                         g_message ("GConf failed: %s", error->message); \
    00141                         g_error_free (error);   \
    00142                         error = NULL;   \
    00143                 }       \
    00144                 if (val == (type) 0)    \
    00145                         val = defaultval; \
    00146                 target = func (val);    \
    00147         }
    00148
    00157 #define GCU_GCONF_GET_STRING(key,target,defaultval) \
    00158         if (target) {   \
    00159                 g_free (target);        \
    00160                 target = NULL;  \
    00161         }       \
    00162         target = gconf_client_get_string (m_ConfClient, key, &error); \
    00163         if (error) {    \
    00164                 if (defaultval) \
    00165                         target = g_strdup (defaultval); \
    00166                 g_message ("GConf failed: %s", error->message); \
    00167                 g_error_free (error);   \
    00168                 error = NULL;   \
    00169         } else if (target == NULL && defaultval)        \
    00170                         target = g_strdup (defaultval);
    00171
    00172 #endif  //      GCU_MACROS_H