electron/atom/common/api/atom_api_id_weak_map.h

44 lines
1.1 KiB
C
Raw Normal View History

2015-10-29 16:27:30 +05:30
// 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_API_ATOM_API_ID_WEAK_MAP_H_
#define ATOM_COMMON_API_ATOM_API_ID_WEAK_MAP_H_
2015-10-29 16:27:30 +05:30
2016-05-11 15:51:22 +09:00
#include "atom/common/key_weak_map.h"
2015-10-29 16:27:30 +05:30
#include "native_mate/object_template_builder.h"
#include "native_mate/handle.h"
namespace atom {
namespace api {
2016-04-25 10:17:54 +09:00
class IDWeakMap : public mate::Wrappable<IDWeakMap> {
2015-10-29 16:27:30 +05:30
public:
static mate::Handle<IDWeakMap> Create(v8::Isolate* isolate);
2015-10-29 16:27:30 +05:30
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype);
protected:
2016-04-25 10:17:54 +09:00
explicit IDWeakMap(v8::Isolate* isolate);
~IDWeakMap();
2015-10-29 16:27:30 +05:30
private:
// Api for IDWeakMap.
void Set(v8::Isolate* isolate, int32_t id, v8::Local<v8::Object> object);
v8::Local<v8::Object> Get(v8::Isolate* isolate, int32_t id);
bool Has(int32_t id);
void Remove(int32_t id);
2016-05-11 15:51:22 +09:00
atom::KeyWeakMap<int32_t> id_weak_map_;
2015-10-29 16:27:30 +05:30
DISALLOW_COPY_AND_ASSIGN(IDWeakMap);
2015-10-29 16:27:30 +05:30
};
} // namespace api
} // namespace atom
#endif // ATOM_COMMON_API_ATOM_API_ID_WEAK_MAP_H_