]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - include/preferencesystem.h
Introduce Property<T> to simplify preferences system
[xonotic/netradiant.git] / include / preferencesystem.h
index a82676ec0b65e920006b03c694a8ad3cb4cd1b10..6479ec91d32e7adabafc1d654d5b85611717754c 100644 (file)
 
 #include "generic/constant.h"
 #include "generic/callback.h"
+#include "property.h"
 
-class PreferenceSystem
-{
+class PreferenceSystem {
 public:
-INTEGER_CONSTANT( Version, 1 );
-STRING_CONSTANT( Name, "preferences" );
+       INTEGER_CONSTANT(Version, 1);
+       STRING_CONSTANT(Name, "preferences");
 
-virtual void registerPreference( const char* name, const ImportExportCallback<const char *>::Import_t& importer, const ImportExportCallback<const char *>::Export_t& exporter ) = 0;
+       virtual void registerPreference(const char *name, const Property<const char *> &cb) = 0;
 };
 
+template<class Self>
+Property<const char *> make_property_string(Self &it) {
+       return make_property<PropertyAdaptor<Self, const char *>>(it);
+}
+
+template<class I, class Self>
+Property<const char *> make_property_string(Self &it) {
+       return make_property_chain<PropertyImpl<detail::propertyimpl_other<I>, const char *>, I>(it);
+}
+
+template<class I>
+Property<const char *> make_property_string() {
+       return make_property_chain<PropertyImpl<detail::propertyimpl_other_free<I>, const char *>, I>();
+}
+
 #include "modulesystem.h"
 
 template<typename Type>