HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 <time.h>
45 
46 namespace Alembic {
47 namespace Abc {
48 namespace ALEMBIC_VERSION_NS {
49 
50 //-*****************************************************************************
51 // Alembic archive information:
52 // Useful utilities that readers and writers can use to provide
53 // useful annotations into the alembic file.
54 
55 //-*****************************************************************************
56 // Some MetaData key constants
57 static ALEMBIC_EXPORT_CONST char * kApplicationNameKey = "_ai_Application";
58 static ALEMBIC_EXPORT_CONST char * kDateWrittenKey = "_ai_DateWritten";
59 static ALEMBIC_EXPORT_CONST char * kUserDescriptionKey = "_ai_Description";
60 
61 //-*****************************************************************************
62 template <class ARCHIVE_CTOR>
64  //! We need to pass in a constructor which provides
65  //! an explicit link to the concrete implementation of
66  //! AbcCoreAbstract that we're using.
67  ARCHIVE_CTOR iCtor,
68 
69  //! File name
70  const std::string &iFileName,
71 
72  //! Application specific information about what is writing the file
73  const std::string & iApplicationWriter,
74 
75  //! Extra information, could be arguments to the tool that is
76  //! writing the file.
77  const std::string & iUserDescription,
78 
79  //! Optional meta data or error handling policy
80  const Argument &iArg0 = Argument(),
81 
82  //! Optional meta data or error handling policy
83  const Argument &iArg1 = Argument() );
84 
85 //-*****************************************************************************
86 ALEMBIC_EXPORT void
88  //! The Archive whose meta data will be inspected
89  IArchive & iArchive,
90 
91  //! Application specific information about what wrote the file
92  std::string & oApplicationWriter,
93 
94  //! What version of Alembic wrote the file (and when it was built)
95  std::string & oAlembicVersion,
96 
97  //! Numeric version of the Alembic API that wrote the file
98  Util::uint32_t & oAlembicApiVersion,
99 
100  //! The data that the file was originally written
101  std::string & oDateWritten,
102 
103  //! Extra information, could be arguments to the tool that wrote the file.
104  std::string & oUserDescription );
105 
106 //-*****************************************************************************
107 //! Convenience function which gets a start and end time for the archive using
108 //! only IArchive::getMaxNumSamplesForTimeSamplingIndex. The hierarchy is
109 //! NOT walked.
110 //! If the archive was written prior to 1.1.3 or no samples were written for
111 //! any of the properties DBL_MAX will be set for oStartTime
112 //! and -DBL_MAX will be set for oEndTime.
113 ALEMBIC_EXPORT void
115  //! The Archive to be inspected
116  IArchive & iArchive,
117  //! The start time for the archive in seconds
118  double & oStartTime,
119  //! The end time for the archive in seconds
120  double & oEndTime );
121 
122 //-*****************************************************************************
123 template <class ARCHIVE_CTOR>
125  ARCHIVE_CTOR iCtor,
126  const std::string &iFileName,
127  const std::string &iApplicationWriter,
128  const std::string &iUserDescription,
129  const Argument &iArg0,
130  const Argument &iArg1 )
131 {
132  AbcA::MetaData md = GetMetaData( iArg0, iArg1 );
134 
135  if ( iApplicationWriter != "" )
136  {
137  md.set( kApplicationNameKey, iApplicationWriter );
138  }
139 
140  time_t rawtimeNow;
141  time( &rawtimeNow );
142  char dateBuf [128];
143 #if defined _WIN32 || defined _WIN64
144  ctime_s( dateBuf, 128, &rawtimeNow);
145 #else
146  ctime_r( &rawtimeNow, dateBuf );
147 #endif
148 
149  std::size_t bufLen = strlen( dateBuf );
150  if ( bufLen > 0 && dateBuf[bufLen - 1] == '\n' )
151  {
152  dateBuf[bufLen - 1] = '\0';
153  }
154  md.set( kDateWrittenKey, dateBuf );
155 
156  if ( iUserDescription != "" )
157  {
158  md.set( kUserDescriptionKey, iUserDescription );
159  }
160 
161  return OArchive( iCtor, iFileName, md, policy );
162 
163 }
164 
165 } // End namespace ALEMBIC_VERSION_NS
166 
167 using namespace ALEMBIC_VERSION_NS;
168 
169 } // End namespace Abc
170 } // End namespace Alembic
171 
172 #endif
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
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
ALEMBIC_EXPORT void GetArchiveInfo(IArchive &iArchive, std::string &oApplicationWriter, std::string &oAlembicVersion, Util::uint32_t &oAlembicApiVersion, std::string &oDateWritten, std::string &oUserDescription)
ErrorHandler::Policy GetErrorHandlerPolicyFromArgs(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition: Argument.h:233
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:124
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_EXPORT_CONST
Definition: Export.h:53
AbcA::MetaData GetMetaData(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition: Argument.h:246
#define ALEMBIC_EXPORT
Definition: Export.h:51
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104