14 #include <boost/uuid/uuid.hpp> 15 #include <boost/uuid/nil_generator.hpp> 22 using std::shared_ptr;
38 template <
class ST = Something>
64 shared_ptr<ST> sp = s.lock();
66 throw std::runtime_error();
79 throw std::runtime_error();
87 const boost::uuids::uuid &
uuid()
const {
93 const weak_ptr<ST>
weak()
const {
107 shared_ptr<ST>
lock() const noexcept {
116 someId = boost::uuids::nil_uuid();
124 return someId < s.uuid();
131 return someId > s.uuid();
138 return someId <= s.uuid();
145 return someId >= s.uuid();
152 return someId == s.uuid();
159 return someId != s.uuid();
175 template <
class ST = Something>
198 throw std::runtime_error();
206 const boost::uuids::uuid &
uuid()
const {
224 bool operator bool() const noexcept {
233 someId = boost::uuids::nil_uuid();
242 return sp->uuid() < s.uuid();
250 return sp->uuid() > s.uuid();
258 return sp->uuid() <= s.uuid();
266 return sp->uuid() >= s.uuid();
274 return sp->uuid() == s.uuid();
282 return sp->uuid() != s.uuid();
296 bool operator() (
const std::shared_ptr<C> &l,
297 const std::shared_ptr<C> &r)
const {
299 const C *pl = l.get();
300 const C *pr = r.get();
shared_ptr< ST > sp
A shared pointer to Something.
OLD Performs a less than comparison on an object contained within a Boost shared pointer.
void reset() noexcept
Loses the reference to Something.
const weak_ptr< ST > weak() const
Returns the weak pointer to Something.
boost::uuids::uuid someId
A unique identifier for Something that is valid across all peers.
const boost::uuids::uuid & uuid() const
Returns the object's unique identifier.
SomethingWeakRef()=default
Makes an uninitalized reference to nothing.
bool operator>(const S &s) const
Something objects are compared using their UUID.
bool operator!=(const S &s) const
Something objects are compared using their UUID.
void reset() noexcept
Loses the reference to Something.
bool operator==(const S &s) const
Something objects are compared using their UUID.
SomethingRef(const shared_ptr< ST > &s)
Makes a new reference to Something from a shared pointer.
shared_ptr< ST > lock() const noexcept
Attempts to obtain a shared pointer to the referenced Something.
bool operator<=(const S &s) const
Something objects are compared using their UUID.
A reference to a Something object.
const shared_ptr< ST > shared() const
Returns the shared pointer to Something.
SomethingWeakRef(const shared_ptr< ST > &s)
Makes a new reference to Something from a shared pointer.
bool expired() const noexcept
Tells if the weak pointer to Something has expired.
weak_ptr< ST > wp
A weak pointer to a Something.
std::set< const std::shared_ptr< Something >, CompareSharedContent< Something > > SomethingSet
const boost::uuids::uuid & uuid() const
Returns the object's unique identifier.
bool operator>=(const S &s) const
Something objects are compared using their UUID.
bool operator<(const S &s) const
Something objects are compared using their UUID.
SomethingWeakRef(const weak_ptr< ST > &s)
Makes a new reference to Something from a weak pointer.
A weak reference to a Something object.