From 34a7988a36fa27f272a913ea20bb658b3b04392b Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 30 Nov 2001 13:06:54 +0000 Subject: [PATCH] Move the IteratorState to a namespace of its own, to move it out of the global namespace. git-svn-id: https://svn.dealii.org/trunk@5318 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/dofs/dof_accessor.templates.h | 10 +-- deal.II/deal.II/include/grid/tria_accessor.h | 3 +- .../include/grid/tria_accessor.templates.h | 36 ++++---- deal.II/deal.II/include/grid/tria_iterator.h | 35 ++++---- .../include/grid/tria_iterator.templates.h | 56 ++++++------- .../deal.II/include/grid/tria_iterator_base.h | 20 +++-- deal.II/deal.II/source/dofs/dof_handler.cc | 2 +- deal.II/deal.II/source/grid/intergrid_map.cc | 2 +- deal.II/deal.II/source/grid/tria.cc | 84 ++++++++++--------- deal.II/deal.II/source/grid/tria_accessor.cc | 18 ++-- .../source/multigrid/mg_dof_accessor.cc | 10 +-- .../source/multigrid/mg_dof_handler.cc | 2 +- .../deal.II/source/multigrid/mg_smoother.cc | 2 +- .../source/numerics/error_estimator.cc | 8 +- deal.II/deal.II/source/numerics/vectors.cc | 2 +- deal.II/doc/news/2001/c-3-2.html | 11 +++ deal.II/examples/step-12/step-12.cc | 3 +- 17 files changed, 167 insertions(+), 137 deletions(-) diff --git a/deal.II/deal.II/include/dofs/dof_accessor.templates.h b/deal.II/deal.II/include/dofs/dof_accessor.templates.h index 3de2e632a7..ca9f1af95c 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.templates.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.templates.h @@ -176,7 +176,7 @@ DoFObjectAccessor<1,dim>::child (const unsigned int i) const dof_handler); #ifdef DEBUG - if (q.state() != past_the_end) + if (q.state() != IteratorState::past_the_end) Assert (q->used(), typename TriaAccessor::ExcUnusedCellAsChild()); #endif return q; @@ -297,7 +297,7 @@ DoFObjectAccessor<2,dim>::child (const unsigned int i) const dof_handler); #ifdef DEBUG - if (q.state() != past_the_end) + if (q.state() != IteratorState::past_the_end) Assert (q->used(), typename TriaAccessor::ExcUnusedCellAsChild()); #endif return q; @@ -435,7 +435,7 @@ DoFObjectAccessor<3,dim>::child (const unsigned int i) const dof_handler); #ifdef DEBUG - if (q.state() != past_the_end) + if (q.state() != IteratorState::past_the_end) Assert (q->used(), typename TriaAccessor::ExcUnusedCellAsChild()); #endif return q; @@ -464,7 +464,7 @@ DoFCellAccessor::neighbor (const unsigned int i) const dof_handler); #ifdef DEBUG - if (q.state() != past_the_end) + if (q.state() != IteratorState::past_the_end) Assert (q->used(), typename TriaAccessor::ExcUnusedCellAsNeighbor()); #endif return q; @@ -482,7 +482,7 @@ DoFCellAccessor::child (const unsigned int i) const dof_handler); #ifdef DEBUG - if (q.state() != past_the_end) + if (q.state() != IteratorState::past_the_end) Assert (q->used(), typename TriaAccessor::ExcUnusedCellAsChild()); #endif return q; diff --git a/deal.II/deal.II/include/grid/tria_accessor.h b/deal.II/deal.II/include/grid/tria_accessor.h index 970f69cf7c..fa8ec1869b 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.h +++ b/deal.II/deal.II/include/grid/tria_accessor.h @@ -161,13 +161,14 @@ class TriaAccessor * present level. */ int index () const; + /** * Return the state of the iterator. * For the different states an accessor * can be in, refer to the * @ref{TriaRawIterator} documentation. */ - IteratorState state () const; + IteratorState::IteratorState state () const; /** * Return a pointer to the triangulation diff --git a/deal.II/deal.II/include/grid/tria_accessor.templates.h b/deal.II/deal.II/include/grid/tria_accessor.templates.h index 1fd585ed08..522339a9c7 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.templates.h +++ b/deal.II/deal.II/include/grid/tria_accessor.templates.h @@ -82,16 +82,16 @@ TriaAccessor::index () const template inline -IteratorState +IteratorState::IteratorState TriaAccessor::state () const { if ((present_level>=0) && (present_index>=0)) - return valid; + return IteratorState::valid; else if ((present_level==-1) && (present_index==-1)) - return past_the_end; + return IteratorState::past_the_end; else - return invalid; + return IteratorState::invalid; }; @@ -113,7 +113,7 @@ inline bool TriaObjectAccessor<1,dim>::used () const { - Assert (state() == valid, + Assert (state() == IteratorState::valid, typename TriaAccessor::ExcDereferenceInvalidObject()); return tria->levels[present_level]->lines.used[present_index]; }; @@ -163,7 +163,7 @@ TriaObjectAccessor<1,dim>::child (const unsigned int i) const TriaIterator > q (tria, present_level+1, child_index (i)); - Assert ((q.state() == past_the_end) || q->used(), + Assert ((q.state() == IteratorState::past_the_end) || q->used(), typename TriaAccessor::ExcUnusedCellAsChild()); return q; @@ -187,7 +187,7 @@ inline bool TriaObjectAccessor<1,dim>::has_children () const { - Assert (state() == valid, + Assert (state() == IteratorState::valid, typename TriaAccessor::ExcDereferenceInvalidObject()); return (tria->levels[present_level]->lines.children[present_index] != -1); } @@ -270,7 +270,7 @@ inline bool TriaObjectAccessor<2,dim>::used () const { - Assert (state() == valid, + Assert (state() == IteratorState::valid, typename TriaAccessor::ExcDereferenceInvalidObject()); return tria->levels[present_level]->quads.used[present_index]; }; @@ -348,7 +348,7 @@ TriaObjectAccessor<2,dim>::child (const unsigned int i) const TriaIterator > q (tria, present_level+1, child_index (i)); - Assert ((q.state() == past_the_end) || q->used(), + Assert ((q.state() == IteratorState::past_the_end) || q->used(), typename TriaAccessor::ExcUnusedCellAsChild()); return q; @@ -371,7 +371,7 @@ inline bool TriaObjectAccessor<2,dim>::has_children () const { - Assert (state() == valid, + Assert (state() == IteratorState::valid, typename TriaAccessor::ExcDereferenceInvalidObject()); return (tria->levels[present_level]->quads.children[present_index] != -1); }; @@ -456,7 +456,7 @@ inline bool TriaObjectAccessor<3,dim>::used () const { - Assert (state() == valid, + Assert (state() == IteratorState::valid, typename TriaAccessor::ExcDereferenceInvalidObject()); return tria->levels[present_level]->hexes.used[present_index]; }; @@ -602,7 +602,7 @@ TriaObjectAccessor<3,dim>::child (const unsigned int i) const TriaIterator > q (tria, present_level+1, child_index (i)); - Assert ((q.state() == past_the_end) || q->used(), + Assert ((q.state() == IteratorState::past_the_end) || q->used(), typename TriaAccessor::ExcUnusedCellAsChild()); return q; @@ -623,7 +623,7 @@ int TriaObjectAccessor<3,dim>::child_index (const unsigned int i) const template bool TriaObjectAccessor<3,dim>::has_children () const { - Assert (state() == valid, + Assert (state() == IteratorState::valid, typename TriaAccessor::ExcDereferenceInvalidObject()); return (tria->levels[present_level]->hexes.children[present_index] != -1); }; @@ -714,7 +714,7 @@ inline bool TriaObjectAccessor::used () const { - Assert (state() == valid, ExcDereferenceInvalidObject()); + Assert (state() == IteratorState::valid, ExcDereferenceInvalidObject()); return tria->levels[present_level]->hexes.used[present_index]; }; @@ -882,7 +882,7 @@ TriaObjectAccessor::child (const unsigned int i) const TriaIterator > q (tria, present_level+1, child_index (i)); - Assert ((q.state() == past_the_end) || q->used(), + Assert ((q.state() == IteratorState::past_the_end) || q->used(), ExcUnusedCellAsChild()); return q; @@ -904,7 +904,7 @@ int TriaObjectAccessor::child_index (const unsigned int i) const template bool TriaObjectAccessor::has_children () const { - Assert (state() == valid, + Assert (state() == IteratorState::valid, typename TriaAccessor::ExcDereferenceInvalidObject()); return (tria->levels[present_level]->hexes.children[present_index] != -1); }; @@ -1140,7 +1140,7 @@ CellAccessor::neighbor (const unsigned int i) const TriaIterator > q (tria, neighbor_level (i), neighbor_index (i)); - Assert ((q.state() == past_the_end) || q->used(), + Assert ((q.state() == IteratorState::past_the_end) || q->used(), typename TriaAccessor::ExcUnusedCellAsNeighbor()); return q; @@ -1156,7 +1156,7 @@ CellAccessor::child (const unsigned int i) const TriaIterator > q (tria, present_level+1, child_index (i)); - Assert ((q.state() == past_the_end) || q->used(), + Assert ((q.state() == IteratorState::past_the_end) || q->used(), typename TriaAccessor::ExcUnusedCellAsChild()); return q; diff --git a/deal.II/deal.II/include/grid/tria_iterator.h b/deal.II/deal.II/include/grid/tria_iterator.h index 3927c7c87d..0cb6ae6684 100644 --- a/deal.II/deal.II/include/grid/tria_iterator.h +++ b/deal.II/deal.II/include/grid/tria_iterator.h @@ -454,7 +454,7 @@ class TriaRawIterator : /** * Return the state of the iterator. */ - IteratorState state () const; + IteratorState::IteratorState state () const; /** * Print the iterator to @p{out}. The @@ -851,7 +851,7 @@ inline const Accessor & TriaRawIterator::operator * () const { - Assert (state() == valid, ExcDereferenceInvalidObject()); + Assert (state() == IteratorState::valid, ExcDereferenceInvalidObject()); return accessor; }; @@ -862,7 +862,7 @@ inline Accessor & TriaRawIterator::operator * () { - Assert (state() == valid, ExcDereferenceInvalidObject()); + Assert (state() == IteratorState::valid, ExcDereferenceInvalidObject()); return accessor; }; @@ -890,7 +890,7 @@ TriaRawIterator::operator -> () template inline -IteratorState +IteratorState::IteratorState TriaRawIterator::state () const { return accessor.state (); @@ -903,17 +903,18 @@ inline bool TriaRawIterator::operator < (const TriaRawIterator &i) const { - Assert (state() != invalid, ExcDereferenceInvalidObject()); - Assert (i.state() != invalid, ExcDereferenceInvalidObject()); + Assert (state() != IteratorState::invalid, ExcDereferenceInvalidObject()); + Assert (i.state() != IteratorState::invalid, ExcDereferenceInvalidObject()); Assert (&accessor.get_triangulation() == &i.accessor.get_triangulation(), ExcInvalidComparison()); return ((((accessor.level() < i.accessor.level()) || ((accessor.level() == i.accessor.level()) && (accessor.index() < i.accessor.index())) ) && - (state()==valid) && - (i.state()==valid) ) || - ((state()==valid) && (i.state()==past_the_end))); + (state()==IteratorState::valid) && + (i.state()==IteratorState::valid) ) || + ((state()==IteratorState::valid) && + (i.state()==IteratorState::past_the_end))); }; @@ -922,7 +923,7 @@ inline TriaRawIterator & TriaRawIterator::operator ++ () { - Assert (state() == valid, ExcAdvanceInvalidObject()); + Assert (state() == IteratorState::valid, ExcAdvanceInvalidObject()); ++accessor; return *this; @@ -935,7 +936,7 @@ inline TriaRawIterator & TriaRawIterator::operator -- () { - Assert (state() == valid, ExcAdvanceInvalidObject()); + Assert (state() == IteratorState::valid, ExcAdvanceInvalidObject()); --accessor; return *this; @@ -981,11 +982,11 @@ TriaIterator::TriaIterator (const TriaRawIterator::TriaActiveIterator (const TriaRawIterator::TriaIterator (const TriaRawIterator &i #ifdef DEBUG // do this like this, because: // if we write - // "Assert (past_the_end || used)" + // "Assert (IteratorState::past_the_end || used)" // used() is called anyway, even if - // state==past_the_end, and will then + // state==IteratorState::past_the_end, and will then // throw the exception! - if (state() != past_the_end) + if (state() != IteratorState::past_the_end) Assert (accessor.used(), ExcAssignmentOfUnusedObject()); #endif @@ -153,11 +153,11 @@ TriaIterator::TriaIterator (Triangulation *parent, #ifdef DEBUG // do this like this, because: // if we write - // "Assert (past_the_end || used)" + // "Assert (IteratorState::past_the_end || used)" // used() is called anyway, even if - // state==past_the_end, and will then + // state==IteratorState::past_the_end, and will then // throw the exception! - if (state() != past_the_end) + if (state() != IteratorState::past_the_end) Assert (accessor.used(), ExcAssignmentOfUnusedObject()); #endif @@ -181,11 +181,11 @@ TriaIterator::operator = (const TriaRawIterator &i) #ifdef DEBUG // do this like this, because: // if we write - // "Assert (past_the_end || used)" + // "Assert (IteratorState::past_the_end || used)" // used() is called anyway, even if - // state==past_the_end, and will then + // state==IteratorState::past_the_end, and will then // throw the exception! - if (state() != past_the_end) + if (state() != IteratorState::past_the_end) Assert (accessor.used(), ExcAssignmentOfUnusedObject()); #endif @@ -197,7 +197,7 @@ template inline TriaIterator & TriaIterator::operator ++ () { while (TriaRawIterator::operator++(), - (state() == valid)) + (state() == IteratorState::valid)) if (accessor.used() == true) return *this; return *this; @@ -219,7 +219,7 @@ inline TriaIterator & TriaIterator::operator -- () { while (TriaRawIterator::operator--(), - (state() == valid)) + (state() == IteratorState::valid)) if (accessor.used() == true) return *this; return *this; @@ -260,11 +260,11 @@ TriaActiveIterator::TriaActiveIterator (const TriaRawIterator::TriaActiveIterator (const TriaIterator::TriaActiveIterator (Triangulation *parent #ifdef DEBUG // do this like this, because: // if we write - // "Assert (past_the_end || used)" + // "Assert (IteratorState::past_the_end || used)" // has_children() is called anyway, even if - // state==past_the_end, and will then + // state==IteratorState::past_the_end, and will then // throw the exception! - if (state() != past_the_end) + if (state() != IteratorState::past_the_end) Assert (accessor.has_children()==false, ExcAssignmentOfInactiveObject()); #endif @@ -329,11 +329,11 @@ TriaActiveIterator::operator = (const TriaRawIterator::operator = (const TriaIterator & #ifdef DEBUG // do this like this, because: // if we write - // "Assert (past_the_end || used)" + // "Assert (IteratorState::past_the_end || used)" // has_children() is called anyway, even if - // state==past_the_end, and will then + // state==IteratorState::past_the_end, and will then // throw the exception! - if (state() != past_the_end) + if (state() != IteratorState::past_the_end) Assert (accessor.has_children()==false, ExcAssignmentOfInactiveObject()); #endif @@ -366,7 +366,7 @@ inline TriaActiveIterator & TriaActiveIterator::operator ++ () { while (TriaIterator::operator++(), - (state() == valid)) + (state() == IteratorState::valid)) if (accessor.has_children() == false) return *this; return *this; @@ -389,7 +389,7 @@ inline TriaActiveIterator & TriaActiveIterator::operator -- () { while (TriaIterator::operator--(), - (state() == valid)) + (state() == IteratorState::valid)) if (accessor.has_children() == false) return *this; return *this; diff --git a/deal.II/deal.II/include/grid/tria_iterator_base.h b/deal.II/deal.II/include/grid/tria_iterator_base.h index 89af62eea3..7f07595410 100644 --- a/deal.II/deal.II/include/grid/tria_iterator_base.h +++ b/deal.II/deal.II/include/grid/tria_iterator_base.h @@ -16,16 +16,26 @@ #include + +/** + * Namespace in which an enumeration is declared that denotes the + * states in which an iterator can be in. + */ +namespace IteratorState +{ + /** * The three states an iterator can be in: valid, past-the-end and * invalid. */ -enum IteratorState -{ - valid, - past_the_end, - invalid + enum IteratorState + { + valid, + past_the_end, + invalid + }; }; + #endif diff --git a/deal.II/deal.II/source/dofs/dof_handler.cc b/deal.II/deal.II/source/dofs/dof_handler.cc index fb1bb3fc4b..0e31262b8b 100644 --- a/deal.II/deal.II/source/dofs/dof_handler.cc +++ b/deal.II/deal.II/source/dofs/dof_handler.cc @@ -1351,7 +1351,7 @@ unsigned int DoFHandler<1>::distribute_dofs_on_cell (active_cell_iterator &cell, { cell_iterator neighbor = cell->neighbor(v); - if (neighbor.state() == valid) + if (neighbor.state() == IteratorState::valid) { // find true neighbor; may be its // a child of @p{neighbor} diff --git a/deal.II/deal.II/source/grid/intergrid_map.cc b/deal.II/deal.II/source/grid/intergrid_map.cc index 6fa4bf0b68..64d7fdd69f 100644 --- a/deal.II/deal.II/source/grid/intergrid_map.cc +++ b/deal.II/deal.II/source/grid/intergrid_map.cc @@ -163,7 +163,7 @@ template