1/*
2 *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
4 *  Use of this source code is governed by a BSD-style license
5 *  that can be found in the LICENSE file in the root of the source
6 *  tree. An additional intellectual property rights grant can be found
7 *  in the file PATENTS.  All contributing project authors may
8 *  be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_LIST_STL_H_
12#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_LIST_STL_H_
13
14#include <list>
15
16#include "constructor_magic.h"
17
18namespace webrtc {
19class ListItem
20{
21friend class ListWrapper;
22
23public:
24    ListItem(const void* ptr);
25    ListItem(const unsigned int item);
26    virtual ~ListItem();
27    void* GetItem() const;
28    unsigned int GetUnsignedItem() const;
29
30private:
31    mutable std::list<ListItem*>::iterator this_iter_;
32    const void*         item_ptr_;
33    const unsigned int  item_;
34    DISALLOW_COPY_AND_ASSIGN(ListItem);
35};
36
37class ListWrapper
38{
39public:
40    ListWrapper();
41    ~ListWrapper();
42
43    // ListWrapper functions
44    unsigned int GetSize() const;
45    int PushBack(const void* ptr);
46    int PushBack(const unsigned int item_id);
47    int PushFront(const void* ptr);
48    int PushFront(const unsigned int item_id);
49    int PopFront();
50    int PopBack();
51    bool Empty() const;
52    ListItem* First() const;
53    ListItem* Last() const;
54    ListItem* Next(ListItem* item) const;
55    ListItem* Previous(ListItem* item) const;
56    int Erase(ListItem* item);
57    int Insert(ListItem* existing_previous_item, ListItem* new_item);
58    int InsertBefore(ListItem* existing_next_item, ListItem* new_item);
59
60private:
61    mutable std::list<ListItem*> list_;
62    DISALLOW_COPY_AND_ASSIGN(ListWrapper);
63};
64} // namespace webrtc
65
66#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_LIST_STL_H_
67