FastLED 3.9.15
Loading...
Searching...
No Matches
ptr.cpp
Go to the documentation of this file.
1#include "fl/ptr.h"
2
3#include "fl/namespace.h"
4
5namespace fl {
6
8Referent::~Referent() = default;
9void Referent::ref() const { mRefCount++; }
10
11int Referent::ref_count() const { return mRefCount; }
12
13void Referent::unref() const {
14 if (--mRefCount == 0) {
15 if (mWeakPtr) {
16 mWeakPtr->setReferent(nullptr);
17 mWeakPtr.reset();
18 }
19 destroy();
20 }
21}
22
23void Referent::destroy() const { delete this; }
24
25Referent::Referent(const Referent &) = default;
26Referent &Referent::operator=(const Referent &) = default;
27Referent::Referent(Referent &&) = default;
29
30} // namespace fl
virtual int ref_count() const
Definition ptr.cpp:11
Referent & operator=(const Referent &)
Ptr< WeakReferent > mWeakPtr
Definition ptr.h:428
int mRefCount
Definition ptr.h:426
virtual ~Referent()
virtual void destroy() const
Definition ptr.cpp:23
Referent()
Definition ptr.cpp:7
virtual void ref() const
Definition ptr.cpp:9
virtual void unref() const
Definition ptr.cpp:13
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16