ResInsight/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrField.h
Magne Sjaastad 1d57b9032b
Custom vfp plot (#11450)
* AppFwk: When clearing a tree selection, make sure all values are cleared
* Fix deprecated implicit lambda
* Add support for using the closest value in addition to exact match
* Add table data source object and add plot with multiple data sources
Delete the temporary RimVfpDeck class
Add RimVfpTable to represent a table in a data source
Add plot able to show data from multiple tables

* AppFwk: Make it possible to call resolveReferences multiple times
Use case: Vfp tables are stored in files. Multiple tables can be present in one file. Pdm table objects are created after resolve references is done as part of parsing file. When the Pdm object are created, resolveReferences can be called once more.

* Call resolveReferencesRecursively() after RimVfpTable objects are created
2024-05-29 12:55:45 +02:00

86 lines
2.5 KiB
C++

#pragma once
#include "cafAssert.h"
#include "cafPdmPointer.h"
#include "cafPdmValueField.h"
namespace caf
{
template <typename T>
class PdmFieldXmlCap;
//==================================================================================================
/// A field that contains a pointer to a PdmObjectHandle derived object.
/// The referenced object will not be printed in the XML-output yet, but
/// it is intended to be written as a reference (by path from common root)
/// This field has nothing to do with ownership at all, and is not a part of the
/// parent-child relations induced by the other PdmChildField<PdmPtrType*> PdmChildArrayField<PdmPtrType*>
/// The pointer is guarded, meaning that it will be set to NULL if the object pointed to
/// is deleted.
//==================================================================================================
template <typename DataType>
class PdmPtrField : public PdmValueField
{
public:
PdmPtrField()
{
bool doNotUsePdmPtrFieldForAnythingButPointersToPdmObject = false;
CAF_ASSERT( doNotUsePdmPtrFieldForAnythingButPointersToPdmObject );
}
};
template <typename DataType>
class PdmPtrField<DataType*> : public PdmValueField
{
typedef DataType* DataTypePtr;
public:
typedef PdmPointer<DataType> FieldDataType;
PdmPtrField() {}
explicit PdmPtrField( const DataTypePtr& fieldValue );
~PdmPtrField() override;
// Assignment
PdmPtrField& operator=( const DataTypePtr& fieldValue );
PdmPtrField& operator=( const FieldDataType& fieldValue );
// Basic access
DataType* value() const { return m_fieldValue; }
void setValue( const DataTypePtr& fieldValue );
// QVariant access
QVariant toQVariant() const override;
void setFromQVariant( const QVariant& variant ) override;
bool isReadOnly() const override { return false; }
// Access operators
/*Conversion*/ operator DataType*() const { return m_fieldValue; }
DataType* operator->() const { return m_fieldValue; }
DataType* operator()() const { return m_fieldValue; }
bool operator==( const DataTypePtr& fieldValue ) { return m_fieldValue == fieldValue; }
std::vector<PdmObjectHandle*> ptrReferencedObjects() const override;
private:
PDM_DISABLE_COPY_AND_ASSIGN( PdmPtrField );
friend class PdmFieldXmlCap<PdmPtrField<DataType*>>;
void setRawPtr( PdmObjectHandle* obj );
PdmPointer<DataType> m_fieldValue;
// Resolving
QString m_referenceString;
};
} // End of namespace caf
#include "cafPdmPtrField.inl"