GrkObjectWrapper.h
Go to the documentation of this file.
#pragma once
#include "grok.h"
#include <atomic>
namespace grk
{
class GrkObjectWrapper
{
public:
explicit GrkObjectWrapper(void);
virtual ~GrkObjectWrapper(void);
int32_t ref(void);
int32_t unref(void);
virtual void release(void) = 0;
private:
std::atomic<int32_t> ref_count;
};
template<typename T>
class GrkObjectWrapperImpl : public GrkObjectWrapper
{
public:
explicit GrkObjectWrapperImpl(T* wrap) : wrappee(wrap) {}
virtual ~GrkObjectWrapperImpl(void) = default;
virtual void release(void)
{
assert(wrappee);
delete wrappee;
wrappee = nullptr;
}
T* getWrappee(void)
{
assert(wrappee);
return wrappee;
}
private:
T* wrappee;
};
} // namespace grk
grk::GrkObjectWrapper
Definition GrkObjectWrapper.h:9
grk::GrkObjectWrapper::release
virtual void release(void)=0
grk::GrkObjectWrapper::GrkObjectWrapper
GrkObjectWrapper(void)
Definition GrkObjectWrapper.cpp:5
grk::GrkObjectWrapper::unref
int32_t unref(void)
Definition GrkObjectWrapper.cpp:12
grk::GrkObjectWrapper::~GrkObjectWrapper
virtual ~GrkObjectWrapper(void)
Definition GrkObjectWrapper.cpp:7
grk::GrkObjectWrapper::ref_count
std::atomic< int32_t > ref_count
Definition GrkObjectWrapper.h:18
grk::GrkObjectWrapper::ref
int32_t ref(void)
Definition GrkObjectWrapper.cpp:8
grk::GrkObjectWrapperImpl
Definition GrkObjectWrapper.h:23
grk::GrkObjectWrapperImpl::GrkObjectWrapperImpl
GrkObjectWrapperImpl(T *wrap)
Definition GrkObjectWrapper.h:25
grk::GrkObjectWrapperImpl::getWrappee
T * getWrappee(void)
Definition GrkObjectWrapper.h:33
grk::GrkObjectWrapperImpl::release
virtual void release(void)
Definition GrkObjectWrapper.h:27
grk::GrkObjectWrapperImpl::wrappee
T * wrappee
Definition GrkObjectWrapper.h:40
grk::GrkObjectWrapperImpl::~GrkObjectWrapperImpl
virtual ~GrkObjectWrapperImpl(void)=default
grok.h
grk
Copyright (C) 2016-2023 Grok Image Compression Inc.
Definition ICacheable.h:20
grk::grk_read
void grk_read(const uint8_t *buffer, TYPE *value, uint32_t numBytes)
Definition BufferedStream.h:239