19 #include <nori/proplist.h>
23 #define DEFINE_PROPERTY_ACCESSOR(Type, TypeName, XmlName) \
24 void PropertyList::set##TypeName(const std::string &name, const Type &value) { \
25 if (m_properties.find(name) != m_properties.end()) \
26 cerr << "Property \"" << name << "\" was specified multiple times!" << endl; \
27 auto &prop = m_properties[name]; \
28 prop.value.TypeName##_value = value; \
29 prop.type = Property::TypeName##_type; \
32 Type PropertyList::get##TypeName(const std::string &name) const { \
33 auto it = m_properties.find(name); \
34 if (it == m_properties.end()) \
35 throw NoriException("Property '%s' is missing!", name); \
36 if (it->second.type != Property::TypeName##_type) \
37 throw NoriException("Property '%s' has the wrong type! " \
38 "(expected <" #XmlName ":" #TypeName ">)!", name); \
39 return it->second.value.TypeName##_value; \
42 Type PropertyList::get##TypeName(const std::string &name, const Type &defVal) const { \
43 auto it = m_properties.find(name); \
44 if (it == m_properties.end()) \
46 if (it->second.type != Property::TypeName##_type) \
47 throw NoriException("Property '%s' has the wrong type! " \
48 "(expected <" #XmlName ":" #TypeName ">)!", name); \
49 return it->second.value.TypeName##_value; \
52 DEFINE_PROPERTY_ACCESSOR(
bool, Boolean,
boolean)
53 DEFINE_PROPERTY_ACCESSOR(
int, Integer, integer)
54 DEFINE_PROPERTY_ACCESSOR(
float, Float,
float)
55 DEFINE_PROPERTY_ACCESSOR(
Color3f, Color, color)
56 DEFINE_PROPERTY_ACCESSOR(
Point3f, Point3, point)
57 DEFINE_PROPERTY_ACCESSOR(
Vector3f, Vector3, vector)
58 DEFINE_PROPERTY_ACCESSOR(
Point2f, Point2, point)
59 DEFINE_PROPERTY_ACCESSOR(
Vector2f, Vector2, vector)
60 DEFINE_PROPERTY_ACCESSOR(std::string, String,
string)
Represents a linear RGB color value.