0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Public Member Functions | List of all members
clanguml::common::model::element_views< Ts > Struct Template Reference

Detailed Description

template<typename... Ts>
struct clanguml::common::model::element_views< Ts >

Definition at line 103 of file element_view.h.

#include <element_view.h>

Public Member Functions

template<typename F >
void for_all_elements (F &&f)
 
template<typename F >
void for_all_elements (F &&f) const
 
template<typename T >
const element_view< T > & view () const
 
template<typename T , typename F >
void dynamic_apply (T *e, F &&f) const
 Calls f function on e if it can be dynamically casted to any type in the element_views.
 
- Public Member Functions inherited from clanguml::common::model::element_view< Ts >
void add (std::reference_wrapper< Ts > element)
 Add reference to diagram element.
 
const reference_vector< Ts > & view () const
 Get collection of reference to diagram elements.
 
reference_vector< Ts > & view ()
 Get collection of reference to diagram elements.
 
common::optional_ref< Ts > 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)
 
void for_each (F &&f) const
 

Member Function Documentation

◆ dynamic_apply()

template<typename... Ts>
template<typename T , typename F >
void clanguml::common::model::element_views< Ts >::dynamic_apply ( T *  e,
F &&  f 
) const
inline

Calls f function on e if it can be dynamically casted to any type in the element_views.

Template Parameters
TElement type
FFunction to call on e
Parameters
ePointer to element
fFunction to call with e dynamically casted to one of types

Definition at line 127 of file element_view.h.

128 {
129 if (e == nullptr)
130 return;
131
132 (
133 [&] {
134 if (auto *ptr = dynamic_cast<Ts *>(e); ptr) {
135 f(ptr);
136 }
137 }(),
138 ...);
139 }

◆ for_all_elements() [1/2]

template<typename... Ts>
template<typename F >
void clanguml::common::model::element_views< Ts >::for_all_elements ( F &&  f)
inline

Definition at line 104 of file element_view.h.

105 {
106 (f(element_view<Ts>::view()), ...);
107 }

◆ for_all_elements() [2/2]

template<typename... Ts>
template<typename F >
void clanguml::common::model::element_views< Ts >::for_all_elements ( F &&  f) const
inline

Definition at line 109 of file element_view.h.

110 {
111 (f(element_view<Ts>::view()), ...);
112 }

◆ view()

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

Definition at line 114 of file element_view.h.

115 {
116 return dynamic_cast<const element_view<T> &>(*this);
117 }

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