Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:19:36

0001 /* This software is distributed under the GNU Lesser General Public License */
0002 //==========================================================================
0003 //
0004 //   GTL.h - Internal header: DO NO USE IT DIRECTLY !!!
0005 //
0006 //==========================================================================
0007 // $Id: GTL.h,v 1.29 2008/02/03 18:17:08 chris Exp $
0008 
0009 #ifndef GTL_GTL_H
0010 #define GTL_GTL_H
0011 
0012 #include <GTL/version.h>
0013 
0014 //--------------------------------------------------------------------------
0015 //   Generic iteration over container elements
0016 //--------------------------------------------------------------------------
0017 //
0018 // elem: loop variable
0019 // cont: container to iterate over
0020 // iter_t: iterator type
0021 // iter: prefix for begin() and end()
0022 //
0023 // contains a hack for Microsoft Visual C++ 5.0, because code like
0024 //
0025 //   for(int i=0; i<10; ++i) { ... do something ... }
0026 //   for(int i=0; i<10; ++i) { ... do something again ... }
0027 //
0028 // is illegal with Microsoft Extensions enabled, but without Microsoft
0029 // Extensions, the Microsoft STL does not work :-(.
0030 // So we code the line number (__LINE__) into our loop variables.
0031 
0032 #define GTL_CONCAT(x, y) x##y
0033 #define GTL_FORALL_VAR(y) GTL_CONCAT(GTL_FORALL_VAR, y)
0034 
0035 #define GTL_FORALL(elem, cont, iter_t, iter)            \
0036 if ((cont).iter##begin() != (cont).iter##end())         \
0037     (elem) = *((cont).iter##begin());               \
0038 for (iter_t GTL_FORALL_VAR(__LINE__) = (cont).iter##begin();    \
0039     GTL_FORALL_VAR(__LINE__) != (cont).iter##end();             \
0040     (elem) = (++GTL_FORALL_VAR(__LINE__)) ==                    \
0041         (cont).iter##end() ? (elem) : *GTL_FORALL_VAR(__LINE__))
0042 
0043 //--------------------------------------------------------------------------
0044 //   Configuration for GCC >= 2.8.0
0045 //--------------------------------------------------------------------------
0046 
0047 //
0048 // Using namespaces is the default; may be unset by one of the 
0049 // following configurations.
0050 //
0051  
0052 #define __GTL_USE_NAMESPACES
0053 
0054 #ifdef __GNUC__
0055 
0056 #  define __GTL_GCC
0057 
0058 #  if __GNUC__ == 2 && __GNUC_MINOR__ >= 8
0059 
0060 #    undef __GTL_USE_NAMESPACES
0061 
0062 #  elif __GNUC__ < 3
0063 
0064 #    error "Need at least version 2.8.0 of GCC to compile GTL."
0065 
0066 #  endif
0067 
0068 // 
0069 // 2/3/2008 chris:
0070 //
0071 // Enable comparison of iterators in debug mode
0072 //
0073 
0074 #  if __GNUC__ >= 4
0075 #    undef _GLIBCXX_DEBUG
0076 #  endif
0077 #endif
0078 
0079 //--------------------------------------------------------------------------
0080 //    Configuration for Microsoft Visual C++ 5.0
0081 //--------------------------------------------------------------------------
0082 
0083 #ifdef _MSC_VER
0084 
0085 #  if _MSC_VER >= 1400 // Visual Studio 2005
0086 
0087 #    define _HAS_ITERATOR_DEBUGGING 0
0088 #    define _CRT_SECURE_NO_DEPRECATE 1
0089 #    define _SECURE_SCL 0
0090 
0091 #  endif
0092 
0093 #  if _MSC_VER >= 1100
0094     
0095 #    define __GTL_USE_NAMESPACES
0096 #    define __GTL_MSVCC
0097 
0098 #    pragma warning( disable : 4786 )
0099 #    pragma warning( disable : 4251 )
0100 
0101 #    if defined(GTL_STATIC)
0102 #      define GTL_EXTERN
0103 #    elif defined(GTL_EXPORTS)
0104 #      define GTL_EXTERN __declspec(dllexport)
0105 #    else
0106 #      define GTL_EXTERN __declspec(dllimport)
0107 #    endif
0108 
0109 #  else
0110 
0111 #    error "Need at least version 5.0 of MS Visual C++ to compile GTL."
0112 
0113 #  endif
0114 #else
0115 
0116 #   define GTL_EXTERN
0117 
0118 #endif
0119 
0120 //--------------------------------------------------------------------------
0121 //   Namespaces
0122 //--------------------------------------------------------------------------
0123 
0124 #ifdef __GTL_USE_NAMESPACES
0125 
0126 #  define __GTL_BEGIN_NAMESPACE namespace GTL {
0127 #  define __GTL_END_NAMESPACE }
0128 
0129 #else
0130 
0131 #  define __GTL_BEGIN_NAMESPACE
0132 #  define __GTL_END_NAMESPACE
0133 
0134 #endif
0135 
0136 //--------------------------------------------------------------------------
0137 //   Temporary hack until Graphlet (i.e. gcc) supports Namespaces
0138 //--------------------------------------------------------------------------
0139 
0140 #ifdef __GTL_USE_NAMESPACES
0141 
0142 namespace GTL {};
0143 using namespace GTL;
0144 
0145 // namespace std {};
0146 //using namespace std;
0147 #include<list>
0148 #include<map>
0149 #include<set>
0150 #include<queue>
0151 #include<deque>
0152 #include<stack>
0153 #include<vector>
0154 #include<iostream>
0155 #include<string>
0156 using std::vector;
0157 using std::list;
0158 using std::queue;
0159 using std::priority_queue;
0160 using std::deque;
0161 using std::pair;
0162 using std::stack;
0163 using std::map;
0164 using std::set;
0165 using std::allocator;
0166 using std::binary_function;
0167 using std::ostream;
0168 using std::ofstream;
0169 using std::cout;
0170 using std::cerr;
0171 using std::endl;
0172 using std::string;
0173 
0174 
0175 
0176 #endif // __GTL_USE_NAMESPACES
0177 
0178 //--------------------------------------------------------------------------
0179 //   Bugfix for EGCS & GCC < 2.95
0180 //--------------------------------------------------------------------------
0181 
0182 #if defined(__GNUC__) && __GNUC__ == 2 && __GNUC_MINOR__ < 95
0183 
0184 #include <map>
0185 #include <memory>
0186 
0187 /**
0188  * @internal
0189  */
0190 template <class T>
0191 class allocator : public alloc
0192 {
0193 };
0194 
0195 #endif
0196 
0197 //--------------------------------------------------------------------------
0198 //   MSVC 6 does not define min and max in <algorithm>
0199 //--------------------------------------------------------------------------
0200 
0201 #if defined(__GTL_MSVCC) && _MSC_VER < 1300
0202 
0203 #ifndef min
0204 template<class T>
0205 const T& min(const T& x, const T& y)
0206 {
0207     return ( x < y ? x : y);
0208 }
0209 #endif
0210 
0211 #ifndef max
0212 template<class T>
0213 const T& max(const T& x, const T& y)
0214 {
0215     return ( x > y ? x : y);
0216 }
0217 #endif
0218 
0219 #endif
0220 
0221 //--------------------------------------------------------------------------
0222 //  enable debugging of memory leaks in debug mode of MSVC
0223 //--------------------------------------------------------------------------
0224 
0225 #ifdef __GTL_MSVCC
0226 #   ifdef _DEBUG
0227 #   define WINVER 0x0400    // compatibility with at least WinNT4
0228     // usually the followin two lines are defined in Microsoft's
0229     // generated stdafx.h
0230 #   define VC_EXTRALEAN // do not include rarely used parts
0231 #   include <afxwin.h>  // MFC core und standard components
0232     // extra definition for check whether all needed headers are included
0233 #   undef SEARCH_MEMORY_LEAKS_ENABLED
0234 #   define SEARCH_MEMORY_LEAKS_ENABLED
0235 #   endif   // _DEBUG
0236 #endif  // __GTL_MSVCC
0237 
0238 #endif // GTL_GTL_H
0239 
0240 //--------------------------------------------------------------------------
0241 //   end of file
0242 //--------------------------------------------------------------------------