#ifndef NALL_PROPERTY_HPP #define NALL_PROPERTY_HPP //nall::property implements a variable container that disallows write access //to non-derived objects. This requires use of property::set(), as C++ lacks //the ability to make this implementation completely transparent. namespace nall { class property { public: template class property_t; protected: template T& get(property_t&); template property_t& set(property_t&, const T); public: template class property_t { public: const T& operator()() const { return value; } property_t() : value() {} property_t(const T value_) : value(value_) {} protected: T value; operator T&() { return value; } property_t& operator=(const T newValue) { value = newValue; return *this; } friend T& property::get(property_t&); friend property_t& property::set(property_t&, const T); }; }; template T& property::get(property::property_t &p) { return p.operator T&(); } template property::property_t& property::set(property::property_t &p, const T value) { return p.operator=(value); } } #endif