Refactor delete operations for pdm objects.

This commit is contained in:
Kristian Bendiksen
2020-05-18 16:02:27 +02:00
committed by Magne Sjaastad
parent 80ee1256e7
commit c366e85682
90 changed files with 474 additions and 438 deletions

View File

@@ -4,11 +4,21 @@
#include "cafAssert.h"
#include "cafPdmFieldHandle.h"
#include "cafPdmObjectCapability.h"
#include "cafPdmChildArrayField.h"
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmObjectHandle::PdmObjectHandle()
{
m_parentField = nullptr;
m_isDeletable = false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -174,6 +184,30 @@ PdmFieldHandle* PdmObjectHandle::parentField() const
return m_parentField;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmObjectHandle::setDeletable(bool isDeletable)
{
m_isDeletable = isDeletable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool PdmObjectHandle::isDeletable() const
{
return m_isDeletable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmObjectHandle::onChildDeleted(PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects)
{
}
// These two functions can be used when PdmCore is used standalone without PdmUi/PdmXml
/*
PdmUiObjectHandle* PdmObjectHandle::uiCapability()

View File

@@ -16,6 +16,7 @@ class PdmObjectCapability;
class PdmFieldHandle;
class PdmUiObjectHandle;
class PdmXmlObjectHandle;
class PdmChildArrayFieldHandle;
//==================================================================================================
/// The base class of all objects
@@ -23,7 +24,7 @@ class PdmXmlObjectHandle;
class PdmObjectHandle
{
public:
PdmObjectHandle() { m_parentField = nullptr; }
PdmObjectHandle();
virtual ~PdmObjectHandle();
static QString classKeywordStatic(); // For PdmXmlFieldCap to be able to handle fields of PdmObjectHandle directly
@@ -85,6 +86,11 @@ public:
PdmUiObjectHandle* uiCapability() const; // Implementation is in cafPdmUiObjectHandle.cpp
PdmXmlObjectHandle* xmlCapability() const; // Implementation is in cafPdmXmlObjectHandle.cpp
virtual void setDeletable(bool isDeletable);
virtual bool isDeletable() const;
virtual void onChildDeleted(PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects);
protected:
void addField(PdmFieldHandle* field, const QString& keyword);
@@ -119,6 +125,8 @@ private:
// Support system for PdmPointer
friend class PdmPointerImpl;
std::set<PdmObjectHandle**> m_pointersReferencingMe;
bool m_isDeletable;
};
}