0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
clanguml::common::model::element_view< T > Class Template Reference

Detailed Description

template<typename T>
class clanguml::common::model::element_view< T >

Provides type based views over elements in a diagram.

Template Parameters
TType of diagram element

Definition at line 33 of file element_view.h.

#include <element_view.h>

Public Member Functions

void add (std::reference_wrapper< T > element)
 Add reference to diagram element.
 
const reference_vector< T > & view () const
 Get collection of reference to diagram elements.
 
reference_vector< T > & view ()
 Get collection of reference to diagram elements.
 
common::optional_ref< T > get (eid_t id) const
 Get typed diagram element by id.
 
bool is_empty () const
 Check whether the element view is empty.
 
void remove (const std::set< eid_t > &element_ids)
 
template<typename F >
void for_each (F &&f) const
 

Private Attributes

reference_vector< T > elements_
 

Member Function Documentation

◆ add()

template<typename T >
void clanguml::common::model::element_view< T >::add ( std::reference_wrapper< T >  element)
inline

Add reference to diagram element.

Parameters
elementReference to diagram element of specific type

Definition at line 40 of file element_view.h.

41 {
42 elements_.emplace_back(std::move(element));
43 }

◆ for_each()

template<typename T >
template<typename F >
void clanguml::common::model::element_view< T >::for_each ( F &&  f) const
inline

Definition at line 92 of file element_view.h.

93 {
94 for (const auto &e : elements_) {
95 f(e.get());
96 }
97 }

◆ get()

template<typename T >
common::optional_ref< T > clanguml::common::model::element_view< T >::get ( eid_t  id) const
inline

Get typed diagram element by id.

Parameters
idGlobal id of a diagram element
Returns

Definition at line 65 of file element_view.h.

66 {
67 for (const auto &e : elements_) {
68 if (e.get().id() == id) {
69 return {e};
70 }
71 }
72
73 return {};
74 }

◆ is_empty()

template<typename T >
bool clanguml::common::model::element_view< T >::is_empty ( ) const
inline

Check whether the element view is empty.

Returns
True, if the view does not contain any elements

Definition at line 81 of file element_view.h.

81{ return elements_.empty(); }

◆ remove()

template<typename T >
void clanguml::common::model::element_view< T >::remove ( const std::set< eid_t > &  element_ids)
inline

Definition at line 83 of file element_view.h.

84 {
85 elements_.erase(std::remove_if(elements_.begin(), elements_.end(),
86 [&element_ids](auto &&e) {
87 return element_ids.count(e.get().id()) > 0;
88 }),
89 elements_.end());
90 }

◆ view() [1/2]

template<typename T >
reference_vector< T > & clanguml::common::model::element_view< T >::view ( )
inline

Get collection of reference to diagram elements.

Returns

Definition at line 57 of file element_view.h.

57{ return elements_; }

◆ view() [2/2]

template<typename T >
const reference_vector< T > & clanguml::common::model::element_view< T >::view ( ) const
inline

Get collection of reference to diagram elements.

Returns

Definition at line 50 of file element_view.h.

50{ return elements_; }

Member Data Documentation

◆ elements_

template<typename T >
reference_vector<T> clanguml::common::model::element_view< T >::elements_
private

Definition at line 100 of file element_view.h.


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