MCPcopy Create free account
hub / github.com/ImageEngine/cortex / store

Method store

src/IECore/ObjectPool.cpp:82–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82ConstObjectPtr ObjectPool::store( const Object *obj, StoreMode mode )
83{
84 MurmurHash h = obj->hash();
85
86 // first tries to see if the object is already in the cache and return that one quickly.
87 ConstObjectPtr cachedObj = m_data->cache.get(h);
88 if ( cachedObj )
89 {
90 return cachedObj;
91 }
92
93 if ( mode == StoreCopy )
94 {
95 cachedObj = obj->copy();
96 m_data->cache.set( h, cachedObj, obj->memoryUsage() );
97 return cachedObj;
98 }
99 else if ( mode == StoreReference )
100 {
101 m_data->cache.set( h, obj, obj->memoryUsage() );
102 return obj;
103 }
104 else
105 {
106 throw Exception( "Invalid store mode!" );
107 }
108}
109
110bool ObjectPool::contains( const MurmurHash &hash ) const
111{

Callers 5

testUniquenessMethod · 0.95
testStoreModeMethod · 0.95
testRemovalMethod · 0.95
testMaxMemoryUsageMethod · 0.95
storeFunction · 0.80

Calls 5

hashMethod · 0.45
getMethod · 0.45
copyMethod · 0.45
setMethod · 0.45
memoryUsageMethod · 0.45

Tested by 4

testUniquenessMethod · 0.76
testStoreModeMethod · 0.76
testRemovalMethod · 0.76
testMaxMemoryUsageMethod · 0.76