Home | History | Annotate | Download | only in source
      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_NO_STL_H_
     12 #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_LIST_NO_STL_H_
     13 
     14 #include "constructor_magic.h"
     15 
     16 namespace webrtc {
     17 class CriticalSectionWrapper;
     18 
     19 class ListNoStlItem
     20 {
     21 public:
     22     ListNoStlItem(const void* ptr);
     23     ListNoStlItem(const unsigned int item);
     24     virtual ~ListNoStlItem();
     25     void* GetItem() const;
     26     unsigned int GetUnsignedItem() const;
     27 
     28 protected:
     29     ListNoStlItem* next_;
     30     ListNoStlItem* prev_;
     31 
     32 private:
     33     friend class ListNoStl;
     34 
     35     const void*         item_ptr_;
     36     const unsigned int  item_;
     37     DISALLOW_COPY_AND_ASSIGN(ListNoStlItem);
     38 };
     39 
     40 
     41 class ListNoStl
     42 {
     43 public:
     44     ListNoStl();
     45     virtual ~ListNoStl();
     46 
     47     // ListWrapper functions
     48     unsigned int GetSize() const;
     49     int PushBack(const void* ptr);
     50     int PushBack(const unsigned int item_id);
     51     int PushFront(const void* ptr);
     52     int PushFront(const unsigned int item_id);
     53     int PopFront();
     54     int PopBack();
     55     bool Empty() const;
     56     ListNoStlItem* First() const;
     57     ListNoStlItem* Last() const;
     58     ListNoStlItem* Next(ListNoStlItem* item) const;
     59     ListNoStlItem* Previous(ListNoStlItem* item) const;
     60     int Erase(ListNoStlItem* item);
     61     int Insert(ListNoStlItem* existing_previous_item,
     62                ListNoStlItem* new_item);
     63 
     64     int InsertBefore(ListNoStlItem* existing_next_item,
     65                      ListNoStlItem* new_item);
     66 
     67 private:
     68     void PushBack(ListNoStlItem* item);
     69     void PushFront(ListNoStlItem* item);
     70 
     71     CriticalSectionWrapper* critical_section_;
     72     ListNoStlItem* first_;
     73     ListNoStlItem* last_;
     74     unsigned int size_;
     75     DISALLOW_COPY_AND_ASSIGN(ListNoStl);
     76 };
     77 } // namespace webrtc
     78 
     79 #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_LIST_NO_STL_H_
     80