electron/atom/common/id_weak_map.h

34 lines
774 B
C
Raw Normal View History

2015-06-24 13:22:09 +08:00
// Copyright (c) 2015 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_COMMON_ID_WEAK_MAP_H_
#define ATOM_COMMON_ID_WEAK_MAP_H_
2016-05-11 14:46:32 +09:00
#include "atom/common/key_weak_map.h"
2015-06-24 13:22:09 +08:00
namespace atom {
2016-05-11 13:40:33 +09:00
// Provides key increments service in addition to KeyWeakMap.
2016-05-11 14:46:32 +09:00
class IDWeakMap : public KeyWeakMap<int32_t> {
2016-05-11 13:40:33 +09:00
public:
IDWeakMap();
~IDWeakMap() override;
// Adds |object| to WeakMap and returns its allocated |id|.
int32_t Add(v8::Isolate* isolate, v8::Local<v8::Object> object);
2015-06-24 13:22:09 +08:00
private:
// Returns next available ID.
int32_t GetNextID();
2015-06-24 13:22:09 +08:00
// ID of next stored object.
int32_t next_id_;
DISALLOW_COPY_AND_ASSIGN(IDWeakMap);
};
} // namespace atom
#endif // ATOM_COMMON_ID_WEAK_MAP_H_