Field3D
FieldMetadata.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------//
2
3/*
4 * Copyright (c) 2014 Sony Pictures Imageworks Inc.,
5 * Pixar Animation Studios 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
44//----------------------------------------------------------------------------//
45
46#include "FieldMetadata.h"
47
48#include "Field.h"
49
50//----------------------------------------------------------------------------//
51
53
54//----------------------------------------------------------------------------//
55// FieldMetadata implementations
56//----------------------------------------------------------------------------//
57
58void FieldMetadata::setVecFloatMetadata(const std::string &name,
59 const V3f &val)
60{
61 m_vecFloatMetadata[name] = val;
62 if (m_owner) {
64 }
65}
66
67//----------------------------------------------------------------------------//
68
69void FieldMetadata::setFloatMetadata(const std::string &name,
70 const float val)
71{
72 m_floatMetadata[name] = val;
73 if (m_owner) {
75 }
76}
77
78//----------------------------------------------------------------------------//
79
80void FieldMetadata::setVecIntMetadata(const std::string &name,
81 const V3i &val)
82{
83 m_vecIntMetadata[name] = val;
84 if (m_owner) {
86 }
87}
88
89//----------------------------------------------------------------------------//
90
91void FieldMetadata::setIntMetadata(const std::string &name,
92 const int val)
93{
94 m_intMetadata[name] = val;
95 if (m_owner) {
97 }
98}
99
100//----------------------------------------------------------------------------//
101
102void FieldMetadata::setStrMetadata(const std::string &name,
103 const std::string &val)
104{
105 m_strMetadata[name] = val;
106 if (m_owner) {
108 }
109}
110
111//----------------------------------------------------------------------------//
112
113V3f FieldMetadata::vecFloatMetadata(const std::string &name,
114 const V3f& defaultVal) const
115{
116 V3f retVal = defaultVal;
117
118 VecFloatMetadata::const_iterator i = m_vecFloatMetadata.find(name);
119 if (i != m_vecFloatMetadata.end()) {
120 retVal = i->second;
121 }
122
123 return retVal;
124}
125
126//----------------------------------------------------------------------------//
127
128float FieldMetadata::floatMetadata(const std::string &name,
129 const float defaultVal) const
130{
131 float retVal = defaultVal;
132
133 FloatMetadata::const_iterator i = m_floatMetadata.find(name);
134 if (i != m_floatMetadata.end()) {
135 retVal = i->second;
136 }
137
138 return retVal;
139}
140
141//----------------------------------------------------------------------------//
142
143V3i FieldMetadata::vecIntMetadata(const std::string &name,
144 const V3i& defaultVal) const
145{
146 V3i retVal = defaultVal;
147
148 VecIntMetadata::const_iterator i = m_vecIntMetadata.find(name);
149 if (i != m_vecIntMetadata.end()) {
150 retVal = i->second;
151 }
152
153 return retVal;
154}
155
156//----------------------------------------------------------------------------//
157
158int FieldMetadata::intMetadata(const std::string &name,
159 const int defaultVal) const
160{
161 int retVal = defaultVal;
162
163 IntMetadata::const_iterator i = m_intMetadata.find(name);
164 if (i != m_intMetadata.end()) {
165 retVal = i->second;
166 }
167
168 return retVal;
169}
170
171//----------------------------------------------------------------------------//
172
173std::string FieldMetadata::strMetadata(const std::string &name,
174 const std::string &defaultVal) const
175{
176 std::string retVal = defaultVal;
177
178 StrMetadata::const_iterator i = m_strMetadata.find(name);
179 if (i != m_strMetadata.end()) {
180 retVal = i->second;
181 }
182
183 return retVal;
184}
185
186//----------------------------------------------------------------------------//
187
189
190//----------------------------------------------------------------------------//
Basic container for metedata.
Contains Field, WritableField and ResizableField classes.
Imath::V3i V3i
Definition SpiMathLib.h:71
Imath::V3f V3f
Definition SpiMathLib.h:73
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.
IntMetadata m_intMetadata
Int metadata.
StrMetadata m_strMetadata
String metadata.
void setStrMetadata(const std::string &name, const std::string &val)
Set the a string value for the given metadata name.
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.
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.
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_SOURCE_CLOSE
Definition ns.h:60