[Insight-users] Retain the output of filters using Smart Pointers

Jayme Kosior jckosior at ucalgary.ca
Tue Jun 8 18:22:24 EDT 2004


Hello.

I want to retain the output of a filter using a smart pointer.  Here is 
the following pseudo-code:

// Create smart pointer
SmartPointer s_ptr;
....
	{
		// Create a filter, do some processing (i.e. reading a file)
		Filter filter;

		... do some processing

		// Get the output of the filter (a regular pointer to an image) and 
assign it to the smart pointer
		ptr = filter->GetOutput();
	}

// Filter object now out of scope and so it is destroyed

1. When I assign the output of the filter to the smart pointer, is the 
reference count of the filter's output incremented to 2?

2. Once the filter is out of scope (i.e. the braces), is the filter's 
output image retained by the smart pointer (meaning the reference count 
is now 1) ?



Thank you for your time.

Jayme



More information about the Insight-users mailing list