0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
clanguml::common::model::decorated_element Class Reference

Base class for decorated diagram elements. More...

Detailed Description

Base class for decorated diagram elements.

Decorators in clang-uml mean that custom {} directives can be applied to them in the code comments.

See also
clanguml::decorators::decorator

Definition at line 48 of file decorated_element.h.

#include <decorated_element.h>

Public Member Functions

virtual ~decorated_element ()=default
 
bool skip () const
 
bool skip_relationship () const
 
std::pair< relationship_t, std::string > get_relationship () const
 
std::string style_spec () const
 
const std::vector< std::shared_ptr< decorators::decorator > > & decorators () const
 
void add_decorators (const std::vector< std::shared_ptr< decorators::decorator > > &decorators)
 
void append (const decorated_element &de)
 
std::optional< comment_tcomment () const
 
void set_comment (const comment_t &c)
 
virtual std::optional< std::string > doxygen_link () const
 

Private Attributes

std::vector< std::shared_ptr< decorators::decorator > > decorators_
 
std::optional< comment_tcomment_
 

Constructor & Destructor Documentation

◆ ~decorated_element()

virtual clanguml::common::model::decorated_element::~decorated_element ( )
virtualdefault

Member Function Documentation

◆ add_decorators()

void clanguml::common::model::decorated_element::add_decorators ( const std::vector< std::shared_ptr< decorators::decorator > > &  decorators)

Add decorators to the element.

Parameters
decoratorsList of decorator pointers.

Definition at line 75 of file decorated_element.cc.

77{
78 for (const auto &d : decorators) {
79 decorators_.push_back(d);
80 }
81}

◆ append()

void clanguml::common::model::decorated_element::append ( const decorated_element de)

Append decorators from another element.

Parameters
deSource element to copy decorators from.

Definition at line 83 of file decorated_element.cc.

84{
85 for (const auto &d : de.decorators()) {
86 decorators_.push_back(d);
87 }
88}

◆ comment()

std::optional< comment_t > clanguml::common::model::decorated_element::comment ( ) const

Get entire comment model for this element.

Returns
Comment model.

Definition at line 90 of file decorated_element.cc.

90{ return comment_; }

◆ decorators()

const std::vector< std::shared_ptr< decorators::decorator > > & clanguml::common::model::decorated_element::decorators ( ) const

Get all decorators for this element.

Returns
List of decorator pointers.

Definition at line 70 of file decorated_element.cc.

71{
72 return decorators_;
73}

◆ doxygen_link()

std::optional< std::string > clanguml::common::model::decorated_element::doxygen_link ( ) const
virtual

Return Doxygen HTML documentation link for the element.

Returns
Element context.

Reimplemented in clanguml::class_diagram::model::class_, clanguml::class_diagram::model::enum_, and clanguml::common::model::package.

Definition at line 94 of file decorated_element.cc.

95{
96 return std::nullopt;
97}

◆ get_relationship()

std::pair< relationship_t, std::string > clanguml::common::model::decorated_element::get_relationship ( ) const

If this element is a member or a method, get relationship decorator if any.

/// @uml{aggregation[0..1:1..5]}
std::vector<C> ccc;
Returns
Relationship specified as a decorator on class member.

Definition at line 41 of file decorated_element.cc.

42{
43 for (const auto &d : decorators_)
44 if (std::dynamic_pointer_cast<decorators::association>(d))
46 std::dynamic_pointer_cast<decorators::relationship>(d)
47 ->multiplicity};
48 else if (std::dynamic_pointer_cast<decorators::aggregation>(d))
50 std::dynamic_pointer_cast<decorators::relationship>(d)
51 ->multiplicity};
52 else if (std::dynamic_pointer_cast<decorators::composition>(d))
54 std::dynamic_pointer_cast<decorators::relationship>(d)
55 ->multiplicity};
56
57 return {relationship_t::kNone, ""};
58}

◆ set_comment()

void clanguml::common::model::decorated_element::set_comment ( const comment_t c)

Set comment model for this element.

Comment model is currently a JSON object.

Parameters
cComment model.

Definition at line 92 of file decorated_element.cc.

92{ comment_ = c; }

◆ skip()

bool clanguml::common::model::decorated_element::skip ( ) const

Whether this element should be skipped from the diagram.

Returns

Definition at line 23 of file decorated_element.cc.

24{
25 return std::any_of(
26 decorators_.begin(), decorators_.end(), [](const auto &d) {
27 return std::dynamic_pointer_cast<decorators::skip>(d) != nullptr;
28 });
29}

◆ skip_relationship()

bool clanguml::common::model::decorated_element::skip_relationship ( ) const

Whether this relationship should be skipped from the diagram.

Returns

Definition at line 31 of file decorated_element.cc.

32{
33 return std::any_of(
34 decorators_.begin(), decorators_.end(), [](const auto &d) {
35 return std::dynamic_pointer_cast<decorators::skip_relationship>(
36 d) != nullptr;
37 });
38}

◆ style_spec()

std::string clanguml::common::model::decorated_element::style_spec ( ) const

Get stype specification for this element, if any.

/// @uml{style[#back:lightgreen|yellow;header:blue/red]}
class A { };
Returns

Definition at line 60 of file decorated_element.cc.

61{
62 for (const auto &d : decorators_)
63 if (std::dynamic_pointer_cast<decorators::style>(d))
64 return std::dynamic_pointer_cast<decorators::style>(d)->spec;
65
66 return "";
67}

Member Data Documentation

◆ comment_

std::optional<comment_t> clanguml::common::model::decorated_element::comment_
private

Definition at line 139 of file decorated_element.h.

◆ decorators_

std::vector<std::shared_ptr<decorators::decorator> > clanguml::common::model::decorated_element::decorators_
private

Definition at line 138 of file decorated_element.h.


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