//-***************************************************************************** const AbcA::PropertyHeader * CprData::getPropertyHeader( AbcA::CompoundPropertyReaderPtr iParent, const std::string &iName ) { // map of names to indexes filled by ctor (CprAttrVistor), // so multithread safe. SubPropertiesMap::iterator fiter = m_subProperties.find( iName ); if ( fiter == m_subProperties.end() ) { return NULL; } return &(getPropertyHeader(iParent, fiter->second)); }
void aiSchemaBase::setupProperties() { auto cpro = getAbcProperties(); if (!cpro.valid()) { return; } size_t n = cpro.getNumProperties(); for (size_t i = 0; i < n; ++i) { auto header = cpro.getPropertyHeader(i); auto *prop = aiMakeProperty(this, cpro, header); if (prop != nullptr) { m_properties.emplace_back(prop); } } std::sort(m_properties.begin(), m_properties.end(), [](aiPropertyPtr& a, aiPropertyPtr& b) { return a->getName() < b->getName(); }); }
//-***************************************************************************** AbcA::ArrayPropertyReaderPtr CprData::getArrayProperty( AbcA::CompoundPropertyReaderPtr iParent, const std::string &iName ) { // map of names to indexes filled by ctor (CprAttrVistor), // so multithread safe. SubPropertiesMap::iterator fiter = m_subProperties.find( iName ); if ( fiter == m_subProperties.end() ) { return AbcA::ArrayPropertyReaderPtr(); } // make sure we've read the header getPropertyHeader( iParent, fiter->second ); SubProperty & sub = m_propertyHeaders[fiter->second]; if ( !(sub.header->isArray()) ) { ABCA_THROW( "Tried to read an array property from a non-array: " << iName << ", type: " << sub.header->getPropertyType() ); } Alembic::Util::scoped_lock l( m_subPropertyMutexes[fiter->second] ); AbcA::BasePropertyReaderPtr bptr = sub.made.lock(); if ( ! bptr ) { // Make a new one. bptr = Alembic::Util::shared_ptr<AprImpl>( new AprImpl( iParent, m_group, sub.header, sub.isScalarLike, sub.numSamples, sub.firstChangedIndex, sub.lastChangedIndex ) ); sub.made = bptr; } AbcA::ArrayPropertyReaderPtr ret = Alembic::Util::dynamic_pointer_cast<AbcA::ArrayPropertyReader, AbcA::BasePropertyReader>( bptr ); return ret; }
//-***************************************************************************** AbcA::CompoundPropertyReaderPtr CprData::getCompoundProperty( AbcA::CompoundPropertyReaderPtr iParent, const std::string &iName ) { // map of names to indexes filled by ctor (CprAttrVistor), // so multithread safe. SubPropertiesMap::iterator fiter = m_subProperties.find( iName ); if ( fiter == m_subProperties.end() ) { return AbcA::CompoundPropertyReaderPtr(); } // make sure we've read the header getPropertyHeader( iParent, fiter->second ); SubProperty & sub = m_propertyHeaders[fiter->second]; if ( !(sub.header->isCompound()) ) { ABCA_THROW( "Tried to read a compound property from a non-compound: " << iName << ", type: " << sub.header->getPropertyType() ); } AbcA::BasePropertyReaderPtr bptr = sub.made.lock(); if ( ! bptr ) { // Make a new one. bptr = Alembic::Util::shared_ptr<CprImpl>( new CprImpl( iParent, m_group, sub.header ) ); sub.made = bptr; } AbcA::CompoundPropertyReaderPtr ret = Alembic::Util::dynamic_pointer_cast<AbcA::CompoundPropertyReader, AbcA::BasePropertyReader>( bptr ); return ret; }