Skip to content

Commit

Permalink
Use \n instead of std::endl to avoid flushing of stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
shoops committed Feb 5, 2025
1 parent 8a6f041 commit 4af20ee
Show file tree
Hide file tree
Showing 113 changed files with 1,503 additions and 1,604 deletions.
30 changes: 29 additions & 1 deletion copasi/MIRIAM/CMIRIAMResource.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019 - 2022 by Pedro Mendes, Rector and Visitors of the
// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the
// University of Virginia, University of Heidelberg, and University
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -31,9 +31,12 @@
#include "CRDFTriplet.h"
#include "CRDFNode.h"

#include "copasi/commandline/COptions.h"
#include "copasi/utilities/CCopasiException.h"
#include "copasi/utilities/CDirEntry.h"
#include "copasi/core/CRootContainer.h"
#include "copasi/commandline/CConfigurationFile.h"
#include "copasi/xml/CGroupXML.h"

#include <sbml/xml/XMLNode.h>
#include <sbml/xml/XMLAttributes.h>
Expand Down Expand Up @@ -298,6 +301,31 @@ const CMIRIAMResources & CMIRIAMResources::operator=(const CCopasiParameterGroup
return *this;
}

bool CMIRIAMResources::save()
{
std::string FileName = COptions::getConfigDir() + CDirEntry::Separator + "MIRIAMResources.xml";
CGroupXML XML(*this);

bool success = XML.CCopasiXMLInterface::save(FileName, CDirEntry::dirName(FileName));

return success;
}

bool CMIRIAMResources::load()
{
std::string FileName = COptions::getConfigDir() + CDirEntry::Separator + "MIRIAMResources.xml";

CMIRIAMResource Loaded;
CGroupXML XML(Loaded);

bool success = XML.CCopasiXMLInterface::save(FileName, CDirEntry::dirName(FileName));

if (success)
*this = Loaded;

return success;
}

