Lumiera  0.pre.03
»edit your freedom«
ScopedPtrVect< T > Class Template Reference

#include "lib/scoped-ptrvect.hpp"

Description

template<class T>
class lib::ScopedPtrVect< T >

Simple vector based collection of pointers, managing lifecycle of the pointed-to objects.

Implemented as a non-copyable object, based on a vector of bare pointers (private inheritance)

Definition at line 71 of file scoped-ptrvect.hpp.

Public Types

typedef ConstIterType const_iterator
 
typedef T const & const_reference
 
typedef IterType iterator
 
typedef T & reference
 
typedef size_t size_type
 
typedef T value_type
 

Public Member Functions

 ScopedPtrVect (size_type capacity)
 
iterator begin ()
 
const_iterator begin () const
 
size_type capacity () const
 
void clear ()
 
T * detach (void *objAddress)
 withdraw responsibility for a specific object. More...
 
bool empty () const
 
iterator end ()
 
const_iterator end () const
 
T & manage (T *obj)
 take ownership of the given object, adding it at the end of the collection More...
 
size_type max_size () const
 
T & operator[] (size_type i)
 
size_type size () const
 

Private Types

typedef std::vector< T * > _Vec
 
typedef IterType::ConstIterType ConstIterType
 
typedef PtrDerefIter< RIterIterType
 
typedef IterType::WrappedConstIterType RcIter
 
typedef RangeIter< VIter > RIter
 
typedef _Vec::iterator VIter
 

Private Member Functions

RIter allPtrs ()
 
RIter allPtrs () const
 
T * get (size_type i)
 
- Private Member Functions inherited from NonCopyable
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Member Function Documentation

◆ manage()

T& manage ( T *  obj)
inline

take ownership of the given object, adding it at the end of the collection

Note
object is deleted in case of any problem while adding it

Definition at line 116 of file scoped-ptrvect.hpp.

Referenced by DiagnosticOutputSlot::build(), CommandArgument_test::createTuples(), and DisplayService::setUp().

+ Here is the caller graph for this function:

◆ detach()

T* detach ( void *  objAddress)
inline

withdraw responsibility for a specific object.

This object will be removed form this collection and returned as-is; it won't be deleted when the ScopedPtrVect goes out of scope.

Parameters
objaddress of the object in question.
Returns
pointer to the object, if found. Otherwise, NULL will be returned and the collection of managed objects remains unaltered
Note
EX_STRONG
Todo:
TICKET #856 better return a Maybe<T&> instead of a pointer?

Definition at line 143 of file scoped-ptrvect.hpp.

◆ get()

T* get ( size_type  i)
inlineprivate

element access, including range and null check

Definition at line 202 of file scoped-ptrvect.hpp.

Referenced by WrappedStandardExeBuilder::__call__().

+ Here is the caller graph for this function:

◆ allPtrs()

RIter allPtrs ( )
inlineprivate

access sequence of all managed pointers

Definition at line 213 of file scoped-ptrvect.hpp.

Referenced by ScopedPtrVect< Gtk::Widget >::allPtrs().

+ Here is the caller graph for this function:
+ Inheritance diagram for ScopedPtrVect< T >:
+ Collaboration diagram for ScopedPtrVect< T >:

The documentation for this class was generated from the following file: