Lumiera  0.pre.03
»edit your freedom«
scoped-ptrvect.hpp File Reference

Go to the source code of this file.

Description

Managing lifecycle for a collection of objects.

Sometimes we need to build and own a number of objects, including lifecycle management. For example, a service provider may need to maintain a number of individual process handles. The solution here is deliberately kept simple, it is similar to using a STL container with shared_ptr(s), but behaves rather like std::unique_ptr. It provides the same basic functionality as boost::ptr_vector, but doesn't require us to depend on boost-serialisation.

Some details to note:

  • contained objects accessed by reference, never NULL.
  • the exposed iterator automatically dereferences
  • TODO: detaching of objects...
  • TODO: retro-fit with RefArray interface
Warning
deliberately not threadsafe
See also
scoped-ptrvect-test.cpp
scoped-holder.hpp
stage::DisplayService usage example

Definition in file scoped-ptrvect.hpp.

#include "include/logging.h"
#include "lib/iter-adapter-ptr-deref.hpp"
#include "lib/nocopy.hpp"
#include "lib/error.hpp"
#include "lib/util.hpp"
#include <vector>
#include <algorithm>

Classes

class  ScopedPtrVect< T >
 Simple vector based collection of pointers, managing lifecycle of the pointed-to objects. More...
 

Namespaces

 lib
 Implementation namespace for support and library code.