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

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 to allow it to access the private members of this class. The functionality of this class is identical to the Element class except that it is used to manage a linked list of References. The RefManager can be used to manage a linked list of References to any type of object. The object type is specified by the TO template parameter. And the type of object that the Reference is managing is specified by the FROM template parameter. By default the TO and FROM template parameters are the same type. But they can be different types if the Reference is managing a base class of the object. The reference list is a doubly linked list. The list is circular so the first element's previous element is the last element and the last element's next element is the first element. The reason we link the TO and FROM objects together is so that we can easily invalidate all the References in the list when the FROM object is destroyed. By creating a dynamic responsibility chain between the ReferenceManager and the Reference, we can provide a simple and efficient way to manage a linked list of References and visit objects of a specific type by using the ReferenceManager. More...

#include <RefManager.hpp>

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

Public Types

typedef Head::Iterator< Reference< TO, FROM > > iterator
 
- Public Types inherited from Horizon::Structures::LinkedList::Head
typedef Iterator< Elementiterator
 

Public Member Functions

 RefManager ()
 
Reference< TO, FROM > * first ()
 Returns the first Reference in the list. More...
 
Reference< TO, FROM > const * first () const
 
iterator begin ()
 Returns the iterator at the beginning of the list. More...
 
iterator end ()
 Returns the iterator at the end of the list. More...
 
virtual ~RefManager ()
 
void clear_all ()
 
- Public Member Functions inherited from Horizon::Structures::LinkedList::Head
 Head ()
 
bool is_empty () const
 Returns true if the list is empty. More...
 
Elementfirst ()
 Returns the first Element in the list. More...
 
Element const * first () const
 
Elementlast ()
 Returns the last Element in the list. More...
 
Element const * last () const
 
void push_front (Element *pElem)
 push_front() and push_back() are used to add an Element to the list. More...
 
void push_back (Element *pElem)
 
uint32_t get_size () const
 returns the number of Elements in the list (not including the head and tail Elements or the first and last Elements) More...
 
void inc_size ()
 
void dec_size ()
 

Additional Inherited Members

- Protected Member Functions inherited from Horizon::Structures::LinkedList::Head
 ~Head ()
 

Detailed Description

template<class TO, class FROM>
class Horizon::Structures::LinkedList::RefManager< 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 to allow it to access the private members of this class. The functionality of this class is identical to the Element class except that it is used to manage a linked list of References. The RefManager can be used to manage a linked list of References to any type of object. The object type is specified by the TO template parameter. And the type of object that the Reference is managing is specified by the FROM template parameter. By default the TO and FROM template parameters are the same type. But they can be different types if the Reference is managing a base class of the object. The reference list is a doubly linked list. The list is circular so the first element's previous element is the last element and the last element's next element is the first element. The reason we link the TO and FROM objects together is so that we can easily invalidate all the References in the list when the FROM object is destroyed. By creating a dynamic responsibility chain between the ReferenceManager and the Reference, we can provide a simple and efficient way to manage a linked list of References and visit objects of a specific type by using the ReferenceManager.

Parameters
_nextThe next Reference in the list.
_prevThe previous Reference in the list.
_refThe Reference that this Reference is managing.
_headThe Head that this Reference is in.
_validTrue if the Reference is valid.

Member Typedef Documentation

◆ iterator

template<class TO , class FROM >
typedef Head::Iterator<Reference<TO, FROM> > Horizon::Structures::LinkedList::RefManager< TO, FROM >::iterator

Constructor & Destructor Documentation

◆ RefManager()

template<class TO , class FROM >
Horizon::Structures::LinkedList::RefManager< TO, FROM >::RefManager ( )
inline
36{ }

◆ ~RefManager()

template<class TO , class FROM >
virtual Horizon::Structures::LinkedList::RefManager< TO, FROM >::~RefManager ( )
inlinevirtual
48 {
49 clear_all();
50 }
void clear_all()
Definition: RefManager.hpp:52

References Horizon::Structures::LinkedList::RefManager< TO, FROM >::clear_all().

+ Here is the call graph for this function:

Member Function Documentation

◆ begin()

template<class TO , class FROM >
iterator Horizon::Structures::LinkedList::RefManager< TO, FROM >::begin ( )
inline

Returns the iterator at the beginning of the list.

43{ return iterator(first()); }
Reference< TO, FROM > * first()
Returns the first Reference in the list.
Definition: RefManager.hpp:39
Head::Iterator< Reference< TO, FROM > > iterator
Definition: RefManager.hpp:35

References Horizon::Structures::LinkedList::RefManager< TO, FROM >::first().

+ Here is the call graph for this function:

◆ clear_all()

template<class TO , class FROM >
void Horizon::Structures::LinkedList::RefManager< TO, FROM >::clear_all ( )
inline
53 {
54 while (Reference<TO, FROM> *ref = first())
55 ref->invalidate();
56 }

References Horizon::Structures::LinkedList::RefManager< TO, FROM >::first().

Referenced by Horizon::Structures::LinkedList::RefManager< TO, FROM >::~RefManager().

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

◆ end()

template<class TO , class FROM >
iterator Horizon::Structures::LinkedList::RefManager< TO, FROM >::end ( )
inline

Returns the iterator at the end of the list.

45{ return iterator(nullptr); }

◆ first() [1/2]

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

Returns the first Reference in the list.

39{ return static_cast<Reference<TO, FROM> *>(Head::first()); }
Element * first()
Returns the first Element in the list.
Definition: Head.hpp:46

References Horizon::Structures::LinkedList::Head::first().

Referenced by Horizon::Structures::LinkedList::RefManager< TO, FROM >::begin(), and Horizon::Structures::LinkedList::RefManager< TO, FROM >::clear_all().

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

◆ first() [2/2]

template<class TO , class FROM >
Reference< TO, FROM > const * Horizon::Structures::LinkedList::RefManager< TO, FROM >::first ( ) const
inline
40{ return static_cast<Reference<TO, FROM> const *>(Head::first()); }

References Horizon::Structures::LinkedList::Head::first().

+ Here is the call graph for this function:

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