FieldMetadata.cpp
Go to the documentation of this file.
//----------------------------------------------------------------------------//
/*
* Copyright (c) 2014 Sony Pictures Imageworks Inc.,
* Pixar Animation Studios Inc.
*
* 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 the
* names of its 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.
*/
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
#include "FieldMetadata.h"
#include "Field.h"
//----------------------------------------------------------------------------//
FIELD3D_NAMESPACE_OPEN
//----------------------------------------------------------------------------//
// FieldMetadata implementations
//----------------------------------------------------------------------------//
void FieldMetadata::setVecFloatMetadata(const std::string &name,
const V3f &val)
{
m_vecFloatMetadata[name] = val;
if (m_owner) {
m_owner->metadataHasChanged(name);
}
}
//----------------------------------------------------------------------------//
void FieldMetadata::setFloatMetadata(const std::string &name,
const float val)
{
m_floatMetadata[name] = val;
if (m_owner) {
m_owner->metadataHasChanged(name);
}
}
//----------------------------------------------------------------------------//
void FieldMetadata::setVecIntMetadata(const std::string &name,
const V3i &val)
{
m_vecIntMetadata[name] = val;
if (m_owner) {
m_owner->metadataHasChanged(name);
}
}
//----------------------------------------------------------------------------//
void FieldMetadata::setIntMetadata(const std::string &name,
const int val)
{
m_intMetadata[name] = val;
if (m_owner) {
m_owner->metadataHasChanged(name);
}
}
//----------------------------------------------------------------------------//
void FieldMetadata::setStrMetadata(const std::string &name,
const std::string &val)
{
m_strMetadata[name] = val;
if (m_owner) {
m_owner->metadataHasChanged(name);
}
}
//----------------------------------------------------------------------------//
V3f FieldMetadata::vecFloatMetadata(const std::string &name,
const V3f& defaultVal) const
{
V3f retVal = defaultVal;
VecFloatMetadata::const_iterator i = m_vecFloatMetadata.find(name);
if (i != m_vecFloatMetadata.end()) {
retVal = i->second;
}
return retVal;
}
//----------------------------------------------------------------------------//
float FieldMetadata::floatMetadata(const std::string &name,
const float defaultVal) const
{
float retVal = defaultVal;
FloatMetadata::const_iterator i = m_floatMetadata.find(name);
if (i != m_floatMetadata.end()) {
retVal = i->second;
}
return retVal;
}
//----------------------------------------------------------------------------//
V3i FieldMetadata::vecIntMetadata(const std::string &name,
const V3i& defaultVal) const
{
V3i retVal = defaultVal;
VecIntMetadata::const_iterator i = m_vecIntMetadata.find(name);
if (i != m_vecIntMetadata.end()) {
retVal = i->second;
}
return retVal;
}
//----------------------------------------------------------------------------//
int FieldMetadata::intMetadata(const std::string &name,
const int defaultVal) const
{
int retVal = defaultVal;
IntMetadata::const_iterator i = m_intMetadata.find(name);
if (i != m_intMetadata.end()) {
retVal = i->second;
}
return retVal;
}
//----------------------------------------------------------------------------//
std::string FieldMetadata::strMetadata(const std::string &name,
const std::string &defaultVal) const
{
std::string retVal = defaultVal;
StrMetadata::const_iterator i = m_strMetadata.find(name);
if (i != m_strMetadata.end()) {
retVal = i->second;
}
return retVal;
}
//----------------------------------------------------------------------------//
FIELD3D_NAMESPACE_SOURCE_CLOSE
//----------------------------------------------------------------------------//
FieldMetadata.h
Basic container for metedata.
Field.h
Contains Field, WritableField and ResizableField classes.
V3i
Imath::V3i V3i
Definition SpiMathLib.h:71
V3f
Imath::V3f V3f
Definition SpiMathLib.h:73
FieldMetadata::intMetadata
const IntMetadata & intMetadata() const
Read only access to the m_intMetadata dictionary.
Definition FieldMetadata.h:159
FieldMetadata::setIntMetadata
void setIntMetadata(const std::string &name, const int val)
Set the a int value for the given metadata name.
Definition FieldMetadata.cpp:91
FieldMetadata::m_intMetadata
IntMetadata m_intMetadata
Int metadata.
Definition FieldMetadata.h:198
FieldMetadata::m_strMetadata
StrMetadata m_strMetadata
String metadata.
Definition FieldMetadata.h:200
FieldMetadata::setStrMetadata
void setStrMetadata(const std::string &name, const std::string &val)
Set the a string value for the given metadata name.
Definition FieldMetadata.cpp:102
FieldMetadata::setVecFloatMetadata
void setVecFloatMetadata(const std::string &name, const V3f &val)
Set the a V3f value for the given metadata name.
Definition FieldMetadata.cpp:58
FieldMetadata::setVecIntMetadata
void setVecIntMetadata(const std::string &name, const V3i &val)
Set the a V3i value for the given metadata name.
Definition FieldMetadata.cpp:80
FieldMetadata::m_vecIntMetadata
VecIntMetadata m_vecIntMetadata
V3i metadata.
Definition FieldMetadata.h:196
FieldMetadata::m_vecFloatMetadata
VecFloatMetadata m_vecFloatMetadata
V3f metadata.
Definition FieldMetadata.h:192
FieldMetadata::vecFloatMetadata
const VecFloatMetadata & vecFloatMetadata() const
Read only access to the m_vecFloatMetadata dictionary.
Definition FieldMetadata.h:147
FieldMetadata::strMetadata
const StrMetadata & strMetadata() const
Read only access to the m_strMetadata dictionary.
Definition FieldMetadata.h:163
FieldMetadata::floatMetadata
const FloatMetadata & floatMetadata() const
Read only access to the m_floatMetadata dictionary.
Definition FieldMetadata.h:151
FieldMetadata::m_floatMetadata
FloatMetadata m_floatMetadata
Float metadata.
Definition FieldMetadata.h:194
FieldMetadata::m_owner
MetadataCallback * m_owner
Pointer to owner. It is assumed that this has a lifetime at least as long as the Metadata instance.
Definition FieldMetadata.h:204
FieldMetadata::setFloatMetadata
void setFloatMetadata(const std::string &name, const float val)
Set the a float value for the given metadata name.
Definition FieldMetadata.cpp:69
FieldMetadata::vecIntMetadata
const VecIntMetadata & vecIntMetadata() const
Read only access to the m_vecIntMetadata dictionary.
Definition FieldMetadata.h:155
FIELD3D_NAMESPACE_OPEN
Definition FieldMapping.cpp:74
FIELD3D_NAMESPACE_SOURCE_CLOSE
#define FIELD3D_NAMESPACE_SOURCE_CLOSE
Definition ns.h:60