// SPDX-License-Identifier: GPL-2.0-or-later #ifndef INKSCAPE_DISPLAY_DRAWINGITEM_PTR_H #define INKSCAPE_DISPLAY_DRAWINGITEM_PTR_H #include #include namespace Inkscape { class DrawingItem; } /** * Deleter object which calls the unlink() method of DrawingItem to schedule deferred destruction. */ struct UnlinkDeleter { template void operator()(T *t) { static_assert(std::is_base_of_v); t->unlink(); } }; /** * Smart pointer used by the Object Tree to hold items in the Display Tree, like std::unique_ptr. * * Upon deletion, the pointed-to object and its subtree will be destroyed immediately if not currently in use by a snapshot. * Otherwise, destruction is deferred to after the snapshot is released. */ template using DrawingItemPtr = std::unique_ptr; /** * Convienence function to create a DrawingItemPtr, like std::make_unique. */ template auto make_drawingitem(Args&&... args) { return DrawingItemPtr(new T(std::forward(args)...)); }; #endif // INKSCAPE_DISPLAY_DRAWINGITEM_PTR_H