libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
sharedptr.h File Reference
#include <atomic>
#include <cassert>
#include <typeinfo>
#include <utility>
#include <promeki/core/namespace.h>
Include dependency graph for sharedptr.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  RefCount
 An atomic reference count object. More...
 
class  SharedPtrProxy< T >
 A proxy class for managing reference counting of objects that do not natively support it. More...
 
struct  IsSharedObject< T, typename >
 
struct  IsSharedObject< T, std::void_t< decltype(&T::_promeki_refct)> >
 
class  SharedPtr< T, CopyOnWrite, ST >
 A smart pointer class with reference counting and optional copy-on-write semantics. More...
 

Macros

#define PROMEKI_SHARED(BASE)
 Macro to simplify making a base object into a native shared object.
 
#define PROMEKI_SHARED_DERIVED(BASE, DERIVED)
 Macro to simplify making a derived object into a native shared object.
 
#define PROMEKI_SHARED_FINAL(TYPE)
 Macro for non-polymorphic native shared objects.
 

Detailed Description

Author
Jason Howard jth@h.nosp@m.owar.nosp@m.dlogi.nosp@m.c.co.nosp@m.m

See LICENSE file in the project root folder for license information.

Macro Definition Documentation

◆ PROMEKI_SHARED_DERIVED

#define PROMEKI_SHARED_DERIVED (   BASE,
  DERIVED 
)
Value:
public: \
virtual BASE *_promeki_clone() const override { return new DERIVED(*this); }
Dynamic array container wrapping std::vector.
Definition list.h:40

Macro to simplify making a derived object into a native shared object.

This assumes the base class has used PROMEKI_SHARED() macro or otherwise implemented the functionality to be a native shared object.

Example:

class MyDerivedClass : public MyBaseClass {
public:
virtual ~MyDerivedClass();
// The rest of your class defintion
}
List()=default
Default constructor. Creates an empty list.
#define PROMEKI_SHARED_DERIVED(BASE, DERIVED)
Macro to simplify making a derived object into a native shared object.
Definition sharedptr.h:67

◆ PROMEKI_SHARED_FINAL

#define PROMEKI_SHARED_FINAL (   TYPE)
Value:
public: \
RefCount _promeki_refct; \
TYPE *_promeki_clone() const { return new TYPE(*this); }
An atomic reference count object.
Definition sharedptr.h:101

Macro for non-polymorphic native shared objects.

Use this instead of PROMEKI_SHARED when the class will never be subclassed (e.g. private inner Data classes). It avoids the overhead of a vtable pointer by using non-virtual _promeki_clone(). The class does not need a virtual destructor.

Example:

class Data {
public:
int value = 0;
};
const T & value(const Result< T > &r)
Returns the value from a Result.
Definition result.h:56
#define PROMEKI_SHARED_FINAL(TYPE)
Macro for non-polymorphic native shared objects.
Definition sharedptr.h:88