rpa::obuf_slice_bounded< RangeOutp > Class Template Reference

This is the slice used by an obuf_iterator whose buffers have a size limit. More...

#include <common.h>

List of all members.

Public Types

typedef RangeOutp range_type
typedef range_type::result_t result_t
typedef result_t::internal_buffer intern_t
typedef container_traits<
typename intern_t::physical_buf_t > 
cont_trts
typedef cont_trts::iterator iterator
typedef cont_trts::const_iterator const_iterator

Public Member Functions

 obuf_slice_bounded ()
 obuf_slice_bounded (range_type *aRng, seqnum_t seqNum)
 obuf_slice_bounded (const obuf_slice_bounded &aSR, seqnum_t seqNum)
iterator begout (void)
 Works, whether the buffer is local, or if it is a reference.
size_t max_size (void) const
 Used for creating a range_step based on a slice 'chopped' from this output sequence.
result_t::seq_out_iterator flush (iterator aEnd)
 Called after the last insertion was done.
result_t::seq_out_iterator flush_empty (void)
 ~obuf_slice_bounded ()
seqnum_t sequence_number (void) const
void set_number (seqnum_t seqNum)
 Used for an in-place chop.

Private Member Functions

 assert_declare (size_t, _BufSz)
 Checks that the requested buffer size is lower or equal than the max.
 assert_declare (bool, _BeforeBegin)
obuf_slice_boundedoperator= (const obuf_slice_bounded &aSR)
 Not assignable - which is good, because no buffer copy is required.

Private Attributes

range_type_Rng
intern_t _SliceBufLimit
seqnum_t _SeqNum


Detailed Description

template<class RangeOutp>
class rpa::obuf_slice_bounded< RangeOutp >

This is the slice used by an obuf_iterator whose buffers have a size limit.


Member Typedef Documentation

template<class RangeOutp>
typedef cont_trts::const_iterator rpa::obuf_slice_bounded< RangeOutp >::const_iterator

template<class RangeOutp>
typedef container_traits< typename intern_t::physical_buf_t > rpa::obuf_slice_bounded< RangeOutp >::cont_trts

template<class RangeOutp>
typedef result_t::internal_buffer rpa::obuf_slice_bounded< RangeOutp >::intern_t

template<class RangeOutp>
typedef cont_trts::iterator rpa::obuf_slice_bounded< RangeOutp >::iterator

template<class RangeOutp>
typedef RangeOutp rpa::obuf_slice_bounded< RangeOutp >::range_type

template<class RangeOutp>
typedef range_type::result_t rpa::obuf_slice_bounded< RangeOutp >::result_t


Constructor & Destructor Documentation

template<class RangeOutp>
rpa::obuf_slice_bounded< RangeOutp >::obuf_slice_bounded (  )  [inline]

The result of this constructor should never be called, but is needed because this datatype is the second part of tuple2 which has a default constructor, which is used if 'chop' returns an empty slice. TODO: Make it private.

template<class RangeOutp>
rpa::obuf_slice_bounded< RangeOutp >::obuf_slice_bounded ( range_type aRng,
seqnum_t  seqNum 
) [inline, explicit]

Called only once per sub-thread, and the only moment where we really get a buffer, per sub-thread.

template<class RangeOutp>
rpa::obuf_slice_bounded< RangeOutp >::obuf_slice_bounded ( const obuf_slice_bounded< RangeOutp > &  aSR,
seqnum_t  seqNum 
) [inline]

We must explicitely implement the defaut constructor because of the pointer. Beware that it is HIGHLY desirable that this constructor is inlined, to avoid a cache copy. There are three possibilities for this copy constructor :

template<class RangeOutp>
rpa::obuf_slice_bounded< RangeOutp >::~obuf_slice_bounded (  )  [inline]

Flushes the temporary buffer into the output container. Only ONE 'splice' MUST occur at a time. If the output buffer has a limited size like here, it happens each time the buffer will be flushed, except the last time. NOTE: This is also true for 'range_jump', but NOT for 'range_step !

