Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #define FREPPLE_CORE
00029 #include "frepple.h"
00030 #include "freppleinterface.h"
00031 using namespace frepple;
00032 #include <sys/stat.h>
00033
00034
00035 DECLARE_EXPORT(const char*) FreppleVersion()
00036 {
00037 return PACKAGE_VERSION;
00038 }
00039
00040
00041 DECLARE_EXPORT(void) FreppleInitialize()
00042 {
00043
00044 static bool initialized = false;
00045 if (initialized) return;
00046 initialized = true;
00047
00048
00049 LibraryModel::initialize();
00050 LibrarySolver::initialize();
00051
00052
00053 string init = Environment::searchFile("init.py");
00054 if (!init.empty())
00055 {
00056
00057 try
00058 {
00059 CommandPython cmd;
00060 cmd.setFileName(init);
00061 cmd.execute();
00062 }
00063 catch (...)
00064 {
00065 logger << "Exception caught during execution of 'init.py'" << endl;
00066 throw;
00067 }
00068 }
00069
00070
00071 init = Environment::searchFile("init.xml");
00072 if (!init.empty())
00073 {
00074
00075 try {CommandReadXMLFile(init).execute();}
00076 catch (...)
00077 {
00078 logger << "Exception caught during execution of 'init.xml'" << endl;
00079 throw;
00080 }
00081 }
00082 }
00083
00084
00085 DECLARE_EXPORT(void) FreppleReadXMLData (const char* x, bool validate, bool validateonly)
00086 {
00087 if (x) CommandReadXMLString(string(x), validate, validateonly).execute();
00088 }
00089
00090
00091 DECLARE_EXPORT(void) FreppleReadXMLFile (const char* x, bool validate, bool validateonly)
00092 {
00093 CommandReadXMLFile(x, validate, validateonly).execute();
00094 }
00095
00096
00097 DECLARE_EXPORT(void) FreppleSaveFile(const char* x)
00098 {
00099 CommandSave(x).execute();
00100 }
00101
00102
00103
00104
00105
00106
00107
00108 DECLARE_EXPORT(void) FreppleExit()
00109 {
00110
00111 Environment::setLogFile("");
00112 }
00113
00114
00115 DECLARE_EXPORT(void) FreppleLog(const string& msg)
00116 {
00117 logger << msg << endl;
00118 }
00119
00120
00121 extern "C" DECLARE_EXPORT(void) FreppleLog(const char* msg)
00122 {
00123 logger << msg << endl;
00124 }
00125
00126
00127 extern "C" DECLARE_EXPORT(int) FreppleWrapperInitialize()
00128 {
00129 try {FreppleInitialize();}
00130 catch (...) {return EXIT_FAILURE;}
00131 return EXIT_SUCCESS;
00132 }
00133
00134
00135 extern "C" DECLARE_EXPORT(int) FreppleWrapperReadXMLData(char* d, bool v, bool c)
00136 {
00137 try {FreppleReadXMLData(d, v, c);}
00138 catch (...) {return EXIT_FAILURE;}
00139 return EXIT_SUCCESS;
00140 }
00141
00142
00143 extern "C" DECLARE_EXPORT(int) FreppleWrapperReadXMLFile(const char* f, bool v, bool c)
00144 {
00145 try {FreppleReadXMLFile(f, v, c);}
00146 catch (...) {return EXIT_FAILURE;}
00147 return EXIT_SUCCESS;
00148 }
00149
00150
00151 extern "C" DECLARE_EXPORT(int) FreppleWrapperSaveFile(char* f)
00152 {
00153 try {FreppleSaveFile(f);}
00154 catch (...) {return EXIT_FAILURE;}
00155 return EXIT_SUCCESS;
00156 }
00157
00158
00159 extern "C" DECLARE_EXPORT(int) FreppleWrapperExit()
00160 {
00161 try {FreppleExit();}
00162 catch (...) {return EXIT_FAILURE;}
00163 return EXIT_SUCCESS;
00164 }
00165