示例#1
0
AttributeCache::AttributeCache( const std::string &filename, IndexedIO::OpenMode mode )
{
	IndexedIOPtr io = IndexedIO::create(filename, IndexedIO::rootPath, mode );

	if ( mode == IndexedIO::Write || mode == IndexedIO::Append )
	{
		m_headersIO = io->subdirectory("headers", IndexedIO::CreateIfMissing );
		m_objectsIO = io->subdirectory("objects", IndexedIO::CreateIfMissing );

		CompoundObjectPtr header = HeaderGenerator::header();
		for ( CompoundObject::ObjectMap::const_iterator it = header->members().begin(); it != header->members().end(); it++ )
		{
			writeHeader( it->first, it->second.get() );
		}
	}
	if ( mode == IndexedIO::Read )
	{
		try
		{
			m_headersIO = io->subdirectory("headers");
			m_objectsIO = io->subdirectory("objects");
		}
		catch (IECore::Exception &e)
		{
			throw Exception("Not an AttributeCache file.");
		}
	}
}
示例#2
0
		void save( IECore::Object::SaveContext *context ) const
		{
			IndexedIOPtr container = context->container( ShaderNetwork::staticTypeName(), g_ioVersion );

			IndexedIOPtr shaders = container->subdirectory( "shaders", IndexedIO::CreateIfMissing );
			IndexedIOPtr connections = container->subdirectory( "connections", IndexedIO::CreateIfMissing );

			int connectionIndex = 0;
			for( const Node &node : m_nodes )
			{
				context->save( node.shader.get(), shaders.get(), node.handle );
				for( const Connection &connection : node.inputConnections )
				{
					InternedString c[4] = {
						connection.source.shader,
						connection.source.name,
						connection.destination.shader,
						connection.destination.name
					};
					connections->write(
						std::to_string( connectionIndex ),
						c, 4
					);
					connectionIndex++;
				}
			}

			InternedString o[2] = { m_output.shader, m_output.name };
			container->write( "output", o, 2 );
		}
示例#3
0
void Primitive::save( IECore::Object::SaveContext *context ) const
{
    VisibleRenderable::save( context );
    IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion );
    IndexedIOPtr ioVariables = container->subdirectory( g_variablesEntry, IndexedIO::CreateIfMissing );
    for( PrimitiveVariableMap::const_iterator it=variables.begin(); it!=variables.end(); it++ )
    {
        IndexedIOPtr ioPrimVar = ioVariables->subdirectory( it->first, IndexedIO::CreateIfMissing );
        const int i = it->second.interpolation;
        ioPrimVar->write( g_interpolationEntry, i );
        context->save( it->second.data.get(), ioPrimVar.get(), g_dataEntry );
    }
}
void MatrixMotionTransform::save( SaveContext *context ) const
{
	Transform::save( context );
	IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion );
	container = container->subdirectory( g_snapshotsEntry, IndexedIO::CreateIfMissing );
	int i = 0;
	for( SnapshotMap::const_iterator it=m_snapshots.begin(); it!=m_snapshots.end(); it++ )
	{
		string is = str( boost::format( "%d" ) % i );
		IndexedIOPtr snapshotContainer = container->subdirectory( is, IndexedIO::CreateIfMissing );
		snapshotContainer->write( g_timeEntry, it->first );
		snapshotContainer->write( g_matrixEntry, it->second.getValue(), 16 );
		i++;
	}
}
void MotionPrimitive::save( IECore::Object::SaveContext *context ) const
{
	VisibleRenderable::save( context );
	IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion );
	IndexedIOPtr snapshots = container->subdirectory( g_snapshotsEntry, IndexedIO::CreateIfMissing );

	int i = 0;
	for( SnapshotMap::const_iterator it=m_snapshots.begin(); it!=m_snapshots.end(); it++ )
	{
		string is = str( boost::format( "%d" ) % i );
		IndexedIOPtr snapshot = snapshots->subdirectory( is, IndexedIO::CreateIfMissing );
		snapshot->write( g_timeEntry, it->first );
		context->save( it->second, snapshot, g_primitiveEntry );
		i++;
	}
}
示例#6
0
IndexedIOPtr Object::SaveContext::container( const std::string &typeName, unsigned int ioVersion )
{
	IndexedIOPtr typeIO = m_ioInterface->subdirectory( typeName, IndexedIO::CreateIfMissing );
	typeIO->write( g_ioVersionEntry, ioVersion );
	IndexedIOPtr dataIO = typeIO->subdirectory( g_dataEntry, IndexedIO::CreateIfMissing );
	dataIO->removeAll();
	return dataIO;
}
示例#7
0
void CompoundDataBase::save( SaveContext *context ) const
{
	Data::save( context );
	IndexedIOPtr container = context->container( staticTypeName(), 0 );
	container = container->subdirectory( g_membersEntry, IndexedIO::CreateIfMissing );
	const CompoundDataMap &m = readable();
	CompoundDataMap::const_iterator it;
	for( it=m.begin(); it!=m.end(); it++ )
	{
		context->save( it->second.get(), container.get(), it->first );
	}
}
示例#8
0
void ObjectVector::save( SaveContext *context ) const
{
	Object::save( context );
	IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion );

	unsigned int size = m_members.size();
	container->write( g_sizeEntry, size );

	IndexedIOPtr ioMembers = container->subdirectory( g_membersEntry, IndexedIO::CreateIfMissing );

	unsigned i=0;
	for( MemberContainer::const_iterator it=m_members.begin(); it!=m_members.end(); it++ )
	{
		if( *it )
		{
			std::string name = str( boost::format( "%d" ) % i );
			context->save( *it, ioMembers, name );
		}
		i++;
	}
}