PPL  1.2
Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl Class Reference

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:

Public Member Functions

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

Static Public Member Functions

static dimension_type max_size ()
 Returns the size() of the largest possible Impl. More...
 
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. More...
 
static void operator delete (void *p)
 Uses the standard delete operator to free the memory p points to. More...
 
static void operator delete (void *p, dimension_type capacity)
 Placement version: uses the standard operator delete to free the memory p points to. More...
 

Private Member Functions

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

Private Attributes

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

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 352 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.

108  : size_(0) {
109 }
dimension_type size_
The number of coefficients in the row.
Definition: DB_Row_defs.hh:446
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.

113  {
114  shrink(0);
115 }
void shrink(dimension_type new_size)
Shrinks the row by erasing elements at the end.
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

Increments the size of *this by 1.

Definition at line 101 of file DB_Row_inlines.hh.

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

101  {
102  ++size_;
103 }
dimension_type size_
The number of coefficients in the row.
Definition: DB_Row_defs.hh:446
template<typename T >
template<typename U >
void Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::construct_upward_approximation ( const U &  y)

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(), Parma_Polyhedra_Library::ROUND_UP, and Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::vec_.

34  {
35  const dimension_type y_size = y.size();
36 #if PPL_CXX_SUPPORTS_ZERO_LENGTH_ARRAYS
37  // Construct in direct order: will destroy in reverse order.
38  for (dimension_type i = 0; i < y_size; ++i) {
39  construct(vec_[i], y[i], ROUND_UP);
40  bump_size();
41  }
42 #else // PPL_CXX_SUPPORTS_ZERO_LENGTH_ARRAYS
43  if (y_size > 0) {
44  assign_r(vec_[0], y[0], ROUND_UP);
45  bump_size();
46  // Construct in direct order: will destroy in reverse order.
47  for (dimension_type i = 1; i < y_size; ++i) {
48  construct(vec_[i], y[i], ROUND_UP);
49  bump_size();
50  }
51  }
52 #endif // PPL_CXX_SUPPORTS_ZERO_LENGTH_ARRAYS
53 }
Enable_If< Is_Native_Or_Checked< To >::value &&Is_Special< From >::value, Result >::type assign_r(To &to, const From &, Rounding_Dir dir)
T vec_[ 1]
The vector of coefficients.
Definition: DB_Row_defs.hh:455
size_t dimension_type
An unsigned integral type for representing space dimensions.
void bump_size()
Increments the size of *this by 1.
Enable_If< Is_Native_Or_Checked< To >::value &&Is_Special< From >::value, Result >::type construct(To &to, const From &, Rounding_Dir dir)
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)

Exception-safe copy construction mechanism for coefficients.

Definition at line 96 of file DB_Row_templates.hh.

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

96  {
97  const dimension_type y_size = y.size();
98 #if PPL_CXX_SUPPORTS_ZERO_LENGTH_ARRAYS
99  // Construct in direct order: will destroy in reverse order.
100  for (dimension_type i = 0; i < y_size; ++i) {
101  new(&vec_[i]) T(y.vec_[i]);
102  bump_size();
103  }
104 #else // PPL_CXX_SUPPORTS_ZERO_LENGTH_ARRAYS
105  if (y_size > 0) {
106  vec_[0] = y.vec_[0];
107  bump_size();
108  // Construct in direct order: will destroy in reverse order.
109  for (dimension_type i = 1; i < y_size; ++i) {
110  new(&vec_[i]) T(y.vec_[i]);
111  bump_size();
112  }
113  }
114 #endif // PPL_CXX_SUPPORTS_ZERO_LENGTH_ARRAYS
115 }
T vec_[ 1]
The vector of coefficients.
Definition: DB_Row_defs.hh:455
size_t dimension_type
An unsigned integral type for representing space dimensions.
void bump_size()
Increments the size of *this by 1.
template<typename T >
void Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::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 58 of file DB_Row_templates.hh.

References Parma_Polyhedra_Library::assign_r(), Parma_Polyhedra_Library::PLUS_INFINITY, and Parma_Polyhedra_Library::ROUND_NOT_NEEDED.

58  {
59  PPL_ASSERT(size() <= new_size && new_size <= max_size());
60 #if !PPL_CXX_SUPPORTS_ZERO_LENGTH_ARRAYS
61  if (size() == 0 && new_size > 0) {
62  // vec_[0] is already constructed: we just need to assign +infinity.
64  bump_size();
65  }
66 #endif
67  // Construct in direct order: will destroy in reverse order.
68  for (dimension_type i = size(); i < new_size; ++i) {
69  new(&vec_[i]) T(PLUS_INFINITY, ROUND_NOT_NEEDED);
70  bump_size();
71  }
72 }
Enable_If< Is_Native_Or_Checked< To >::value &&Is_Special< From >::value, Result >::type assign_r(To &to, const From &, Rounding_Dir dir)
T vec_[ 1]
The vector of coefficients.
Definition: DB_Row_defs.hh:455
size_t dimension_type
An unsigned integral type for representing space dimensions.
void bump_size()
Increments the size of *this by 1.
Plus_Infinity PLUS_INFINITY
Definition: checked.cc:31
dimension_type size() const
Returns the actual size of this.
static dimension_type max_size()
Returns the size() of the largest possible Impl.
template<typename T >
memory_size_type Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::external_memory_in_bytes ( ) const

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

