Skip to content

Commit 7185a1e

Browse files
committedApr 16, 2021
Fix for #127
Adds boolean 'reverse' to the Axis object. Axis is already an l1v4 addition, so we don't need special level/version-checking code.
1 parent 40adb97 commit 7185a1e

File tree

5 files changed

+281
-0
lines changed

5 files changed

+281
-0
lines changed
 

‎src/sedml/SedAxis.cpp

+146
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ SedAxis::SedAxis(unsigned int level, unsigned int version)
5959
, mIsSetMax (false)
6060
, mGrid (false)
6161
, mIsSetGrid (false)
62+
, mReverse (false)
63+
, mIsSetReverse (false)
6264
, mStyle ("")
6365
, mElementName("axis")
6466
{
@@ -78,6 +80,8 @@ SedAxis::SedAxis(SedNamespaces *sedmlns)
7880
, mIsSetMax (false)
7981
, mGrid (false)
8082
, mIsSetGrid (false)
83+
, mReverse (false)
84+
, mIsSetReverse (false)
8185
, mStyle ("")
8286
, mElementName("axis")
8387
{
@@ -97,6 +101,8 @@ SedAxis::SedAxis(const SedAxis& orig)
97101
, mIsSetMax ( orig.mIsSetMax )
98102
, mGrid ( orig.mGrid )
99103
, mIsSetGrid ( orig.mIsSetGrid )
104+
, mReverse ( orig.mReverse )
105+
, mIsSetReverse ( orig.mIsSetReverse )
100106
, mStyle ( orig.mStyle )
101107
, mElementName ( orig.mElementName )
102108
{
@@ -119,6 +125,8 @@ SedAxis::operator=(const SedAxis& rhs)
119125
mIsSetMax = rhs.mIsSetMax;
120126
mGrid = rhs.mGrid;
121127
mIsSetGrid = rhs.mIsSetGrid;
128+
mReverse = rhs.mReverse;
129+
mIsSetReverse = rhs.mIsSetReverse;
122130
mStyle = rhs.mStyle;
123131
mElementName = rhs.mElementName;
124132
}
@@ -196,6 +204,16 @@ SedAxis::getGrid() const
196204
}
197205

198206

207+
/*
208+
* Returns the value of the "reverse" attribute of this SedAxis.
209+
*/
210+
bool
211+
SedAxis::getReverse() const
212+
{
213+
return mReverse;
214+
}
215+
216+
199217
/*
200218
* Returns the value of the "style" attribute of this SedAxis.
201219
*/
@@ -246,6 +264,16 @@ SedAxis::isSetGrid() const
246264
}
247265

248266

267+
/*
268+
* Predicate returning @c true if this SedAxis's "reverse" attribute is set.
269+
*/
270+
bool
271+
SedAxis::isSetReverse() const
272+
{
273+
return mIsSetReverse;
274+
}
275+
276+
249277
/*
250278
* Predicate returning @c true if this SedAxis's "style" attribute is set.
251279
*/
@@ -328,6 +356,18 @@ SedAxis::setGrid(bool grid)
328356
}
329357

330358

359+
/*
360+
* Sets the value of the "reverse" attribute of this SedAxis.
361+
*/
362+
int
363+
SedAxis::setReverse(bool reverse)
364+
{
365+
mReverse = reverse;
366+
mIsSetReverse = true;
367+
return LIBSEDML_OPERATION_SUCCESS;
368+
}
369+
370+
331371
/*
332372
* Sets the value of the "style" attribute of this SedAxis.
333373
*/
@@ -417,6 +457,26 @@ SedAxis::unsetGrid()
417457
}
418458

419459

460+
/*
461+
* Unsets the value of the "reverse" attribute of this SedAxis.
462+
*/
463+
int
464+
SedAxis::unsetReverse()
465+
{
466+
mReverse = false;
467+
mIsSetReverse = false;
468+
469+
if (isSetReverse() == false)
470+
{
471+
return LIBSEDML_OPERATION_SUCCESS;
472+
}
473+
else
474+
{
475+
return LIBSEDML_OPERATION_FAILED;
476+
}
477+
}
478+
479+
420480
/*
421481
* Unsets the value of the "style" attribute of this SedAxis.
422482
*/
@@ -570,6 +630,12 @@ SedAxis::getAttribute(const std::string& attributeName, bool& value) const
570630
return_value = LIBSEDML_OPERATION_SUCCESS;
571631
}
572632

633+
if (attributeName == "reverse")
634+
{
635+
value = getReverse();
636+
return_value = LIBSEDML_OPERATION_SUCCESS;
637+
}
638+
573639
return return_value;
574640
}
575641

