Horizon Official Technical Documentation
Horizon::Structures::LinkedList::Reference< TO, FROM > Class Template Referenceabstract

#include <Reference.hpp>

+ Inheritance diagram for Horizon::Structures::LinkedList::Reference< TO, FROM >:
+ Collaboration diagram for Horizon::Structures::LinkedList::Reference< TO, FROM >:

Public Member Functions

 Reference ()
 
virtual ~Reference ()
 
void link (TO *toObj, FROM *fromObj)
 Links the Reference to the specified object by adding it to the front of the list. More...
 
void remove ()
 
void invalidate ()
 
bool is_valid () const
 
Reference< TO, FROM > * next ()
 
Reference< TO, FROM > const * next () const
 
Reference< TO, FROM > * prev ()
 
Reference< TO, FROM > const * prev () const
 
Reference< TO, FROM > * nocheck_next ()
 
Reference< TO, FROM > const * nocheck_next () const
 
Reference< TO, FROM > * nocheck_prev ()
 
Reference< TO, FROM > const * nocheck_prev () const
 
TO * operator-> () const
 
TO * target () const
 
FROM * source () const
 
- Public Member Functions inherited from Horizon::Structures::LinkedList::Element
 Element ()
 
bool has_next () const
 Returns true if this Element has a next Element in the list. More...
 
bool has_prev () const
 Returns true if this Element has a previous Element in the list. More...
 
bool is_in_list () const
 Returns true if this Element is in a list. More...
 
Elementnext ()
 Returns the next Element in the list. More...
 
Element const * next () const
 
Elementprev ()
 Returns the previous Element in the list. More...
 
Element const * prev () const
 
Elementnocheck_next ()
 Returns the next Element in the list without checking if it exists. More...
 
Element const * nocheck_next () const
 
Elementnocheck_prev ()
 Returns the previous Element in the list without checking if it exists. More...
 
Element const * nocheck_prev () const
 
void delink ()
 Removes this Element from the list. More...
 
void push_before (Element *pElem)
 Pushes this Element before the given Element. More...
 
void push_after (Element *pElem)
 Pushes this Element after the given Element. More...
 

Protected Member Functions

virtual void target_object_build_link ()=0
 
virtual void target_object_destroy_link ()=0
 
virtual void source_object_destroy_link ()=0
 
- Protected Member Functions inherited from Horizon::Structures::LinkedList::Element
 ~Element ()
 

Private Member Functions

 Reference (Reference const &)=delete
 
Referenceoperator= (Reference const &)=delete
 

Private Attributes

TO * _ref_to
 
FROM * _ref_from
 

Detailed Description

template<class TO, class FROM>
class Horizon::Structures::LinkedList::Reference< TO, FROM >

This class is used to manage a linked list of References. It is not intended to be used directly. It is used as a base class for other classes that need to manage a linked list. The Head class is a friend of this class (derived from Element) to allow it to access the private members of this class. The relationship between the Reference and the ReferenceManager is a one-to-many relationship, where the ReferenceManager is the one and the Reference is the many. The ReferenceManager is responsible for creating and destroying the Reference. The ReferenceManager is also responsible for calling the link() and remove() methods of the Reference. This creates a dynamic responsibility chain between the ReferenceManager and the Reference.

Parameters
_next(derived from Element)The next Reference in the list.
_prev(derived from Element) The previous Reference in the list.
_ref_toThe object that is being referenced.
_ref_fromThe object that is referencing.

Constructor & Destructor Documentation

◆ Reference() [1/2]

template<class TO , class FROM >
Horizon::Structures::LinkedList::Reference< TO, FROM >::Reference ( )
inline

◆ ~Reference()

template<class TO , class FROM >
virtual Horizon::Structures::LinkedList::Reference< TO, FROM >::~Reference ( )
inlinevirtual
44{ }

◆ Reference() [2/2]

template<class TO , class FROM >
Horizon::Structures::LinkedList::Reference< TO, FROM >::Reference ( Reference< TO, FROM > const &  )
privatedelete

Member Function Documentation

◆ invalidate()

template<class TO , class FROM >
void Horizon::Structures::LinkedList::Reference< TO, FROM >::invalidate ( )
inline
78 {
80 delink();
81 _ref_to = nullptr;
82 }
void delink()
Removes this Element from the list.
Definition: Element.hpp:50

References Horizon::Structures::LinkedList::Reference< TO, FROM >::_ref_to, Horizon::Structures::LinkedList::Element::delink(), and Horizon::Structures::LinkedList::Reference< TO, FROM >::source_object_destroy_link().

Referenced by TestObject< T >::remove_reference().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_valid()

template<class TO , class FROM >
bool Horizon::Structures::LinkedList::Reference< TO, FROM >::is_valid ( ) const
inline

◆ link()

template<class TO , class FROM >
void Horizon::Structures::LinkedList::Reference< TO, FROM >::link ( TO *  toObj,
FROM *  fromObj 
)
inline

Links the Reference to the specified object by adding it to the front of the list.

