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 {
72 public:
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 
111  void operator = (const FieldMetadata &other)
112  {
113  m_vecFloatMetadata = other.m_vecFloatMetadata;
114  m_floatMetadata = other.m_floatMetadata;
115  m_vecIntMetadata = other.m_vecIntMetadata;
116  m_intMetadata = other.m_intMetadata;
117  m_strMetadata = other.m_strMetadata;
118  }
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 
148  { return m_vecFloatMetadata; }
149 
152  { return m_floatMetadata; }
153 
156  { return m_vecIntMetadata; }
157 
159  const IntMetadata& intMetadata() const
160  { return m_intMetadata; }
161 
163  const StrMetadata& strMetadata() const
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 
FIELD3D_NAMESPACE_HEADER_CLOSE
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Definition: ns.h:58
V3i
Imath::V3i V3i
Definition: SpiMathLib.h:71
FieldMetadata::vecFloatMetadata
const VecFloatMetadata & vecFloatMetadata() const
Read only access to the m_vecFloatMetadata dictionary.
Definition: FieldMetadata.h:147
Types.h
Contains typedefs for the commonly used types in Field3D.
FieldMetadata::floatMetadata
const FloatMetadata & floatMetadata() const
Read only access to the m_floatMetadata dictionary.
Definition: FieldMetadata.h:151
V3f
Imath::V3f V3f
Definition: SpiMathLib.h:73
MetadataCallback
Definition: FieldMetadata.h:71
FieldMetadata::VecIntMetadata
std::map< std::string, V3i > VecIntMetadata
Definition: FieldMetadata.h:93
FieldMetadata::m_vecFloatMetadata
VecFloatMetadata m_vecFloatMetadata
V3f metadata.
Definition: FieldMetadata.h:192
FieldMetadata::~FieldMetadata
virtual ~FieldMetadata()
Definition: FieldMetadata.h:105
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::m_floatMetadata
FloatMetadata m_floatMetadata
Float metadata.
Definition: FieldMetadata.h:194
FieldMetadata::vecIntMetadata
const VecIntMetadata & vecIntMetadata() const
Read only access to the m_vecIntMetadata dictionary.
Definition: FieldMetadata.h:155
FieldMetadata::IntMetadata
std::map< std::string, int > IntMetadata
Definition: FieldMetadata.h:91
FieldMetadata::FieldMetadata
FieldMetadata(MetadataCallback *owner)
Definition: FieldMetadata.h:101
FieldMetadata::intMetadata
const IntMetadata & intMetadata() const
Read only access to the m_intMetadata dictionary.
Definition: FieldMetadata.h:159
ns.h
FieldMetadata::FieldMetadata
FieldMetadata(const FieldMetadata &)
FieldMetadata::StrMetadata
std::map< std::string, std::string > StrMetadata
Definition: FieldMetadata.h:90
FieldMetadata
Definition: FieldMetadata.h:85
FieldMetadata::strMetadata
const StrMetadata & strMetadata() const
Read only access to the m_strMetadata dictionary.
Definition: FieldMetadata.h:163
FieldMetadata::m_intMetadata
IntMetadata m_intMetadata
Int metadata.
Definition: FieldMetadata.h:198
FieldMetadata::m_strMetadata
StrMetadata m_strMetadata
String metadata.
Definition: FieldMetadata.h:200
FIELD3D_API
#define FIELD3D_API
Definition: ns.h:77
FIELD3D_NAMESPACE_OPEN
Definition: FieldMapping.cpp:74
FieldMetadata::m_vecIntMetadata
VecIntMetadata m_vecIntMetadata
V3i metadata.
Definition: FieldMetadata.h:196
FieldMetadata::VecFloatMetadata
std::map< std::string, V3f > VecFloatMetadata
Definition: FieldMetadata.h:94
FieldMetadata::FloatMetadata
std::map< std::string, float > FloatMetadata
Definition: FieldMetadata.h:92
MetadataCallback::metadataHasChanged
virtual void metadataHasChanged(const std::string &)
Alerts the callback holder that the metadata has changed.
Definition: FieldMetadata.h:75