X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbindable.h;h=76c2fb528b7967839fa606a6c8a076ce190ee525;hb=904de4f7fd994886adbd3a6c03bc1b7c14ebc562;hp=d85ec78daac037710390a7949c1deb164c3dbb51;hpb=42ace9ac1350d3ae009bdd2fb335ac1e57d1b36b;p=libs%2Fgl.git diff --git a/source/bindable.h b/source/bindable.h index d85ec78d..76c2fb52 100644 --- a/source/bindable.h +++ b/source/bindable.h @@ -1,16 +1,13 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2010 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef MSP_GL_BINDABLE_H_ #define MSP_GL_BINDABLE_H_ namespace Msp { namespace GL { +/** +A helper class for single-point binding. Provides tracking of the currently +bound object. +*/ template class Bindable { @@ -98,11 +95,21 @@ private: Base *binder; public: + template + Bind(const T &o, bool r = false): + binder(r ? create(&o, T::current()) : create(&o)) + { } + template Bind(const T *o, bool r = false): binder(r ? create(o, T::current()) : create(o)) { } + template + Bind(T *o, bool r = false): + binder(r ? create(o, T::current()) : create(o)) + { } + private: Bind(const Bind &); Bind &operator=(const Bind &);