Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl Class Reference
[C++ Language Interface]

The real implementation of a DB_Row object. More...

#include <DB_Row.defs.hh>

Collaboration diagram for Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Impl ()
 Default constructor.
 ~Impl ()
 Destructor.
void expand_within_capacity (dimension_type new_size)
 Expands the row to size new_size.
void shrink (dimension_type new_size)
 Shrinks the row by erasing elements at the end.
void copy_construct_coefficients (const Impl &y)
 Exception-safe copy construction mechanism for coefficients.
template<typename U>
void construct_upward_approximation (const U &y)
 Exception-safe upward approximation construction mechanism for coefficients.
memory_size_type total_memory_in_bytes () const
 Returns a lower bound to the total size in bytes of the memory occupied by *this.
memory_size_type total_memory_in_bytes (dimension_type capacity) const
 Returns the total size in bytes of the memory occupied by *this.
memory_size_type external_memory_in_bytes () const
 Returns the size in bytes of the memory managed by *this.
Size accessors.
dimension_type size () const
 Returns the actual size of this.
void set_size (dimension_type new_sz)
 Sets to new_sz the actual size of *this.
void bump_size ()
 Increments the size of *this by 1.
Subscript operators.
T & operator[] (dimension_type k)
 Returns a reference to the element of *this indexed by k.
const T & operator[] (dimension_type k) const
 Returns a constant reference to the element of *this indexed by k.

Static Public Member Functions

static dimension_type max_size ()
 Returns the size() of the largest possible Impl.
Custom allocator and deallocator.
static void * operator new (size_t fixed_size, dimension_type capacity)
 Allocates a chunk of memory able to contain capacity T objects beyond the specified fixed_size and returns a pointer to the new allocated memory.
static void operator delete (void *p)
 Uses the standard delete operator to free the memory p points to.
static void operator delete (void *p, dimension_type capacity)
 Placement version: uses the standard operator delete to free the memory p points to.

Private Member Functions

 Impl (const Impl &y)
 Private and unimplemented: copy construction is not allowed.
Imploperator= (const Impl &)
 Private and unimplemented: assignment is not allowed.
void copy_construct (const Impl &y)
 Exception-safe copy construction mechanism.

Private Attributes

dimension_type size_
 The number of coefficients in the row.
vec_ [1]
 The vector of coefficients.

Friends

class DB_Row< T >


Detailed Description

template<typename T>
class Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl

The real implementation of a DB_Row object.

The class DB_Row_Impl_Handler::Impl provides the implementation of DB_Row objects and, in particular, of the corresponding memory allocation functions.

Definition at line 336 of file DB_Row.defs.hh.


Constructor & Destructor Documentation

template<typename T>
Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::Impl (  )  [inline]

Default constructor.

Definition at line 104 of file DB_Row.inlines.hh.

00105   : size_(0) {
00106 }

template<typename T>
Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::~Impl (  )  [inline]

Destructor.

Uses shrink() method with argument $0$ to delete all the row elements.

Definition at line 110 of file DB_Row.inlines.hh.

References Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::shrink().

00110                                   {
00111   shrink(0);
00112 }

template<typename T>
Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::Impl ( const Impl y  )  [private]

Private and unimplemented: copy construction is not allowed.


Member Function Documentation

template<typename T>
void * Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::operator new ( size_t  fixed_size,
dimension_type  capacity 
) [inline, static]

Allocates a chunk of memory able to contain capacity T objects beyond the specified fixed_size and returns a pointer to the new allocated memory.

Definition at line 35 of file DB_Row.inlines.hh.

00036                                                                           {
00037 #if PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00038   return ::operator new(fixed_size + capacity*sizeof(T));
00039 #else
00040   assert(capacity >= 1);
00041   return ::operator new(fixed_size + (capacity-1)*sizeof(T));
00042 #endif
00043 }

