Intrusive Containers
Loading...
Searching...
No Matches
ManyManyLink< R, N, s, n, L > Class Template Reference

Intermediate Link for a many-many relationship. More...

#include <ManyMany.h>

Inheritance diagram for ManyManyLink< R, N, s, n, L >:
Collaboration diagram for ManyManyLink< R, N, s, n, L >:

Public Member Functions

 ManyManyLink (R *root=nullptr, N *node=nullptr, L *link1=nullptr, L *link2=nullptr)
 
virtual ~ManyManyLink ()
 
void add (R &root, N &node)
 
void add (R *root, N *node, L *link1=nullptr, L *link2=nullptr)
 Link a Root to a Node with this Lisk.
 
void addAfter (L &node, bool upgrade=false)
 Add ourself to a list after another node.
 
void addAfter (L *node, bool upgrade=false)
 Add ourself to a list after another node.
 
void addAfter (L &node, bool upgrade=false)
 Add ourself to a list after another node.
 
void addAfter (L *node, bool upgrade=false)
 Add ourself to a list after another node.
 
void addTo (N &root, bool upgrade=false)
 Add ourself to a list at "natural" postion.
 
void addTo (N *root, bool upgrade=false)
 Add ourself to a list at "natural" postion.
 
void addTo (R &root, bool upgrade=false)
 Add ourself to a list at "natural" postion.
 
void addTo (R *root, bool upgrade=false)
 Add ourself to a list at "natural" postion.
 
void addToEnd (N &root, bool upgrade=false)
 Add ourselfs to the end of a list.
 
void addToEnd (N *root, bool upgrade=false)
 Add ourselfs to the End of a list.
 
void addToEnd (R &root, bool upgrade=false)
 Add ourselfs to the end of a list.
 
void addToEnd (R *root, bool upgrade=false)
 Add ourselfs to the End of a list.
 
void addToFront (N &root, bool upgrade=false)
 Add ourselves to the front of a list.
 
void addToFront (N *root, bool upgrade=false)
 Add ourselfs to the front of a list.
 
void addToFront (R &root, bool upgrade=false)
 Add ourselves to the front of a list.
 
void addToFront (R *root, bool upgrade=false)
 Add ourselfs to the front of a list.
 
bool check () const override
 Check a DListInNode.
 
L * next () const
 Return pointer to next node on list.
 
L * next () const
 Return pointer to next node on list.
 
L * nextNode () const
 
L * nextRoot () const
 
N * node () const
 
L * prev () const
 Return pointer to previous node on list.
 
L * prev () const
 Return pointer to previous node on list.
 
L * prevNode () const
 
L * prevRoot () const
 
unsigned readLock (bool upgrade) const
 
unsigned readLock (bool upgrade) const
 
void readUnlock (unsigned save) const
 
void readUnlock (unsigned save) const
 
void remove ()
 
R * root () const
 
void setRoot (N *root)
 
void setRoot (R *root)
 
unsigned writeLock (bool upgrade) const
 
unsigned writeLock (bool upgrade) const
 
void writeUnlock (unsigned save) const
 
void writeUnlock (unsigned save) const
 

Protected Member Functions

void setRoot (C *root)
 Set our Container.
 
void setRoot (C *root)
 Set our Container.
 

Private Types

typedef class DListInNode< N, L, s, 2 *n+1 > BaseNode
 
typedef class DListInNode< R, L, s, 2 *n > BaseRoot
 
typedef Container< s > C
 The type of the Container that we are part of.
 
typedef class ManyManyLink< R, N, s, n, L > Link
 
typedef class ManyManyNode< R, N, s, n, L > Node
 
typedef class ManyManyRoot< R, N, s, n, L > Root
 
typedef class DListInRoot< N, L, s, 2 *n+1 > RootNode
 
typedef class DListInRoot< R, L, s, 2 *n > RootRoot
 

Static Private Member Functions

static L & getLink (L *link)
 Convert a possible link pointer into an actual link object.
 

Private Attributes

bool m_dynamic = false
 
L * m_next
 Pointer to net node on list.
 
L * m_prev
 Pointer to previous node on list.
 
R * m_root
 Pointer to list we are on.
 
friend Node
 
friend Root
 

Detailed Description

