5 #include <tbb/spin_mutex.h>
\r
11 mutable tbb::spin_mutex mutex_;
\r
12 const printable* parent_;
\r
14 printable(const printable* parent = nullptr){set_parent(parent);}
\r
16 std::wstring print() const
\r
18 tbb::spin_mutex::scoped_lock lock(mutex_);
\r
19 return (parent_ ? parent_->print() + L"/" : L"") + do_print();
\r
22 virtual void swap(object& other)
\r
24 tbb::spin_mutex::scoped_lock lock(mutex_);
\r
25 std::swap(parent_, other.parent_);
\r
28 const object* get_parent() const
\r
30 tbb::spin_mutex::scoped_lock lock(mutex_);
\r
34 void set_parent(const object* parent)
\r
36 tbb::spin_mutex::scoped_lock lock(mutex_);
\r
37 parent_ = parent != this ? parent : nullptr;
\r
41 virtual std::wstring do_print() const = 0;
\r