Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

nvutil::addReference Struct Reference

Convenient helper functor that can be used in STL algorithms to add a reference to reference counted objects. More...

#include <RCObject.h>

List of all members.

Public Methods

template<typename RCOBJPTR> RCOBJPTR operator() (RCOBJPTR pRCObject)
 Function call operator for one argument, being the pointer to an object. More...

template<typename AnyType, typename RCOBJPTR> const std::pair< AnyType,
RCOBJPTR > & 
operator() (std::pair< AnyType, RCOBJPTR > &p)
 Function call operator for a pair of arguments. More...


Detailed Description

Convenient helper functor that can be used in STL algorithms to add a reference to reference counted objects.

With this helper functor it's easy and efficient to add a reference to each object contained in a STL container. To copy a container of reference counted objects and increase their reference count you could do something like that:

   for ( iter=src.begin() ; iter!=src.end() ; ++iter )
   {
     dst.push_back( *iter );
     (*iter)->addRef();
   }
or, equivalently but more efficiently, using this functor:
   transform( src.begin(), src.end(), inserter( dst, dst.begin()), addReference() );


Member Function Documentation

template<typename RCOBJPTR>
RCOBJPTR nvutil::addReference::operator() RCOBJPTR    pRCObject
 

Function call operator for one argument, being the pointer to an object.

The member function addRef() of an RCObject is called on the argument.

Returns:
the argument for usage in the algorithm
Parameters:
pRCObject  pointer to reference counted object

template<typename AnyType, typename RCOBJPTR>
const std::pair< AnyType, RCOBJPTR > & nvutil::addReference::operator() std::pair< AnyType, RCOBJPTR > &    p
 

Function call operator for a pair of arguments.

The member function addRef() of an RCObject is called on the second element of the pair of arguments.

Returns:
the argument for usage in the algorithm
Parameters:
p  pointer to a pair of any argument and a reference counted object


The documentation for this struct was generated from the following file:
Generated on Tue Mar 1 13:20:46 2005 for NVSGSDK by NVIDIA