Skip to content

Commit

Permalink
Allow various 'get' functions to work with const input.
Browse files Browse the repository at this point in the history
Needed a couple particular functions for Antimony, so implemented support for those and several others.  Many many other possible functions could be similarly updated, but it's very late in the process to suddenly realize that 'gets' only need const input, so this is probably fine for now.
  • Loading branch information
luciansmith committed Dec 12, 2024
1 parent a9e6ef5 commit 6c4aa1c
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 128 deletions.
34 changes: 17 additions & 17 deletions src/features/error_log/libsbmlnetwork_error_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void error_log_clearErrorLog(SBMLDocument* document) {
}
}

const std::string error_log_getErrorLog(Layout* layout) {
const std::string error_log_getErrorLog(const Layout* layout) {
std::string errorLog = "";
if (layout) {
errorLog += error_log_prepareErrorMessage(user_data_getUserData(layout, "error_log"), errorLog);
Expand Down Expand Up @@ -89,14 +89,14 @@ void error_log_clearErrorLog(Layout* layout) {
}
}

const std::string error_log_getErrorLog(GraphicalObject* graphicalObject) {
const std::string error_log_getErrorLog(const GraphicalObject* graphicalObject) {
std::string errorLog = "";
if (graphicalObject)
errorLog += error_log_prepareErrorMessage(user_data_getUserData(graphicalObject, "error_log"), errorLog);
if (graphicalObject->getBoundingBox())
errorLog += error_log_prepareErrorMessage(error_log_getErrorLog(graphicalObject->getBoundingBox()), errorLog);
if (isSetCurve(graphicalObject))
errorLog += error_log_prepareErrorMessage(error_log_getErrorLog(getCurve(graphicalObject)), errorLog);
errorLog += error_log_prepareErrorMessage(error_log_getErrorLog(getCurve(const_cast<GraphicalObject*>(graphicalObject))), errorLog);

return errorLog;
}
Expand All @@ -111,7 +111,7 @@ void error_log_clearErrorLog(GraphicalObject* graphicalObject) {
}
}

const std::string error_log_getErrorLog(BoundingBox* boundingBox) {
const std::string error_log_getErrorLog(const BoundingBox* boundingBox) {
std::string errorLog = "";
if (boundingBox)
errorLog += error_log_prepareErrorMessage(user_data_getUserData(boundingBox, "error_log"), errorLog);
Expand All @@ -124,12 +124,12 @@ void error_log_clearErrorLog(BoundingBox* boundingBox) {
user_data_setUserData(boundingBox, "error_log", "");
}

const std::string error_log_getErrorLog(Curve* curve) {
const std::string error_log_getErrorLog(const Curve* curve) {
std::string errorLog = "";
if (curve)
errorLog += error_log_prepareErrorMessage(user_data_getUserData(curve, "error_log"), errorLog);
for (unsigned int i = 0; i < getNumCurveSegments(curve); i++)
errorLog += error_log_prepareErrorMessage(error_log_getErrorLog(getCurveSegment(curve, i)), errorLog);
errorLog += error_log_prepareErrorMessage(error_log_getErrorLog(getCurveSegment(const_cast<Curve*>(curve), i)), errorLog);

return errorLog;
}
Expand All @@ -142,7 +142,7 @@ void error_log_clearErrorLog(Curve* curve) {
}
}

const std::string error_log_getErrorLog(LineSegment* lineSegment) {
const std::string error_log_getErrorLog(const LineSegment* lineSegment) {
std::string errorLog = "";
if (lineSegment)
errorLog += error_log_prepareErrorMessage(user_data_getUserData(lineSegment, "error_log"), errorLog);
Expand All @@ -155,14 +155,14 @@ void error_log_clearErrorLog(LineSegment* lineSegment) {
user_data_setUserData(lineSegment, "error_log", "");
}

const std::string error_log_getErrorLog(RenderInformationBase* renderInformation) {
const std::string error_log_getErrorLog(const RenderInformationBase* renderInformation) {
std::string errorLog = "";
if (renderInformation)
errorLog += error_log_prepareErrorMessage(user_data_getUserData(renderInformation, "error_log"), errorLog);
for (unsigned int i = 0; i < renderInformation->getNumColorDefinitions(); i++)
errorLog += error_log_prepareErrorMessage(error_log_getErrorLog(renderInformation->getColorDefinition(i)), errorLog);
for (unsigned int i = 0; i < renderInformation->getNumGradientDefinitions(); i++) {
GradientBase* gradientBase = renderInformation->getGradientDefinition(i);
const GradientBase* gradientBase = renderInformation->getGradientDefinition(i);
errorLog += error_log_prepareErrorMessage(error_log_getErrorLog(gradientBase), errorLog);
for (unsigned int j = 0; j < gradientBase->getNumGradientStops(); j++)
errorLog += error_log_prepareErrorMessage(error_log_getErrorLog(gradientBase->getGradientStop(j)), errorLog);
Expand Down Expand Up @@ -205,7 +205,7 @@ void error_log_clearErrorLog(RenderInformationBase* renderInformation) {
}
}

const std::string error_log_getErrorLog(ColorDefinition* colorDefinition) {
const std::string error_log_getErrorLog(const ColorDefinition* colorDefinition) {
std::string errorLog = "";
if (colorDefinition)
errorLog += error_log_prepareErrorMessage(user_data_getUserData(colorDefinition, "error_log"), errorLog);
Expand All @@ -218,7 +218,7 @@ void error_log_clearErrorLog(ColorDefinition* colorDefinition) {
user_data_setUserData(colorDefinition, "error_log", "");
}

const std::string error_log_getErrorLog(GradientBase* gradientBase) {
const std::string error_log_getErrorLog(const GradientBase* gradientBase) {
std::string errorLog = "";
if (gradientBase)
errorLog += error_log_prepareErrorMessage(user_data_getUserData(gradientBase, "error_log"), errorLog);
Expand All @@ -231,7 +231,7 @@ void error_log_clearErrorLog(GradientBase* gradientBase) {
user_data_setUserData(gradientBase, "error_log", "");
}

const std::string error_log_getErrorLog(GradientStop* gradientStop) {
const std::string error_log_getErrorLog(const GradientStop* gradientStop) {
std::string errorLog = "";
if (gradientStop)
errorLog += error_log_prepareErrorMessage(user_data_getUserData(gradientStop, "error_log"), errorLog);
Expand All @@ -244,7 +244,7 @@ void error_log_clearErrorLog(GradientStop* gradientStop) {
user_data_setUserData(gradientStop, "error_log", "");
}

const std::string error_log_getErrorLog(LineEnding* lineEnding) {
const std::string error_log_getErrorLog(const LineEnding* lineEnding) {
std::string errorLog = "";
if (lineEnding)
errorLog += error_log_prepareErrorMessage(user_data_getUserData(lineEnding, "error_log"), errorLog);
Expand All @@ -257,7 +257,7 @@ void error_log_clearErrorLog(LineEnding* lineEnding) {
user_data_setUserData(lineEnding, "error_log", "");
}

const std::string error_log_getErrorLog(Style* style) {
const std::string error_log_getErrorLog(const Style* style) {
std::string errorLog = "";
if (style) {
errorLog += error_log_prepareErrorMessage(user_data_getUserData(style, "error_log"), errorLog);
Expand All @@ -274,7 +274,7 @@ void error_log_clearErrorLog(Style* style) {
}
}

const std::string error_log_getErrorLog(RenderGroup* renderGroup) {
const std::string error_log_getErrorLog(const RenderGroup* renderGroup) {
std::string errorLog = "";
if (renderGroup) {
errorLog += error_log_prepareErrorMessage(user_data_getUserData(renderGroup, "error_log"), errorLog);
Expand All @@ -293,7 +293,7 @@ void error_log_clearErrorLog(RenderGroup* renderGroup) {
}
}

const std::string error_log_getErrorLog(Transformation2D* transformation2D) {
const std::string error_log_getErrorLog(const Transformation2D* transformation2D) {
std::string errorLog = "";
if (transformation2D)
errorLog += error_log_prepareErrorMessage(user_data_getUserData(transformation2D, "error_log"), errorLog);
Expand All @@ -306,7 +306,7 @@ void error_log_clearErrorLog(Transformation2D* transformation2D) {
user_data_setUserData(transformation2D, "error_log", "");
}

const std::string error_log_getErrorLog(SBase* sBase) {
const std::string error_log_getErrorLog(const SBase* sBase) {
std::string errorLog = "";
if (sBase)
errorLog = error_log_prepareErrorMessage(user_data_getUserData(sBase, "error_log"), errorLog);
Expand Down
28 changes: 14 additions & 14 deletions src/features/error_log/libsbmlnetwork_error_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,59 @@ using namespace libsbml;

namespace LIBSBMLNETWORK_CPP_NAMESPACE {

const std::string error_log_getErrorLog(Layout *layout);
const std::string error_log_getErrorLog(const Layout *layout);

void error_log_clearErrorLog(Layout *layout);

const std::string error_log_getErrorLog(GraphicalObject *graphicalObject);
const std::string error_log_getErrorLog(const GraphicalObject *graphicalObject);

void error_log_clearErrorLog(GraphicalObject *graphicalObject);

const std::string error_log_getErrorLog(BoundingBox *boundingBox);
const std::string error_log_getErrorLog(const BoundingBox *boundingBox);

void error_log_clearErrorLog(BoundingBox *boundingBox);

const std::string error_log_getErrorLog(Curve *curve);
const std::string error_log_getErrorLog(const Curve *curve);

void error_log_clearErrorLog(Curve *curve);

const std::string error_log_getErrorLog(LineSegment *lineSegment);
const std::string error_log_getErrorLog(const LineSegment *lineSegment);

void error_log_clearErrorLog(LineSegment *lineSegment);

const std::string error_log_getErrorLog(RenderInformationBase* renderInformation);
const std::string error_log_getErrorLog(const RenderInformationBase* renderInformation);

void error_log_clearErrorLog(RenderInformationBase* renderInformation);

const std::string error_log_getErrorLog(ColorDefinition* colorDefinition);
const std::string error_log_getErrorLog(const ColorDefinition* colorDefinition);

void error_log_clearErrorLog(ColorDefinition* colorDefinition);

const std::string error_log_getErrorLog(GradientBase* gradientBase);
const std::string error_log_getErrorLog(const GradientBase* gradientBase);

void error_log_clearErrorLog(GradientBase* gradientBase);

const std::string error_log_getErrorLog(GradientStop* gradientStop);
const std::string error_log_getErrorLog(const GradientStop* gradientStop);

void error_log_clearErrorLog(GradientStop* gradientStop);

const std::string error_log_getErrorLog(LineEnding* lineEnding);
const std::string error_log_getErrorLog(const LineEnding* lineEnding);

void error_log_clearErrorLog(LineEnding* lineEnding);

const std::string error_log_getErrorLog(Style* style);
const std::string error_log_getErrorLog(const Style* style);

void error_log_clearErrorLog(Style* style);

const std::string error_log_getErrorLog(RenderGroup* renderGroup);
const std::string error_log_getErrorLog(const RenderGroup* renderGroup);

void error_log_clearErrorLog(RenderGroup* renderGroup);

const std::string error_log_getErrorLog(Transformation2D* transformation2D);
const std::string error_log_getErrorLog(const Transformation2D* transformation2D);

void error_log_clearErrorLog(Transformation2D* transformation2D);

const std::string error_log_getErrorLog(SBase* sBase);
const std::string error_log_getErrorLog(const SBase* sBase);

void error_log_clearErrorLog(SBase* sBase);

Expand Down
4 changes: 2 additions & 2 deletions src/features/user_data/libsbmlnetwork_user_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int user_data_freeUserData(Layout* layout) {
return 0;
}

std::vector<std::map<std::string, std::string>> user_data_getUserData(Layout* layout) {
std::vector<std::map<std::string, std::string>> user_data_getUserData(const Layout* layout) {
std::vector<std::map<std::string, std::string>> userData;
for (unsigned int i = 0; i < layout->getNumCompartmentGlyphs(); i++) {
auto compartmentGlyphUserData = layout->getCompartmentGlyph(i)->getUserData();
Expand Down Expand Up @@ -198,7 +198,7 @@ int user_data_freeUserData(RenderInformationBase* renderInformation) {
return 0;
}

std::vector<std::map<std::string, std::string>> user_data_getUserData(RenderInformationBase* renderInformation) {
std::vector<std::map<std::string, std::string>> user_data_getUserData(const RenderInformationBase* renderInformation) {
std::vector<std::map<std::string, std::string>> userData;
for (unsigned int i = 0; i < renderInformation->getNumColorDefinitions(); i++) {
auto colorDefinitionUserData = renderInformation->getColorDefinition(i)->getUserData();
Expand Down
6 changes: 3 additions & 3 deletions src/features/user_data/libsbmlnetwork_user_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int user_data_freeUserData(SBMLDocument* document);

int user_data_freeUserData(Layout* layout);

std::vector<std::map<std::string, std::string>> user_data_getUserData(Layout* layout);
std::vector<std::map<std::string, std::string>> user_data_getUserData(const Layout* layout);

int user_data_setUserData(GraphicalObject* graphicalObject, const std::string& key, const std::string& value);

Expand All @@ -31,9 +31,9 @@ int user_data_setGraphicalObjectUserData(GraphicalObject* graphicalObject, const

int user_data_freeUserData(RenderInformationBase* renderInformation);

std::vector<std::map<std::string, std::string>> user_data_getUserData(RenderInformationBase* renderInformationBase);
std::vector<std::map<std::string, std::string>> user_data_getUserData(const RenderInformationBase* renderInformationBase);

const std::string user_data_getUserData(SBase* sbase, const std::string& key);
const std::string user_data_getUserData(const SBase* sbase, const std::string& key);

int user_data_setUserData(SBase* sBase, const std::string& key, const std::string& value);

Expand Down
42 changes: 21 additions & 21 deletions src/libsbmlnetwork_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,12 @@ const std::string getReactionId(GraphicalObject* reactionGlyph) {
return "";
}

bool isReactionGlyph(Layout* layout, const std::string& id, const unsigned int reactionGlyphIndex) {
return isReactionGlyph(getReactionGlyph(layout, id, reactionGlyphIndex));
bool isReactionGlyph(const Layout* layout, const std::string& id, const unsigned int reactionGlyphIndex) {
return isReactionGlyph(getReactionGlyph(const_cast<Layout*>(layout), id, reactionGlyphIndex));
}

bool isReactionGlyph(GraphicalObject* graphicalObject) {
if (dynamic_cast<ReactionGlyph*>(graphicalObject))
bool isReactionGlyph(const GraphicalObject* graphicalObject) {
if (dynamic_cast<const ReactionGlyph*>(graphicalObject))
return true;

return false;
Expand Down Expand Up @@ -552,8 +552,8 @@ const int getSpeciesReferenceIndexAssociatedWithSpecies(Layout* layout, const st
return -1;
}

bool isSpeciesReferenceGlyph(GraphicalObject* graphicalObject) {
if (dynamic_cast<SpeciesReferenceGlyph*>(graphicalObject))
bool isSpeciesReferenceGlyph(const GraphicalObject* graphicalObject) {
if (dynamic_cast<const SpeciesReferenceGlyph*>(graphicalObject))
return true;

return false;
Expand Down Expand Up @@ -617,11 +617,11 @@ bool isSetText(GraphicalObject* textGlyph) {
return false;
}

const std::string getText(Layout* layout, const std::string& id, unsigned int graphicalObjectIndex, unsigned int textGlyphIndex) {
return getText(getTextGlyph(layout, getGraphicalObject(layout, id, graphicalObjectIndex), textGlyphIndex));
const std::string getText(const Layout* layout, const std::string& id, unsigned int graphicalObjectIndex, unsigned int textGlyphIndex) {
return getText(getTextGlyph(const_cast<Layout*>(layout), getGraphicalObject(const_cast<Layout*>(layout), id, graphicalObjectIndex), textGlyphIndex));
}

const std::string getText(GraphicalObject* textGlyph) {
const std::string getText(const GraphicalObject* textGlyph) {
if (isTextGlyph(textGlyph))
return ((TextGlyph*)textGlyph)->getText();

Expand Down Expand Up @@ -758,12 +758,12 @@ GraphicalObject* getGraphicalObject(Layout* layout, GraphicalObject* textGlyph)
return getGraphicalObjectUsingItsOwnId(layout, getGraphicalObjectId(textGlyph));
}

bool isTextGlyph(Layout* layout, const std::string& id, unsigned int textGlyphIndex) {
return isTextGlyph(getTextGlyph(layout, id, textGlyphIndex));
bool isTextGlyph(const Layout* layout, const std::string& id, unsigned int textGlyphIndex) {
return isTextGlyph(getTextGlyph(const_cast<Layout*>(layout), id, textGlyphIndex));
}

bool isTextGlyph(GraphicalObject* graphicalObject) {
if (dynamic_cast<TextGlyph*>(graphicalObject))
bool isTextGlyph(const GraphicalObject* graphicalObject) {
if (dynamic_cast<const TextGlyph*>(graphicalObject))
return true;

return false;
Expand Down Expand Up @@ -1243,11 +1243,11 @@ int setTextDimensionHeight(Layout* layout, GraphicalObject* graphicalObject, uns
return -1;
}

bool isSetCurve(Layout* layout, const std::string& id, unsigned int graphicalObjectIndex) {
return isSetCurve(getGraphicalObject(layout, id, graphicalObjectIndex));
bool isSetCurve(const Layout* layout, const std::string& id, unsigned int graphicalObjectIndex) {
return isSetCurve(getGraphicalObject(const_cast<Layout*>(layout), id, graphicalObjectIndex));
}

bool isSetCurve(GraphicalObject* graphicalObject) {
bool isSetCurve(const GraphicalObject* graphicalObject) {
if (isReactionGlyph(graphicalObject))
return ((ReactionGlyph*)graphicalObject)->isSetCurve();
if (isSpeciesReferenceGlyph(graphicalObject))
Expand Down Expand Up @@ -1276,15 +1276,15 @@ int removeCurve(GraphicalObject* graphicalObject) {
return -1;
}

const unsigned int getNumCurveSegments(Layout* layout, const std::string& id, unsigned int graphicalObjectIndex) {
return getNumCurveSegments(getGraphicalObject(layout, id, graphicalObjectIndex));
const unsigned int getNumCurveSegments(const Layout* layout, const std::string& id, unsigned int graphicalObjectIndex) {
return getNumCurveSegments(getGraphicalObject(const_cast<Layout*>(layout), id, graphicalObjectIndex));
}

const unsigned int getNumCurveSegments(GraphicalObject* graphicalObject) {
return getNumCurveSegments(getCurve(graphicalObject));
const unsigned int getNumCurveSegments(const GraphicalObject* graphicalObject) {
return getNumCurveSegments(getCurve(const_cast<GraphicalObject*>(graphicalObject)));
}

const unsigned int getNumCurveSegments(Curve* curve) {
const unsigned int getNumCurveSegments(const Curve* curve) {
if (curve)
return curve->getNumCurveSegments();

Expand Down
Loading

0 comments on commit 6c4aa1c

Please sign in to comment.