Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
scoped-ptrvect.hpp File Reference

Managing lifecycle for a collection of objects. More...

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.

Some details to note:

  • contained objects accessed by reference, never NULL.
  • the exposed iterator automatically dereferences
  • can be move-assigned and move constructed, like unique_ptr
Warning
deliberately not threadsafe
Remarks
This library class provides the same basic functionality as boost::ptr_vector, but doesn't require us to depend on boost-serialisation. Furthermore, Boost provides several variants of containers and a much more feature-rich API, also with the ability to clone / move containers; yet we prefer to leave out most functionality, in favour of adding a dedicated API with #manage() and #detach() to indicated semantics. And we value the ability to integrate with Lumiera Forward Iterators.
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>

Namespaces

namespace  lib
 Implementation namespace for support and library code.
 

Classes

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