/* * Copyright (c) 2008 * Evan Teran * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appears in all copies and that both the * copyright notice and this permission notice appear in supporting * documentation, and that the same name not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. We make no representations about the * suitability this software for any purpose. It is provided "as is" * without express or implied warranty. */ #ifndef PROPERTY_H_20060118_H_ #define PROPERTY_H_20060118_H_ template struct PropertyBase { typedef void (Object::*setter_ptr)(T); typedef T (Object::*getter_ptr)() const; PropertyBase(Object *owner) : owner_(owner) { } protected: const Object *base() const { return owner_; } Object *base() { return owner_; } private: Object *owner_; }; template ::getter_ptr G> struct PropertyRO : public virtual PropertyBase { PropertyRO(Object *owner) : PropertyBase(owner) { } operator T () const { return (PropertyBase::base()->*G)(); } }; template ::setter_ptr S> struct PropertyWO : public virtual PropertyBase { PropertyWO(Object *owner) : PropertyBase(owner) { } T operator=(const T &value) { (PropertyBase::base()->*S)(value); return value; } }; template ::getter_ptr G, typename PropertyBase::setter_ptr S> struct PropertyRW : public PropertyRO, public PropertyWO { using PropertyWO::operator= ; PropertyRW(Object *_owner) : PropertyBase(_owner), PropertyRO(_owner), PropertyWO(_owner) { } }; #endif

AltStyle によって変換されたページ (->オリジナル) /