[osg-users] About MixinVector

Jean-Sébastien Guay jean-sebastien.guay at cm-labs.com
Thu Jun 26 08:22:00 PDT 2008


Hi Paul,

> Can someone please explain the MixinVector change and why it was 
> necessary? Also, please explain the name "MixinVector" -- what, exactly, 
> is a "Mixin"? If this is a design pattern, I must admit I'm not familiar 
> with it.

To add to what Robert said:

http://en.wikipedia.org/wiki/Mixin

"In object-oriented programming languages, a mixin is a class that 
provides a certain functionality to be inherited by a subclass, but is 
not meant to stand alone. Inheriting from a mixin is not a form of 
specialization but is rather a means to collect functionality. A class 
may inherit most or all of its functionality by inheriting from one or 
more mixins through multiple inheritance."

In effect, since MixinVector has a std::vector, and has operations that 
just redirect calls to the internal std::vector (like operator[], 
push_back() etc.), and then the Array classes inherit from MixinVector 
instead of directly from std::vector, the functionality is the same, but 
it removes the problem that was caused by std::vector's destructor not 
being virtual.

It's debatable whether std::vector was just not meant to be subclassed 
or whether it was an oversight when designing it... The previous use 
would certainly have been valid if the destructor had been declared virtual.

Hope this helps,

J-S
-- 
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.guay at cm-labs.com
                                http://www.cm-labs.com/
                         http://whitestar02.webhop.org/


More information about the osg-users mailing list