template<class R, class N, ContainerThreadSafety s, int n, class L>
class ManyManyLink< R, N, s, n, L >

Intermediate Link for a many-many relationship.

Allowed to be pointing to a user class to allow properties on the relationship.

Invariant
From DListInNode:

Member Typedef Documentation

◆ BaseNode

template<class R , class N , ContainerThreadSafety s, int n, class L >
class DListInNode< N, L, s, 2 *n+1 > ManyManyLink< R, N, s, n, L >::BaseNode
private

◆ BaseRoot

template<class R , class N , ContainerThreadSafety s, int n, class L >
class DListInNode< R, L, s, 2 *n > ManyManyLink< R, N, s, n, L >::BaseRoot
private

◆ C

template<ContainerThreadSafety s>
Container<s> ContainerNode< s >::C
privateinherited

The type of the Container that we are part of.

◆ Link

template<class R , class N , ContainerThreadSafety s, int n, class L >
class ManyManyLink< R, N, s, n, L > ManyManyLink< R, N, s, n, L >::Link
private

◆ Node

template<class R , class N , ContainerThreadSafety s, int n, class L >
class ManyManyNode< R, N, s, n, L > ManyManyLink< R, N, s, n, L >::Node
private

◆ Root

template<class R , class N , ContainerThreadSafety s, int n, class L >
class ManyManyRoot< R, N, s, n, L > ManyManyLink< R, N, s, n, L >::Root
private

◆ RootNode

template<class R , class N , ContainerThreadSafety s, int n, class L >
class DListInRoot< N, L, s, 2 *n+1 > ManyManyLink< R, N, s, n, L >::RootNode
private

◆ RootRoot

template<class R , class N , ContainerThreadSafety s, int n, class L >
class DListInRoot< R, L, s, 2 *n > ManyManyLink< R, N, s, n, L >::RootRoot
private

Constructor & Destructor Documentation

◆ ManyManyLink()

template<class R , class N , ContainerThreadSafety s, int n, class L >
ManyManyLink< R, N, s, n, L >::ManyManyLink ( R * root = nullptr,
N * node = nullptr,
L * link1 = nullptr,
L * link2 = nullptr )

◆ ~ManyManyLink()

template<class R , class N , ContainerThreadSafety s, int n, class L >
ManyManyLink< R, N, s, n, L >::~ManyManyLink ( )
virtual

Member Function Documentation

◆ add() [1/2]

template<class R , class N , ContainerThreadSafety s, int n, class L >
void ManyManyLink< R, N, s, n, L >::add ( R & root,
N & node )

◆ add() [2/2]

template<class R , class N , ContainerThreadSafety s, int n, class L >
void ManyManyLink< R, N, s, n, L >::add ( R * root,
N * node,
L * link1 = nullptr,
L * link2 = nullptr )

Link a Root to a Node with this Lisk.

Template Parameters
R
N
L
s
n
Parameters
root
node
link1
link2

If link1 or link2 point to either the Root or Node we are to connect to, then we will link ourselves on that side just after that link. Otherwise we link at the front of the lists.

◆ addAfter() [1/4]

void DListInNode< N, L, s, n >::addAfter ( L & node,
bool upgrade = false )
inlineinherited

Add ourself to a list after another node.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
nodeThe node to add ourself after. If that node is not on a list, do nothing.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addAfter() [2/4]

void DListInNode< N, L, s, n >::addAfter ( L * node,
bool upgrade = false )
inlineinherited

Add ourself to a list after another node.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
nodeThe node to add ourself after. If Node is NULL, or not on a list, do nothing.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addAfter() [3/4]

void DListInNode< R, L, s, n >::addAfter ( L & node,
bool upgrade = false )
inlineinherited

Add ourself to a list after another node.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
nodeThe node to add ourself after. If that node is not on a list, do nothing.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addAfter() [4/4]

void DListInNode< R, L, s, n >::addAfter ( L * node,
bool upgrade = false )
inlineinherited

Add ourself to a list after another node.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
nodeThe node to add ourself after. If Node is NULL, or not on a list, do nothing.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addTo() [1/4]

void DListInNode< N, L, s, n >::addTo ( N & myRoot,
bool upgrade = false )
inherited

Add ourself to a list at "natural" postion.

