Alembic Version 1.1

Loading...
Searching...
No Matches
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 static ALEMBIC_EXPORT_CONST char * kDCCFPSKey = "_ai_DCC_FPS";
61
62//-*****************************************************************************
63 template <class ARCHIVE_CTOR>
64 OArchive CreateArchiveWithInfo(
68 ARCHIVE_CTOR iCtor,
69
71 const std::string &iFileName,
72
74 const std::string & iApplicationWriter,
75
78 const std::string & iUserDescription,
79
81 const Argument &iArg0 = Argument(),
82
84 const Argument &iArg1 = Argument() );
85
86//-*****************************************************************************
87 template <class ARCHIVE_CTOR>
88 OArchive CreateArchiveWithInfo(
92 ARCHIVE_CTOR iCtor,
93
95 const std::string &iFileName,
96
98 double iDCCFPS,
99
101 const std::string & iApplicationWriter,
102
105 const std::string & iUserDescription,
106
108 const Argument &iArg0 = Argument(),
109
111 const Argument &iArg1 = Argument() );
112
113//-*****************************************************************************
114 ALEMBIC_EXPORT void
115 GetArchiveInfo(
117 IArchive & iArchive,
118
120 std::string & oApplicationWriter,
121
123 std::string & oAlembicVersion,
124
126 Util::uint32_t & oAlembicApiVersion,
127
129 std::string & oDateWritten,
130
132 std::string & oUserDescription );
133
134//-*****************************************************************************
135 ALEMBIC_EXPORT void
136 GetArchiveInfo(
138 IArchive & iArchive,
139
141 std::string & oApplicationWriter,
142
144 std::string & oAlembicVersion,
145
147 Util::uint32_t & oAlembicApiVersion,
148
150 std::string & oDateWritten,
151
153 std::string & oUserDescription,
154
157 double & oDCCFPS);
158
159//-*****************************************************************************
166 ALEMBIC_EXPORT void
167 GetArchiveStartAndEndTime(
169 IArchive & iArchive,
171 double & oStartTime,
173 double & oEndTime );
174
175//-*****************************************************************************
176 template <class ARCHIVE_CTOR>
177 OArchive CreateArchiveWithInfo(
178 ARCHIVE_CTOR iCtor,
179 const std::string &iFileName,
180 double iDCCFPS,
181 const std::string &iApplicationWriter,
182 const std::string &iUserDescription,
183 const Argument &iArg0,
184 const Argument &iArg1 )
185{
186 AbcA::MetaData md = GetMetaData( iArg0, iArg1 );
187 ErrorHandler::Policy policy = GetErrorHandlerPolicyFromArgs( iArg0, iArg1 );
188
189 if ( iApplicationWriter != "" )
190 {
191 md.set( kApplicationNameKey, iApplicationWriter );
192 }
193
194 time_t rawtimeNow;
195 time( &rawtimeNow );
196 char dateBuf [128];
197#if defined _WIN32 || defined _WIN64
198 ctime_s( dateBuf, 128, &rawtimeNow);
199#else
200 ctime_r( &rawtimeNow, dateBuf );
201#endif
202
203 std::size_t bufLen = strlen( dateBuf );
204 if ( bufLen > 0 && dateBuf[bufLen - 1] == '\n' )
205 {
206 dateBuf[bufLen - 1] = '\0';
207 }
208 md.set( kDateWrittenKey, dateBuf );
209
210 if ( iUserDescription != "" )
211 {
212 md.set( kUserDescriptionKey, iUserDescription );
213 }
214
215 if ( iDCCFPS > 0.0 )
216 {
217 md.set( kDCCFPSKey, std::to_string( iDCCFPS ) );
218 }
219
220 return OArchive( iCtor, iFileName, md, policy );
221
222}
223
224 template <class ARCHIVE_CTOR>
225 OArchive CreateArchiveWithInfo(
226 ARCHIVE_CTOR iCtor,
227 const std::string &iFileName,
228 const std::string &iApplicationWriter,
229 const std::string &iUserDescription,
230 const Argument &iArg0,
231 const Argument &iArg1 )
232{
233 return CreateArchiveWithInfo( iCtor, iFileName, 0, iApplicationWriter,
234 iUserDescription, iArg0, iArg1 );
235}
236
237} // End namespace ALEMBIC_VERSION_NS
238
239 using namespace ALEMBIC_VERSION_NS;
240
241} // End namespace Abc
242} // End namespace Alembic
243
244#endif
Foundation.h
Export.h
ALEMBIC_EXPORT_CONST
#define ALEMBIC_EXPORT_CONST
Definition Export.h:53
ALEMBIC_EXPORT
#define ALEMBIC_EXPORT
Definition Export.h:51
IArchive.h
OArchive.h
ALEMBIC_VERSION_NS
#define ALEMBIC_VERSION_NS
Definition Foundation.h:105
Alembic::Abc::ALEMBIC_VERSION_NS::Argument
Definition Argument.h:120
Alembic::Abc::ALEMBIC_VERSION_NS::ErrorHandler::Policy
Policy
Definition ErrorHandler.h:52
Alembic::Abc::ALEMBIC_VERSION_NS::IArchive
Definition IArchive.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::OArchive
Definition OArchive.h:53
Alembic::Util::ALEMBIC_VERSION_NS::uint32_t
Alembic::Abc::ALEMBIC_VERSION_NS
Definition ArchiveInfo.h:48
Alembic::Abc::ALEMBIC_VERSION_NS::GetErrorHandlerPolicyFromArgs
ErrorHandler::Policy GetErrorHandlerPolicyFromArgs(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition Argument.h:258
Alembic::Abc::ALEMBIC_VERSION_NS::CreateArchiveWithInfo
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:225
Alembic::Abc::ALEMBIC_VERSION_NS::kApplicationNameKey
static ALEMBIC_EXPORT_CONST char * kApplicationNameKey
Definition ArchiveInfo.h:57
Alembic::Abc::ALEMBIC_VERSION_NS::kUserDescriptionKey
static ALEMBIC_EXPORT_CONST char * kUserDescriptionKey
Definition ArchiveInfo.h:59
Alembic::Abc::ALEMBIC_VERSION_NS::GetArchiveInfo
ALEMBIC_EXPORT void GetArchiveInfo(IArchive &iArchive, std::string &oApplicationWriter, std::string &oAlembicVersion, Util::uint32_t &oAlembicApiVersion, std::string &oDateWritten, std::string &oUserDescription)
Alembic::Abc::ALEMBIC_VERSION_NS::GetArchiveStartAndEndTime
ALEMBIC_EXPORT void GetArchiveStartAndEndTime(IArchive &iArchive, double &oStartTime, double &oEndTime)
Alembic::Abc::ALEMBIC_VERSION_NS::kDateWrittenKey
static ALEMBIC_EXPORT_CONST char * kDateWrittenKey
Definition ArchiveInfo.h:58
Alembic::Abc::ALEMBIC_VERSION_NS::kDCCFPSKey
static ALEMBIC_EXPORT_CONST char * kDCCFPSKey
Definition ArchiveInfo.h:60
Alembic::Abc::ALEMBIC_VERSION_NS::GetMetaData
AbcA::MetaData GetMetaData(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition Argument.h:273
Alembic::Abc
Definition ArchiveInfo.h:47
Alembic
Alembic namespace ...
Definition ArchiveInfo.h:46