blob: 9d8f5d8878189411bec0828240c154bc7928e273 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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.org6e0ce732012-12-18 17:18:35 +000014#include "webrtc/system_wrappers/interface/constructor_magic.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000015
16namespace webrtc {
phoglund@webrtc.org6e0ce732012-12-18 17:18:35 +000017
niklase@google.com470e71d2011-07-07 08:21:25 +000018class CriticalSectionWrapper;
19
phoglund@webrtc.org6e0ce732012-12-18 17:18:35 +000020class MapNoStlItem {
21 friend class Map;
niklase@google.com470e71d2011-07-07 08:21:25 +000022
phoglund@webrtc.org6e0ce732012-12-18 17:18:35 +000023 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.com470e71d2011-07-07 08:21:25 +000030
phoglund@webrtc.org6e0ce732012-12-18 17:18:35 +000031 protected:
32 MapNoStlItem* next_;
33 MapNoStlItem* prev_;
niklase@google.com470e71d2011-07-07 08:21:25 +000034
phoglund@webrtc.org6e0ce732012-12-18 17:18:35 +000035 private:
36 int item_id_;
37 void* item_ptr_;
38 DISALLOW_COPY_AND_ASSIGN(MapNoStlItem);
niklase@google.com470e71d2011-07-07 08:21:25 +000039};
40
phoglund@webrtc.org6e0ce732012-12-18 17:18:35 +000041class MapNoStl {
42 public:
43 MapNoStl();
44 virtual ~MapNoStl();
niklase@google.com470e71d2011-07-07 08:21:25 +000045
phoglund@webrtc.org6e0ce732012-12-18 17:18:35 +000046 // 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.com470e71d2011-07-07 08:21:25 +000056
phoglund@webrtc.org6e0ce732012-12-18 17:18:35 +000057 private:
58 MapNoStlItem* Locate(int id) const;
59 int Remove(MapNoStlItem* item);
niklase@google.com470e71d2011-07-07 08:21:25 +000060
phoglund@webrtc.org6e0ce732012-12-18 17:18:35 +000061 CriticalSection* critical_section_;
62 MapNoStlItem* first_;
63 MapNoStlItem* last_;
64 int size_;
65 DISALLOW_COPY_AND_ASSIGN(MapNoStl);
niklase@google.com470e71d2011-07-07 08:21:25 +000066};
phoglund@webrtc.org6e0ce732012-12-18 17:18:35 +000067
niklase@google.com470e71d2011-07-07 08:21:25 +000068} // namespace webrtc
69
phoglund@webrtc.org6e0ce732012-12-18 17:18:35 +000070#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_MAP_NO_STL_H_