Definition at line 119 of file DB_Row_templates.hh.

References Parma_Polyhedra_Library::external_memory_in_bytes().

119  {
120  memory_size_type n = 0;
121  for (dimension_type i = size(); i-- > 0; ) {
123  }
124  return n;
125 }
T vec_[ 1]
The vector of coefficients.
Definition: DB_Row_defs.hh:455
size_t dimension_type
An unsigned integral type for representing space dimensions.
Enable_If< Is_Native< T >::value, memory_size_type >::type external_memory_in_bytes(const T &)
For native types, returns the size in bytes of the memory managed by the type of the (unused) paramet...
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
dimension_type size() const
Returns the actual size of this.
template<typename T >
dimension_type Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::max_size ( )
inlinestatic

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< T >::max_size().

83  {
84  return std::numeric_limits<size_t>::max() / sizeof(T);
85 }
template<typename T >
void Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::operator delete ( void *  p)
inlinestatic

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

Definition at line 50 of file DB_Row_inlines.hh.

50  {
51  ::operator delete(p);
52 }
template<typename T >
void Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::operator delete ( void *  p,
dimension_type  capacity 
)
inlinestatic

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

Definition at line 56 of file DB_Row_inlines.hh.

56  {
57  ::operator delete(p);
58 }
template<typename T >
void * Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::operator new ( size_t  fixed_size,
dimension_type  capacity 
)
inlinestatic

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.

39  {
40 #if PPL_CXX_SUPPORTS_ZERO_LENGTH_ARRAYS
41  return ::operator new(fixed_size + capacity*sizeof(T));
42 #else
43  PPL_ASSERT(capacity >= 1);
44  return ::operator new(fixed_size + (capacity-1)*sizeof(T));
45 #endif
46 }
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 >
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_.

134  {
135  PPL_ASSERT(k < size());
136  return vec_[k];
137 }
T vec_[ 1]
The vector of coefficients.
Definition: DB_Row_defs.hh:455
dimension_type size() const
Returns the actual size of this.
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.

141  {
142  PPL_ASSERT(k < size());
143  return vec_[k];
144 }
T vec_[ 1]
The vector of coefficients.
Definition: DB_Row_defs.hh:455
dimension_type size() const
Returns the actual size of this.
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.

95  {
96  size_ = new_sz;
97 }
dimension_type size_
The number of coefficients in the row.
Definition: DB_Row_defs.hh:446
template<typename T >
void Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::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 76 of file DB_Row_templates.hh.

76  {
77  const dimension_type old_size = size();
78  PPL_ASSERT(new_size <= old_size);
79  // Since ~T() does not throw exceptions, nothing here does.
80  set_size(new_size);
81 #if !PPL_CXX_SUPPORTS_ZERO_LENGTH_ARRAYS
82  // Make sure we do not try to destroy vec_[0].
83  if (new_size == 0) {
84  ++new_size;
85  }
86 #endif
87  // We assume construction was done "forward".
88  // We thus perform destruction "backward".
89  for (dimension_type i = old_size; i-- > new_size; ) {
90  vec_[i].~T();
91  }
92 }
void set_size(dimension_type new_sz)
Sets to new_sz the actual size of *this.
T vec_[ 1]
The vector of coefficients.
Definition: DB_Row_defs.hh:455
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type size() const
Returns the actual size of this.
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 ( ) 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_.

75  {
76  // In general, this is a lower bound, as the capacity of *this
77  // may be strictly greater than `size_'
79 }
memory_size_type total_memory_in_bytes() const
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
dimension_type size_
The number of coefficients in the row.
Definition: DB_Row_defs.hh:446
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::external_memory_in_bytes().

63  {
64  return
65  sizeof(*this)
66  + capacity*sizeof(T)
67 #if !PPL_CXX_SUPPORTS_ZERO_LENGTH_ARRAYS
68  - 1*sizeof(T)
69 #endif
71 }
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.

Friends And Related Function Documentation

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

Definition at line 443 of file DB_Row_defs.hh.

Member Data Documentation

template<typename T>
dimension_type Parma_Polyhedra_Library::DB_Row_Impl_Handler< T >::Impl::size_
private

The number of coefficients in the row.

Definition at line 446 of file DB_Row_defs.hh.

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


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