The buffer must be empty, i.e. flushed or never used.


Member Function Documentation

template<class RangeOutp>
rpa::obuf_slice_bounded< RangeOutp >::assert_declare ( bool  ,
_BeforeBegin   
) [private]

This slice can be in two modes :

template<class RangeOutp>
rpa::obuf_slice_bounded< RangeOutp >::assert_declare ( size_t  ,
_BufSz   
) [private]

Checks that the requested buffer size is lower or equal than the max.

template<class RangeOutp>
iterator rpa::obuf_slice_bounded< RangeOutp >::begout ( void   )  [inline]

Works, whether the buffer is local, or if it is a reference.

We do not check whether '_BeforeBegin' is true. because the method 'begin' can be safely called several times.

If this is a destructive buffer like a list (which is spliced when flushed), it can be empty. Otherwise it must be big enough.

We could maybe put the begin of the buffer in a temporary variable, because it is allocated once and for all. If we use 'begout', this provides a insertion iterator, with this error : error: conversion from `stdback_insert_iterator<DeqStrT>' to non-scalar type `std_Deque_iterator<std::string, std::string&, std::string*>' requested What we need here is a std::forward_iterator, not a std::output_iterator.

template<class RangeOutp>
result_t::seq_out_iterator rpa::obuf_slice_bounded< RangeOutp >::flush ( iterator  aEnd  )  [inline]

Called after the last insertion was done.

'aEnd' tells that we have to flush only up to this point. This is necessary because this slice will be injected (In fact, only its 'begin()' ) into a plain output sequence for a range_step. Normally, we would not be able to know how many elements were written. So, at the end of the processing of each thread, this method is called with the iterator after the last used. Please note that if nothing was inserted, this method may not be called. It may sound odd to use 'iterator' instead of 'const_iterator'. This is because we pass the last output iterator used by the algorithm. Most of times, it is the same, but not for example, for std::output_iterator.

The method 'begin' must have been called at least once : Otherwise, calling 'flush' is meaningless.

In all situations, we have to lock.

After the flush, the buffer must still have the right size, except if this is a list-like buffer, i.e. a destructive one, and then, it will be empty.

template<class RangeOutp>
result_t::seq_out_iterator rpa::obuf_slice_bounded< RangeOutp >::flush_empty ( void   )  [inline]

template<class RangeOutp>
size_t rpa::obuf_slice_bounded< RangeOutp >::max_size ( void   )  const [inline]

Used for creating a range_step based on a slice 'chopped' from this output sequence.

If this is a destructive buffer, it may now be empty if we just flushed it.

template<class RangeOutp>
obuf_slice_bounded& rpa::obuf_slice_bounded< RangeOutp >::operator= ( const obuf_slice_bounded< RangeOutp > &  aSR  )  [private]

Not assignable - which is good, because no buffer copy is required.

template<class RangeOutp>
seqnum_t rpa::obuf_slice_bounded< RangeOutp >::sequence_number ( void   )  const [inline]

template<class RangeOutp>
void rpa::obuf_slice_bounded< RangeOutp >::set_number ( seqnum_t  seqNum  )  [inline]

Used for an in-place chop.


Member Data Documentation

template<class RangeOutp>
range_type* rpa::obuf_slice_bounded< RangeOutp >::_Rng [private]

template<class RangeOutp>
seqnum_t rpa::obuf_slice_bounded< RangeOutp >::_SeqNum [private]

template<class RangeOutp>
intern_t rpa::obuf_slice_bounded< RangeOutp >::_SliceBufLimit [private]

If 'BufIter' is void or not, we will have to allocate a buffer, or the slice will have a reference pointing to a pre-allocated buffer : To get a new buffer, we use the buffer iterator maybe contained in 'obuf_iterator'.


The documentation for this class was generated from the following file:
Generated on Tue Sep 25 10:20:36 2007 for rpa by  doxygen 1.4.7