2018-08-17 01:13:21 -07:00
|
|
|
#pragma once
|
|
|
|
|
2018-08-17 01:34:58 -07:00
|
|
|
#include <cstddef>
|
2018-08-17 01:13:21 -07:00
|
|
|
extern "C" {
|
|
|
|
#include "libabacus.h"
|
|
|
|
#include "util.h"
|
|
|
|
}
|
|
|
|
|
2018-08-17 01:34:58 -07:00
|
|
|
class ref {
|
2018-08-17 01:13:21 -07:00
|
|
|
private:
|
2018-08-17 01:34:58 -07:00
|
|
|
libab_ref val;
|
2018-08-17 01:13:21 -07:00
|
|
|
public:
|
2018-08-17 01:34:58 -07:00
|
|
|
ref();
|
|
|
|
ref(void* data, void (*free_func)(void*));
|
|
|
|
ref(const ref& other);
|
|
|
|
ref& operator=(const ref& other);
|
|
|
|
ref& operator=(std::nullptr_t);
|
2018-08-17 01:13:21 -07:00
|
|
|
template <typename T>
|
|
|
|
bool operator==(T data);
|
2018-08-17 01:34:58 -07:00
|
|
|
operator libab_ref*();
|
|
|
|
~ref();
|
2018-08-17 01:13:21 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
T* get(libab_ref* ref) {
|
|
|
|
return (T*) libab_ref_get(ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
2018-08-17 01:34:58 -07:00
|
|
|
bool ref::operator==(T data) {
|
|
|
|
return libab_ref_get(&val) == (void*) data;
|
2018-08-17 01:13:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
2018-08-17 01:34:58 -07:00
|
|
|
bool ref::operator==<std::nullptr_t>(std::nullptr_t t);
|