matador::container< Type, ContainerType > Class Template Reference

Has many relation class using a std::vector as container. More...

#include <container.hpp>

Inherits abstract_container.

Public Types

using traits = container_iterator_traits< Type, ContainerType >
 
using iterator = container_iterator< Type, ContainerType >
 
using const_iterator = const_container_iterator< Type, ContainerType >
 
using value_type = typename traits::value_type
 
using holder_type = typename traits::holder_type
 
using holder_container_type = typename traits::holder_container_type
 
using size_type = typename holder_container_type::size_type
 

Public Member Functions

template<typename U = Type>
 container ()
 Creates an empty container object.
 
template<typename U = Type>
 container (size_t size)
 
iterator begin ()
 Returns the begin iterator of the container.
 
iterator end ()
 Returns the end iterator of the container.
 
const_iterator begin () const
 Returns the const begin iterator of the container.
 
const_iterator end () const
 Returns the const end iterator of the container.
 
value_type front ()
 Returns a copy of the first element.
 
value_type front () const
 Returns a const copy of the first element.
 
value_type back ()
 Returns a const copy of the first element.
 
value_type back () const
 Returns a const copy of the last element.
 
size_type size () const
 Returns the current size of the container.
 
bool empty () const
 Returns true if the container is empty.
 
void reset ()
 Clears the container.
 
void append (const typename iterator::holder_type &item)
 Appends an item to the end of the container.
 
iterator insert (iterator pos, const value_type &value)
 Inserts an element at the given position.
 
template<template< class ... > class C = ContainerType>
void push_front (const value_type &value)
 Inserts an element at first position.
 
void push_back (const value_type &value)
 Inserts an element at last position.
 
void clear ()
 Clears the vector.
 
iterator remove (const value_type &value)
 
template<class P >
iterator remove_if (P predicate)
 
iterator erase (iterator i)
 Remove the element at given position.
 
iterator erase (iterator start, iterator end)
 Remove the elements of given range.
 
template<class P >
iterator find_if (P predicate)
 Finds an element matching the predicate.
 

Public Attributes

size_t size_ {}
 

Friends

class detail::relation_endpoint_value_inserter< Type >
 
class detail::relation_endpoint_value_remover< Type >
 
class detail::object_deleter
 
class detail::object_inserter
 
class object_store
 
class object_serializer
 
class object_deserializer
 

Detailed Description

template<class Type, template< class ... > class ContainerType = std::vector>
class matador::container< Type, ContainerType >

Has many relation class using a std::vector as container.

The has many relation class uses a std::vector as internal container to store the objects.

It provides all main interface functions std::vector provides

  • insert element at a iterator position
  • access with bracket operator []
  • push back an element
  • erase an element at iterator position
  • erase a range of elements within first and last iterator position
  • clear the container

All of these methods are wrapped around the std::vector methods plus the modification in the corresponding object_store and notification of the transaction observer

The relation holds object_ptr elements as well as scalar data elements.

Template Parameters
TypeThe type of the elements

Member Typedef Documentation

◆ const_iterator

template<class Type , template< class ... > class ContainerType = std::vector>
using matador::container< Type, ContainerType >::const_iterator = const_container_iterator<Type, ContainerType>

Shortcut to iterator class

◆ holder_container_type

template<class Type , template< class ... > class ContainerType = std::vector>
using matador::container< Type, ContainerType >::holder_container_type = typename traits::holder_container_type

Shortcut to container type

◆ holder_type

template<class Type , template< class ... > class ContainerType = std::vector>
using matador::container< Type, ContainerType >::holder_type = typename traits::holder_type

Shortcut to holder_type

◆ iterator

template<class Type , template< class ... > class ContainerType = std::vector>
using matador::container< Type, ContainerType >::iterator = container_iterator<Type, ContainerType>

Shortcut to iterator class

◆ size_type

template<class Type , template< class ... > class ContainerType = std::vector>
using matador::container< Type, ContainerType >::size_type = typename holder_container_type::size_type

Shortcut to size_type

◆ traits

template<class Type , template< class ... > class ContainerType = std::vector>
using matador::container< Type, ContainerType >::traits = container_iterator_traits<Type, ContainerType>

Shortcut to traits class

◆ value_type

template<class Type , template< class ... > class ContainerType = std::vector>
using matador::container< Type, ContainerType >::value_type = typename traits::value_type

Shortcut to value_type

Constructor & Destructor Documentation

◆ container()

template<class Type , template< class ... > class ContainerType = std::vector>
template<typename U = Type>
matador::container< Type, ContainerType >::container ( )
inline

Creates an empty container object.

Creates an empty container object with a std::vector as container type

Member Function Documentation

◆ append()

template<class Type , template< class ... > class ContainerType = std::vector>
void matador::container< Type, ContainerType >::append ( const typename iterator::holder_type item)
inline

Appends an item to the end of the container.