void CMIRIAMResources::createDisplayNameMap()
{
mDisplayName2Resource.clear();
Expand Down
14 changes: 13 additions & 1 deletion copasi/MIRIAM/CMIRIAMResource.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the
// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the
// University of Virginia, University of Heidelberg, and University
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -263,6 +263,18 @@ class CMIRIAMResources : public CCopasiParameterGroup
*/
virtual bool elevateChildren();

/**
* Save the configuration file.
* @return bool success
*/
virtual bool save();

/**
* Load the configuration file.
* @return bool success
*/
virtual bool load();

/**
* Assignment operator
* @param const CCopasiParameterGroup & rhs
Expand Down
51 changes: 25 additions & 26 deletions copasi/MIRIAM/CRDFPredicate.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the
// University of Virginia, University of Heidelberg, and University
// of Connecticut School of Medicine.
// All rights reserved.

// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.

// Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.

// Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., EML Research, gGmbH, University of Heidelberg,
// and The University of Manchester.
// All rights reserved.
// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the
// University of Virginia, University of Heidelberg, and University
// of Connecticut School of Medicine.
// All rights reserved.

// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.

// Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.

// Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., EML Research, gGmbH, University of Heidelberg,
// and The University of Manchester.
// All rights reserved.

#include "copasi/copasi.h"

Expand Down Expand Up @@ -149,7 +149,6 @@ const std::string CRDFPredicate::PredicatePrefix[] =
"end" // end
};


// static
std::map< std::string, CRDFPredicate::ePredicateType > CRDFPredicate::URI2Predicate;

Expand Down Expand Up @@ -627,7 +626,7 @@ std::string CRDFPredicate::getElementNameForType(ePredicateType type)
{
if (type < copasi_encodes || type >= unknown)
return std::string();

return PredicatePrefix[type];
}

Expand Down Expand Up @@ -822,15 +821,15 @@ std::ostream & operator << (std::ostream & os, const CRDFPredicate::Path & path)
for (; it != end; ++it)
os << *it << " ";

return os << std::endl;
return os << "\n";
}

std::ostream & operator << (std::ostream & os, const CRDFPredicate::sAllowedLocation & location)
{
os << "MaxOccurance: " << location.MaxOccurance << std::endl;
os << "ReadOnly: " << location.ReadOnly << std::endl;
os << "Type: " << location.Type << std::endl;
os << location.Location << std::endl;
os << "MaxOccurance: " << location.MaxOccurance << "\n";
os << "ReadOnly: " << location.ReadOnly << "\n";
os << "Type: " << location.Type << "\n";
os << location.Location << "\n";

return os;
}
6 changes: 3 additions & 3 deletions copasi/MIRIAM/CRDFTriplet.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019 by Pedro Mendes, Rector and Visitors of the
// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the
// University of Virginia, University of Heidelberg, and University
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -61,10 +61,10 @@ std::ostream & operator << (std::ostream & os, const CRDFTriplet & triplet)
{
os << triplet.pSubject->getSubject() << ", ";
os << triplet.Predicate.getURI() << ", ";
os << triplet.pObject->getObject() << std::endl;
os << triplet.pObject->getObject() << "\n";
}
else
os << "Invalid Triplet" << std::endl;
os << "Invalid Triplet" << "\n";

return os;
}
14 changes: 7 additions & 7 deletions copasi/UI/CQBrowserPaneDM.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the
// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the
// University of Virginia, University of Heidelberg, and University
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -1220,12 +1220,12 @@ int CQBrowserPaneDM::CNode::getRow() const

std::ostream & operator<<(std::ostream &os, const CQBrowserPaneDM::CNode & n)
{
os << "CQBrowserPaneDM::CNode:" << std::endl;
//os << " mChemicalEquation: " << d.getChemicalEquation() << std::endl;
//os << " mChemicalEquationConverted: " << d.getChemicalEquationConverted() << std::endl;
os << "CQBrowserPaneDM::CNode:" << "\n";
//os << " mChemicalEquation: " << d.getChemicalEquation() << "\n";
//os << " mChemicalEquationConverted: " << d.getChemicalEquationConverted() << "\n";

os << " mId: " << (size_t) n.mData.mId << std::endl;
os << " mCN: " << n.mData.mCN << std::endl;
os << " mDisplayRole: " << TO_UTF8(n.mData.mDisplayRole) << std::endl;
os << " mId: " << (size_t) n.mData.mId << "\n";
os << " mCN: " << n.mData.mCN << "\n";
os << " mDisplayRole: " << TO_UTF8(n.mData.mDisplayRole) << "\n";
return os;
}
10 changes: 5 additions & 5 deletions copasi/UI/CQDifferentialEquations.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019 - 2021 by Pedro Mendes, Rector and Visitors of the
// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the
// University of Virginia, University of Heidelberg, and University
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -93,13 +93,13 @@ void CQDifferentialEquations::saveMML(const QString& outfilename)
std::ofstream ofile;
ofile.open(CLocaleString::fromUtf8(TO_UTF8(outfilename)).c_str(), std::ios::trunc);

ofile << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
ofile << "<!DOCTYPE math PUBLIC \"-//W3C//DTD MathML 2.0//EN\" \"http://www.w3.org/Math/DTD/mathml2/mathml2.dtd\">" << std::endl;
ofile << "<math xmlns=\"http://www.w3.org/1998/Math/MathML\">" << std::endl;
ofile << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << "\n";
ofile << "<!DOCTYPE math PUBLIC \"-//W3C//DTD MathML 2.0//EN\" \"http://www.w3.org/Math/DTD/mathml2/mathml2.dtd\">" << "\n";
ofile << "<math xmlns=\"http://www.w3.org/1998/Math/MathML\">" << "\n";

ofile << mml.str();

ofile << "</math>" << std::endl;
ofile << "</math>" << "\n";

ofile.close();
}
Expand Down
11 changes: 5 additions & 6 deletions copasi/UI/CQExpressionMmlStackedWidget.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019 - 2023 by Pedro Mendes, Rector and Visitors of the
// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the
// University of Virginia, University of Heidelberg, and University
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -165,7 +165,6 @@ void CQExpressionMmlStackedWidget::reset()
mpExpressionWidget->setExpression("");

updateWidget();

}

void CQExpressionMmlStackedWidget::init()
Expand Down Expand Up @@ -271,13 +270,13 @@ void CQExpressionMmlStackedWidget::saveMML(const QString& outfilename)
std::ofstream ofile;
ofile.open(CLocaleString::fromUtf8(TO_UTF8(outfilename)).c_str(), std::ios::trunc);

ofile << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
ofile << "<!DOCTYPE math PUBLIC \"-//W3C//DTD MathML 2.0//EN\" \"http://www.w3.org/Math/DTD/mathml2/mathml2.dtd\">" << std::endl;
ofile << "<math xmlns=\"http://www.w3.org/1998/Math/MathML\">" << std::endl;
ofile << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << "\n";
ofile << "<!DOCTYPE math PUBLIC \"-//W3C//DTD MathML 2.0//EN\" \"http://www.w3.org/Math/DTD/mathml2/mathml2.dtd\">" << "\n";
ofile << "<math xmlns=\"http://www.w3.org/1998/Math/MathML\">" << "\n";

mpExpressionWidget->writeMathML(ofile);

ofile << "</math>" << std::endl;
ofile << "</math>" << "\n";

ofile.close();
}
Expand Down
12 changes: 6 additions & 6 deletions copasi/UI/CQExpressionWidget.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the
// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the
// University of Virginia, University of Heidelberg, and University
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -60,11 +60,11 @@
#ifdef DEBUG_UI
std::ostream & operator<<(std::ostream & os, const QTextCursor & d)
{
os << "Position: " << d.position() << std::endl;
os << "Selection Start: " << d.selectionStart() << std::endl;
os << "Selection End: " << d.selectionEnd() << std::endl;
os << "Anchor: " << d.anchor() << std::endl;
os << "Selected Text: " << TO_UTF8(d.selectedText()) << std::endl;
os << "Position: " << d.position() << "\n";
os << "Selection Start: " << d.selectionStart() << "\n";
os << "Selection End: " << d.selectionEnd() << "\n";
os << "Anchor: " << d.anchor() << "\n";
os << "Selected Text: " << TO_UTF8(d.selectedText()) << "\n";
return os;
}
#endif // DEBUG_UI
Expand Down
22 changes: 11 additions & 11 deletions copasi/UI/CQOptimizationResult.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the
// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the
// University of Virginia, University of Heidelberg, and University
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -222,38 +222,38 @@ void CQOptimizationResult::slotSave(void)
if (file.fail()) return;

// The global result and statistics
file << "Objective Value" << std::endl;
file << mpProblem->getSolutionValue() << std::endl;
file << "Objective Value" << "\n";
file << mpProblem->getSolutionValue() << "\n";

file << "Function Evaluations\tCPU Time [s]\tEvaluations/second [1/s]" << std::endl;
file << "Function Evaluations\tCPU Time [s]\tEvaluations/second [1/s]" << "\n";
const size_t & FunctionEvaluations = mpProblem->getFunctionEvaluations();
const C_FLOAT64 & ExecutionTime = mpProblem->getExecutionTime();
file << FunctionEvaluations << "\t";
file << ExecutionTime << "\t";
file << FunctionEvaluations / ExecutionTime << std::endl << std::endl;
file << FunctionEvaluations / ExecutionTime << "\n" << "\n";

// Set up the parameters table
file << "Parameters:" << std::endl;
file << "Parameters:" << "\n";
file << TO_UTF8(toTsvString(mpParameters->model(), true, false))
<< std::endl;
<< "\n";

// log
const COptMethod * pMethod = dynamic_cast<const COptMethod *>(mpTask->getMethod());

if (pMethod)
{

file << std::endl;
file << "\n";

// Set up log output
file << "Method Log:" << std::endl;
file << "Method Log:" << "\n";

file << pMethod->getMethodLog().getPlainLog().c_str();

file << std::endl;
file << "\n";
}

file << std::endl;
file << "\n";
}

void CQOptimizationResult::slotUpdateModel()
Expand Down
Loading

0 comments on commit 4af20ee

Please sign in to comment.