Пример #1
0
bool CCompiler::compileSource(const string& sourceFileName)
{
    //Compile the code and load the resulting dll, and call an exported function in it...
#if defined(_WIN32) || defined(__CODEGEARC__)
    string dllFName(changeFileExtensionTo(getFileName(sourceFileName), "dll"));
#elif defined(__unix__)
    string dllFName(changeFileExtensionTo(getFileName(sourceFileName), "so"));
#elif defined(__APPLE__)
    string dllFName(changeFileExtensionTo(getFileName(sourceFileName), "dylib"));
#endif
    mDLLFileName = joinPath(getFilePath(sourceFileName), dllFName);

    //Setup compiler environment
    setupCompilerEnvironment();

    string exeCmd = createCompilerCommand(sourceFileName);

    //exeCmd += " > compileLog.log";
    Log(lDebug2)<<"Compiling model..";
    Log(lDebug)<<"\nExecuting compile command: "<<exeCmd;

    if(!compile(exeCmd))
    {
        Log(Logger::LOG_ERROR)<<"Creating DLL failed..";
        throw Exception("Creating Model DLL failed..");
    }

    //Check if the DLL exists...
    return fileExists(mDLLFileName);
}
bool SBMLModelSimulation::SaveResult()
{
    string resultFileName(joinPath(mDataOutputFolder, "rr_" + mModelFileName));
    resultFileName = changeFileExtensionTo(resultFileName, ".csv");
    Log(lInfo)<<"Saving result to file: "<<resultFileName;
    RoadRunnerData resultData(mEngine);

    ofstream fs(resultFileName.c_str());
    fs << resultData;
    fs.close();
    return true;
}
Пример #3
0
string getFileNameNoExtension(const string& fileN)
{
    string fName;
    if(fileN.find_last_of( '\\' ) != std::string::npos)
    {
        fName = fileN.substr(fileN.find_last_of( '\\' )+ 1, fileN.size());
    }
    else if(fileN.find_last_of( '/' ) != std::string::npos)
    {
        fName = fileN.substr(fileN.find_last_of( '/' ) + 1, fileN.size());
    }
    else
    {
        fName = fileN;
    }

    return changeFileExtensionTo(fName, "");
}
bool SBMLModelSimulation::SaveModelAsXML(const string& folder)
{
    if(!mEngine)
    {
        return false;
    }
    string fName = joinPath(folder, mModelFileName);
    fName = changeFileExtensionTo(fName, "xml");

    fstream fs(fName.c_str(), fstream::out);

    if(!fs)
    {
        Log(Logger::LOG_ERROR)<<"Failed writing sbml to file "<< fName;
        return false;
    }
    fs<<mEngine->getSBML();
    fs.close();
    return true;
}