openModeller  Version 1.4.0
os_specific.hh
Go to the documentation of this file.
00001 
00028 #ifndef _OS_SPECIFICHH_
00029 #define _OS_SPECIFICHH_
00030 
00031 #if (defined(__unix__) || defined(unix) || defined(__APPLE__)) && !defined(USG)
00032 #include <sys/param.h>
00033 #define dllexp
00034 #define OM_ALG_DLL_EXPORT
00035 #define OM_XML_DLL_EXPORT
00036 #endif
00037 
00046 #ifdef BSD
00047 #include <sys/sysctl.h>
00048 #include <err.h>
00049 #endif
00050 
00051 #include <vector>
00052 #include <string>
00053 
00054 /****************************************************************/
00055 /****** DEFINE MACRO TO NEATLY HANDLE UNUSED VARS ***************/
00056 #ifdef _MSC_VER
00057   // fake use to make unused variable warnings go away in Visual C++
00058   #define UNUSED(symbol) symbol
00059 #else
00060   #define UNUSED(symbol)
00061 #endif
00062 
00063 /****************************************************************/
00064 /****** Replace finite with _finite when using MSVC *************/
00065 #ifdef _MSC_VER
00066   #define finite _finite // function used by maxent
00067 #endif
00068 
00069 /****************************************************************/
00070 /****** Sleep function (millisenconds) **************************/
00071 #ifdef WIN32
00072 #include <windows.h>
00073 #else
00074 #include <unistd.h>
00075 #define Sleep(x) usleep((x)*1000)
00076 #endif
00077 
00078 
00079 /****************************************************************/
00080 /********************* Dynamic Linking Loader *******************/
00081 
00082 #ifdef WIN32 
00083 #include <windows.h>
00084 typedef HMODULE DLLHandle;
00085 #else
00086 typedef void *DLLHandle;
00087 #endif
00088 
00089 extern DLLHandle   dllOpen    ( char const *dll_file_name );
00090 extern void       *dllFunction( DLLHandle, char const *function_name );
00091 extern int         dllClose   ( DLLHandle );
00092 extern const char *dllError   ( DLLHandle );
00093 
00098 dllexp void setupExternalResources();
00099 
00105 dllexp std::string omDataPath( std::string dir="" );
00106 
00111 std::vector<std::string> initialPluginPath();
00112 
00120 std::vector<std::string> scanDirectory( std::string dir );
00121 
00129 dllexp int initRandom( unsigned int new_seed=0 );
00130 
00131 #ifdef WIN32 
00132 // rand_r implementation for Windows
00133 dllexp int rand_r( unsigned * seed );
00134 #endif
00135 
00140 std::string getWorkingPath();
00141 
00147 bool pathExists( const std::string path );
00148 
00154 bool createPath( const std::string path );
00155 
00156 #endif