System : Added const to functions related to write of field data

This commit is contained in:
Magne Sjaastad 2016-12-09 21:04:16 +01:00
parent 3fabe5f8b5
commit 0f630c1f22
6 changed files with 24 additions and 23 deletions

View File

@ -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;
};

View File

@ -30,7 +30,7 @@ template<typename FieldType >
///
//--------------------------------------------------------------------------------------------------
template<typename FieldType >
void caf::PdmFieldXmlCap<FieldType>::writeFieldData(QXmlStreamWriter& xmlStream)
void caf::PdmFieldXmlCap<FieldType>::writeFieldData(QXmlStreamWriter& xmlStream) const
{
this->assertValid();
PdmFieldWriter<typename FieldType::FieldDataType>::writeFieldData(m_field->value(), xmlStream);
@ -79,7 +79,7 @@ template<typename FieldType >
//--------------------------------------------------------------------------------------------------
template<typename DataType >
void caf::PdmFieldXmlCap< caf::PdmPtrField<DataType*> >::writeFieldData(QXmlStreamWriter& xmlStream)
void caf::PdmFieldXmlCap< caf::PdmPtrField<DataType*> >::writeFieldData(QXmlStreamWriter& xmlStream) const
{
this->assertValid();
@ -142,7 +142,7 @@ template<typename FieldType >
//--------------------------------------------------------------------------------------------------
template<typename DataType >
void caf::PdmFieldXmlCap< caf::PdmPtrArrayField<DataType*> >::writeFieldData(QXmlStreamWriter& xmlStream)
void caf::PdmFieldXmlCap< caf::PdmPtrArrayField<DataType*> >::writeFieldData(QXmlStreamWriter& xmlStream) const
{
this->assertValid();
@ -264,7 +264,7 @@ void caf::PdmFieldXmlCap< caf::PdmChildField<DataType*> >::readFieldData(QXmlStr
//--------------------------------------------------------------------------------------------------
template<typename DataType >
void caf::PdmFieldXmlCap< caf::PdmChildField<DataType*> >::writeFieldData(QXmlStreamWriter& xmlStream)
void caf::PdmFieldXmlCap< caf::PdmChildField<DataType*> >::writeFieldData(QXmlStreamWriter& xmlStream) const
{
if (m_field->m_fieldValue.rawPtr() == NULL) return;
@ -287,7 +287,7 @@ void caf::PdmFieldXmlCap< caf::PdmChildField<DataType*> >::writeFieldData(QXmlSt
///
//--------------------------------------------------------------------------------------------------
template<typename DataType>
void caf::PdmFieldXmlCap< caf::PdmChildArrayField<DataType*> >::writeFieldData(QXmlStreamWriter& xmlStream)
void caf::PdmFieldXmlCap< caf::PdmChildArrayField<DataType*> >::writeFieldData(QXmlStreamWriter& xmlStream) const
{
typename std::vector< PdmPointer<DataType> >::iterator it;
for (it = m_field->m_pointers.begin(); it != m_field->m_pointers.end(); ++it)

View File

@ -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() { };

View File

@ -108,13 +108,13 @@ void PdmXmlObjectHandle::readFields(QXmlStreamReader& xmlStream, PdmObjectFactor
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmXmlObjectHandle::writeFields(QXmlStreamWriter& xmlStream)
void PdmXmlObjectHandle::writeFields(QXmlStreamWriter& xmlStream) const
{
std::vector<PdmFieldHandle*> 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);

View File

@ -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);

View File

@ -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()