template<typename T>
void Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::operator delete ( void *  p  )  [inline, static]

Uses the standard delete operator to free the memory p points to.

Definition at line 47 of file DB_Row.inlines.hh.

00047                                                    {
00048   ::operator delete(p);
00049 }

template<typename T>
void Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::operator delete ( void *  p,
dimension_type  capacity 
) [inline, static]

Placement version: uses the standard operator delete to free the memory p points to.

Definition at line 53 of file DB_Row.inlines.hh.

00053                                                                    {
00054   ::operator delete(p);
00055 }

template<typename T>
void Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::expand_within_capacity ( dimension_type  new_size  )  [inline]

Expands the row to size new_size.

It is assumed that new_size is between the current size and capacity.

Definition at line 56 of file DB_Row.templates.hh.

References Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::bump_size(), Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::max_size(), PLUS_INFINITY, Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::size(), and Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::vec_.

Referenced by Parma_Polyhedra_Library::DB_Row< T >::expand_within_capacity().

00056                                                           {
00057   assert(size() <= new_size && new_size <= max_size());
00058 #if !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00059   // vec_[0] is already constructed.
00060   if (size() == 0 && new_size > 0)
00061     bump_size();
00062 #endif
00063   // Construct in direct order: will destroy in reverse order.
00064   for (dimension_type i = size(); i < new_size; ++i) {
00065     new (&vec_[i]) T(PLUS_INFINITY, ROUND_NOT_NEEDED);
00066     bump_size();
00067   }
00068 }

template<typename T>
void Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::shrink ( dimension_type  new_size  )  [inline]

Shrinks the row by erasing elements at the end.

It is assumed that new_size is not greater than the current size.

Definition at line 72 of file DB_Row.templates.hh.

References Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::set_size(), Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::size(), and Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::vec_.

Referenced by Parma_Polyhedra_Library::DB_Row< T >::shrink(), and Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::~Impl().

00072                                                           {
00073   const dimension_type old_size = size();
00074   assert(new_size <= old_size);
00075   // Since ~T() does not throw exceptions, nothing here does.
00076   set_size(new_size);
00077 #if !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00078   // Make sure we do not try to destroy vec_[0].
00079   if (new_size == 0)
00080     ++new_size;
00081 #endif
00082   // We assume construction was done "forward".
00083   // We thus perform destruction "backward".
00084   for (dimension_type i = old_size; i-- > new_size; )
00085     vec_[i].~T();
00086 }

template<typename T>
void Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::copy_construct_coefficients ( const Impl y  )  [inline]

Exception-safe copy construction mechanism for coefficients.

Definition at line 90 of file DB_Row.templates.hh.

References Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::bump_size(), Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::size(), and Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::vec_.

Referenced by Parma_Polyhedra_Library::DB_Row< T >::copy_construct_coefficients().

