ManaPlus
Public Member Functions | Data Fields
MStack< T > Struct Template Reference

#include <mstack.h>

Public Member Functions

 MStack (const size_t maxSize)
 
 ~MStack ()
 
T & push ()
 
T & getPop ()
 
const T & getPopConst ()
 
void pop ()
 
T & top () const
 
const T & topConst () const
 
void clear ()
 
bool empty () const
 

Data Fields

T * mStack
 
size_t mMaxSize
 
T * mPointer
 
const T *const mStartPointer
 
const T *const mEndPointer
 

Detailed Description

template<typename T>
struct MStack< T >

Definition at line 29 of file mstack.h.

Constructor & Destructor Documentation

◆ MStack()

template<typename T>
MStack< T >::MStack ( const size_t  maxSize)
inlineexplicit

Definition at line 31 of file mstack.h.

31  :
32  mStack(new T[maxSize]),
33  mMaxSize(maxSize),
34  mPointer(mStack - 1),
35  mStartPointer(mStack - 1),
36  mEndPointer(mStack + maxSize - 1)
37  {
38  }
T * mPointer
Definition: mstack.h:95
T * mStack
Definition: mstack.h:92
const T *const mEndPointer
Definition: mstack.h:97
size_t mMaxSize
Definition: mstack.h:94
const T *const mStartPointer
Definition: mstack.h:96

◆ ~MStack()

template<typename T>
MStack< T >::~MStack ( )
inline

Definition at line 40 of file mstack.h.

41  {
42  delete [] mStack;
43  }
T * mStack
Definition: mstack.h:92

Member Function Documentation

◆ clear()

template<typename T>
void MStack< T >::clear ( )
inline

Definition at line 82 of file mstack.h.

83  {
84  mPointer = mStack - 1;
85  }
T * mPointer
Definition: mstack.h:95
T * mStack
Definition: mstack.h:92

◆ empty()

template<typename T>
bool MStack< T >::empty ( ) const
inline

◆ getPop()

template<typename T>
T& MStack< T >::getPop ( )
inline

Definition at line 57 of file mstack.h.

58  {
59  return *(mPointer--);
60  }
T * mPointer
Definition: mstack.h:95

◆ getPopConst()

template<typename T>
const T& MStack< T >::getPopConst ( )
inline

Definition at line 62 of file mstack.h.

63  {
64  return *(mPointer--);
65  }
T * mPointer
Definition: mstack.h:95

◆ pop()

template<typename T>
void MStack< T >::pop ( )
inline

Definition at line 67 of file mstack.h.

Referenced by Graphics::popClipArea().

68  {
69  mPointer --;
70  }
T * mPointer
Definition: mstack.h:95

◆ push()

template<typename T>
T& MStack< T >::push ( )
inline

Definition at line 47 of file mstack.h.

Referenced by Graphics::pushClipArea().

48  {
49  if (mPointer == mEndPointer)
50  {
51  logger->log("error: max stack size reached");
52  return *mPointer;
53  }
54  return *(++mPointer);
55  }
T * mPointer
Definition: mstack.h:95
Logger * logger
Definition: logger.cpp:88
const T *const mEndPointer
Definition: mstack.h:97
void log(const char *const log_text,...)
Definition: logger.cpp:264

◆ top()

template<typename T>
T& MStack< T >::top ( ) const
inline

Definition at line 72 of file mstack.h.

Referenced by MobileOpenGL2Graphics::calcPatternInline(), ModernOpenGLGraphics::calcPatternInline(), SDLGraphics::calcPatternInline(), SDLGraphics::calcTileSDL(), MobileOpenGL2Graphics::calcTileVertexesInline(), ModernOpenGLGraphics::calcTileVertexesInline(), SDLGraphics::drawHLine(), SDLGraphics::drawImageCached(), ModernOpenGLGraphics::drawImageInline(), SDLGraphics::drawImageInline(), MobileOpenGL2Graphics::drawImageInline(), MobileOpenGL2Graphics::drawLine(), ModernOpenGLGraphics::drawLine(), MobileOpenGL2Graphics::drawNet(), ModernOpenGLGraphics::drawNet(), SDLGraphics::drawPatternCached(), MobileOpenGL2Graphics::drawPatternInline(), SDLGraphics::drawPatternInline(), ModernOpenGLGraphics::drawPatternInline(), MobileOpenGL2Graphics::drawPoint(), SDLGraphics::drawPoint(), ModernOpenGLGraphics::drawPoint(), MobileOpenGL2Graphics::drawRectangle(), ModernOpenGLGraphics::drawRectangle(), SDLGraphics::drawRescaledImage(), ModernOpenGLGraphics::drawRescaledImage(), MobileOpenGL2Graphics::drawRescaledImage(), SDLGraphics::drawRescaledPattern(), ModernOpenGLGraphics::drawRescaledPattern(), MobileOpenGL2Graphics::drawRescaledPattern(), SDLGraphics::drawVLine(), SDLGraphics::fillRectangle(), ModernOpenGLGraphics::fillRectangle(), MobileOpenGL2Graphics::fillRectangle(), Graphics::getTopClip(), MobileOpenGLGraphics::popClipArea(), NormalOpenGLGraphics::popClipArea(), SDLGraphics::popClipArea(), ModernOpenGLGraphics::popClipArea(), SafeOpenGLGraphics::popClipArea(), MobileOpenGL2Graphics::popClipArea(), ModernOpenGLGraphics::pushClipArea(), MobileOpenGLGraphics::pushClipArea(), SDLGraphics::pushClipArea(), SafeOpenGLGraphics::pushClipArea(), NullOpenGLGraphics::pushClipArea(), MobileOpenGL2Graphics::pushClipArea(), NormalOpenGLGraphics::pushClipArea(), and Graphics::pushClipArea().

73  {
74  return *mPointer;
75  }
T * mPointer
Definition: mstack.h:95

◆ topConst()

template<typename T>
const T& MStack< T >::topConst ( ) const
inline

Definition at line 77 of file mstack.h.

78  {
79  return *mPointer;
80  }
T * mPointer
Definition: mstack.h:95

Field Documentation

◆ mEndPointer

template<typename T>
const T* const MStack< T >::mEndPointer

Definition at line 97 of file mstack.h.

Referenced by MStack< ClipRect >::push().

◆ mMaxSize

template<typename T>
size_t MStack< T >::mMaxSize

Definition at line 94 of file mstack.h.

◆ mPointer

template<typename T>
T* MStack< T >::mPointer

◆ mStack

template<typename T>
T* MStack< T >::mStack

Definition at line 92 of file mstack.h.

Referenced by MStack< ClipRect >::clear(), and MStack< ClipRect >::~MStack().

◆ mStartPointer

template<typename T>
const T* const MStack< T >::mStartPointer

Definition at line 96 of file mstack.h.

Referenced by MStack< ClipRect >::empty().


The documentation for this struct was generated from the following file: