Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/IECore/BlindDataHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class IECORE_API BlindDataHolder : public Object

private :

mutable CompoundDataPtr m_data;
CompoundDataPtr m_data;

static const unsigned int m_ioVersion;

Expand Down
47 changes: 7 additions & 40 deletions src/IECore/BlindDataHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ IE_CORE_DEFINEOBJECTTYPEDESCRIPTION(BlindDataHolder);

BlindDataHolder::BlindDataHolder()
{
m_data = 0;
m_data = new CompoundData();
}

BlindDataHolder::BlindDataHolder(CompoundDataPtr data) : m_data(data)
Expand All @@ -60,41 +60,26 @@ BlindDataHolder::~BlindDataHolder()

CompoundData *BlindDataHolder::blindData()
{
if ( !m_data )
{
m_data = new CompoundData();
}
return m_data.get();
}

const CompoundData *BlindDataHolder::blindData() const
{
if ( !m_data )
{
m_data = new CompoundData();
}
return m_data.get();
}

void BlindDataHolder::copyFrom( const Object *other, CopyContext *context )
{
Object::copyFrom( other, context );
const BlindDataHolder *tOther = static_cast<const BlindDataHolder *>( other );
if ( tOther->m_data )
{
m_data = context->copy<CompoundData>( tOther->m_data.get() );
}
else
{
m_data = 0;
}
m_data = context->copy<CompoundData>( tOther->m_data.get() );
}

void BlindDataHolder::save( SaveContext *context ) const
{
Object::save( context );

bool haveData = ( m_data && m_data->readable().size() );
bool haveData = m_data->readable().size();

if ( haveData )
{
Expand All @@ -117,7 +102,7 @@ void BlindDataHolder::load( LoadContextPtr context )
}
else
{
m_data = 0;
m_data = new CompoundData();
}
}

Expand All @@ -128,39 +113,21 @@ bool BlindDataHolder::isEqualTo( const Object *other ) const
return false;
}
const BlindDataHolder *tOther = static_cast<const BlindDataHolder *>( other );
if ( m_data )
{
if ( tOther->m_data )
{
return m_data->isEqualTo( tOther->m_data.get() );
}
else
{
return ( m_data->readable().size() == 0 );
}
}
if ( tOther->m_data )
{
return ( tOther->m_data->readable().size() == 0 );
}
return true;
return m_data->isEqualTo( tOther->m_data.get() );
}

void BlindDataHolder::memoryUsage( Object::MemoryAccumulator &a ) const
{
Object::memoryUsage( a );
if ( m_data )
{
a.accumulate( m_data.get() );
}
a.accumulate( m_data.get() );
}

void BlindDataHolder::hash( MurmurHash &h ) const
{
Object::hash( h );
// Our hash when blindData is empty or when m_data is unnitialized is the same.
// This is currently garanteed by CompoundData but we are safer this way.
if ( m_data && m_data->readable().size() )
if ( m_data->readable().size() )
{
m_data->hash( h );
}
Expand Down
6 changes: 6 additions & 0 deletions test/IECore/BlindDataHolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ def testLoadSave(self):

b2 = Object.load( iface, "test" )
self.assertEqual( b1, b2 )

# should have written a "blindData" entry into the indexed io hierarchy
self.failUnless( isinstance( iface.directory( ["test","data","BlindDataHolder", "data", "blindData"], IndexedIO.MissingBehaviour.NullIfMissing ), IndexedIO ) )

# second test: overriding with no blind data
b1 = BlindDataHolder()
Expand All @@ -124,6 +127,9 @@ def testLoadSave(self):
g2 = Object.load( iface, "test" )
self.assertEqual( g1, g2 )

# "blindData" entry should be excluded from the IndexedIO hierarchy
self.assertEqual( iface.directory( ["test","data","BlindDataHolder"], IndexedIO.MissingBehaviour.NullIfMissing ), None )

def testHash( self ) :

b1 = BlindDataHolder()
Expand Down