Parma_Polyhedra_Library::Row_Impl_Handler::Impl Class Reference
[C++ Language Interface]

The actual implementation of a Row object. More...

#include <Row.defs.hh>

Collaboration diagram for Parma_Polyhedra_Library::Row_Impl_Handler::Impl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Impl (Row::Flags f)
 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.
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.
Flags accessors

const Row::Flagsflags () const
 Returns a const reference to the flags of *this.
Row::Flagsflags ()
 Returns a non-const reference to the flags of *this.
Size accessors

dimension_type size () const
 Returns the actual size of this.
void set_size (dimension_type new_size)
 Sets to new_size the actual size of *this.
void bump_size ()
 Increment the size of *this by 1.
Subscript operators

Coefficientoperator[] (dimension_type k)
 Returns a reference to the element of *this indexed by k.
Coefficient_traits::const_reference 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)
 Placement allocation function.
static void operator delete (void *p)
 Usual (non-placement) deallocation function.
static void operator delete (void *p, dimension_type capacity)
 Placement deallocation function.

Private Member Functions

 Impl ()
 Private and unimplemented: default construction is not allowed.
 Impl (const Impl &y)
 Private and unimplemented: copy construction is not allowed.
Imploperator= (const Impl &)
 Private and unimplemented: assignment is not allowed.

Private Attributes

dimension_type size_
 The number of coefficients in the row.
Row::Flags flags_
 The flags of this row.
Coefficient vec_ [1]
 The vector of coefficients.

Detailed Description

The actual implementation of a Row object.

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

Definition at line 389 of file Row.defs.hh.


Constructor & Destructor Documentation

Parma_Polyhedra_Library::Row_Impl_Handler::Impl::Impl ( Row::Flags  f  )  [inline]

Constructor.

Definition at line 117 of file Row.inlines.hh.

00118   : size_(0), flags_(f) {
00119 }

Parma_Polyhedra_Library::Row_Impl_Handler::Impl::~Impl (  )  [inline]

Destructor.

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

Definition at line 122 of file Row.inlines.hh.

References shrink().

00122                             {
00123   shrink(0);
00124 }

Parma_Polyhedra_Library::Row_Impl_Handler::Impl::Impl (  )  [private]

Private and unimplemented: default construction is not allowed.

Parma_Polyhedra_Library::Row_Impl_Handler::Impl::Impl ( const Impl y  )  [private]

Private and unimplemented: copy construction is not allowed.


Member Function Documentation

void Parma_Polyhedra_Library::Row_Impl_Handler::Impl::bump_size (  )  [inline]

Increment the size of *this by 1.

Definition at line 112 of file Row.inlines.hh.

References size_.

Referenced by copy_construct_coefficients().

00112                                 {
00113   ++size_;
00114 }

void Parma_Polyhedra_Library::Row_Impl_Handler::Impl::copy_construct_coefficients ( const Impl y  ) 

Exception-safe copy construction mechanism for coefficients.

Definition at line 66 of file Row.cc.

References bump_size(), size(), and vec_.

Referenced by Parma_Polyhedra_Library::Row::copy_construct_coefficients().

00066                                                                   {
00067   const dimension_type y_size = y.size();
00068 #if PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00069   for (dimension_type i = 0; i < y_size; ++i) {
00070     new (&vec_[i]) Coefficient(y.vec_[i]);
00071     bump_size();
00072   }
00073 #else
00074   PPL_ASSERT(y_size > 0);
00075   if (y_size > 0) {
00076     vec_[0] = y.vec_[0];
00077     bump_size();
00078     for (dimension_type i = 1; i < y_size; ++i) {
00079       new (&vec_[i]) Coefficient(y.vec_[i]);
00080       bump_size();
00081     }
00082   }
00083 #endif
00084 }

void Parma_Polyhedra_Library::Row_Impl_Handler::Impl::expand_within_capacity ( dimension_type  new_size  ) 

Expands the row to size new_size.

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

Definition at line 35 of file Row.cc.

Referenced by Parma_Polyhedra_Library::Row::expand_within_capacity().

00035                                                           {
00036   PPL_ASSERT(size() <= new_size && new_size <= max_size());
00037 #if !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00038   // vec_[0] is already constructed.
00039   if (size() == 0 && new_size > 0)
00040     bump_size();
00041 #endif
00042   for (dimension_type i = size(); i < new_size; ++i) {
00043     new (&vec_[i]) Coefficient();
00044     bump_size();
00045   }
00046 }

PPL::memory_size_type Parma_Polyhedra_Library::Row_Impl_Handler::Impl::external_memory_in_bytes (  )  const

Returns the size in bytes of the memory managed by *this.

Definition at line 202 of file Row.cc.

References Parma_Polyhedra_Library::external_memory_in_bytes(), size(), and vec_.

Referenced by total_memory_in_bytes().

00202                                                         {
00203   memory_size_type n = 0;
00204   for (dimension_type i = size(); i-- > 0; )
00205     n += PPL::external_memory_in_bytes(vec_[i]);
00206   return n;
00207 }

Row::Flags & Parma_Polyhedra_Library::Row_Impl_Handler::Impl::flags (  )  [inline]

Returns a non-const reference to the flags of *this.

Definition at line 132 of file Row.inlines.hh.

References flags_.

00132                             {
00133   return flags_;
00134 }

const Row::Flags & Parma_Polyhedra_Library::Row_Impl_Handler::Impl::flags (  )  const [inline]

Returns a const reference to the flags of *this.

Definition at line 127 of file Row.inlines.hh.

References flags_.

Referenced by Parma_Polyhedra_Library::Row::flags().

