示例#1
0
//-*****************************************************************************
void
WriteKey( hid_t iHashDset,
          const std::string &iAttrName,
          const AbcA::ArraySample::Key &iKey )
{
    // keys are 16 bytes.
    WriteSmallArray( iHashDset, iAttrName,
                     H5T_STD_U8LE,
                     H5T_NATIVE_UINT8,
                     16,
                     ( const void * )&iKey.digest );
}
示例#2
0
//-*****************************************************************************
// Dimensions aren't a scalar, and thus must be written carefully.
void
WriteDimensions( hid_t iParent,
                 const std::string &iAttrName,
                 const Dimensions &iDims )
{

    size_t rank = iDims.rank();

    // Create temporary storage to write
    std::vector<uint32_t> dimStorage( rank );

    // Copy into it.
    for ( size_t r = 0; r < rank; ++r )
    {
        dimStorage[r] = ( uint32_t )iDims[r];
    }

    WriteSmallArray( iParent, iAttrName, H5T_STD_U32LE,
                     H5T_NATIVE_UINT32,
                     rank,
                     ( const void * )&dimStorage.front() );
}
示例#3
0
//-*****************************************************************************
void WritePropertyInfo( hid_t iGroup,
                    const AbcA::PropertyHeader &iHeader,
                    bool isScalarLike,
                    uint32_t iTimeSamplingIndex,
                    uint32_t iNumSamples,
                    uint32_t iFirstChangedIndex,
                    uint32_t iLastChangedIndex )
{

    uint32_t info[5] = {0, 0, 0, 0, 0};
    uint32_t numFields = 1;

    // 0000 0000 0000 0000 0000 0000 0000 0011
    static const uint32_t ptypeMask = 0x0003;

    // 0000 0000 0000 0000 0000 0000 0011 1100
    static const uint32_t podMask = 0x003c;

    // 0000 0000 0000 0000 0000 0000 0100 0000
    static const uint32_t hasTsidxMask = 0x0040;

    // 0000 0000 0000 0000 0000 0000 1000 0000
    static const uint32_t noRepeatsMask = 0x0080;

    // 0000 0000 0000 0000 1111 1111 0000 0000
    static const uint32_t extentMask = 0xff00;

    // compounds are treated differently
    if ( iHeader.getPropertyType() != AbcA::kCompoundProperty )
    {
        // Slam the property type in there.
        info[0] |= ptypeMask & ( uint32_t )iHeader.getPropertyType();

        // arrays may be scalar like, scalars are already scalar like
        info[0] |= ( uint32_t ) isScalarLike;

        uint32_t pod = ( uint32_t )iHeader.getDataType().getPod();
        info[0] |= podMask & ( pod << 2 );

        if (iTimeSamplingIndex != 0)
        {
            info[0] |= hasTsidxMask;
        }

        if (iFirstChangedIndex == 1 && iLastChangedIndex == iNumSamples - 1)
        {
            info[0] |= noRepeatsMask;
        }

        uint32_t extent = ( uint32_t )iHeader.getDataType().getExtent();
        info[0] |= extentMask & ( extent << 8 );

        ABCA_ASSERT( iFirstChangedIndex <= iNumSamples &&
            iLastChangedIndex <= iNumSamples &&
            iFirstChangedIndex <= iLastChangedIndex,
            "Illegal Sampling!" << std::endl <<
            "Num Samples: " << iNumSamples << std::endl <<
            "First Changed Index: " << iFirstChangedIndex << std::endl <<
            "Last Changed Index: " << iLastChangedIndex << std::endl );

        // Write the num samples. Only bother writing if
        // the num samples is greater than 1.  Existence of name.smp0
        // is used by the reader to determine if 0 or 1 sample.
        if ( iNumSamples > 1 )
        {
            info[1] = iNumSamples;
            numFields ++;
            if ( iFirstChangedIndex > 1 || ( iLastChangedIndex != 0 &&
                iLastChangedIndex != iNumSamples - 1 ) )
            {
                info[2] = iFirstChangedIndex;
                info[3] = iLastChangedIndex;
                numFields += 2;
            }
        }

        // finally set time sampling index on the end if necessary
        if (iTimeSamplingIndex != 0)
        {
            info[numFields] = iTimeSamplingIndex;
            numFields ++;
        }

    }

    WriteSmallArray( iGroup, iHeader.getName() + ".info",
        H5T_STD_U32LE, H5T_NATIVE_UINT32, numFields,
        ( const void * ) info );

    WriteMetaData( iGroup, iHeader.getName() + ".meta", iHeader.getMetaData());
}
示例#4
0
//-*****************************************************************************
void SpwImpl::copyPreviousSample( hid_t iGroup,
                                  const std::string &iSampleName,
                                  index_t iSampleIndex )
{
    assert( iGroup >= 0 );
    assert( m_previousSample.getData() );
    
    // Write the sample.
    const AbcA::DataType &dtype = m_header->getDataType();
    uint8_t extent = dtype.getExtent();

    if ( dtype.getPod() == kStringPOD )
    {
        const std::string *strings
            = reinterpret_cast<const std::string *>(
                m_previousSample.getData() );
        
        if ( extent == 1 )
        {
            WriteString( iGroup, iSampleName, *strings );
        }
        else
        {
            WriteStrings( iGroup, iSampleName, dtype.getExtent(), strings );
        }
    }
    else if ( dtype.getPod() == kWstringPOD )
    {
        const std::wstring *wstrings
            = reinterpret_cast<const std::wstring *>(
                m_previousSample.getData() );
        
        if ( extent == 1 )
        {
            WriteWstring( iGroup, iSampleName, *wstrings );
        }
        else
        {
            WriteWstrings( iGroup, iSampleName, dtype.getExtent(), wstrings );
        }
    }
    else
    {
        assert( m_fileDataType >= 0 );
        assert( m_nativeDataType >= 0 );
        if (extent == 1)
        {
            WriteScalar( iGroup, iSampleName,
                         m_fileDataType,
                         m_nativeDataType,
                         m_previousSample.getData() );
        }
        else
        {
            WriteSmallArray( iGroup, iSampleName,
                         m_fileDataType,
                         m_nativeDataType,
                         extent,
                         m_previousSample.getData() );
        }
    }
}
示例#5
0
//-*****************************************************************************
void WritePropertyInfo( hid_t iGroup,
                    const std::string &iName,
                    AbcA::PropertyType iPropertyType,
                    const AbcA::DataType &iDataType,
                    bool isScalarLike,
                    uint32_t iTimeSamplingIndex,
                    uint32_t iNumSamples,
                    uint32_t iFirstChangedIndex,
                    uint32_t iLastChangedIndex )
{

    uint32_t info[5] = {0, 0, 0, 0, 0};
    uint32_t numFields = 1;

    static const uint32_t ptypeMask = ( uint32_t )BOOST_BINARY (
        0000 0000 0000 0000 0000 0000 0000 0011 );

    static const uint32_t podMask = ( uint32_t )BOOST_BINARY (
        0000 0000 0000 0000 0000 0000 0011 1100 );

    static const uint32_t hasTsidxMask = ( uint32_t )BOOST_BINARY (
        0000 0000 0000 0000 0000 0000 0100 0000 );

    static const uint32_t noRepeatsMask = ( uint32_t )BOOST_BINARY (
        0000 0000 0000 0000 0000 0000 1000 0000 );

    static const uint32_t extentMask = ( uint32_t )BOOST_BINARY(
        0000 0000 0000 0000 1111 1111 0000 0000 );

    // for compounds we just write out 0
    if ( iPropertyType != AbcA::kCompoundProperty )
    {
        // Slam the property type in there.
        info[0] |= ptypeMask & ( uint32_t )iPropertyType;

        // arrays may be scalar like, scalars are already scalar like
        info[0] |= ( uint32_t ) isScalarLike;

        uint32_t pod = ( uint32_t )iDataType.getPod();
        info[0] |= podMask & ( pod << 2 );

        if (iTimeSamplingIndex != 0)
        {
            info[0] |= hasTsidxMask;
        }

        if (iFirstChangedIndex == 1 && iLastChangedIndex == iNumSamples - 1)
        {
            info[0] |= noRepeatsMask;
        }

        uint32_t extent = ( uint32_t )iDataType.getExtent();
        info[0] |= extentMask & ( extent << 8 );

        ABCA_ASSERT( iFirstChangedIndex <= iNumSamples &&
            iLastChangedIndex <= iNumSamples &&
            iFirstChangedIndex <= iLastChangedIndex,
            "Illegal Sampling!" << std::endl <<
            "Num Samples: " << iNumSamples << std::endl <<
            "First Changed Index: " << iFirstChangedIndex << std::endl <<
            "Last Changed Index: " << iLastChangedIndex << std::endl );

        // Write the num samples. Only bother writing if
        // the num samples is greater than 1.  Existence of name.smp0
        // is used by the reader to determine if 0 or 1 sample.
        if ( iNumSamples > 1 )
        {
            info[1] = iNumSamples;
            numFields ++;
            if ( iFirstChangedIndex > 1 || ( iLastChangedIndex != 0 &&
                iLastChangedIndex != iNumSamples - 1 ) )
            {
                info[2] = iFirstChangedIndex;
                info[3] = iLastChangedIndex;
                numFields += 2;
            }
        }

        // finally set time sampling index on the end if necessary
        if (iTimeSamplingIndex != 0)
        {
            info[numFields] = iTimeSamplingIndex;
            numFields ++;
        }

    }

    WriteSmallArray( iGroup, iName + ".info",
        H5T_STD_U32LE, H5T_NATIVE_UINT32, numFields,
        ( const void * ) info );
}