defs.hpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////
00002 //    This material is provided "as is", with absolutely no warranty
00003 //  expressed or implied. Any use is at your own risk.
00004 //
00005 //    Permission to use or copy this software for any purpose is hereby
00006 //  granted without fee, provided the above notices are retained on all
00007 //  copies. Permission to modify the code and to distribute modified code
00008 //  is granted, provided the above notices are retained, and a notice that
00009 //  the code was modified is included with the above copyright notice.
00010 //////////////////////////////////////////////////////////////////////////
00011 /** @file
00012   @brief Main OMNI definitions.
00013 
00014     This header file is included by all other OMNI files.
00015   So this header file is a root of OMNI library.
00016 
00017 @author Sergey Polichnoy
00018 */
00019 #ifndef __OMNI_DEFS_HPP_
00020 #define __OMNI_DEFS_HPP_
00021 
00022 namespace omni
00023 {
00024 
00025 //////////////////////////////////////////////////////////////////////////
00026 /// @brief Non-Copyable interface.
00027 /**
00028     Some classes should not support copying due to design purposes.
00029   A common practice is to declare copy constructor and assignment operator
00030   in the @b private section and not to define them.
00031 
00032 @code
00033   class X {
00034   public:
00035     // ...
00036 
00037   private: // copying not allowed
00038     X& operator=(const X&); // (!) not defined
00039     X(const X&);            // (!) not defined
00040   };
00041 @endcode
00042 
00043     This practice is good, but too verbose. You should add these
00044   @b private declarations for each appropriated class. Moreover,
00045   it is not so clear for users. A better practice is to derive your
00046   class from the NonCopyable interface.
00047 
00048 @code
00049   // default copying not allowed
00050   class Y: private omni::NonCopyable {
00051   public:
00052     // ...
00053   };
00054 @endcode
00055 
00056     Class NonCopyable is used to protect derived classes from default
00057   copying (copy constructor and assignment operator which compiler
00058   generates by default). It is recommended to use @b private derivation.
00059 
00060     Note that NonCopyable is not strict copying protection.
00061   Derived classes may define their own copy constructor
00062   and/or assignment operator.
00063 */
00064 class NonCopyable {
00065 protected:
00066   NonCopyable() {}      ///< @brief Trivial constructor.
00067   ~NonCopyable() {}     ///< @brief Trivial destructor.
00068 
00069 private: // copying not allowed
00070   NonCopyable& operator=(const NonCopyable&);
00071   NonCopyable(const NonCopyable&);
00072 };
00073 
00074 } // omni namespace
00075 
00076 
00077 #if !defined(OMNI_DOCUMENTATION_MODE)
00078 
00079 //////////////////////////////////////////////////////////////////////////
00080 // compiler specific
00081 #if defined(_MSC_VER) && (1400 <= _MSC_VER)      // Visual C++ 8.0
00082 # define OMNI_EXCEPTION_SPEC
00083 # ifndef OMNI_MT
00084 #   define OMNI_MT 1 // always multi-thread
00085 # endif // OMNI_MT
00086 
00087 #elif defined(_MSC_VER) && (1300 <= _MSC_VER)    // Visual C++ 7.0/7.1
00088 // ...
00089 
00090 #elif defined(_MSC_VER) && (1200 <= _MSC_VER)    // Visual C++ 6.0
00091 # pragma warning(disable: 4786) // identifier was truncated to '255' characters in the debug information
00092 # define OMNI_USE_FACET(loc, fac) std::_USE(loc, fac) // (!)
00093 # define OMNI_FIX_FOR_SCOPE
00094 
00095 #elif defined(__BORLANDC__) && (0x0560 <= __BORLANDC__) // Borland C++ Builder 6.0
00096 # define OMNI_EXCEPTION_SPEC
00097 
00098 #elif defined(__GNUC__)                     // gcc
00099 # define OMNI_EXCEPTION_SPEC
00100 
00101 #elif defined(__EDG__) && defined(__COMO__) // Comeau C++
00102 // ...
00103 
00104 #else
00105 # pragma message("OMNI warning: unknown compiler")
00106 #endif
00107 
00108 
00109 //////////////////////////////////////////////////////////////////////////
00110 // OMNI_DEBUG macro
00111 #if !defined(OMNI_DEBUG)
00112 # if defined(_DEBUG)
00113 #   define OMNI_DEBUG 1
00114 # else
00115 #   define OMNI_DEBUG 0
00116 # endif
00117 #endif
00118 
00119 //////////////////////////////////////////////////////////////////////////
00120 // OMNI_DEBUG_CODE macro
00121 #if OMNI_DEBUG
00122 # define OMNI_DEBUG_CODE(code) code
00123 # if defined(OMNI_SHOW_REMARK)
00124 #   pragma message("OMNI remark: debug mode enabled")
00125 # endif
00126 #else
00127 # define OMNI_DEBUG_CODE(code)
00128 # if defined(OMNI_SHOW_REMARK)
00129 #   pragma message("OMNI remark: debug mode disabled")
00130 # endif
00131 #endif
00132 
00133 
00134 //////////////////////////////////////////////////////////////////////////
00135 // OMNI_MT macro
00136 #if !defined(OMNI_MT)
00137 # if defined(_MT)
00138 #   define OMNI_MT 1
00139 # else
00140 #   define OMNI_MT 0
00141 # endif
00142 #endif
00143 
00144 //////////////////////////////////////////////////////////////////////////
00145 // OMNI_MT_CODE macro
00146 #if OMNI_MT
00147 # define OMNI_MT_CODE(code) code
00148 # if defined(OMNI_SHOW_REMARK)
00149 #   pragma message("OMNI remark: multi-thread mode enabled")
00150 # endif
00151 #else
00152 # define OMNI_MT_CODE(code)
00153 # if defined(OMNI_SHOW_REMARK)
00154 #   pragma message("OMNI remark: multi-thread mode disabled")
00155 # endif
00156 #endif
00157 
00158 
00159 //////////////////////////////////////////////////////////////////////////
00160 // OMNI_UNICODE macro
00161 #if !defined(OMNI_UNICODE)
00162 # if defined(UNICODE) || defined(_UNICODE)
00163 #   define OMNI_UNICODE 1
00164 # else
00165 #   define OMNI_UNICODE 0
00166 # endif
00167 #endif
00168 
00169 
00170 //////////////////////////////////////////////////////////////////////////
00171 // for scope correction
00172 #if defined(OMNI_FIX_FOR_SCOPE)
00173 # define for if (false) {} else for
00174 # if defined(OMNI_SHOW_REMARK)
00175 #   pragma message("OMNI remark: for scope fixed")
00176 # endif
00177 #endif
00178 
00179 
00180 //////////////////////////////////////////////////////////////////////////
00181 // exception specification
00182 #if defined(OMNI_EXCEPTION_SPEC)
00183 # define OMNI_THROW0() throw()
00184 #else
00185 # define OMNI_THROW0()
00186 #endif
00187 
00188 
00189 //////////////////////////////////////////////////////////////////////////
00190 // use facet macro
00191 #if !defined(OMNI_USE_FACET)
00192 # define OMNI_USE_FACET(loc, fac) std::use_facet<fac>(loc)
00193 #endif
00194 
00195 #endif // !OMNI_DOCUMENTATION_MODE
00196 
00197 #endif // __OMNI_DEFS_HPP_

Generated on Wed Jun 6 17:27:46 2007 for OMNI by  doxygen 1.5.2