ghalliday/HPCC-Platform — pull request #2 by ghalliday (2011-11-23 13:42:17+00:00)
Title: Rationalize the Owned/Linked classes

This change is designed to make it easier to understand the smart
pointer objects used to support the link release model. I have
created a new Shared<> template class which is the base class for the
Owned<> and Linked<> classes.
The Shared<> class is similar to a boost intrusive_ptr, and is an STL
compatible object which holds a reference to a linked object or
interface. You can pass and return Shared objects, and not need to
ever call Link/Release/set/setown.

However Shared contains no methods for constructing a Shared from a
pointer, or assigning a pointer to a Shared. This needs to be done
explicitly using the Linked and Owned clasess. This means that it
is explicit whether you are taking ownership of the object or not.
(Boost uses an extra parameter which may reduce link/releases in a few
situations, but is much less clear).

Any function that takes a reference to a smart pointer - so it can be
updated in place, should use a type Shared.

There are also a couple of template functions OWNED and LINKED which
are short cuts for creating an Owned/Linked object. E.g.,
void myFunction(Shared x);
myFunction(OWNED(myPointer));
I'm not so sure they are a good idea - please debate.

Signed-off-by: Gavin Halliday