Loading...
Searching...
No Matches
ArchiveInfo.h
//-*****************************************************************************
//
// Copyright (c) 2009-2013,
// Sony Pictures Imageworks, Inc. and
// Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Sony Pictures Imageworks, nor
// Industrial Light & Magic nor the names of their contributors may be used
// to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//-*****************************************************************************
#ifndef Alembic_Abc_ArchiveInfo_h
#define Alembic_Abc_ArchiveInfo_h
#include <Alembic/Util/Export.h>
#include <Alembic/Abc/Foundation.h>
#include <Alembic/Abc/IArchive.h>
#include <Alembic/Abc/OArchive.h>
#include <cfloat>
#include <time.h>
namespace Alembic {
namespace Abc {
namespace ALEMBIC_VERSION_NS {
//-*****************************************************************************
// Alembic archive information:
// Useful utilities that readers and writers can use to provide
// useful annotations into the alembic file.
//-*****************************************************************************
// Some MetaData key constants
static const char * kApplicationNameKey = "_ai_Application";
static const char * kDateWrittenKey = "_ai_DateWritten";
static const char * kUserDescriptionKey = "_ai_Description";
static const char * kDCCFPSKey = "_ai_DCC_FPS";
//-*****************************************************************************
template <class ARCHIVE_CTOR>
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() );
//-*****************************************************************************
template <class ARCHIVE_CTOR>
OArchive CreateArchiveWithInfo(
ARCHIVE_CTOR iCtor,
const std::string &iFileName,
double iDCCFPS,
const std::string & iApplicationWriter,
const std::string & iUserDescription,
const Argument &iArg0 = Argument(),
const Argument &iArg1 = Argument() );
//-*****************************************************************************
ALEMBIC_EXPORT void
GetArchiveInfo(
IArchive & iArchive,
std::string & oApplicationWriter,
std::string & oAlembicVersion,
Util::uint32_t & oAlembicApiVersion,
std::string & oDateWritten,
std::string & oUserDescription );
//-*****************************************************************************
ALEMBIC_EXPORT void
GetArchiveInfo(
IArchive & iArchive,
std::string & oApplicationWriter,
std::string & oAlembicVersion,
Util::uint32_t & oAlembicApiVersion,
std::string & oDateWritten,
std::string & oUserDescription,
double & oDCCFPS);
//-*****************************************************************************
ALEMBIC_EXPORT void
GetArchiveStartAndEndTime(
IArchive & iArchive,
double & oStartTime,
double & oEndTime );
//-*****************************************************************************
template <class ARCHIVE_CTOR>
OArchive CreateArchiveWithInfo(
ARCHIVE_CTOR iCtor,
const std::string &iFileName,
double iDCCFPS,
const std::string &iApplicationWriter,
const std::string &iUserDescription,
const Argument &iArg0,
const Argument &iArg1 )
{
AbcA::MetaData md = GetMetaData( iArg0, iArg1 );
ErrorHandler::Policy policy = GetErrorHandlerPolicyFromArgs( iArg0, iArg1 );
if ( iApplicationWriter != "" )
{
md.set( kApplicationNameKey, iApplicationWriter );
}
time_t rawtimeNow;
time( &rawtimeNow );
char dateBuf [128];
#if defined _WIN32 || defined _WIN64
ctime_s( dateBuf, 128, &rawtimeNow);
#else
ctime_r( &rawtimeNow, dateBuf );
#endif
std::size_t bufLen = strlen( dateBuf );
if ( bufLen > 0 && dateBuf[bufLen - 1] == '\n' )
{
dateBuf[bufLen - 1] = '\0';
}
md.set( kDateWrittenKey, dateBuf );
if ( iUserDescription != "" )
{
md.set( kUserDescriptionKey, iUserDescription );
}
if ( iDCCFPS > 0.0 )
{
md.set( kDCCFPSKey, std::to_string( iDCCFPS ) );
}
return OArchive( iCtor, iFileName, md, policy );
}
template <class ARCHIVE_CTOR>
OArchive CreateArchiveWithInfo(
ARCHIVE_CTOR iCtor,
const std::string &iFileName,
const std::string &iApplicationWriter,
const std::string &iUserDescription,
const Argument &iArg0,
const Argument &iArg1 )
{
return CreateArchiveWithInfo( iCtor, iFileName, 0, iApplicationWriter,
iUserDescription, iArg0, iArg1 );
}
} // End namespace ALEMBIC_VERSION_NS
using namespace ALEMBIC_VERSION_NS;
} // End namespace Abc
} // End namespace Alembic
#endif
Alembic::Abc::ALEMBIC_VERSION_NS::Argument
Definition Argument.h:120
Alembic::Abc::ALEMBIC_VERSION_NS::IArchive
Definition IArchive.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::OArchive
Definition OArchive.h:53
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::MetaData
Definition MetaData.h:60
Alembic
Alembic namespace ...
Definition ArchiveInfo.cpp:39