File indexing completed on 2024-11-24 04:54:34
0001 /* 0002 SPDX-License-Identifier: MPL-2.0 0003 */ 0004 0005 /* Copyright (c) 2015 Brian R. Bondy. Distributed under the MPL2 license. 0006 * This Source Code Form is subject to the terms of the Mozilla Public 0007 * License, v. 2.0. If a copy of the MPL was not distributed with this 0008 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 0009 0010 #ifndef BLOOMFILTERWRAP_H_ 0011 #define BLOOMFILTERWRAP_H_ 0012 0013 #include <node.h> 0014 #include <node_object_wrap.h> 0015 0016 #include "BloomFilter.h" 0017 0018 namespace BloomFilterWrap { 0019 0020 /** 0021 * Wraps Bloom Filter for use in Node 0022 */ 0023 class BloomFilterWrap : public BloomFilter, public node::ObjectWrap { 0024 public: 0025 static void Init(v8::Local<v8::Object> exports); 0026 0027 private: 0028 BloomFilterWrap(unsigned int bitsPerElement = 10, 0029 unsigned int estimatedNumElements = 50000, 0030 HashFn hashFns[] = defaultHashFns, 0031 int numHashFns = sizeof(defaultHashFns)/sizeof(defaultHashFns[0])); 0032 virtual ~BloomFilterWrap(); 0033 0034 static void New(const v8::FunctionCallbackInfo<v8::Value>& args); 0035 0036 static void Add(const v8::FunctionCallbackInfo<v8::Value>& args); 0037 static void Exists(const v8::FunctionCallbackInfo<v8::Value>& args); 0038 0039 static v8::Persistent<v8::Function> constructor; 0040 }; 0041 0042 } // namespace BloomFilterWrap 0043 0044 #endif // BLOOMFILTERWRAP_H_