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 337 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 107 of file DB_Row.inlines.hh.

00108   : size_(0) {
00109 }

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 113 of file DB_Row.inlines.hh.

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

00113                                   {
00114   shrink(0);
00115 }

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::bump_size (  )  [inline]
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 34 of file DB_Row.templates.hh.

References Parma_Polyhedra_Library::assign_r(), 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().

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

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

Exception-safe copy construction mechanism.

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 94 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().

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

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 58 of file DB_Row.templates.hh.

References Parma_Polyhedra_Library::assign_r(), Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::bump_size(), Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::max_size(), Parma_Polyhedra_Library::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().

00058                                                           {
00059   PPL_ASSERT(size() <= new_size && new_size <= max_size());
00060 #if !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00061   if (size() == 0 && new_size > 0) {
00062     // vec_[0] is already constructed: we just need to assign +infinity.
00063     assign_r(vec_[0], PLUS_INFINITY, ROUND_NOT_NEEDED);
00064     bump_size();
00065   }
00066 #endif
00067   // Construct in direct order: will destroy in reverse order.
00068   for (dimension_type i = size(); i < new_size; ++i) {
00069     new (&vec_[i]) T(PLUS_INFINITY, ROUND_NOT_NEEDED);
00070     bump_size();
00071   }
00072 }

template<typename T >
memory_size_type Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::external_memory_in_bytes (  )  const [inline]
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 83 of file DB_Row.inlines.hh.

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

00083                                      {
00084   return std::numeric_limits<size_t>::max() / sizeof(T);
00085 }

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 56 of file DB_Row.inlines.hh.

00056                                                                    {
00057   ::operator delete(p);
00058 }

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 50 of file DB_Row.inlines.hh.

00050                                                    {
00051   ::operator delete(p);
00052 }

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 38 of file DB_Row.inlines.hh.

00039                                                                           {
00040 #if PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00041   return ::operator new(fixed_size + capacity*sizeof(T));
00042 #else
00043   PPL_ASSERT(capacity >= 1);
00044   return ::operator new(fixed_size + (capacity-1)*sizeof(T));
00045 #endif
00046 }

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 >
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 141 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_.

00141                                                                    {
00142   PPL_ASSERT(k < size());
00143   return vec_[k];
00144 }

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 134 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_.

00134                                                              {
00135   PPL_ASSERT(k < size());
00136   return vec_[k];
00137 }

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 95 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().

00095                                                                 {
00096   size_ = new_sz;
00097 }

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 76 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().

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

template<typename T >
dimension_type Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::size (  )  const [inline]
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 63 of file DB_Row.inlines.hh.

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

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

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 75 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().

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


Friends And Related Function Documentation

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

Definition at line 428 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 Sun Feb 27 16:20:30 2011 for PPL by  doxygen 1.6.3