editor/txmgr/nsTransactionStack.h
author Aaron Klotz <aklotz@mozilla.com>
Sun, 08 Feb 2015 14:29:13 -0700
changeset 255417 f74a7a410dd3e8ba6fdcf7bee0c48324c3b00be1
parent 211836 1f9ddc6738f63865f02dd7823df817ae51e29f7e
child 299739 91d4539e00cecb658604e021675a923c60ef3235
permissions -rw-r--r--
Bug 1102297: Obtain user GEOID from Windows; r=jimm

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef nsTransactionStack_h__
#define nsTransactionStack_h__

#include <deque>
#include "nsAutoPtr.h"

class nsCycleCollectionTraversalCallback;
class nsTransactionItem;

class nsTransactionStack
{
public:
  enum Type { FOR_UNDO, FOR_REDO };

  explicit nsTransactionStack(Type aType);
  ~nsTransactionStack();

  void Push(nsTransactionItem *aTransactionItem);
  already_AddRefed<nsTransactionItem> Pop();
  already_AddRefed<nsTransactionItem> PopBottom();
  already_AddRefed<nsTransactionItem> Peek();
  already_AddRefed<nsTransactionItem> GetItem(int32_t aIndex);
  void Clear();
  int32_t GetSize() { return mDeque.size(); }

  void DoUnlink() { Clear(); }
  void DoTraverse(nsCycleCollectionTraversalCallback &cb);

private:
  std::deque<nsRefPtr<nsTransactionItem> > mDeque;
  const Type mType;
};

#endif // nsTransactionStack_h__