MCPcopy Create free account
hub / github.com/ImageEngine/cortex / SceneCache::WriterImplementation

Class SceneCache::WriterImplementation

src/IECoreScene/SceneCache.cpp:1193–2215  ·  view source on GitHub ↗

Writer implementation for SceneCache Each location keeps refcount pointers to their child locations, so they can always return the same (unfinished child) and when the root is destroyed, it can trigger the recursive computation of bounding boxes and the global storage of all sampleTime vectors used in the file.

Source from the content-addressed store, hash-verified

1191/// Each location keeps refcount pointers to their child locations, so they can always return the same (unfinished child) and when the root is destroyed, it
1192/// can trigger the recursive computation of bounding boxes and the global storage of all sampleTime vectors used in the file.
1193class SceneCache::WriterImplementation : public SceneCache::Implementation
1194{
1195 public :
1196
1197 IE_CORE_DECLAREPTR( WriterImplementation )
1198
1199 WriterImplementation( IndexedIOPtr io, Implementation *parent = nullptr) : SceneCache::Implementation( io ), m_parent(static_cast< WriterImplementation* >( parent ))
1200 {
1201 if ( m_parent )
1202 {
1203 // use same map from the root
1204 m_sampleTimesMap = m_parent->m_sampleTimesMap;
1205 }
1206 else
1207 {
1208 // only the root instance allocate the map.
1209 m_sampleTimesMap = new SampleTimesMap;
1210 }
1211 }
1212
1213 ~WriterImplementation() override
1214 {
1215 // the root location destruction triggers the flush on the file.
1216 if ( !m_parent )
1217 {
1218 try
1219 {
1220 flush();
1221 }
1222 catch ( std::exception &e )
1223 {
1224 msg( Msg::Error, "SceneCache::~SceneCache", ( boost::format( "Corrupted file resulted from exception while flushing data: %s." ) % e.what() ).str() );
1225 }
1226 catch (...)
1227 {
1228 msg( Msg::Error, "SceneCache::~SceneCache", "Corrupted file resulted from unknown exception while flushing data." );
1229 }
1230 }
1231 }
1232
1233 const SceneCache::Name &name() const
1234 {
1235 if ( m_parent )
1236 {
1237 return m_indexedIO->currentEntryId();
1238 }
1239 return SceneInterface::rootName;
1240 }
1241
1242 void path( SceneCache::Path &p ) const
1243 {
1244 IndexedIO::EntryIDList ioPath;
1245 m_indexedIO->path( ioPath );
1246 IndexedIO::EntryIDList::const_iterator pIt = ioPath.begin();
1247 pIt++; // skip root entry
1248 while( pIt != ioPath.end() )
1249 {
1250 pIt++; // skip children entry

Callers

nothing calls this directly

Calls 1

currentEntryIdMethod · 0.80

Tested by

no test coverage detected