2015-07-29 14:19:43 +02:00
#include "cafPdmXmlFieldHandle.h"
2017-03-08 08:19:51 +01:00
#include "cafAssert.h"
2015-07-29 14:19:43 +02:00
#include "cafPdmFieldHandle.h"
#include "cafPdmXmlObjectHandle.h"
#include <iostream>
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool PdmXmlFieldHandle :: assertValid () const
{
if ( m_owner -> keyword (). isEmpty ())
{
std :: cout << "PdmField: Detected use of non-initialized field. Did you forget to do CAF_PDM_InitField() on this field ? \n " ;
return false ;
}
if ( ! PdmXmlObjectHandle :: isValidXmlElementName ( m_owner -> keyword ()))
{
std :: cout << "PdmField: The supplied keyword: \" " << m_owner -> keyword (). toStdString () << " \" is an invalid XML element name, and will break your file format! \n " ;
return false ;
}
return true ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmXmlFieldHandle :: PdmXmlFieldHandle ( PdmFieldHandle * owner , bool giveOwnership ) : m_isIOReadable ( true ), m_isIOWritable ( true )
{
m_owner = owner ;
owner -> addCapability ( this , giveOwnership );
}
2017-10-03 15:23:44 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmXmlFieldHandle :: disableIO ()
{
setIOReadable ( false );
setIOWritable ( false );
}
2015-07-29 14:19:43 +02:00
//--------------------------------------------------------------------------------------------------
/// Returns the classKeyword of the child class type, if this field is supposed to contain pointers
/// to PdmObjectHandle derived onbjects.
/// Returns empty string if the field is not containig some PdmObjectHandle type
//--------------------------------------------------------------------------------------------------
QString PdmXmlFieldHandle :: childClassKeyword ()
{
return m_childClassKeyword ;
}
2015-08-05 12:34:07 +02:00
//--------------------------------------------------------------------------------------------------
/// Implementation of uiCapability() defined in cafPdmFieldHandle.h
//--------------------------------------------------------------------------------------------------
PdmXmlFieldHandle * PdmFieldHandle :: xmlCapability ()
{
2015-10-23 15:21:23 +02:00
PdmXmlFieldHandle * xmlField = capability < PdmXmlFieldHandle > ();
2017-03-08 08:19:51 +01:00
CAF_ASSERT ( xmlField );
2015-08-05 12:34:07 +02:00
2015-10-23 15:21:23 +02:00
return xmlField ;
2015-08-05 12:34:07 +02:00
}
2015-07-29 14:19:43 +02:00
} // End of namespace caf