9#ifndef SQUID_SRC_CBDATA_H
10#define SQUID_SRC_CBDATA_H
239#define cbdataReferenceValidDone(var, ptr) cbdataInternalReferenceDoneValid((void **)&(var), (ptr))
257#define CBDATA_DECL_(type, methodSpecifiers) \
258 void *operator new(size_t size) { \
259 assert(size == sizeof(type)); \
260 if (!CBDATA_##type) CBDATA_##type = cbdataInternalAddType(CBDATA_##type, #type, sizeof(type)); \
261 return (type *)cbdataInternalAlloc(CBDATA_##type); \
264 void operator delete (void *address) { \
265 if (address) cbdataInternalFree(address); \
267 void *toCbdata() methodSpecifiers { return this; } \
269 static cbdata_type CBDATA_##type;
289#define CBDATA_CLASS(type) public: CBDATA_DECL_(type, noexcept)
294#define CBDATA_CLASS_WITH_MAKE(type) private: CBDATA_DECL_(type, noexcept)
299#define CBDATA_CHILD(type) public: CBDATA_DECL_(type, final) \
300 void finalizedInCbdataChild() final {}
311#define CBDATA_INTERMEDIATE() \
313 void *toCbdata() override { return this; } \
325#define CBDATA_CLASS_INIT(type) cbdata_type type::CBDATA_##type = CBDATA_UNKNOWN
333#define CBDATA_NAMESPACED_CLASS_INIT(namespace, type) cbdata_type namespace::type::CBDATA_##type = CBDATA_UNKNOWN
348#define cbdataReference(var) (cbdataInternalLock(var), var)
357#define cbdataReferenceDone(var) do {if (var) {cbdataInternalUnlock(var); var = nullptr;}} while(0)
372 template<
typename wrapped_type>
void unwrap(wrapped_type **output) {
373 *output =
static_cast<wrapped_type *
>(
data);
void * cbdataInternalFree(void *p)
void cbdataInternalUnlock(const void *p)
#define cbdataReferenceDone(var)
#define cbdataReference(var)
static const cbdata_type CBDATA_UNKNOWN
int cbdataInternalReferenceDoneValid(void **p, void **tp)
#define cbdataReferenceValidDone(var, ptr)
cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, int size)
int cbdataReferenceValid(const void *p)
void * cbdataInternalAlloc(cbdata_type type)
#define CBDATA_CLASS(type)
void cbdataInternalLock(const void *p)
an old-style void* callback parameter
CallbackData(CallbackData &&other)
CallbackData & operator=(const CallbackData &other)
void * data_
raw callback data, maybe invalid
CallbackData(const CallbackData &other)
virtual void finalizedInCbdataChild()=0
hack: ensure CBDATA_CHILD() after a toCbdata()-defining CBDATA_INTERMEDIATE()
virtual void * toCbdata()=0
void unwrap(wrapped_type **output)
generic_cbdata(void *aData)