Skip to content

Commit

Permalink
SedModel: prevent GCC (and Clang) from complaining about SedModel::Im…
Browse files Browse the repository at this point in the history
…pl::serialise() hiding SedBase::Impl::serialise().

I originally wanted to do for GCC what we did for Clang, but it didn't work. So, I rearranged things instead.
  • Loading branch information
agarny committed Jan 15, 2025
1 parent 02d81d2 commit 88d2f17
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/sed/seddocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ std::string SedDocument::Impl::serialise(const std::string &pBasePath) const
xmlAddChild(node, sedListOfModels);

for (const auto &model : mModels) {
model->pimpl()->serialise(sedListOfModels, pBasePath);
model->pimpl()->setBasePath(pBasePath);
model->pimpl()->serialise(sedListOfModels);
}
}

Expand Down
13 changes: 9 additions & 4 deletions src/sed/sedmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,25 @@ bool SedModel::Impl::isValid()
return !hasErrors();
}

void SedModel::Impl::serialise(xmlNodePtr pNode, const std::string &pBasePath) const
void SedModel::Impl::setBasePath(const std::string &pBasePath)
{
mBasePath = pBasePath;
}

void SedModel::Impl::serialise(xmlNodePtr pNode) const
{
auto *node = xmlNewNode(nullptr, toConstXmlCharPtr("model"));

SedBase::Impl::serialise(node);

xmlNewProp(node, toConstXmlCharPtr("language"), toConstXmlCharPtr("urn:sedml:language:cellml"));

auto source = pBasePath.empty() ?
auto source = mBasePath.empty() ?
urlPath(mFile->path()) :
#ifdef BUILDING_USING_MSVC
forwardSlashPath(relativePath(mFile->path(), pBasePath));
forwardSlashPath(relativePath(mFile->path(), mBasePath));
#else
relativePath(mFile->path(), pBasePath);
relativePath(mFile->path(), mBasePath);
#endif

xmlNewProp(node, toConstXmlCharPtr("source"), toConstXmlCharPtr(source));
Expand Down
10 changes: 3 additions & 7 deletions src/sed/sedmodel_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace libOpenCOR {
class SedModel::Impl: public SedBase::Impl
{
public:
std::string mBasePath;
FilePtr mFile;

explicit Impl(const SedDocumentPtr &pDocument, const FilePtr &pFile);
Expand All @@ -33,13 +34,8 @@ class SedModel::Impl: public SedBase::Impl

bool isValid();

#ifdef BUILDING_USING_CLANG
// Prevent Clang from complaining about SedModel::Impl::serialise() hiding SedBase::Impl::serialise().

using SedBase::Impl::serialise;
#endif

void serialise(xmlNodePtr pNode, const std::string &pBasePath) const;
void setBasePath(const std::string &pBasePath);
void serialise(xmlNodePtr pNode) const override;
};

} // namespace libOpenCOR

0 comments on commit 88d2f17

Please sign in to comment.