00090                                                                      {
00091   const dimension_type y_size = y.size();
00092 #if PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00093   // Construct in direct order: will destroy in reverse order.
00094   for (dimension_type i = 0; i < y_size; ++i) {
00095     new (&vec_[i]) T(y.vec_[i]);
00096     bump_size();
00097   }
00098 #else // PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00099   assert(y_size > 0);
00100   if (y_size > 0) {
00101     vec_[0] = y.vec_[0];
00102     bump_size();
00103     // Construct in direct order: will destroy in reverse order.
00104     for (dimension_type i = 1; i < y_size; ++i) {
00105       new (&vec_[i]) T(y.vec_[i]);
00106       bump_size();
00107     }
00108   }
00109 #endif // PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00110 }

template<typename T>
template<typename U>
void Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::construct_upward_approximation ( const U &  y  )  [inline]

Exception-safe upward approximation construction mechanism for coefficients.

Definition at line 31 of file DB_Row.templates.hh.

References Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::bump_size(), Parma_Polyhedra_Library::construct(), and Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::vec_.

Referenced by Parma_Polyhedra_Library::DB_Row< T >::construct_upward_approximation().

00031                                                                      {
00032   const dimension_type y_size = y.size();
00033 #if PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00034   // Construct in direct order: will destroy in reverse order.
00035   for (dimension_type i = 0; i < y_size; ++i) {
00036     construct(vec_[i], y[i], ROUND_UP);
00037     bump_size();
00038   }
00039 #else // PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00040   assert(y_size > 0);
00041   if (y_size > 0) {
00042     vec_[0] = y[0];
00043     bump_size();
00044     // Construct in direct order: will destroy in reverse order.
00045     for (dimension_type i = 1; i < y_size; ++i) {
00046       construct(vec_[i], y[i], ROUND_UP);
00047       bump_size();
00048     }
00049   }
00050 #endif // PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00051 }

template<typename T>
dimension_type Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::max_size (  )  [inline, static]

Returns the size() of the largest possible Impl.

Definition at line 80 of file DB_Row.inlines.hh.

Referenced by Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::expand_within_capacity().

00080                                      {
00081   return size_t(-1)/sizeof(T);
00082 }

template<typename T>
dimension_type Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::size (  )  const [inline]

template<typename T>
void Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::set_size ( dimension_type  new_sz  )  [inline]

Sets to new_sz the actual size of *this.

Definition at line 92 of file DB_Row.inlines.hh.

References Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::size_.

Referenced by Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::shrink().

00092                                                                 {
00093   size_ = new_sz;
00094 }

template<typename T>
void Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::bump_size (  )  [inline]

template<typename T>
T & Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::operator[] ( dimension_type  k  )  [inline]

Returns a reference to the element of *this indexed by k.

Definition at line 131 of file DB_Row.inlines.hh.

References Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::size(), and Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::vec_.

00131                                                              {
00132   assert(k < size());
00133   return vec_[k];
00134 }

template<typename T>
const T & Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::operator[] ( dimension_type  k  )  const [inline]

Returns a constant reference to the element of *this indexed by k.

Definition at line 138 of file DB_Row.inlines.hh.

References Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::size(), and Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::vec_.

00138                                                                    {
00139   assert(k < size());
00140   return vec_[k];
00141 }

template<typename T>
memory_size_type Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::total_memory_in_bytes (  )  const [inline]

Returns a lower bound to the total size in bytes of the memory occupied by *this.

Definition at line 72 of file DB_Row.inlines.hh.

References Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::size_.

Referenced by Parma_Polyhedra_Library::DB_Row< T >::external_memory_in_bytes().

00072                                                         {
00073   // In general, this is a lower bound, as the capacity of *this
00074   // may be strictly greater than `size_'
00075   return total_memory_in_bytes(size_);
00076 }

template<typename T>
memory_size_type Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::total_memory_in_bytes ( dimension_type  capacity  )  const [inline]

Returns the total size in bytes of the memory occupied by *this.

Definition at line 60 of file DB_Row.inlines.hh.

References Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::external_memory_in_bytes().

00060                                                      {
00061   return
00062     sizeof(*this)
00063     + capacity*sizeof(T)
00064 #if !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00065     - 1*sizeof(T)
00066 #endif
00067     + external_memory_in_bytes();
00068 }

template<typename T>
memory_size_type Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::external_memory_in_bytes (  )  const [inline]

template<typename T>
Impl& Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::operator= ( const Impl  )  [private]

Private and unimplemented: assignment is not allowed.

template<typename T>
void Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::copy_construct ( const Impl y  )  [private]

Exception-safe copy construction mechanism.


Friends And Related Function Documentation

template<typename T>
friend class DB_Row< T > [friend]

Definition at line 427 of file DB_Row.defs.hh.


Member Data Documentation

template<typename T>
T Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::vec_[1] [private]


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

Generated on Sat Oct 11 10:41:15 2008 for PPL by  doxygen 1.5.6