Parameters
toObjThe object to reference.
fromObjThe object that is referencing.
50 {
51 assert(fromObj);
52
53 // Clear if any previous references to a reference manager.
54 if (is_valid())
55 remove();
56
57 // Build the link.
58 if (toObj != nullptr) {
59 _ref_to = toObj;
60 _ref_from = fromObj;
62 }
63 }
bool is_valid() const
Definition: Reference.hpp:84
void remove()
Definition: Reference.hpp:67

References Horizon::Structures::LinkedList::Reference< TO, FROM >::_ref_from, Horizon::Structures::LinkedList::Reference< TO, FROM >::_ref_to, Horizon::Structures::LinkedList::Reference< TO, FROM >::is_valid(), Horizon::Structures::LinkedList::Reference< TO, FROM >::remove(), and Horizon::Structures::LinkedList::Reference< TO, FROM >::target_object_build_link().

Referenced by Horizon::Zone::GridObject< T >::add_grid_reference(), TestObject< T >::add_reference(), and ReferenceObject< T >::add_reference().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ next() [1/2]

template<class TO , class FROM >
Reference< TO, FROM > * Horizon::Structures::LinkedList::Reference< TO, FROM >::next ( )
inline
89{ return((Reference<TO, FROM> *) Element::next()); }
Element * next()
Returns the next Element in the list.
Definition: Element.hpp:36

References Horizon::Structures::LinkedList::Element::next().

+ Here is the call graph for this function:

◆ next() [2/2]

template<class TO , class FROM >
Reference< TO, FROM > const * Horizon::Structures::LinkedList::Reference< TO, FROM >::next ( ) const
inline
90{ return((Reference<TO, FROM> const*) Element::next()); }

References Horizon::Structures::LinkedList::Element::next().

+ Here is the call graph for this function:

◆ nocheck_next() [1/2]

template<class TO , class FROM >
Reference< TO, FROM > * Horizon::Structures::LinkedList::Reference< TO, FROM >::nocheck_next ( )
inline
94{ return((Reference<TO, FROM> *) Element::nocheck_next()); }
Element * nocheck_next()
Returns the next Element in the list without checking if it exists.
Definition: Element.hpp:43

References Horizon::Structures::LinkedList::Element::nocheck_next().

+ Here is the call graph for this function:

◆ nocheck_next() [2/2]

template<class TO , class FROM >
Reference< TO, FROM > const * Horizon::Structures::LinkedList::Reference< TO, FROM >::nocheck_next ( ) const
inline
95{ return((Reference<TO, FROM> const *) Element::nocheck_next()); }

References Horizon::Structures::LinkedList::Element::nocheck_next().

+ Here is the call graph for this function:

◆ nocheck_prev() [1/2]

template<class TO , class FROM >
Reference< TO, FROM > * Horizon::Structures::LinkedList::Reference< TO, FROM >::nocheck_prev ( )
inline
96{ return((Reference<TO, FROM> *) Element::nocheck_prev()); }
Element * nocheck_prev()
Returns the previous Element in the list without checking if it exists.
Definition: Element.hpp:46

References Horizon::Structures::LinkedList::Element::nocheck_prev().

+ Here is the call graph for this function:

◆ nocheck_prev() [2/2]

template<class TO , class FROM >
Reference< TO, FROM > const * Horizon::Structures::LinkedList::Reference< TO, FROM >::nocheck_prev ( ) const
inline
97{ return((Reference<TO, FROM> const *) Element::nocheck_prev()); }

References Horizon::Structures::LinkedList::Element::nocheck_prev().

+ Here is the call graph for this function:

◆ operator->()

template<class TO , class FROM >
TO * Horizon::Structures::LinkedList::Reference< TO, FROM >::operator-> ( ) const
inline

◆ operator=()

template<class TO , class FROM >
Reference & Horizon::Structures::LinkedList::Reference< TO, FROM >::operator= ( Reference< TO, FROM > const &  )
privatedelete

◆ prev() [1/2]

template<class TO , class FROM >
Reference< TO, FROM > * Horizon::Structures::LinkedList::Reference< TO, FROM >::prev ( )
inline
91{ return((Reference<TO, FROM> *) Element::prev()); }
Element * prev()
Returns the previous Element in the list.
Definition: Element.hpp:39

References Horizon::Structures::LinkedList::Element::prev().

Referenced by BOOST_AUTO_TEST_CASE().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prev() [2/2]

template<class TO , class FROM >
Reference< TO, FROM > const * Horizon::Structures::LinkedList::Reference< TO, FROM >::prev ( ) const
inline
92{ return((Reference<TO, FROM> const*) Element::prev()); }

References Horizon::Structures::LinkedList::Element::prev().

+ Here is the call graph for this function:

◆ remove()

◆ source()

template<class TO , class FROM >
FROM * Horizon::Structures::LinkedList::Reference< TO, FROM >::source ( ) const
inline

◆ source_object_destroy_link()

◆ target()

template<class TO , class FROM >
TO * Horizon::Structures::LinkedList::Reference< TO, FROM >::target ( ) const
inline

◆ target_object_build_link()

◆ target_object_destroy_link()

Member Data Documentation

◆ _ref_from

◆ _ref_to


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