HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IFactory.h
Go to the documentation of this file.
1 //-*****************************************************************************
2 //
3 // Copyright (c) 2013-2015,
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 #ifndef Alembic_AbcCoreFactory_IFactory_h
38 #define Alembic_AbcCoreFactory_IFactory_h
39 
41 #include <Alembic/Abc/IArchive.h>
42 #include <Alembic/Util/Export.h>
43 
44 namespace Alembic {
45 namespace AbcCoreFactory {
46 namespace ALEMBIC_VERSION_NS {
47 
49 {
50 public:
51  IFactory();
52  ~IFactory();
53 
54  //! The type which yielded a valid IArchive (or kUnknown if invalid)
55  enum CoreType
56  {
60  kUnknown
61  };
62 
63  //! Try to open a file and set oType to the one that yields a successful
64  //! oType, or kUnknown if the IArchive isn't valid
65  Alembic::Abc::IArchive getArchive( const std::string & iFileName,
66  CoreType & oType );
67 
68  //! Try to open a file and return IArchive. If the file wasn't a valid
69  //! file or known type and invalid archive is returned.
70  Alembic::Abc::IArchive getArchive( const std::string & iFileName );
71 
72  //! Open a series of alembic files, layering each file on top of the next
73  //! to present a single IArchive
74  Alembic::Abc::IArchive getArchive(
75  const std::vector< std::string > & iFileNames );
76 
77  //! Try to open and layer a series of files file and return IArchive.
78  //! If all of the files are invalid, an invalid archive is returned.
79  //! If only some of the archives are invalid, only the good ones are
80  //! opened and layered, while invalid ones are ignored.
81  Alembic::Abc::IArchive getArchive(
82  const std::vector< std::string > & iFileNames, CoreType & oType );
83 
84  //! Use the streams (Alembic does not take ownership) to read the data from
85  //! This is currently only valid for Ogawa. The streams must all reference
86  //! the same data.
87  Alembic::Abc::IArchive getArchive(
88  const std::vector< std::istream * > & iStreams, CoreType & oType );
89 
90  // TODO, how do we best layer streams, and strings
91 
92  //! If opening an HDF5 file, sets whether to use the cached hierarchy
93  //! if it exists, the default value is true
94  void setHDF5CacheHierarchy( bool iCacheHierarchy )
95  {
96  m_cacheHierarchy = iCacheHierarchy;
97  }
98 
99  //! Gets whether an HDF5 file will use the cached hierarchy
100  bool getHDF5CacheHierarchy() const { return m_cacheHierarchy; }
101 
102  //! Set the array sample cache, the HDF5 implementation optionally uses this
105  {
106  m_cachePtr = iCachePtr;
107  }
108 
109  //! Get the array sample cache
111  {
112  return m_cachePtr;
113  }
114 
115  //! Gets the number of streams that will be opened when opening an Ogawa
116  //! file
117  size_t getOgawaNumStreams() const { return m_numStreams; }
118 
119  //! Sets the number of streams that will be opened when opening an Ogawa
120  //! file, the default is 1
121  void setOgawaNumStreams( size_t iNumStreams )
122  {
123  m_numStreams = iNumStreams;
124  }
125 
127  {
129  kMemoryMappedFiles
130  };
131 
132  //! Get the I/O strategy used for reading Ogawa files.
133  OgawaReadStrategy getOgawaReadStrategy() { return m_readStrategy; }
134 
135  //! Sets the I/O strategy used for reading Ogawa files. The default is
136  //! kMemoryMappedFiles.
138  {
139  m_readStrategy = iStrategy;
140  }
141 
142 
143  //! Gets the error handler policy
145 
146  //! Sets the error handler policy, the default is kThrowPolicy
148  {
149  m_policy = iPolicy;
150  }
151 
152 private:
153  bool m_cacheHierarchy;
154  size_t m_numStreams;
155  OgawaReadStrategy m_readStrategy;
158 
159 };
160 
161 } // End namespace ALEMBIC_VERSION_NS
162 
163 using namespace ALEMBIC_VERSION_NS;
164 
165 } // End namespace Abc
166 } // End namespace Alembic
167 
168 #endif
void setSampleCache(Alembic::AbcCoreAbstract::ReadArraySampleCachePtr iCachePtr)
Set the array sample cache, the HDF5 implementation optionally uses this.
Definition: IFactory.h:103
Alembic::Abc::ErrorHandler::Policy getPolicy()
Gets the error handler policy.
Definition: IFactory.h:144
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
#define ALEMBIC_EXPORT
Definition: Export.h:51
OgawaReadStrategy getOgawaReadStrategy()
Get the I/O strategy used for reading Ogawa files.
Definition: IFactory.h:133
void setHDF5CacheHierarchy(bool iCacheHierarchy)
Definition: IFactory.h:94
Alembic::Util::shared_ptr< ReadArraySampleCache > ReadArraySampleCachePtr
void setPolicy(Alembic::Abc::ErrorHandler::Policy iPolicy)
Sets the error handler policy, the default is kThrowPolicy.
Definition: IFactory.h:147
Alembic::AbcCoreAbstract::ReadArraySampleCachePtr getSampleCache() const
Get the array sample cache.
Definition: IFactory.h:110
CoreType
The type which yielded a valid IArchive (or kUnknown if invalid)
Definition: IFactory.h:55
bool getHDF5CacheHierarchy() const
Gets whether an HDF5 file will use the cached hierarchy.
Definition: IFactory.h:100
void setOgawaReadStrategy(OgawaReadStrategy iStrategy)
Definition: IFactory.h:137
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:88