HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ArchiveInfo.h
Go to the documentation of this file.
1 //-*****************************************************************************
2 //
3 // Copyright (c) 2009-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 #ifndef Alembic_Abc_ArchiveInfo_h
38 #define Alembic_Abc_ArchiveInfo_h
39 
40 #include <Alembic/Util/Export.h>
41 #include <Alembic/Abc/Foundation.h>
42 #include <Alembic/Abc/IArchive.h>
43 #include <Alembic/Abc/OArchive.h>
44 #include <cfloat>
45 #include <time.h>
46 
47 namespace Alembic {
48 namespace Abc {
49 namespace ALEMBIC_VERSION_NS {
50 
51 //-*****************************************************************************
52 // Alembic archive information:
53 // Useful utilities that readers and writers can use to provide
54 // useful annotations into the alembic file.
55 
56 //-*****************************************************************************
57 // Some MetaData key constants
58 static ALEMBIC_EXPORT_CONST char * kApplicationNameKey = "_ai_Application";
59 static ALEMBIC_EXPORT_CONST char * kDateWrittenKey = "_ai_DateWritten";
60 static ALEMBIC_EXPORT_CONST char * kUserDescriptionKey = "_ai_Description";
61 static ALEMBIC_EXPORT_CONST char * kDCCFPSKey = "_ai_DCC_FPS";
62 
63 //-*****************************************************************************
64 template <class ARCHIVE_CTOR>
66  //! We need to pass in a constructor which provides
67  //! an explicit link to the concrete implementation of
68  //! AbcCoreAbstract that we're using.
69  ARCHIVE_CTOR iCtor,
70 
71  //! File name
72  const std::string &iFileName,
73 
74  //! Application specific information about what is writing the file
75  const std::string & iApplicationWriter,
76 
77  //! Extra information, could be arguments to the tool that is
78  //! writing the file.
79  const std::string & iUserDescription,
80 
81  //! Optional meta data or error handling policy
82  const Argument &iArg0 = Argument(),
83 
84  //! Optional meta data or error handling policy
85  const Argument &iArg1 = Argument() );
86 
87 //-*****************************************************************************
88 template <class ARCHIVE_CTOR>
90  //! We need to pass in a constructor which provides
91  //! an explicit link to the concrete implementation of
92  //! AbcCoreAbstract that we're using.
93  ARCHIVE_CTOR iCtor,
94 
95  //! File name
96  const std::string &iFileName,
97 
98  //! Optional FPS hint that the DCC used at write time
99  double iDCCFPS,
100 
101  //! Application specific information about what is writing the file
102  const std::string & iApplicationWriter,
103 
104  //! Extra information, could be arguments to the tool that is
105  //! writing the file.
106  const std::string & iUserDescription,
107 
108  //! Optional meta data or error handling policy
109  const Argument &iArg0 = Argument(),
110 
111  //! Optional meta data or error handling policy
112  const Argument &iArg1 = Argument() );
113 
114 //-*****************************************************************************
115 ALEMBIC_EXPORT void
117  //! The Archive whose meta data will be inspected
118  IArchive & iArchive,
119 
120  //! Application specific information about what wrote the file
121  std::string & oApplicationWriter,
122 
123  //! What version of Alembic wrote the file (and when it was built)
124  std::string & oAlembicVersion,
125 
126  //! Numeric version of the Alembic API that wrote the file
127  Util::uint32_t & oAlembicApiVersion,
128 
129  //! The data that the file was originally written
130  std::string & oDateWritten,
131 
132  //! Extra information, could be arguments to the tool that wrote the file.
133  std::string & oUserDescription );
134 
135 //-*****************************************************************************
136 ALEMBIC_EXPORT void
138  //! The Archive whose meta data will be inspected
139  IArchive & iArchive,
140 
141  //! Application specific information about what wrote the file
142  std::string & oApplicationWriter,
143 
144  //! What version of Alembic wrote the file (and when it was built)
145  std::string & oAlembicVersion,
146 
147  //! Numeric version of the Alembic API that wrote the file
148  Util::uint32_t & oAlembicApiVersion,
149 
150  //! The data that the file was originally written
151  std::string & oDateWritten,
152 
153  //! Extra information, could be arguments to the tool that wrote the file.
154  std::string & oUserDescription,
155 
156  //! Optional hint about what FPS was being used by the DCC when this archive
157  //! was created.
158  double & oDCCFPS);
159 
160 //-*****************************************************************************
161 //! Convenience function which gets a start and end time for the archive using
162 //! only IArchive::getMaxNumSamplesForTimeSamplingIndex. The hierarchy is
163 //! NOT walked.
164 //! If the archive was written prior to 1.1.3 or no samples were written for
165 //! any of the properties DBL_MAX will be set for oStartTime
166 //! and -DBL_MAX will be set for oEndTime.
167 ALEMBIC_EXPORT void
169  //! The Archive to be inspected
170  IArchive & iArchive,
171  //! The start time for the archive in seconds
172  double & oStartTime,
173  //! The end time for the archive in seconds
174  double & oEndTime );
175 
176 //-*****************************************************************************
177 template <class ARCHIVE_CTOR>
179  ARCHIVE_CTOR iCtor,
180  const std::string &iFileName,
181  double iDCCFPS,
182  const std::string &iApplicationWriter,
183  const std::string &iUserDescription,
184  const Argument &iArg0,
185  const Argument &iArg1 )
186 {
187  AbcA::MetaData md = GetMetaData( iArg0, iArg1 );
189 
190  if ( iApplicationWriter != "" )
191  {
192  md.set( kApplicationNameKey, iApplicationWriter );
193  }
194 
195  time_t rawtimeNow;
196  time( &rawtimeNow );
197  char dateBuf [128];
198 #if defined _WIN32 || defined _WIN64
199  ctime_s( dateBuf, 128, &rawtimeNow);
200 #else
201  ctime_r( &rawtimeNow, dateBuf );
202 #endif
203 
204  std::size_t bufLen = strlen( dateBuf );
205  if ( bufLen > 0 && dateBuf[bufLen - 1] == '\n' )
206  {
207  dateBuf[bufLen - 1] = '\0';
208  }
209  md.set( kDateWrittenKey, dateBuf );
210 
211  if ( iUserDescription != "" )
212  {
213  md.set( kUserDescriptionKey, iUserDescription );
214  }
215 
216  if ( iDCCFPS > 0.0 )
217  {
218  md.set( kDCCFPSKey, std::to_string( iDCCFPS ) );
219  }
220 
221  return OArchive( iCtor, iFileName, md, policy );
222 
223 }
224 
225 template <class ARCHIVE_CTOR>
227  ARCHIVE_CTOR iCtor,
228  const std::string &iFileName,
229  const std::string &iApplicationWriter,
230  const std::string &iUserDescription,
231  const Argument &iArg0,
232  const Argument &iArg1 )
233 {
234  return CreateArchiveWithInfo( iCtor, iFileName, 0, iApplicationWriter,
235  iUserDescription, iArg0, iArg1 );
236 }
237 
238 } // End namespace ALEMBIC_VERSION_NS
239 
240 using namespace ALEMBIC_VERSION_NS;
241 
242 } // End namespace Abc
243 } // End namespace Alembic
244 
245 #endif
auto to_string(const T &value) -> std::string
Definition: format.h:2597
hboost::math::policies::policy< hboost::math::policies::domain_error< hboost::math::policies::ignore_error >, hboost::math::policies::pole_error< hboost::math::policies::ignore_error >, hboost::math::policies::overflow_error< hboost::math::policies::ignore_error >, hboost::math::policies::underflow_error< hboost::math::policies::ignore_error >, hboost::math::policies::denorm_error< hboost::math::policies::ignore_error >, hboost::math::policies::rounding_error< hboost::math::policies::ignore_error >, hboost::math::policies::evaluation_error< hboost::math::policies::ignore_error >, hboost::math::policies::indeterminate_result_error< hboost::math::policies::ignore_error > > policy
Definition: SYS_MathCbrt.h:35
GT_API const UT_StringHolder time
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
#define ALEMBIC_EXPORT
Definition: Export.h:51
AbcA::MetaData GetMetaData(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition: Argument.h:273
ErrorHandler::Policy GetErrorHandlerPolicyFromArgs(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition: Argument.h:258
ALEMBIC_EXPORT void GetArchiveInfo(IArchive &iArchive, std::string &oApplicationWriter, std::string &oAlembicVersion, Util::uint32_t &oAlembicApiVersion, std::string &oDateWritten, std::string &oUserDescription)
#define ALEMBIC_EXPORT_CONST
Definition: Export.h:53
OArchive CreateArchiveWithInfo(ARCHIVE_CTOR iCtor, const std::string &iFileName, const std::string &iApplicationWriter, const std::string &iUserDescription, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Definition: ArchiveInfo.h:226
ALEMBIC_EXPORT void GetArchiveStartAndEndTime(IArchive &iArchive, double &oStartTime, double &oEndTime)
void set(const std::string &iKey, const std::string &iData)
Definition: MetaData.h:168
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:88