OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
base.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_BASE_HH
20 #define OST_BASE_HH
21 
22 #include <string>
23 #include <cmath>
24 #include <math.h>
25 #include <complex>
26 #include <ost/config.hh>
27 #include <ost/dllexport.hh>
28 
29 #ifndef uint
30 typedef unsigned int uint;
31 #endif
32 
33 #ifndef uchar
34  typedef unsigned char uchar;
35 #endif
36 
37 #ifndef ushort
38  typedef unsigned short int ushort;
39 #endif
40 
41 
42 #if OST_DOUBLE_PRECISION
43  typedef double Real;
44 #else
45  typedef float Real;
46 #endif
47 
48 #ifdef Complex
49  // undef Complex from xorg X.h to avoid clash with our definition
50  #undef Complex
51 #endif
52 typedef std::complex<Real> Complex;
53 typedef unsigned short Word;
54 
55 
56 
57 #ifndef round_function
58 #define round_function
59 #ifndef round
60 inline Real round( Real d )
61 {
62  return floor(d+Real(0.5));
63 }
64 #endif
65 #endif
66 
67 #ifndef rint_function
68 #define rint_function
69 #ifndef rint
70 inline Real rint(Real d)
71 {
72  return floor(d+Real(0.5));
73 }
74 #endif
75 #endif
76 
77 #if _MSC_VER
78 #pragma warning(disable:4251)
79 #pragma warning(disable:4275)
80 #pragma warning(disable:4244)
81 #pragma warning(disable:4231)
82 #pragma warning(disable:4305)
83 #pragma warning(disable:4351) // turn off "new behavior ... will be default initialized" warning
84 
85 #ifndef log2_function
86 #define log2_function
87 #ifndef log2
88  //C99 defines log2, C90 does not and MSVC is C90:(
89  // Calculates log2 of number.
90 inline double log2( double n )
91  {
92  // log(n)/log(2) is log2.
93  return log( double(n) ) / log( 2.0 );
94  }
95 #endif
96 #endif
97 
98 # ifdef FindAtom
99 # undef FindAtom
100 # endif
101 # ifdef AddAtom
102 # undef AddAtom
103 # endif
104 
105 #endif
106 
107 
108 typedef std::string String;
109 
110 
111 #endif