Coverage Report

Created: 2023-03-26 07:07

/src/alembic/lib/Alembic/AbcCoreOgawa/ReadWrite.cpp
Line
Count
Source (jump to first uncovered line)
1
//-*****************************************************************************
2
//
3
// Copyright (c) 2013,
4
//  Sony Pictures Imageworks Inc. and
5
//  Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
6
//
7
// All rights reserved.
8
//
9
// Redistribution and use in source and binary forms, with or without
10
// modification, are permitted provided that the following conditions are
11
// met:
12
// *       Redistributions of source code must retain the above copyright
13
// notice, this list of conditions and the following disclaimer.
14
// *       Redistributions in binary form must reproduce the above
15
// copyright notice, this list of conditions and the following disclaimer
16
// in the documentation and/or other materials provided with the
17
// distribution.
18
// *       Neither the name of Sony Pictures Imageworks, nor
19
// Industrial Light & Magic, nor the names of their contributors may be used
20
// to endorse or promote products derived from this software without specific
21
// prior written permission.
22
//
23
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
//
35
//-*****************************************************************************
36
37
#include <Alembic/AbcCoreOgawa/ReadWrite.h>
38
#include <Alembic/AbcCoreOgawa/Foundation.h>
39
#include <Alembic/AbcCoreOgawa/AwImpl.h>
40
#include <Alembic/AbcCoreOgawa/ArImpl.h>
41
42
namespace Alembic {
43
namespace AbcCoreOgawa {
44
namespace ALEMBIC_VERSION_NS {
45
46
//-*****************************************************************************
47
WriteArchive::WriteArchive()
48
0
{
49
0
}
50
51
//-*****************************************************************************
52
AbcA::ArchiveWriterPtr
53
WriteArchive::operator()( const std::string &iFileName,
54
                          const AbcA::MetaData &iMetaData ) const
55
0
{
56
0
    Alembic::Util::shared_ptr<AwImpl> archivePtr(
57
0
        new AwImpl( iFileName, iMetaData ) );
58
0
    return archivePtr;
59
0
}
60
61
//-*****************************************************************************
62
AbcA::ArchiveWriterPtr
63
WriteArchive::operator()( std::ostream * iStream,
64
                          const AbcA::MetaData &iMetaData ) const
65
0
{
66
0
    Alembic::Util::shared_ptr<AwImpl> archivePtr(
67
0
        new AwImpl( iStream, iMetaData ) );
68
0
    return archivePtr;
69
0
}
70
71
//-*****************************************************************************
72
ReadArchive::ReadArchive()
73
0
{
74
0
    m_numStreams = 1;
75
0
    m_useMMap = true;
76
0
}
77
78
//-*****************************************************************************
79
ReadArchive::ReadArchive( size_t iNumStreams, bool iUseMMap )
80
267
{
81
267
    m_numStreams = iNumStreams;
82
267
    m_useMMap = iUseMMap;
83
267
}
84
85
//-*****************************************************************************
86
ReadArchive::ReadArchive( const std::vector< std::istream * > & iStreams )
87
    : m_numStreams( 1 ), m_useMMap(true), m_streams( iStreams )
88
0
{
89
0
}
90
91
//-*****************************************************************************
92
AbcA::ArchiveReaderPtr
93
ReadArchive::operator()( const std::string &iFileName ) const
94
0
{
95
0
    AbcA::ArchiveReaderPtr archivePtr;
96
97
0
    if ( m_streams.empty() )
98
0
    {
99
0
        archivePtr = Alembic::Util::shared_ptr<ArImpl>(
100
0
            new ArImpl( iFileName, m_numStreams, m_useMMap ) );
101
0
    }
102
0
    else
103
0
    {
104
0
        archivePtr = Alembic::Util::shared_ptr<ArImpl>(
105
0
            new ArImpl( m_streams ) );
106
0
    }
107
0
    return archivePtr;
108
0
}
109
110
//-*****************************************************************************
111
// The given cache is ignored.
112
AbcA::ArchiveReaderPtr
113
ReadArchive::operator()( const std::string &iFileName,
114
            AbcA::ReadArraySampleCachePtr iCache ) const
115
267
{
116
267
    AbcA::ArchiveReaderPtr archivePtr;
117
118
267
    if ( m_streams.empty() )
119
267
    {
120
267
        archivePtr = Alembic::Util::shared_ptr<ArImpl> (
121
267
            new ArImpl( iFileName, m_numStreams, m_useMMap ) );
122
267
    }
123
0
    else
124
0
    {
125
0
        archivePtr = Alembic::Util::shared_ptr<ArImpl> (
126
0
            new ArImpl( m_streams ) );
127
0
    }
128
267
    return archivePtr;
129
267
}
130
131
} // End namespace ALEMBIC_VERSION_NS
132
} // End namespace AbcCoreOgawa
133
} // End namespace Alembic