FieldMetadata.h
Go to the documentation of this file.
//----------------------------------------------------------------------------//
/*
* Copyright (c) 2010 Sony Pictures Imageworks 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.
*/
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
#ifndef _INCLUDED_Field3D_FieldMetadata_H_
#define _INCLUDED_Field3D_FieldMetadata_H_
//----------------------------------------------------------------------------//
#include <list>
#include <string>
#include <vector>
#include <map>
#include "Types.h"
//----------------------------------------------------------------------------//
#include "ns.h"
FIELD3D_NAMESPACE_OPEN
//----------------------------------------------------------------------------//
// MetadataCallback
//----------------------------------------------------------------------------//
class MetadataCallback
{
public:
virtual void metadataHasChanged(const std::string &)
{ /* Default does nothing. */ }
};
//----------------------------------------------------------------------------//
// FieldMetadata
//----------------------------------------------------------------------------//
class FieldMetadata
{
public:
// Typedefs ------------------------------------------------------------------
typedef std::map<std::string, std::string> StrMetadata;
typedef std::map<std::string, int> IntMetadata;
typedef std::map<std::string, float> FloatMetadata;
typedef std::map<std::string, V3i> VecIntMetadata;
typedef std::map<std::string, V3f> VecFloatMetadata;
// Ctor, dtor ----------------------------------------------------------------
FieldMetadata(MetadataCallback *owner)
: m_owner(owner)
{ }
virtual ~FieldMetadata() {}
// Operators -----------------------------------------------------------------
void operator = (const FieldMetadata &other)
{
m_vecFloatMetadata = other.m_vecFloatMetadata;
m_floatMetadata = other.m_floatMetadata;
m_vecIntMetadata = other.m_vecIntMetadata;
m_intMetadata = other.m_intMetadata;
m_strMetadata = other.m_strMetadata;
}
// Access to metadata --------------------------------------------------------
V3f vecFloatMetadata(const std::string &name, const V3f &defaultVal) const;
float floatMetadata(const std::string &name, const float defaultVal) const;
V3i vecIntMetadata(const std::string &name, const V3i &defaultVal) const;
int intMetadata(const std::string &name, const int defaultVal) const;
std::string strMetadata(const std::string &name,
const std::string &defaultVal) const;
const VecFloatMetadata& vecFloatMetadata() const
{ return m_vecFloatMetadata; }
const FloatMetadata& floatMetadata() const
{ return m_floatMetadata; }
const VecIntMetadata& vecIntMetadata() const
{ return m_vecIntMetadata; }
const IntMetadata& intMetadata() const
{ return m_intMetadata; }
const StrMetadata& strMetadata() const
{ return m_strMetadata; }
void setVecFloatMetadata(const std::string &name, const V3f &val);
void setFloatMetadata(const std::string &name, const float val);
void setVecIntMetadata(const std::string &name, const V3i &val);
void setIntMetadata(const std::string &name, const int val);
void setStrMetadata(const std::string &name, const std::string &val);
private:
// Private member functions --------------------------------------------------
FieldMetadata(const FieldMetadata &);
// Private data members ------------------------------------------------------
VecFloatMetadata m_vecFloatMetadata;
FloatMetadata m_floatMetadata;
VecIntMetadata m_vecIntMetadata;
IntMetadata m_intMetadata;
StrMetadata m_strMetadata;
MetadataCallback *m_owner;
};
//----------------------------------------------------------------------------//
FIELD3D_NAMESPACE_HEADER_CLOSE
//----------------------------------------------------------------------------//
#endif /* _INCLUDED_Field3D_FieldMetadata_H_ */
V3i
Imath::V3i V3i
Definition SpiMathLib.h:71
V3f
Imath::V3f V3f
Definition SpiMathLib.h:73
Types.h
Contains typedefs for the commonly used types in Field3D.
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::VecIntMetadata
std::map< std::string, V3i > VecIntMetadata
Definition FieldMetadata.h:93
FieldMetadata::StrMetadata
std::map< std::string, std::string > StrMetadata
Definition FieldMetadata.h:90
FieldMetadata::IntMetadata
std::map< std::string, int > IntMetadata
Definition FieldMetadata.h:91
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::FieldMetadata
FieldMetadata(MetadataCallback *owner)
Definition FieldMetadata.h:101
FieldMetadata::FieldMetadata
FieldMetadata(const FieldMetadata &)
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::FloatMetadata
std::map< std::string, float > FloatMetadata
Definition FieldMetadata.h:92
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::operator=
void operator=(const FieldMetadata &other)
Definition FieldMetadata.h:111
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::~FieldMetadata
virtual ~FieldMetadata()
Definition FieldMetadata.h:105
FieldMetadata::VecFloatMetadata
std::map< std::string, V3f > VecFloatMetadata
Definition FieldMetadata.h:94
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
MetadataCallback
Definition FieldMetadata.h:71
MetadataCallback::metadataHasChanged
virtual void metadataHasChanged(const std::string &)
Alerts the callback holder that the metadata has changed.
Definition FieldMetadata.h:75
FIELD3D_NAMESPACE_OPEN
Definition FieldMapping.cpp:74
ns.h
FIELD3D_NAMESPACE_HEADER_CLOSE
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Definition ns.h:58