niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
phoglund@webrtc.org | 6e0ce73 | 2012-12-18 17:18:35 +0000 | [diff] [blame] | 14 | #include "webrtc/system_wrappers/interface/constructor_magic.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 15 | |
| 16 | namespace webrtc { |
phoglund@webrtc.org | 6e0ce73 | 2012-12-18 17:18:35 +0000 | [diff] [blame] | 17 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 18 | class CriticalSectionWrapper; |
| 19 | |
phoglund@webrtc.org | 6e0ce73 | 2012-12-18 17:18:35 +0000 | [diff] [blame] | 20 | class MapNoStlItem { |
| 21 | friend class Map; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | |
phoglund@webrtc.org | 6e0ce73 | 2012-12-18 17:18:35 +0000 | [diff] [blame] | 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); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 30 | |
phoglund@webrtc.org | 6e0ce73 | 2012-12-18 17:18:35 +0000 | [diff] [blame] | 31 | protected: |
| 32 | MapNoStlItem* next_; |
| 33 | MapNoStlItem* prev_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 34 | |
phoglund@webrtc.org | 6e0ce73 | 2012-12-18 17:18:35 +0000 | [diff] [blame] | 35 | private: |
| 36 | int item_id_; |
| 37 | void* item_ptr_; |
| 38 | DISALLOW_COPY_AND_ASSIGN(MapNoStlItem); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | }; |
| 40 | |
phoglund@webrtc.org | 6e0ce73 | 2012-12-18 17:18:35 +0000 | [diff] [blame] | 41 | class MapNoStl { |
| 42 | public: |
| 43 | MapNoStl(); |
| 44 | virtual ~MapNoStl(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | |
phoglund@webrtc.org | 6e0ce73 | 2012-12-18 17:18:35 +0000 | [diff] [blame] | 46 | // MapWrapper functions. |
| 47 | int Insert(int id, void* ptr); |
| 48 | int Erase(MapNoStlItem* item); |
| 49 | int Erase(int id); |
| 50 | int Size() const; |
| 51 | MapNoStlItem* First() const; |
| 52 | MapNoStlItem* Last() const; |
| 53 | MapNoStlItem* Next(MapNoStlItem* item) const; |
| 54 | MapNoStlItem* Previous(MapNoStlItem* item) const; |
| 55 | MapNoStlItem* Find(int id) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | |
phoglund@webrtc.org | 6e0ce73 | 2012-12-18 17:18:35 +0000 | [diff] [blame] | 57 | private: |
| 58 | MapNoStlItem* Locate(int id) const; |
| 59 | int Remove(MapNoStlItem* item); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 60 | |
phoglund@webrtc.org | 6e0ce73 | 2012-12-18 17:18:35 +0000 | [diff] [blame] | 61 | CriticalSection* critical_section_; |
| 62 | MapNoStlItem* first_; |
| 63 | MapNoStlItem* last_; |
| 64 | int size_; |
| 65 | DISALLOW_COPY_AND_ASSIGN(MapNoStl); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 66 | }; |
phoglund@webrtc.org | 6e0ce73 | 2012-12-18 17:18:35 +0000 | [diff] [blame] | 67 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 68 | } // namespace webrtc |
| 69 | |
phoglund@webrtc.org | 6e0ce73 | 2012-12-18 17:18:35 +0000 | [diff] [blame] | 70 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_MAP_NO_STL_H_ |