hexed 0.4.0
 
Loading...
Searching...
No Matches
hexed::mutual::Base< T, U > Class Template Referenceabstract

abstract base class for all mutually-connected objects More...

#include <mutual.hpp>

Inheritance diagram for hexed::mutual::Base< T, U >:
hexed::mutual::Multiple< T, U > hexed::mutual::Single< T, U > hexed::Reciprocal_list< T, U > hexed::Reciprocal_ptr< T, U >

Public Member Functions

virtual T * _mine ()
 
virtual const T * _mine () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Protected Member Functions

virtual void _set (Base< U, T > &that)=0
 takes the necessary steps to connect this to that, without worrying about anything on that's end
 
virtual void _unset (Base< U, T > &that)=0
 takes the necessary steps to disconnect this from that, without worrying about anything on that's end
 
void _connect (Base< U, T > &that)
 may be overridden by derived classes to provide partners to data of some arbitrary type T
 
void _disconnect (Base< U, T > &that)
 mutually disconnects this and that by calling both of their _unset() member functions
 

Static Protected Member Functions

static U * _yours (Base< U, T > &that)
 Accesses the _mine() of that
 
static const U * _yours (const Base< U, T > &that)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Protected Attributes

Lock _lock
 

Friends

class Base< U, T >
 

Detailed Description

template<typename T, typename U>
class hexed::mutual::Base< T, U >

abstract base class for all mutually-connected objects

Implements the basic mechanics of mutual connection and disconnection. Derived classes may provide data of currently unknown type, so Base takes a template parameter T and provides a virtual function _mine() to access data of type T. It may be desireable for a Base to be mutually connected with another Base (its "partner") that provides data of a different type, so Base takes a second parameter U which is its partner's T. Derived classes must override _set() and _unset() to implement the process of connecting themself to a partner. Derived classes should implement an interface that calls _connect and _disconnect as desired, including:

  • A destructor that _disconnects the object from its partners.
  • Move semantics that cause the moved-to object to steal the partners of the moved-from object.

Derived classes may override _mine() to provide their partners access to some data.

Thread Safety
Connection and disconnection, and by consequence move semantics, are not thread safe in general.

Member Function Documentation

◆ _connect()

template<typename T , typename U >
void hexed::mutual::Base< T, U >::_connect ( Base< U, T > & that)
inlineprotected

may be overridden by derived classes to provide partners to data of some arbitrary type T

mutually connects this and that by calling both of their _set() member functions


The documentation for this class was generated from the following file: