Skip to content
Snippets Groups Projects
ElInfoStack.h 1.92 KiB
Newer Older
Thomas Witkowski's avatar
Thomas Witkowski committed
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
Thomas Witkowski's avatar
Thomas Witkowski committed
// ==                                                                        ==
// ============================================================================
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


Thomas Witkowski's avatar
Thomas Witkowski committed

/** \file ElInfo.h */

#ifndef AMDIS_ELINFOSTACK_H
#define AMDIS_ELINFOSTACK_H

#include <vector>
#include "ElInfo.h"
Thomas Witkowski's avatar
Thomas Witkowski committed

namespace AMDiS {

  /** \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:
    /// Constructer, creates the stack.
Thomas Witkowski's avatar
Thomas Witkowski committed
    ElInfoStack(Mesh *mesh);
    
    /// Destructor, deletes all ElInfos on the stack.
Thomas Witkowski's avatar
Thomas Witkowski committed
    ~ElInfoStack();

    /// Get a new element from the stack an increase the stack position.
Thomas Witkowski's avatar
Thomas Witkowski committed
    ElInfo* getNextElement();

    /// Decrease the stack position.
Thomas Witkowski's avatar
Thomas Witkowski committed
    void getBackElement();

    /// Returns a pointer to the currently used element of the stack.
Thomas Witkowski's avatar
Thomas Witkowski committed
    ElInfo* getCurrentElement();

  protected:
    /// The mesh on which the traverse is done.
Thomas Witkowski's avatar
Thomas Witkowski committed
    Mesh *mesh_;

    /// The stack of pointers to ElInfo objects.
    std::vector<ElInfo*> elInfoStack_;
    /// Current position (depth) of the recursive mesh traverse.
Thomas Witkowski's avatar
Thomas Witkowski committed
    int stackPosition_;
  };
  
}

#endif  // AMDIS_ELINFOSTACK_H