From 0f630c1f222617620f0b3ec631270a77c495cb1f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 9 Dec 2016 21:04:16 +0100 Subject: [PATCH] System : Added const to functions related to write of field data --- .../cafPdmXml/cafInternalPdmXmlFieldCapability.h | 10 +++++----- .../cafPdmXml/cafInternalPdmXmlFieldCapability.inl | 10 +++++----- .../cafPdmXml/cafPdmXmlFieldHandle.h | 13 +++++++------ .../cafPdmXml/cafPdmXmlObjectHandle.cpp | 6 +++--- .../cafPdmXml/cafPdmXmlObjectHandle.h | 6 +++--- .../cafPdmXml/cafPdmXmlObjectHandleMacros.h | 2 +- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.h index 420b115320..b904463a0a 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.h @@ -15,7 +15,7 @@ public: // Xml Serializing public: virtual void readFieldData(QXmlStreamReader& xmlStream, PdmObjectFactory* objectFactory); - virtual void writeFieldData(QXmlStreamWriter& xmlStream); + virtual void writeFieldData(QXmlStreamWriter& xmlStream) const; private: FieldType* m_field; }; @@ -39,7 +39,7 @@ public: // Xml Serializing public: virtual void readFieldData(QXmlStreamReader& xmlStream, PdmObjectFactory* objectFactory); - virtual void writeFieldData(QXmlStreamWriter& xmlStream); + virtual void writeFieldData(QXmlStreamWriter& xmlStream) const; virtual void resolveReferences(); private: @@ -68,7 +68,7 @@ public: // Xml Serializing public: virtual void readFieldData(QXmlStreamReader& xmlStream, PdmObjectFactory* objectFactory); - virtual void writeFieldData(QXmlStreamWriter& xmlStream); + virtual void writeFieldData(QXmlStreamWriter& xmlStream) const; virtual void resolveReferences(); private: @@ -92,7 +92,7 @@ public: // Xml Serializing public: virtual void readFieldData(QXmlStreamReader& xmlStream, PdmObjectFactory* objectFactory); - virtual void writeFieldData(QXmlStreamWriter& xmlStream); + virtual void writeFieldData(QXmlStreamWriter& xmlStream) const; private: FieldType* m_field; }; @@ -110,7 +110,7 @@ public: // Xml Serializing public: virtual void readFieldData(QXmlStreamReader& xmlStream, PdmObjectFactory* objectFactory); - virtual void writeFieldData(QXmlStreamWriter& xmlStream); + virtual void writeFieldData(QXmlStreamWriter& xmlStream) const; private: FieldType* m_field; }; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl index 2bebe739a2..09ebeb0665 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl @@ -30,7 +30,7 @@ template /// //-------------------------------------------------------------------------------------------------- template - void caf::PdmFieldXmlCap::writeFieldData(QXmlStreamWriter& xmlStream) +void caf::PdmFieldXmlCap::writeFieldData(QXmlStreamWriter& xmlStream) const { this->assertValid(); PdmFieldWriter::writeFieldData(m_field->value(), xmlStream); @@ -79,7 +79,7 @@ template //-------------------------------------------------------------------------------------------------- template - void caf::PdmFieldXmlCap< caf::PdmPtrField >::writeFieldData(QXmlStreamWriter& xmlStream) + void caf::PdmFieldXmlCap< caf::PdmPtrField >::writeFieldData(QXmlStreamWriter& xmlStream) const { this->assertValid(); @@ -142,7 +142,7 @@ template //-------------------------------------------------------------------------------------------------- template - void caf::PdmFieldXmlCap< caf::PdmPtrArrayField >::writeFieldData(QXmlStreamWriter& xmlStream) + void caf::PdmFieldXmlCap< caf::PdmPtrArrayField >::writeFieldData(QXmlStreamWriter& xmlStream) const { this->assertValid(); @@ -264,7 +264,7 @@ void caf::PdmFieldXmlCap< caf::PdmChildField >::readFieldData(QXmlStr //-------------------------------------------------------------------------------------------------- template -void caf::PdmFieldXmlCap< caf::PdmChildField >::writeFieldData(QXmlStreamWriter& xmlStream) +void caf::PdmFieldXmlCap< caf::PdmChildField >::writeFieldData(QXmlStreamWriter& xmlStream) const { if (m_field->m_fieldValue.rawPtr() == NULL) return; @@ -287,7 +287,7 @@ void caf::PdmFieldXmlCap< caf::PdmChildField >::writeFieldData(QXmlSt /// //-------------------------------------------------------------------------------------------------- template -void caf::PdmFieldXmlCap< caf::PdmChildArrayField >::writeFieldData(QXmlStreamWriter& xmlStream) +void caf::PdmFieldXmlCap< caf::PdmChildArrayField >::writeFieldData(QXmlStreamWriter& xmlStream) const { typename std::vector< PdmPointer >::iterator it; for (it = m_field->m_pointers.begin(); it != m_field->m_pointers.end(); ++it) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlFieldHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlFieldHandle.h index bf426be4a1..8db7870ca7 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlFieldHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlFieldHandle.h @@ -25,17 +25,18 @@ public: PdmXmlFieldHandle(PdmFieldHandle* owner , bool giveOwnership); virtual ~PdmXmlFieldHandle() { } - PdmFieldHandle* fieldHandle() { return m_owner; } + PdmFieldHandle* fieldHandle() { return m_owner; } + const PdmFieldHandle* fieldHandle() const { return m_owner; } - bool isIOReadable() { return m_isIOReadable; } - bool isIOWritable() { return m_isIOWritable; } - void setIOWritable(bool isWritable) { m_isIOWritable = isWritable; } - void setIOReadable(bool isReadable) { m_isIOReadable = isReadable; } + bool isIOReadable() const { return m_isIOReadable; } + bool isIOWritable() const { return m_isIOWritable; } + void setIOWritable(bool isWritable) { m_isIOWritable = isWritable; } + void setIOReadable(bool isReadable) { m_isIOReadable = isReadable; } QString childClassKeyword(); virtual void readFieldData(QXmlStreamReader& xmlStream, PdmObjectFactory* objectFactory) = 0; - virtual void writeFieldData(QXmlStreamWriter& xmlStream) = 0; + virtual void writeFieldData(QXmlStreamWriter& xmlStream) const = 0; virtual void resolveReferences() { }; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp index 9bcaa193a5..99431fc596 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp @@ -108,13 +108,13 @@ void PdmXmlObjectHandle::readFields(QXmlStreamReader& xmlStream, PdmObjectFactor //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmXmlObjectHandle::writeFields(QXmlStreamWriter& xmlStream) +void PdmXmlObjectHandle::writeFields(QXmlStreamWriter& xmlStream) const { std::vector fields; m_owner->fields(fields); for (size_t it = 0; it < fields.size(); ++it) { - PdmXmlFieldHandle* field = fields[it]->xmlCapability(); + const PdmXmlFieldHandle* field = fields[it]->xmlCapability(); if (field && field->isIOWritable()) { QString keyword = field->fieldHandle()->keyword(); @@ -188,7 +188,7 @@ PdmObjectHandle* PdmXmlObjectHandle::copyByXmlSerialization(PdmObjectFactory* ob //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString PdmXmlObjectHandle::writeObjectToXmlString() +QString PdmXmlObjectHandle::writeObjectToXmlString() const { QString xmlString; QXmlStreamWriter outputStream(&xmlString); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.h index 0759889f52..5616308e67 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.h @@ -30,18 +30,18 @@ public: virtual ~PdmXmlObjectHandle() { } /// The classKeyword method is overridden in subclasses by the CAF_PDM_XML_HEADER_INIT macro - virtual QString classKeyword() = 0; + virtual QString classKeyword() const = 0; /// Convenience methods to serialize/de-serialize this particular object (with children) void readObjectFromXmlString(const QString& xmlString, PdmObjectFactory* objectFactory); - QString writeObjectToXmlString(); + QString writeObjectToXmlString() const; static PdmObjectHandle* readUnknownObjectFromXmlString(const QString& xmlString, PdmObjectFactory* objectFactory); PdmObjectHandle* copyByXmlSerialization(PdmObjectFactory* objectFactory); // Main XML serialization methods that is used internally by the document serialization system // Not supposed to be used directly. void readFields(QXmlStreamReader& inputStream, PdmObjectFactory* objectFactory); - void writeFields(QXmlStreamWriter& outputStream); + void writeFields(QXmlStreamWriter& outputStream) const; /// Check if a string is a valid Xml element name static bool isValidXmlElementName(const QString& name); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandleMacros.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandleMacros.h index a00116f2df..ecdcd13808 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandleMacros.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandleMacros.h @@ -22,7 +22,7 @@ // To be renamed CAF_PDM_XML_HEADER_INIT #define CAF_PDM_XML_HEADER_INIT \ public: \ - virtual QString classKeyword() { return classKeywordStatic(); } \ + virtual QString classKeyword() const { return classKeywordStatic(); } \ static QString classKeywordStatic(); \ \ static bool Error_You_forgot_to_add_the_macro_CAF_PDM_XML_HEADER_INIT_and_or_CAF_PDM_XML_SOURCE_INIT_to_your_cpp_file_for_this_class()