Field3D
FieldMetadata.h
Go to the documentation of this file.
1
2//----------------------------------------------------------------------------//
3
4/*
5 * Copyright (c) 2010 Sony Pictures Imageworks Inc
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
11 * are met:
12 *
13 * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the
18 * distribution. Neither the name of Sony Pictures Imageworks nor the
19 * names of its contributors may be used to endorse or promote
20 * products derived from this software without specific prior written
21 * 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
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
34 * OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37//----------------------------------------------------------------------------//
38
46//----------------------------------------------------------------------------//
47
48#ifndef _INCLUDED_Field3D_FieldMetadata_H_
49#define _INCLUDED_Field3D_FieldMetadata_H_
50
51//----------------------------------------------------------------------------//
52
53#include <list>
54#include <string>
55#include <vector>
56#include <map>
57
58#include "Types.h"
59
60//----------------------------------------------------------------------------//
61
62#include "ns.h"
63
65
66//----------------------------------------------------------------------------//
67// MetadataCallback
68//----------------------------------------------------------------------------//
69
71{
72public:
73
75 virtual void metadataHasChanged(const std::string &)
76 { /* Default does nothing. */ }
77
78};
79
80//----------------------------------------------------------------------------//
81// FieldMetadata
82//----------------------------------------------------------------------------//
83
85{
86 public:
87
88 // Typedefs ------------------------------------------------------------------
89
90 typedef std::map<std::string, std::string> StrMetadata;
91 typedef std::map<std::string, int> IntMetadata;
92 typedef std::map<std::string, float> FloatMetadata;
93 typedef std::map<std::string, V3i> VecIntMetadata;
94 typedef std::map<std::string, V3f> VecFloatMetadata;
95
96 // Ctor, dtor ----------------------------------------------------------------
97
100
102 : m_owner(owner)
103 { }
104
105 virtual ~FieldMetadata() {}
106
108
109 // Operators -----------------------------------------------------------------
110
119
120 // Access to metadata --------------------------------------------------------
121
124
127 V3f vecFloatMetadata(const std::string &name, const V3f &defaultVal) const;
128
131 float floatMetadata(const std::string &name, const float defaultVal) const;
132
135 V3i vecIntMetadata(const std::string &name, const V3i &defaultVal) const;
136
139 int intMetadata(const std::string &name, const int defaultVal) const;
140
143 std::string strMetadata(const std::string &name,
144 const std::string &defaultVal) const;
145
149
152 { return m_floatMetadata; }
153
156 { return m_vecIntMetadata; }
157
160 { return m_intMetadata; }
161
164 { return m_strMetadata; }
165
167 void setVecFloatMetadata(const std::string &name, const V3f &val);
168
170 void setFloatMetadata(const std::string &name, const float val);
171
173 void setVecIntMetadata(const std::string &name, const V3i &val);
174
176 void setIntMetadata(const std::string &name, const int val);
177
179 void setStrMetadata(const std::string &name, const std::string &val);
180
182
183 private:
184
185 // Private member functions --------------------------------------------------
186
188
189 // Private data members ------------------------------------------------------
190
201
205
206};
207
208//----------------------------------------------------------------------------//
209
211
212//----------------------------------------------------------------------------//
213
214#endif /* _INCLUDED_Field3D_FieldMetadata_H_ */
215
Imath::V3i V3i
Definition SpiMathLib.h:71
Imath::V3f V3f
Definition SpiMathLib.h:73
Contains typedefs for the commonly used types in Field3D.
const IntMetadata & intMetadata() const
Read only access to the m_intMetadata dictionary.
void setIntMetadata(const std::string &name, const int val)
Set the a int value for the given metadata name.
std::map< std::string, int > IntMetadata
IntMetadata m_intMetadata
Int metadata.
StrMetadata m_strMetadata
String metadata.
std::map< std::string, V3i > VecIntMetadata
void setStrMetadata(const std::string &name, const std::string &val)
Set the a string value for the given metadata name.
FieldMetadata(MetadataCallback *owner)
FieldMetadata(const FieldMetadata &)
std::map< std::string, V3f > VecFloatMetadata
void setVecFloatMetadata(const std::string &name, const V3f &val)
Set the a V3f value for the given metadata name.
void setVecIntMetadata(const std::string &name, const V3i &val)
Set the a V3i value for the given metadata name.
VecIntMetadata m_vecIntMetadata
V3i metadata.
VecFloatMetadata m_vecFloatMetadata
V3f metadata.
const VecFloatMetadata & vecFloatMetadata() const
Read only access to the m_vecFloatMetadata dictionary.
const StrMetadata & strMetadata() const
Read only access to the m_strMetadata dictionary.
std::map< std::string, std::string > StrMetadata
void operator=(const FieldMetadata &other)
const FloatMetadata & floatMetadata() const
Read only access to the m_floatMetadata dictionary.
FloatMetadata m_floatMetadata
Float metadata.
MetadataCallback * m_owner
Pointer to owner. It is assumed that this has a lifetime at least as long as the Metadata instance.
virtual ~FieldMetadata()
std::map< std::string, float > FloatMetadata
void setFloatMetadata(const std::string &name, const float val)
Set the a float value for the given metadata name.
const VecIntMetadata & vecIntMetadata() const
Read only access to the m_vecIntMetadata dictionary.
virtual void metadataHasChanged(const std::string &)
Alerts the callback holder that the metadata has changed.
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Definition ns.h:58