00127                                   {
00128   return flags_;
00129 }

dimension_type Parma_Polyhedra_Library::Row_Impl_Handler::Impl::max_size (  )  [inline, static]

Returns the size() of the largest possible Impl.

Definition at line 97 of file Row.inlines.hh.

Referenced by Parma_Polyhedra_Library::Row::max_size().

00097                                {
00098   return std::numeric_limits<size_t>::max() / sizeof(Coefficient);
00099 }

void Parma_Polyhedra_Library::Row_Impl_Handler::Impl::operator delete ( void *  p,
dimension_type  capacity 
) [inline, static]

Placement deallocation function.

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

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

00092                                                              {
00093   ::operator delete(p);
00094 }

void Parma_Polyhedra_Library::Row_Impl_Handler::Impl::operator delete ( void *  p  )  [inline, static]

Usual (non-placement) deallocation function.

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

Note:
The definition of this custom deallocation function is required since otherwise the placement deallocation function static void operator delete(void* p, dimension_type capacity); would be wrongly interpreted as a usual (non-placement) deallocation function (see C++98 3.7.3.2p2). This happens because dimension_type is just an alias for std::size_t. See also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42115

Definition at line 87 of file Row.inlines.hh.

00087                                              {
00088   ::operator delete(p);
00089 }

void * Parma_Polyhedra_Library::Row_Impl_Handler::Impl::operator new ( size_t  fixed_size,
dimension_type  capacity 
) [inline, static]

Placement allocation function.

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

Definition at line 76 of file Row.inlines.hh.

00077                                                                     {
00078 #if PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00079   return ::operator new(fixed_size + capacity*sizeof(Coefficient));
00080 #else
00081   PPL_ASSERT(capacity >= 1);
00082   return ::operator new(fixed_size + (capacity-1)*sizeof(Coefficient));
00083 #endif
00084 }

Impl& Parma_Polyhedra_Library::Row_Impl_Handler::Impl::operator= ( const Impl  )  [private]

Private and unimplemented: assignment is not allowed.

Coefficient_traits::const_reference Parma_Polyhedra_Library::Row_Impl_Handler::Impl::operator[] ( dimension_type  k  )  const [inline]

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

Definition at line 143 of file Row.inlines.hh.

References size(), and vec_.

00143                                                              {
00144   PPL_ASSERT(k < size());
00145   return vec_[k];
00146 }

Coefficient & Parma_Polyhedra_Library::Row_Impl_Handler::Impl::operator[] ( dimension_type  k  )  [inline]

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

Definition at line 137 of file Row.inlines.hh.

References size(), and vec_.

00137                                                        {
00138   PPL_ASSERT(k < size());
00139   return vec_[k];
00140 }

void Parma_Polyhedra_Library::Row_Impl_Handler::Impl::set_size ( dimension_type  new_size  )  [inline]

Sets to new_size the actual size of *this.

Definition at line 107 of file Row.inlines.hh.

References size_.

Referenced by shrink().

00107                                                             {
00108   size_ = new_size;
00109 }

void Parma_Polyhedra_Library::Row_Impl_Handler::Impl::shrink ( dimension_type  new_size  ) 

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 49 of file Row.cc.

References set_size(), size(), and vec_.

Referenced by Parma_Polyhedra_Library::Row::shrink(), and ~Impl().

00049                                                        {
00050   const dimension_type old_size = size();
00051   PPL_ASSERT(new_size <= old_size);
00052   // Since ~Coefficient() does not throw exceptions, nothing here does.
00053   set_size(new_size);
00054 #if !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00055   // Make sure we do not try to destroy vec_[0].
00056   if (new_size == 0)
00057     ++new_size;
00058 #endif
00059   // We assume construction was done "forward".
00060   // We thus perform destruction "backward".
00061   for (dimension_type i = old_size; i-- > new_size; )
00062     vec_[i].~Coefficient();
00063 }

dimension_type Parma_Polyhedra_Library::Row_Impl_Handler::Impl::size (  )  const [inline]

Returns the actual size of this.

Definition at line 102 of file Row.inlines.hh.

References size_.

Referenced by copy_construct_coefficients(), external_memory_in_bytes(), operator[](), shrink(), and Parma_Polyhedra_Library::Row::size().

00102                                  {
00103   return size_;
00104 }

memory_size_type Parma_Polyhedra_Library::Row_Impl_Handler::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 149 of file Row.inlines.hh.

References external_memory_in_bytes().

00149                                                                          {
00150   return
00151     sizeof(*this)
00152     + capacity*sizeof(Coefficient)
00153 #if !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00154     - 1*sizeof(Coefficient)
00155 #endif
00156     + external_memory_in_bytes();
00157 }

memory_size_type Parma_Polyhedra_Library::Row_Impl_Handler::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 160 of file Row.inlines.hh.

References size_.

Referenced by Parma_Polyhedra_Library::Row::external_memory_in_bytes().

00160                                                   {
00161   // In general, this is a lower bound, as the capacity of *this
00162   // may be strictly greater than `size_'
00163   return total_memory_in_bytes(size_);
00164 }


Member Data Documentation

The flags of this row.

Definition at line 501 of file Row.defs.hh.

Referenced by flags().

The number of coefficients in the row.

Definition at line 498 of file Row.defs.hh.

Referenced by bump_size(), set_size(), size(), and total_memory_in_bytes().

The vector of coefficients.

Definition at line 508 of file Row.defs.hh.

Referenced by copy_construct_coefficients(), external_memory_in_bytes(), operator[](), and shrink().


The documentation for this class was generated from the following files:
Generated on Sun Feb 27 16:20:22 2011 for PPL by  doxygen 1.6.3