Note that this is the front for singly linked lists, and the end for doubly linked lists.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
myRootList to add to.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addTo() [2/4]

void DListInNode< N, L, s, n >::addTo ( N * myRoot,
bool upgrade = false )
inherited

Add ourself to a list at "natural" postion.

Note that this is the front for singly linked lists, and the end for doubly linked lists.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
myRootList to add to.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addTo() [3/4]

void DListInNode< R, L, s, n >::addTo ( R & myRoot,
bool upgrade = false )
inherited

Add ourself to a list at "natural" postion.

Note that this is the front for singly linked lists, and the end for doubly linked lists.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
myRootList to add to.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addTo() [4/4]

void DListInNode< R, L, s, n >::addTo ( R * myRoot,
bool upgrade = false )
inherited

Add ourself to a list at "natural" postion.

Note that this is the front for singly linked lists, and the end for doubly linked lists.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
myRootList to add to.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addToEnd() [1/4]

void DListInNode< N, L, s, n >::addToEnd ( N & myRoot,
bool upgrade = false )
inlineinherited

Add ourselfs to the end of a list.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
myRootList to add to.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addToEnd() [2/4]

void DListInNode< N, L, s, n >::addToEnd ( N * myRoot,
bool upgrade = false )
inlineinherited

Add ourselfs to the End of a list.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
myRootList to add to.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

If NULL, just remove from all lists.

◆ addToEnd() [3/4]

void DListInNode< R, L, s, n >::addToEnd ( R & myRoot,
bool upgrade = false )
inlineinherited

Add ourselfs to the end of a list.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
myRootList to add to.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addToEnd() [4/4]

void DListInNode< R, L, s, n >::addToEnd ( R * myRoot,
bool upgrade = false )
inlineinherited

Add ourselfs to the End of a list.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
myRootList to add to.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

If NULL, just remove from all lists.

◆ addToFront() [1/4]

void DListInNode< N, L, s, n >::addToFront ( N & myRoot,
bool upgrade = false )
inlineinherited

Add ourselves to the front of a list.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
myRootList to add to.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addToFront() [2/4]

void DListInNode< N, L, s, n >::addToFront ( N * myRoot,
bool upgrade = false )
inlineinherited

Add ourselfs to the front of a list.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
myRootList to add to. If NULL, just remove from all lists.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addToFront() [3/4]

void DListInNode< R, L, s, n >::addToFront ( R & myRoot,
bool upgrade = false )
inlineinherited

Add ourselves to the front of a list.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
myRootList to add to.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addToFront() [4/4]

void DListInNode< R, L, s, n >::addToFront ( R * myRoot,
bool upgrade = false )
inlineinherited

Add ourselfs to the front of a list.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
myRootList to add to. If NULL, just remove from all lists.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ check()

template<class R , class N , ContainerThreadSafety s, int n, class L >
bool ManyManyLink< R, N, s, n, L >::check ( ) const
overridevirtual

Check a DListInNode.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Returns
true if check passes

Reimplemented from DListInNode< R, L, s, 2 *n >.

◆ getLink()

template<class R , class N , ContainerThreadSafety s, int n, class L >
L & ManyManyLink< R, N, s, n, L >::getLink ( L * link)
staticprivate

Convert a possible link pointer into an actual link object.

If we are given a non-null pointer, us it, otherwise dynamically create the needed ManyManyLink object, and mark it to be deleted when removed.

◆ next() [1/2]

L * DListInNode< N, L, s, n >::next ( ) const
inlineinherited

Return pointer to next node on list.

◆ next() [2/2]

L * DListInNode< R, L, s, n >::next ( ) const
inlineinherited

Return pointer to next node on list.

◆ nextNode()

template<class R , class N , ContainerThreadSafety s, int n, class L >
L * ManyManyLink< R, N, s, n, L >::nextNode ( ) const
inline

◆ nextRoot()

template<class R , class N , ContainerThreadSafety s, int n, class L >
L * ManyManyLink< R, N, s, n, L >::nextRoot ( ) const
inline

◆ node()

template<class R , class N , ContainerThreadSafety s, int n, class L >
N * ManyManyLink< R, N, s, n, L >::node ( ) const
inline

◆ prev() [1/2]

L * DListInNode< N, L, s, n >::prev ( ) const
inlineinherited

Return pointer to previous node on list.