Parameters
itemElement to be appended

◆ back() [1/2]

template<class Type , template< class ... > class ContainerType = std::vector>
value_type matador::container< Type, ContainerType >::back ( )
inline

Returns a const copy of the first element.

Returns
A const copy of the first element

◆ back() [2/2]

template<class Type , template< class ... > class ContainerType = std::vector>
value_type matador::container< Type, ContainerType >::back ( ) const
inline

Returns a const copy of the last element.

Returns
A const copy of the last element

◆ begin() [1/2]

template<class Type , template< class ... > class ContainerType = std::vector>
iterator matador::container< Type, ContainerType >::begin ( )
inline

Returns the begin iterator of the container.

Returns
The begin iterator

◆ begin() [2/2]

template<class Type , template< class ... > class ContainerType = std::vector>
const_iterator matador::container< Type, ContainerType >::begin ( ) const
inline

Returns the const begin iterator of the container.

Returns
The const begin iterator

◆ empty()

template<class Type , template< class ... > class ContainerType = std::vector>
bool matador::container< Type, ContainerType >::empty ( ) const
inline

Returns true if the container is empty.

Returns
True if the container is empty

◆ end() [1/2]

template<class Type , template< class ... > class ContainerType = std::vector>
iterator matador::container< Type, ContainerType >::end ( )
inline

Returns the end iterator of the container.

Returns
The end iterator

◆ end() [2/2]

template<class Type , template< class ... > class ContainerType = std::vector>
const_iterator matador::container< Type, ContainerType >::end ( ) const
inline

Returns the const end iterator of the container.

Returns
The const end iterator

◆ erase() [1/2]

template<class Type , template< class ... > class ContainerType = std::vector>
iterator matador::container< Type, ContainerType >::erase ( iterator  i)
inline

Remove the element at given position.

Erase the element at given position and return the iterator following the last removed element.

Parameters
iIterator to the element to remove
Returns
Iterator following the last removed element

◆ erase() [2/2]

template<class Type , template< class ... > class ContainerType = std::vector>
iterator matador::container< Type, ContainerType >::erase ( iterator  start,
iterator  end 
)
inline

Remove the elements of given range.

Remove the elements of the given range identified by the first and last iterator position. Where the first iterator is included and the last iterator is not included [first; last)

Parameters
startFirst iterator of the range
endLast iterator of the ranges
Returns
Iterator following the last removed element

◆ find_if()

template<class Type , template< class ... > class ContainerType = std::vector>
template<class P >
iterator matador::container< Type, ContainerType >::find_if ( predicate)
inline

Finds an element matching the predicate.

Finds the first element where the given predicate matches. If it doesn't match end() is returned

Template Parameters
PThe type of the predicate object
Parameters
predicateThe predicate object
Returns
The found element of end()

◆ front() [1/2]

template<class Type , template< class ... > class ContainerType = std::vector>
value_type matador::container< Type, ContainerType >::front ( )
inline

Returns a copy of the first element.

Returns
A copy of the first element

◆ front() [2/2]

template<class Type , template< class ... > class ContainerType = std::vector>
value_type matador::container< Type, ContainerType >::front ( ) const
inline

Returns a const copy of the first element.

Returns
A const copy of the first element

◆ insert()

template<class Type , template< class ... > class ContainerType = std::vector>
iterator matador::container< Type, ContainerType >::insert ( iterator  pos,
const value_type value 
)
inline

Inserts an element at the given position.

Parameters
posThe position to insert at
valueThe element to be inserted
Returns
The iterator at position of inserted element

◆ push_back()

template<class Type , template< class ... > class ContainerType = std::vector>
void matador::container< Type, ContainerType >::push_back ( const value_type value)
inline

Inserts an element at last position.

Parameters
valueThe element to be inserted

◆ push_front()

template<class Type , template< class ... > class ContainerType = std::vector>
template<template< class ... > class C = ContainerType>
void matador::container< Type, ContainerType >::push_front ( const value_type value)
inline

Inserts an element at first position.

Parameters
valueThe element to be inserted

◆ remove()

template<class Type , template< class ... > class ContainerType = std::vector>
iterator matador::container< Type, ContainerType >::remove ( const value_type value)
inline

Removes all values equal to given value from the container

Parameters
valueValue to remove

◆ remove_if()

template<class Type , template< class ... > class ContainerType = std::vector>
template<class P >
iterator matador::container< Type, ContainerType >::remove_if ( predicate)
inline

Removes all elements from the container for which the given predicate returns true.

Template Parameters
PType of the predicate
Parameters
predicatePredicate to be evaluated

◆ size()

template<class Type , template< class ... > class ContainerType = std::vector>
size_type matador::container< Type, ContainerType >::size ( ) const
inline

Returns the current size of the container.

Returns
The current size

The documentation for this class was generated from the following file:
  • matador/object/container.hpp