Nori

include/nori/proplist.h

Go to the documentation of this file.
00001 /*
00002     This file is part of Nori, a simple educational ray tracer
00003 
00004     Copyright (c) 2012 by Wenzel Jakob and Steve Marschner.
00005 
00006     Nori is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License Version 3
00008     as published by the Free Software Foundation.
00009 
00010     Nori is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 #if !defined(__PROPLIST_H)
00020 #define __PROPLIST_H
00021 
00022 #include <nori/color.h>
00023 #include <nori/transform.h>
00024 #include <boost/variant.hpp>
00025 #include <map>
00026 
00027 NORI_NAMESPACE_BEGIN
00028 
00029 /**
00030  * \brief This is a sssociative container used to supply the constructors
00031  * of \ref NoriObject subclasses with parameter information.
00032  */
00033 class PropertyList {
00034 public:
00035         PropertyList() { }
00036 
00037         /// Set a boolean property
00038         void setBoolean(const QString &name, const bool &value);
00039         
00040         /// Get a boolean property, and throw an exception if it does not exist
00041         bool getBoolean(const QString &name) const;
00042 
00043         /// Get a boolean property, and use a default value if it does not exist
00044         bool getBoolean(const QString &name, const bool &defaultValue) const;
00045 
00046         /// Set an integer property
00047         void setInteger(const QString &name, const int &value);
00048         
00049         /// Get an integer property, and throw an exception if it does not exist
00050         int getInteger(const QString &name) const;
00051 
00052         /// Get am integer property, and use a default value if it does not exist
00053         int getInteger(const QString &name, const int &defaultValue) const;
00054 
00055         /// Set a float property
00056         void setFloat(const QString &name, const float &value);
00057         
00058         /// Get a float property, and throw an exception if it does not exist
00059         float getFloat(const QString &name) const;
00060 
00061         /// Get a float property, and use a default value if it does not exist
00062         float getFloat(const QString &name, const float &defaultValue) const;
00063 
00064         /// Set a string property
00065         void setString(const QString &name, const QString &value);
00066 
00067         /// Get a string property, and throw an exception if it does not exist
00068         QString getString(const QString &name) const;
00069 
00070         /// Get a string property, and use a default value if it does not exist
00071         QString getString(const QString &name, const QString &defaultValue) const;
00072 
00073         /// Set a color property
00074         void setColor(const QString &name, const Color3f &value);
00075 
00076         /// Get a color property, and throw an exception if it does not exist
00077         Color3f getColor(const QString &name) const;
00078 
00079         /// Get a color property, and use a default value if it does not exist
00080         Color3f getColor(const QString &name, const Color3f &defaultValue) const;
00081 
00082         /// Set a point property
00083         void setPoint(const QString &name, const Point3f &value);
00084 
00085         /// Get a point property, and throw an exception if it does not exist
00086         Point3f getPoint(const QString &name) const;
00087 
00088         /// Get a point property, and use a default value if it does not exist
00089         Point3f getPoint(const QString &name, const Point3f &defaultValue) const;
00090 
00091         /// Set a vector property
00092         void setVector(const QString &name, const Vector3f &value);
00093 
00094         /// Get a vector property, and throw an exception if it does not exist
00095         Vector3f getVector(const QString &name) const;
00096 
00097         /// Get a vector property, and use a default value if it does not exist
00098         Vector3f getVector(const QString &name, const Vector3f &defaultValue) const;
00099 
00100         /// Set a transform property
00101         void setTransform(const QString &name, const Transform &value);
00102 
00103         /// Get a transform property, and throw an exception if it does not exist
00104         Transform getTransform(const QString &name) const;
00105 
00106         /// Get a transform property, and use a default value if it does not exist
00107         Transform getTransform(const QString &name, const Transform &defaultValue) const;
00108 private:
00109         typedef boost::variant<bool, int, float, QString, 
00110                 Color3f, Point3f, Transform> Property;
00111 
00112         std::map<QString, Property> m_properties;
00113 };
00114 
00115 NORI_NAMESPACE_END
00116 
00117 #endif /* __PROPLIST_H */
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines