• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_MAP_NO_STL_H_
12 #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_MAP_NO_STL_H_
13 
14 #include "constructor_magic.h"
15 
16 namespace webrtc {
17 class CriticalSectionWrapper;
18 
19 class MapNoStlItem
20 {
21 friend class Map;
22 
23 public:
24     MapNoStlItem(int id, void* ptr);
25     virtual ~MapNoStlItem();
26     void* GetItem();
27     int GetId();
28     unsigned int GetUnsignedId();
29     void SetItem(void* ptr);
30 
31 protected:
32     MapNoStlItem* next_;
33     MapNoStlItem* prev_;
34 
35 private:
36     int item_id_;
37     void* item_ptr_;
38     DISALLOW_COPY_AND_ASSIGN(MapNoStlItem);
39 };
40 
41 class MapNoStl
42 {
43 public:
44     MapNoStl();
45     virtual ~MapNoStl();
46 
47     // MapWrapper functions.
48     int Insert(int id, void* ptr);
49     int Erase(MapNoStlItem* item);
50     int Erase(int id);
51     int Size() const;
52     MapNoStlItem* First() const;
53     MapNoStlItem* Last() const;
54     MapNoStlItem* Next(MapNoStlItem* item) const;
55     MapNoStlItem* Previous(MapNoStlItem* item) const;
56     MapNoStlItem* Find(int id) const;
57 
58 private:
59     MapNoStlItem* Locate(int id) const;
60     int Remove(MapNoStlItem* item);
61 
62     CriticalSection* critical_section_;
63     MapNoStlItem* first_;
64     MapNoStlItem* last_;
65     int size_;
66     DISALLOW_COPY_AND_ASSIGN(MapNoStl);
67 };
68 } // namespace webrtc
69 
70 #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_MAP_NO_STL_H_
71