[GD-General] d-pointers vs. smart pointers
Brought to you by:
vexxed72
From: <cas...@ya...> - 2002-12-19 00:30:30
|
Hi, I'd also like to mention d-pointers as an alternative to smart pointers. I learned about d-pointers are with the Qt toolkit and they are used extensively in the kde desktop environment. d-pointers are used to manage shared data. They decouple the data from the methods of the object. The data resides on the shared part and the methods reside on a wrapper object that contain a pointer to the data, thus the d-pointer name. The d-pointer pattern is also known as 'pimpl' or 'cheshire cat'. I like d-pointers because they completely abstract the fact that you are using a pointer, and make you think that you are using the object itself. You can pass the object by value, and use it as if it were a native type. Creating a d-pointer object is quite tedious, but you only do it once, and in most cases the effort pays off. Maybe d-pointers aren't as versatile as smart pointers, in fact they are just a restricted and more friendly form of smart ptr. In some cases I think they make your life easier, and specially for 'shared resource management'. Have a look at http://doc.trolltech.com/qq/qq02-data-sharing-with-class.html to find out more. Ignacio Castaño cas...@ya... _______________________________________________________________ Copa del Mundo de la FIFA 2002 El único lugar de Internet con vídeos de los 64 partidos. ¡Apúntante ya! en http://fifaworldcup.yahoo.com/fc/es/ |