#ifndef MATRIXSTACK_H
#define MATRIXSTACK_H

#include "utils/Stack.h"
#include "math/Matrix.h"

template<int N>
class MatrixStack final {
    Stack<Matrix, N> stack;

public:

    MatrixStack() {
        stack.push(Matrix());
    }

    bool pop() {
        stack.pop();
        if(stack.isEmpty()) {
            stack.push(Matrix());
            return true;
        }
        return false;
    }

    bool push() {
        return stack.push(stack.peek());
    }

    Matrix& peek() {
        return stack.peek();
    }

    const Matrix& peek() const {
        return stack.peek();
    }

    void clear() {
        stack.clear();
        stack.push(Matrix());
    }

    template<int L>
    void toString(StringBuffer<L>& s) const {
        s.append(stack);
    }
};

#endif