copasi API  0.1
copasi/copasi.h
Go to the documentation of this file.
00001 // Begin CVS Header
00002 //   $Source: /fs/turing/cvs/copasi_dev/copasi/copasi.h,v $
00003 //   $Revision: 1.74.2.1 $
00004 //   $Name: Build-33 $
00005 //   $Author: shoops $
00006 //   $Date: 2010/09/27 16:53:36 $
00007 // End CVS Header
00008 
00009 // Copyright (C) 2010 by Pedro Mendes, Virginia Tech Intellectual
00010 // Properties, Inc., University of Heidelberg, and The University
00011 // of Manchester.
00012 // All rights reserved.
00013 
00014 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
00015 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
00016 // and The University of Manchester.
00017 // All rights reserved.
00018 
00019 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
00020 // Properties, Inc. and EML Research, gGmbH.
00021 // All rights reserved.
00022 
00023 // copasi.h
00024 //
00025 // This file contains compatability issues
00026 // (C) Stefan Hoops 2001
00027 //
00028 
00029 #ifndef COPASI_copasi
00030 #define COPASI_copasi
00031 
00032 /* #define AVOGADRO 6.0221367e23 */
00033 #define AVOGADRO 6.0221415e23
00034 
00035 #ifdef WIN32
00036 # pragma warning (disable: 4786)
00037 # pragma warning (disable: 4243)
00038 // warning C4355: 'this' : used in base member initializer list
00039 # pragma warning (disable: 4355)
00040 # if  _MSC_VER >= 1400
00041 #  define _CRT_SECURE_NO_DEPRECATE
00042 
00043 // avoid the following warning:
00044 // The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
00045 #  pragma warning(disable : 4996)
00046 # endif
00047 #endif  // WIN32
00048 
00049 #include <assert.h>
00050 #include <fstream>
00051 #include <limits>
00052 
00053 //YH: new defined parameters used by more than one classes
00054 #define SS_FOUND 1             //steady state found
00055 #define SS_NOT_FOUND 0         //steady state not found
00056 #define SS_SINGULAR_JACOBIAN 2
00057 #define SS_DAMPING_LIMIT 3
00058 #define SS_ITERATION_LIMIT 4
00059 #define MCA_OK 0
00060 #define MCA_SINGULAR 1
00061 
00062 #ifdef min
00063 #undef min
00064 #endif
00065 
00066 #ifdef max
00067 #undef max
00068 #endif
00069 #if (defined __SUNPRO_CC && defined Linux)
00070 #ifndef LLONG_MAX
00071 #define  LLONG_MAX _RWSTD_LLONG_MAX
00072 #endif
00073 #endif // Sun C++ Compiler under Linux
00074 
00075 #if (defined SunOS || defined __CYGWIN__ || defined Darwin)
00076 # define C_INT64 long long int
00077 # ifndef LLONG_MAX
00078 #  define  LLONG_MAX LONG_LONG_MAX
00079 # endif
00080 # define LLONG_CONST(n) n ## LL
00081 # define C_INT32 long
00082 # define C_INT16 short
00083 # define C_FLOAT64 double
00084 # define C_FLOAT32 float
00085 # define abs64 abs
00086 #else
00087 #ifdef WIN32
00088 # define abs64 abs
00089 # define C_INT64 __int64
00090 # ifndef LLONG_MAX
00091 #     define LLONG_MAX _I64_MAX
00092 # endif
00093 # define LLONG_CONST(n) n ## i64
00094 # define C_INT32 int
00095 # define C_INT16 short
00096 # define C_FLOAT64 double
00097 # define C_FLOAT32 float
00098 #endif //WIN32
00099 #endif //SunOS || CYGWIN || Darwin
00100 
00101 #ifdef WIN32
00102 # define vsnprintf _vsnprintf // they just have a different name for this guy
00103 # define snprintf  _snprintf  // they just have a different name for this guy
00104 # define strcasecmp _stricmp  // they just have a different name for this guy
00105 # define strdup _strdup       // they just have a different name for this guy
00106 # define finite _finite       // they just have a different name for this guy
00107 # define isnan _isnan         // they just have a different name for this guy
00108 #ifndef __CYGWIN__
00109       #define NOMINMAX
00110    //# define abs64 _abs64
00111    //# define min _cpp_min         // they just have a different name for this guy
00112    //# define max _cpp_max         // they just have a different name for this guy
00113 #else //not CYGWIN
00114    #define abs64 abs
00115 #endif  //CYGWIN
00116 #else //WIN32
00117 # define C_INT64 long long int
00118 # ifndef LLONG_MAX
00119 #    define  LLONG_MAX LONG_LONG_MAX
00120 # endif
00121 # define LLONG_CONST(n) n ## LL
00122 # define C_INT32 long
00123 # define C_INT16 short
00124 # define C_FLOAT64 double
00125 # define C_FLOAT32 float
00126 # define abs64 abs
00127 #endif
00128 
00129 #ifdef _APPLE
00130 #include <cmath>
00131 # ifndef isnan
00132 #  define isnan(__x) ((__x == __x) != true)
00133 # endif
00134 #endif
00135 
00136 #if (defined __GNUC__ && __GNUC__ < 3)
00137 # define ios_base ios
00138 #endif
00139 
00140 # if (defined USE_CLAPACK || defined USE_LAPACK || defined Darwin)
00141 #  define C_INT long
00142 # else
00143 # if (defined USE_MKL || defined USE_SUNPERF || defined __x86_64)
00144 # define C_INT int
00145 # else
00146 #  error Neither USE_CLAPACK, USE_LAPACK, USE_SUNPERF, or USE_MKL is defined!
00147 # endif
00148 #endif
00149 
00150 enum TriLogic
00151 {
00152   TriUnspecified = -1,
00153   TriFalse = 0,
00154   TriTrue = 1
00155 };
00156 
00157 /* This is necessary to link with Intel MKL 721 under Visual C++ 8 */
00158 // #if defined COPASI_MAIN && defined USE_MKL && defined _MSC_VER && _MSC_VER > 1200 && defined _DLL
00159 // extern "C" {FILE _iob[3] = {__iob_func()[0], __iob_func()[1], __iob_func()[2]};}
00160 // #endif
00161 
00162 #ifdef COPASI_MAIN
00163 class CCopasiRootContainer;
00164 CCopasiRootContainer * pRootContainer = NULL;
00165 
00166 class QMutex;
00167 QMutex * pCopasiGuiMutex = NULL;
00168 #endif
00169 
00170 /* Define Constructor/Destructor Trace */
00171 #ifdef COPASI_DEBUG
00172 # include <time.h>
00173 # include <sys/timeb.h>
00174 
00175 # ifdef COPASI_MAIN
00176 #  ifndef Darwin
00177 struct timeb C_init_time;
00178 unsigned C_INT32 C_last_time = 0;
00179 unsigned C_INT32 C_this_time;
00180 #  endif // !Darwin
00181 std::ofstream DebugFile("trace");
00182 # else // not COPASI_MAIN
00183 #  include <fstream>
00184 #  ifndef Darwin
00185 extern struct timeb C_init_time;
00186 extern unsigned C_INT32 C_last_time;
00187 extern unsigned C_INT32 C_this_time;
00188 #  endif // !Darwin
00189 extern std::ofstream DebugFile;
00190 # endif // COPASI_MAIN
00191 
00192 # ifndef Darwin
00193 #  include <iostream>
00194 #  define TIME_TRACE(f, l) {\
00195     ftime(&C_init_time); \
00196     C_this_time = C_init_time.time * 1000 + C_init_time.millitm; \
00197     DebugFile << f <<"(" << l << "):\t" << C_this_time - C_last_time  << std::endl; \
00198     C_last_time = C_this_time;\
00199   }
00200 # endif // !Darwin
00201 
00202 # if (defined COPASI_TRACE_CONSTRUCTION)
00203 #  include <typeinfo>
00204 #  define CONSTRUCTOR_TRACE \
00205   {DebugFile << "Construct:\t" << typeid(*this).name() \
00206     << "\tAddress:\t" << (void *) this << std::endl;}
00207 #  define DESTRUCTOR_TRACE \
00208   {DebugFile << "Destruct:\t" << typeid(*this).name() \
00209     << "\tAddress:\t" << (void *) this << std::endl;}
00210 # endif // COPASI_TRACE_CONSTRUCTION
00211 
00212 # define DEBUG_OUT(s) {DebugFile << (s) << std::endl;}
00213 #else
00214 # ifndef NDEBUG
00215 #  define NDEBUG
00216 # endif // not NDEBUG
00217 # define DEBUG_OUT(s)
00218 #endif // COPASI_DEBUG
00219 
00220 #ifndef CONSTRUCTOR_TRACE
00221 # define CONSTRUCTOR_TRACE
00222 #endif
00223 
00224 #ifndef DESTRUCTOR_TRACE
00225 # define DESTRUCTOR_TRACE
00226 #endif
00227 
00228 #ifndef TIME_TRACE
00229 # define TIME_TRACE(f, l)
00230 #endif
00231 
00232 // protected free
00233 #define pfree(p) {if (p) {free(p); p = NULL;}}
00234 #define pdelete(p) {if (p) {delete p; p = NULL;}}
00235 #define pdeletev(p) {if (p) {delete[] p; p = NULL;}}
00236 #define pcleanup(p) {if (p) {p->cleanup(); delete p; p = NULL;}}
00237 
00238 // suppress unused parameter warnings
00239 #define C_UNUSED(p)
00240 #define COPASI_DEPRECATED
00241 #define C_INVALID_INDEX (std::numeric_limits< unsigned C_INT32 >::max())
00242 #endif // COPASI_copasi
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines