Skip to content

Commit ac6815f

Browse files
committed
Keep access to underlying XMLDocument protected. Add a public Object method that exposes the underlying document's file version instead.
1 parent 8d83ed2 commit ac6815f

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

OpenSim/Common/Object.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,13 +1241,18 @@ updateDefaultObjectsXMLNode(SimTK::Xml::Element& aParent)
12411241
*
12421242
* @return Document's filename for this object.
12431243
*/
1244-
string Object::
1245-
getDocumentFileName() const
1244+
string Object::getDocumentFileName() const
12461245
{
12471246
return _document ? _document->getFileName() : "";
12481247
}
12491248

12501249

1250+
int Object::getDocumentFileVersion() const
1251+
{
1252+
return _document ? _document->getDocumentVersion() : -1;
1253+
}
1254+
1255+
12511256
//-----------------------------------------------------------------------------
12521257
// GENERATE XML DOCUMENT
12531258
//-----------------------------------------------------------------------------

OpenSim/Common/Object.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,17 +563,23 @@ class OSIMCOMMON_API Object
563563
lost here. **/
564564
void setDocument(XMLDocument* doc) {_document=doc;}
565565

566+
/** Get a const pointer to the document (if any) associated with this
567+
object. **/
568+
const XMLDocument* getDocument() const {return _document;}
566569
/** Get a writable pointer to the document (if any) associated with this
567570
object. **/
568571
XMLDocument* updDocument() {return _document;}
569572
public:
570-
/** Get a const pointer to the document (if any) associated with this
571-
object. **/
572-
const XMLDocument* getDocument() const { return _document; }
573-
574573
/** If there is a document associated with this object then return the
575574
file name maintained by the document. Otherwise return an empty string. **/
576575
std::string getDocumentFileName() const;
576+
577+
/** If there is a document associated with this object then return its
578+
version number. For example this is 30000 for OpenSim 3.x documents
579+
and is 305xx for OpenSim 4.0 beta and above. If there is no document
580+
associated with the object, the method returns -1.*/
581+
int getDocumentFileVersion() const;
582+
577583
void setAllPropertiesUseDefault(bool aUseDefault);
578584

579585
/** Write this %Object into an XML file of the given name; conventionally

0 commit comments

Comments
 (0)