summaryrefslogtreecommitdiff
path: root/include/class.h
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-15 01:32:22 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-15 01:32:22 +0100
commit3300d64c4dd61e71b62d5b55b1f16e34d6335680 (patch)
treec2bd999ba1a2a1320acba20fb99acf0defb9651e /include/class.h
parent681d1e6aa735568a492140d2307a89063e7aadb9 (diff)
parentcda98dc0dea7144941a46ff20598f3c095d7a6d0 (diff)
implemented __clone method
Diffstat (limited to 'include/class.h')
-rw-r--r--include/class.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/include/class.h b/include/class.h
index f8e3365..f8ba578 100644
--- a/include/class.h
+++ b/include/class.h
@@ -156,7 +156,27 @@ public:
void property(const char *name, const std::string &value, int flags = Public) { ClassBase::property(name, value, flags); }
void property(const char *name, bool value, int flags = Public) { ClassBase::property(name, value, flags); }
void property(const char *name, double value, int flags = Public) { ClassBase::property(name, value, flags); }
-
+
+ /**
+ * Properties as methods
+ *
+ * This is a smarter way for adding properties to a class. You can define
+ * a property and a method that gets called every time the property is
+ * set or unset.
+ *
+ * If you do not set a setter method, your property will be read-only.
+ *
+ * @param name Name of the property
+ * @param getter The getter method
+ * @param setter The setter method
+ */
+ void property(const char *name, Value (T::*getter)() ) { ClassBase::property(name, static_cast<getter_callback_0>(getter)); }
+ void property(const char *name, Value (T::*getter)() const ) { ClassBase::property(name, static_cast<getter_callback_1>(getter)); }
+ void property(const char *name, Value (T::*getter)() , void (T::*setter)(const Value &value) ) { ClassBase::property(name, static_cast<getter_callback_0>(getter), static_cast<setter_callback_0>(setter)); }
+ void property(const char *name, Value (T::*getter)() const, void (T::*setter)(const Value &value) ) { ClassBase::property(name, static_cast<getter_callback_1>(getter), static_cast<setter_callback_0>(setter)); }
+ void property(const char *name, Value (T::*getter)() , void (T::*setter)(const Value &value) const) { ClassBase::property(name, static_cast<getter_callback_0>(getter), static_cast<setter_callback_1>(setter)); }
+ void property(const char *name, Value (T::*getter)() const, void (T::*setter)(const Value &value) const) { ClassBase::property(name, static_cast<getter_callback_1>(getter), static_cast<setter_callback_1>(setter)); }
+
private:
/**
* Construct a new instance of the object