@@ -706,6 +772,10 @@ SedAxis::isSetAttribute(const std::string& attributeName) const
706772
{
707773
value = isSetGrid();
708774
}
775+
else if (attributeName == "reverse")
776+
{
777+
value = isSetReverse();
778+
}
709779
else if (attributeName == "style")
710780
{
711781
value = isSetStyle();
@@ -732,6 +802,10 @@ SedAxis::setAttribute(const std::string& attributeName, bool value)
732802
{
733803
return_value = setGrid(value);
734804
}
805+
else if (attributeName == "reverse")
806+
{
807+
return_value = setReverse(value);
808+
}
735809

736810
return return_value;
737811
}
@@ -853,6 +927,10 @@ SedAxis::unsetAttribute(const std::string& attributeName)
853927
{
854928
value = unsetGrid();
855929
}
930+
else if (attributeName == "reverse")
931+
{
932+
value = unsetReverse();
933+
}
856934
else if (attributeName == "style")
857935
{
858936
value = unsetStyle();
@@ -884,6 +962,8 @@ SedAxis::addExpectedAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER
884962

885963
attributes.add("grid");
886964

965+
attributes.add("reverse");
966+
887967
attributes.add("style");
888968
}
889969

@@ -1027,6 +1107,23 @@ SedAxis::readAttributes(
10271107
}
10281108
}
10291109

1110+
//
1111+
// reverse bool (use = "optional" )
1112+
//
1113+
1114+
numErrs = log ? log->getNumErrors() : 0;
1115+
mIsSetReverse = attributes.readInto("reverse", mReverse);
1116+
1117+
if (mIsSetReverse == false)
1118+
{
1119+
if (log && log->getNumErrors() == numErrs + 1 &&
1120+
log->contains(XMLAttributeTypeMismatch))
1121+
{
1122+
log->remove(XMLAttributeTypeMismatch);
1123+
log->logError(SedmlAxisReverseMustBeBoolean, level, version);
1124+
}
1125+
}
1126+
10301127
//
10311128
// style SIdRef (use = "optional" )
10321129
//
@@ -1090,6 +1187,11 @@ SedAxis::writeAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream&
10901187
stream.writeAttribute("grid", getPrefix(), mGrid);
10911188
}
10921189

1190+
if (isSetReverse() == true)
1191+
{
1192+
stream.writeAttribute("reverse", getPrefix(), mReverse);
1193+
}
1194+
10931195
if (isSetStyle() == true)
10941196
{
10951197
stream.writeAttribute("style", getPrefix(), mStyle);
@@ -1207,6 +1309,17 @@ SedAxis_getGrid(const SedAxis_t * sa)
12071309
}
12081310

12091311

1312+
/*
1313+
* Returns the value of the "reverse" attribute of this SedAxis_t.
1314+
*/
1315+
LIBSEDML_EXTERN
1316+
int
1317+
SedAxis_getReverse(const SedAxis_t* sa)
1318+
{
1319+
return (sa != NULL) ? static_cast<int>(sa->getReverse()) : 0;
1320+
}
1321+
1322+
12101323
/*
12111324
* Returns the value of the "style" attribute of this SedAxis_t.
12121325
*/
@@ -1267,6 +1380,17 @@ SedAxis_isSetGrid(const SedAxis_t * sa)
12671380
}
12681381

12691382

1383+
/*
1384+
* Predicate returning @c 1 (true) if this SedAxis_t's "reverse" attribute is set.
1385+
*/
1386+
LIBSEDML_EXTERN
1387+
int
1388+
SedAxis_isSetReverse(const SedAxis_t* sa)
1389+
{
1390+
return (sa != NULL) ? static_cast<int>(sa->isSetReverse()) : 0;
1391+
}
1392+
1393+
12701394
/*
12711395
* Predicate returning @c 1 (true) if this SedAxis_t's "style" attribute is
12721396
* set.
@@ -1334,6 +1458,17 @@ SedAxis_setGrid(SedAxis_t * sa, int grid)
13341458
}
13351459

13361460

1461+
/*
1462+
* Sets the value of the "reverse" attribute of this SedAxis_t.
1463+
*/
1464+
LIBSEDML_EXTERN
1465+
int
1466+
SedAxis_setReverse(SedAxis_t* sa, int reverse)
1467+
{
1468+
return (sa != NULL) ? sa->setReverse(reverse) : LIBSEDML_INVALID_OBJECT;
1469+
}
1470+
1471+
13371472
/*
13381473
* Sets the value of the "style" attribute of this SedAxis_t.
13391474
*/
@@ -1389,6 +1524,17 @@ SedAxis_unsetGrid(SedAxis_t * sa)
13891524
}
13901525

13911526

1527+
/*
1528+
* Unsets the value of the "reverse" attribute of this SedAxis_t.
1529+
*/
1530+
LIBSEDML_EXTERN
1531+
int
1532+
SedAxis_unsetReverse(SedAxis_t* sa)
1533+
{
1534+
return (sa != NULL) ? sa->unsetReverse() : LIBSEDML_INVALID_OBJECT;
1535+
}
1536+
1537+
13921538
/*
13931539
* Unsets the value of the "style" attribute of this SedAxis_t.
13941540
*/

0 commit comments

Comments
 (0)