GemaCoreLib
The GeMA Core library
Public Member Functions | Private Member Functions | Private Attributes | List of all members
GmVectorResizer< T > Class Template Reference

A RAII auxiliary class tailored for resizing a GmSingleVector or a GmDualVector and reverting to the original size on the destructor if the commit method was not called. More...

#include <gmVectorResizer.h>

Public Member Functions

 GmVectorResizer (T &v)
 No imediate resize constructor. Resize should be done by a call to add()
 
 GmVectorResizer (T *v)
 No imediate resize constructor for vector pointer, that can be NULL. Resize should be done by a call to add()
 
 GmVectorResizer (T &v, size_t numAddedValues, bool tight=false)
 Resizing constructor. On error will raise a bad_alloc exception.
 
 ~GmVectorResizer ()
 Destructor. Unless commit was called, reverts the vector size to its original one.
 
bool add (size_t numAddedValues, bool tight=false)
 Grow the vector by the given size.
 
size_t old () const
 Returns the old size before the call to add(). If add() was not called, returns 0.
 
void commit ()
 Commits the vector growing.
 

Private Member Functions

 Q_DISABLE_COPY (GmVectorResizer)
 

Private Attributes

T * _v
 
size_t _oldSize
 The real vector.
 

Detailed Description

template<class T>
class GmVectorResizer< T >

A RAII auxiliary class tailored for resizing a GmSingleVector or a GmDualVector and reverting to the original size on the destructor if the commit method was not called.


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