/**
 * @file
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 *
 * The iWear Framework 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 as in version 2 of the License.

 * 
 * The iWear Framework 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
 * The iWear Framework; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __IWEAR_OPTIONGUARD_H
#define __IWEAR_OPTIONGUARD_H

#include <iosfwd>
namespace iwear {
/**
 * This structure will help us guarding against libraries linked together with
 * incompatible compile time defines.
 */
struct optionguard
{
    bool define_glibcxx_debug;
    bool define_iwear_debug;
    bool define__reentrant;
    bool define_mudflap;

    optionguard( bool cxx, bool iwdebug, bool reent, bool mudf, const char* libname );
    static optionguard* masterguard;
private:
    optionguard();
    void create_masterguard(void);
};

std::ostream& operator<<( std::ostream&, const iwear::optionguard& og );
}

#ifdef _GLIBCXX_DEBUG
#define OPTIONGUARD_CXX_VALUE true
#else
#define OPTIONGUARD_CXX_VALUE false
#endif

#ifdef IWEAR_DEBUG
#define OPTIONGUARD_IWDBVALUE true
#else
#define OPTIONGUARD_IWDBVALUE false
#endif

#ifdef _REENTRANT
#define OPTIONGUARD_REENT_VALUE true
#else
#define OPTIONGUARD_REENT_VALUE false
#endif

#ifdef _MUDFLAP
#define OPTIONGUARD_MUDF_VALUE true
#else
#define OPTIONGUARD_MUDF_VALUE false
#endif

#define GEN_OPTIONGUARD(storage, gname, libname) \
storage iwear::optionguard gname \
( \
	OPTIONGUARD_CXX_VALUE,     \
	OPTIONGUARD_IWDBVALUE,     \
	OPTIONGUARD_REENT_VALUE,   \
	OPTIONGUARD_MUDF_VALUE,    \
	libname        \
	);

#endif
