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

Method save

src/IECore/Object.cpp:179–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179void Object::SaveContext::save( const Object *toSave, IndexedIO *container, const IndexedIO::EntryID &name )
180{
181 if ( !toSave )
182 {
183 throw Exception( "Error trying to save NULL pointer object!" );
184 }
185
186 SavedObjects::const_iterator it = m_savedObjects->find( toSave );
187 if( it!=m_savedObjects->end() )
188 {
189 container->write( name, &(it->second[0]), it->second.size() );
190 }
191 else
192 {
193 bool rootObject = ( m_savedObjects->size() == 0 );
194 if ( rootObject )
195 {
196 if ( container->hasEntry( name ) )
197 {
198 container->remove( name );
199 }
200 }
201 IndexedIOPtr nameIO = container->createSubdirectory( name );
202
203 IndexedIO::EntryIDList pathParts;
204 nameIO->path( pathParts );
205 (*m_savedObjects)[toSave] = pathParts;
206
207 nameIO->write( g_typeEntry, toSave->typeName() );
208
209 IndexedIOPtr dataIO = nameIO->createSubdirectory( g_dataEntry );
210 dataIO->removeAll();
211
212 SaveContext context( dataIO, m_savedObjects );
213 toSave->save( &context );
214
215 // Objects saved on a file can be committed to disk to free memory.
216 if ( rootObject )
217 {
218 nameIO->commit();
219 }
220 }
221}
222
223//////////////////////////////////////////////////////////////////////////////////////////
224// load context stuff

Callers

nothing calls this directly

Calls 12

hasEntryMethod · 0.80
createSubdirectoryMethod · 0.80
typeNameMethod · 0.80
removeAllMethod · 0.80
commitMethod · 0.80
findMethod · 0.45
endMethod · 0.45
writeMethod · 0.45
sizeMethod · 0.45
removeMethod · 0.45
pathMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected