//-***************************************************************************** AwImpl::~AwImpl() { // empty out the map so any dataset IDs will be freed up m_writtenSampleMap.clear(); // write out our child headers if ( m_data ) { Util::SpookyHash hash; m_data->writeHeaders( m_metaDataMap, hash ); } // let go of our reference to the data for the top object m_data.reset(); // encode and write the time samplings and max samples into data if ( m_archive.isValid() ) { // encode and write the Metadata for the archive, since the top level // meta data can be kinda big and is very specialized don't worry // about putting it into the meta data map std::string metaData = m_metaData.serialize(); m_archive.getGroup()->addData( metaData.size(), metaData.c_str() ); std::vector< Util::uint8_t > data; Util::uint32_t numSamplings = getNumTimeSamplings(); for ( Util::uint32_t i = 0; i < numSamplings; ++i ) { Util::uint32_t maxSample = m_maxSamples[i]; AbcA::TimeSamplingPtr timePtr = getTimeSampling( i ); WriteTimeSampling( data, maxSample, *timePtr ); } m_archive.getGroup()->addData( data.size(), &( data.front() ) ); m_metaDataMap->write( m_archive.getGroup() ); } }
//-***************************************************************************** uint32_t AwImpl::addTimeSampling( const AbcA::TimeSampling & iTs ) { index_t numTS = m_timeSamples.size(); for (index_t i = 0; i < numTS; ++i) { if (iTs == *(m_timeSamples[i])) return i; } // we've got a new TimeSampling, write it and add it to our vector AbcA::TimeSamplingPtr ts( new AbcA::TimeSampling(iTs) ); m_timeSamples.push_back(ts); index_t latestSample = m_timeSamples.size() - 1; std::stringstream strm; strm << latestSample; std::string name = strm.str(); WriteTimeSampling(m_file, name, *ts); return latestSample; }