mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
CAF: expose inheritance stack and make sure we can alias class keywords
This commit is contained in:
parent
82cf721ae8
commit
83a7ceb204
@ -96,3 +96,28 @@ void PdmObject::childrenFromClassKeyword(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObject::PdmObject() : PdmObjectHandle(), PdmXmlObjectHandle(this, false), PdmUiObjectHandle(this, false)
|
||||
, m_scriptable(false)
|
||||
{
|
||||
registerClassKeyword(classKeywordStatic());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString caf::PdmObject::classKeywordStatic()
|
||||
{
|
||||
return classKeywordAliases().front();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> caf::PdmObject::classKeywordAliases()
|
||||
{
|
||||
return { QString("PdmObject") };
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class PdmObjectCapability;
|
||||
{ \
|
||||
this->isInheritedFromPdmUiObject(); \
|
||||
this->isInheritedFromPdmXmlSerializable(); \
|
||||
this->registerClassKeyword(classKeywordStatic()); \
|
||||
this->registerClassKeyword(classKeyword()); \
|
||||
\
|
||||
static caf::PdmUiItemInfo objDescr(uiName, QString(iconResourceName), toolTip, whatsThis); \
|
||||
this->setUiItemInfo(&objDescr); \
|
||||
@ -141,9 +141,12 @@ namespace caf
|
||||
class PdmObject : public PdmObjectHandle, public PdmXmlObjectHandle, public PdmUiObjectHandle
|
||||
{
|
||||
public:
|
||||
PdmObject() : PdmObjectHandle(), PdmXmlObjectHandle(this, false), PdmUiObjectHandle(this, false) {}
|
||||
PdmObject();
|
||||
~PdmObject() override {}
|
||||
|
||||
static QString classKeywordStatic();
|
||||
static std::vector<QString> classKeywordAliases();
|
||||
|
||||
/// Adds field to the internal data structure and sets the file keyword and Ui information
|
||||
/// Consider this method private. Please use the CAF_PDM_InitField() macro instead
|
||||
template< typename FieldDataType >
|
||||
|
@ -299,6 +299,14 @@ bool PdmXmlObjectHandle::inheritsClassWithKeyword(const QString& testClassKeywor
|
||||
return std::find(m_classInheritanceStack.begin(), m_classInheritanceStack.end(), testClassKeyword) != m_classInheritanceStack.end();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::list<QString>& PdmXmlObjectHandle::classInheritanceStack() const
|
||||
{
|
||||
return m_classInheritanceStack;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -57,7 +57,9 @@ public:
|
||||
void setupBeforeSaveRecursively() { setupBeforeSaveRecursively(this->m_owner); };
|
||||
|
||||
void resolveReferencesRecursively(std::vector<PdmFieldHandle*>* fieldWithFailingResolve = nullptr);
|
||||
|
||||
bool inheritsClassWithKeyword(const QString& testClassKeyword) const;
|
||||
|
||||
const std::list<QString>& classInheritanceStack() const;
|
||||
protected: // Virtual
|
||||
/// Method gets called from PdmDocument after all objects are read.
|
||||
/// Re-implement to set up internal pointers etc. in your data structure
|
||||
@ -71,7 +73,6 @@ protected: // Virtual
|
||||
bool isInheritedFromPdmXmlSerializable() { return true; }
|
||||
|
||||
void registerClassKeyword(const QString& registerKeyword);
|
||||
bool inheritsClassWithKeyword(const QString& testClassKeyword) const;
|
||||
|
||||
private:
|
||||
void initAfterReadRecursively(PdmObjectHandle* object);
|
||||
|
Loading…
Reference in New Issue
Block a user