COPASI API  4.16.103
copasi.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2015 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 // copasi.h
16 //
17 // This file contains compatability issues
18 // (C) Stefan Hoops 2001
19 //
20 
21 #ifndef COPASI_copasi
22 #define COPASI_copasi
23 
24 /* #define AVOGADRO 6.0221367e23 */
25 #define AVOGADRO 6.0221415e23
26 
27 #ifdef WIN32
28 # pragma warning (disable: 4786)
29 # pragma warning (disable: 4243)
30 // warning C4355: 'this' : used in base member initializer list
31 # pragma warning (disable: 4355)
32 # if _MSC_VER >= 1400
33 # define _CRT_SECURE_NO_DEPRECATE
34 
35 // avoid the following warning:
36 // The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
37 # pragma warning(disable : 4996)
38 # endif
39 #endif // WIN32
40 
41 #include <assert.h>
42 #include <fstream>
43 #include <limits>
44 
45 //YH: new defined parameters used by more than one classes
46 #define SS_FOUND 1 //steady state found
47 #define SS_NOT_FOUND 0 //steady state not found
48 #define SS_SINGULAR_JACOBIAN 2
49 #define SS_DAMPING_LIMIT 3
50 #define SS_ITERATION_LIMIT 4
51 
52 #ifdef min
53 # undef min
54 #endif
55 
56 #ifdef max
57 # undef max
58 #endif
59 
60 #if (defined SunOS || defined __CYGWIN__ || defined Darwin)
61 # define C_INT64 long long int
62 # define LLONG_CONST(n) n ## LL
63 # define C_INT32 int
64 # define C_INT16 short
65 # define C_FLOAT64 double
66 # define C_FLOAT32 float
67 # define abs64 abs
68 #else
69 #ifdef WIN32
70 # define C_INT64 __int64
71 # define LLONG_CONST(n) n ## i64
72 # define C_INT32 int
73 # define C_INT16 short
74 # define C_FLOAT64 double
75 # define C_FLOAT32 float
76 # define vsnprintf _vsnprintf // they just have a different name for this guy
77 # define snprintf _snprintf // they just have a different name for this guy
78 # define strcasecmp _stricmp // they just have a different name for this guy
79 # define strdup _strdup // they just have a different name for this guy
80 # define isnan _isnan // they just have a different name for this guy
81 # define finite _finite // they just have a different name for this guy
82 #if _MSC_VER < 1600
83 # define min _cpp_min // they just have a different name for this guy
84 # define max _cpp_max // they just have a different name for this guy
85 #endif // _MSC_VER
86 # define abs64 _abs64
87 #else
88 # define C_INT64 long long int
89 # define LLONG_CONST(n) n ## LL
90 # define C_INT32 int
91 # define C_INT16 short
92 # define C_FLOAT64 double
93 # define C_FLOAT32 float
94 # define abs64 abs
95 #endif
96 #endif
97 
98 #ifdef Darwin
99 # ifndef isnan
100 # define isnan(__x) ((__x == __x) != true)
101 # endif
102 #endif
103 
104 #if (defined __GNUC__ && __GNUC__ < 3)
105 # define ios_base ios
106 #endif
107 
108 // for compatibility with default CLAPACK f2c
109 #ifdef F2C_INTEGER
110 # define C_INT F2C_INTEGER
111 #else
112 # if ((defined __LP64__) && (!(defined HAVE_CLAPACK_H) || (defined Darwin)))
113 # define C_INT int
114 # else
115 # define C_INT long
116 # endif
117 #endif
118 
119 #ifdef F2C_LOGICAL
120 # define C_LOGICAL F2C_LOGICAL
121 #else
122 # define C_LOGICAL C_INT
123 #endif
124 
126 {
128  TriFalse = 0,
130 };
131 
132 /* This is necessary to link with Intel MKL or LAPACK compiled with Intel under Visual C++ 8 */
133 #if defined COPASI_MAIN && defined _MSC_VER && _MSC_VER > 1200 && defined _DLL
134 extern "C"
135 {
136  FILE _iob[3] = {__iob_func()[0], __iob_func()[1], __iob_func()[2]};
137  int __argc = 0;
138  char ** __argv = NULL;
139 }
140 
141 #endif
142 
143 #ifdef COPASI_MAIN
145 CCopasiRootContainer * pRootContainer = NULL;
146 
147 class QMutex;
148 QMutex * pCopasiGuiMutex = NULL;
149 #endif
150 
151 /* Define Constructor/Destructor Trace */
152 #ifdef COPASI_DEBUG_TRACE
153 # include <time.h>
154 # include <sys/time.h>
155 
156 # ifdef COPASI_MAIN
157 # ifndef Darwin
158 timeval C_init_time;
159 unsigned C_INT32 C_last_time = 0;
160 unsigned C_INT32 C_this_time;
161 # endif // !Darwin
162 std::ofstream DebugFile("trace");
163 # else // not COPASI_MAIN
164 # include <fstream>
165 # ifndef Darwin
166 extern timeval C_init_time;
167 extern unsigned C_INT32 C_last_time;
168 extern unsigned C_INT32 C_this_time;
169 # endif // !Darwin
170 extern std::ofstream DebugFile;
171 # endif // COPASI_MAIN
172 
173 # ifndef Darwin
174 # include <iostream>
175 # define TIME_TRACE(f, l) {\
176  gettimeofday(&C_init_time, NULL); \
177  C_this_time = C_init_time.tv_sec * 1000 + C_init_time.tv_usec; \
178  DebugFile << f <<"(" << l << "):\t" << C_this_time - C_last_time << std::endl; \
179  C_last_time = C_this_time;\
180  }
181 # endif // !Darwin
182 
183 # if (defined COPASI_TRACE_CONSTRUCTION)
184 # include <typeinfo>
185 # define CONSTRUCTOR_TRACE \
186  {DebugFile << "Construct:\t" << typeid(*this).name() \
187  << "\tAddress:\t" << (void *) this << std::endl;}
188 # define DESTRUCTOR_TRACE \
189  {DebugFile << "Destruct:\t" << typeid(*this).name() \
190  << "\tAddress:\t" << (void *) this << std::endl;}
191 # endif // COPASI_TRACE_CONSTRUCTION
192 
193 # define DEBUG_OUT(s) {DebugFile << (s) << std::endl;}
194 #else
195 # if !defined (NDEBUG) && !defined (_DEBUG)
196 # define NDEBUG
197 # endif // !defined (NDEBUG) && !defined (_DEBUG)
198 # define DEBUG_OUT(s)
199 #endif // COPASI_DEBUG_TRACE
200 
201 #ifndef CONSTRUCTOR_TRACE
202 # define CONSTRUCTOR_TRACE
203 #endif
204 
205 #ifndef DESTRUCTOR_TRACE
206 # define DESTRUCTOR_TRACE
207 #endif
208 
209 #ifndef TIME_TRACE
210 # define TIME_TRACE(f, l)
211 #endif
212 
213 // protected free
214 #define pfree(p) {if (p) {free(p); p = NULL;}}
215 #define pdelete(p) {if (p) {delete p; p = NULL;}}
216 #define pdeletev(p) {if (p) {delete[] p; p = NULL;}}
217 #define pcleanup(p) {if (p) {p->cleanup(); delete p; p = NULL;}}
218 
219 // suppress unused parameter warnings
220 #define C_UNUSED(p)
221 #define COPASI_DEPRECATED
222 #define C_INVALID_INDEX (std::numeric_limits< size_t >::max())
223 #endif // COPASI_copasi
TriLogic
Definition: copasi.h:125
#define C_INT32
Definition: copasi.h:90