◆ prev() [2/2]

L * DListInNode< R, L, s, n >::prev ( ) const
inlineinherited

Return pointer to previous node on list.

◆ prevNode()

template<class R , class N , ContainerThreadSafety s, int n, class L >
L * ManyManyLink< R, N, s, n, L >::prevNode ( ) const
inline

◆ prevRoot()

template<class R , class N , ContainerThreadSafety s, int n, class L >
L * ManyManyLink< R, N, s, n, L >::prevRoot ( ) const
inline

◆ readLock() [1/2]

unsigned DListInNode< N, L, s, n >::readLock ( bool upgrade) const
inlineinherited

◆ readLock() [2/2]

unsigned DListInNode< R, L, s, n >::readLock ( bool upgrade) const
inlineinherited

◆ readUnlock() [1/2]

void DListInNode< N, L, s, n >::readUnlock ( unsigned save) const
inlineinherited

◆ readUnlock() [2/2]

void DListInNode< R, L, s, n >::readUnlock ( unsigned save) const
inlineinherited

◆ remove()

template<class R , class N , ContainerThreadSafety s, int n, class L >
void ManyManyLink< R, N, s, n, L >::remove ( )

◆ root()

template<class R , class N , ContainerThreadSafety s, int n, class L >
R * ManyManyLink< R, N, s, n, L >::root ( ) const
inline

◆ setRoot() [1/4]

template<ContainerThreadSafety s>
void ContainerNode< s >::setRoot ( C * root)
inlineprotectedinherited

Set our Container.

Used to allow to Node to record what Container it is in. Used only if safety method need resources from the Container, like a Mutex

If an operation changes the root of a node, then it needs to save the original root to exit the critical section on that container that it entered before the operation.

Referenced by ContainerNode< s >::ContainerNode(), DListInNode< R, N, s, n >::setRoot(), ListInNode< R, N, s, n >::setRoot(), and TreeInNode< R, N, K, s, n >::setRoot().

Here is the caller graph for this function:

◆ setRoot() [2/4]

template<ContainerThreadSafety s>
void ContainerNode< s >::setRoot ( C * root)
inlineprotectedinherited

Set our Container.

Used to allow to Node to record what Container it is in. Used only if safety method need resources from the Container, like a Mutex

If an operation changes the root of a node, then it needs to save the original root to exit the critical section on that container that it entered before the operation.

Referenced by ContainerNode< s >::ContainerNode(), DListInNode< R, N, s, n >::setRoot(), ListInNode< R, N, s, n >::setRoot(), and TreeInNode< R, N, K, s, n >::setRoot().

Here is the caller graph for this function:

◆ setRoot() [3/4]

void DListInNode< N, L, s, n >::setRoot ( N * root)
inlineinherited

◆ setRoot() [4/4]

void DListInNode< R, L, s, n >::setRoot ( R * root)
inlineinherited

◆ writeLock() [1/2]

unsigned DListInNode< N, L, s, n >::writeLock ( bool upgrade) const
inlineinherited

◆ writeLock() [2/2]

unsigned DListInNode< R, L, s, n >::writeLock ( bool upgrade) const
inlineinherited

◆ writeUnlock() [1/2]

void DListInNode< N, L, s, n >::writeUnlock ( unsigned save) const
inlineinherited

◆ writeUnlock() [2/2]

void DListInNode< R, L, s, n >::writeUnlock ( unsigned save) const
inlineinherited

Member Data Documentation

◆ m_dynamic

template<class R , class N , ContainerThreadSafety s, int n, class L >
bool ManyManyLink< R, N, s, n, L >::m_dynamic = false
private

◆ m_next

L* DListInNode< R, L, s, n >::m_next
privateinherited

Pointer to net node on list.

◆ m_prev

L* DListInNode< R, L, s, n >::m_prev
privateinherited

Pointer to previous node on list.

◆ m_root

R* DListInNode< R, L, s, n >::m_root
privateinherited

Pointer to list we are on.

◆ Node

template<class R , class N , ContainerThreadSafety s, int n, class L >
friend ManyManyLink< R, N, s, n, L >::Node
private

◆ Root

template<class R , class N , ContainerThreadSafety s, int n, class L >
friend ManyManyLink< R, N, s, n, L >::Root
private

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