ElInfoStack.h 3.41 KB
Newer Older
Thomas Witkowski's avatar
Thomas Witkowski committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file ElInfo.h */

#ifndef AMDIS_ELINFOSTACK_H
#define AMDIS_ELINFOSTACK_H

// ============================================================================
// ===== includes =============================================================
// ============================================================================
#include <vector>
#include "ElInfo.h"

namespace AMDiS {

  // ============================================================================
  // ===== forward declarations =================================================
  // ============================================================================

  class Mesh;


  // ============================================================================
  // ===== class ElInfoStack ====================================================
  // ============================================================================

  /** \ingroup Traverse
   * \brief 
   * Stores a stack of ElInfo object. Is used by meshes for recursive mesh
   * traverse. The use of a stack is cheaper than allocating the ElInfo objects
   * at every recursive step.
   */

  class ElInfoStack
  {
  public:
    /** \brief
     * Constructer, creates the stack.
     */
    ElInfoStack(Mesh *mesh);
    
    /** \brief
     * Destructor, deletes all ElInfos on the stack.
     */
    ~ElInfoStack();

    /** \brief
     * Get a new element from the stack an increase the stack position.
     */
    ElInfo* getNextElement();

    /** \brief
     * Decrease the stack position.
     */
    void getBackElement();

    /** \brief
     * Returns a pointer to the currently used element of the stack.
     */
    ElInfo* getCurrentElement();

  protected:
    /** \brief
     * The mesh on which the traverse is done.
     */
    Mesh *mesh_;

    /** \brief
     * The stack of pointers to ElInfo objects.
     */
    ::std::vector<ElInfo*> elInfoStack_;

    /** \brief
     * Current position (depth) of the recursive mesh traverse.
     */
    int stackPosition_;
  };
  
}


#endif  // AMDIS_ELINFOSTACK_H