mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-26 00:06:49 -06:00
99 lines
3.5 KiB
C++
99 lines
3.5 KiB
C++
namespace caf
|
|
{
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
template<typename DataType >
|
|
caf::PdmPtrField<DataType*>::PdmPtrField(const DataTypePtr& fieldValue)
|
|
{
|
|
m_isResolved = true;
|
|
m_fieldValue = fieldValue;
|
|
if (m_fieldValue != NULL) m_fieldValue->addReferencingPtrField(this);
|
|
}
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
template<typename DataType >
|
|
caf::PdmPtrField<DataType*>::~PdmPtrField()
|
|
{
|
|
if (!m_fieldValue.isNull()) m_fieldValue.rawPtr()->removeReferencingPtrField(this);
|
|
m_fieldValue.setRawPtr(NULL);
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
template<typename DataType >
|
|
void PdmPtrField<DataType*>::setValue(const DataTypePtr& fieldValue)
|
|
{
|
|
assert(isInitializedByInitFieldMacro());
|
|
|
|
if (m_fieldValue) m_fieldValue->removeReferencingPtrField(this);
|
|
m_fieldValue = fieldValue;
|
|
if (m_fieldValue != NULL) m_fieldValue->addReferencingPtrField(this);
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
template<typename DataType >
|
|
void PdmPtrField<DataType*>::setRawPtr(PdmObjectHandle* obj)
|
|
{
|
|
assert(isInitializedByInitFieldMacro());
|
|
|
|
if (m_fieldValue.notNull()) m_fieldValue.rawPtr()->removeReferencingPtrField(this);
|
|
m_fieldValue.setRawPtr(obj);
|
|
if (m_fieldValue.notNull()) m_fieldValue.rawPtr()->addReferencingPtrField(this);
|
|
}
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
template<typename DataType >
|
|
caf::PdmPtrField<DataType*>& PdmPtrField<DataType*>::operator=(const DataTypePtr & fieldValue)
|
|
{
|
|
assert(isInitializedByInitFieldMacro());
|
|
|
|
if (m_fieldValue) m_fieldValue->removeReferencingPtrField(this);
|
|
m_fieldValue = fieldValue;
|
|
if (m_fieldValue != NULL) m_fieldValue->addReferencingPtrField(this);
|
|
|
|
return *this;
|
|
}
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
template<typename DataType >
|
|
caf::PdmPtrField<DataType*>& PdmPtrField<DataType*>::operator=(const FieldDataType & fieldValue)
|
|
{
|
|
assert(isInitializedByInitFieldMacro());
|
|
|
|
if (m_fieldValue) m_fieldValue->removeReferencingPtrField(this);
|
|
m_fieldValue = fieldValue;
|
|
if (m_fieldValue != NULL) m_fieldValue->addReferencingPtrField(this);
|
|
|
|
return *this;
|
|
}
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
template<typename DataType >
|
|
void PdmPtrField<DataType*>::ptrReferencedObjects(std::vector<PdmObjectHandle*>* objectsToFill)
|
|
{
|
|
if (m_fieldValue.rawPtr())
|
|
{
|
|
objectsToFill->push_back(m_fieldValue.rawPtr());
|
|
}
|
|
}
|
|
|
|
} // End of namespace caf
|
|
|