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::diagram Class Referenceabstract

Base class for all diagram models. More...

Detailed Description

Base class for all diagram models.

Definition at line 39 of file diagram.h.

#include <diagram.h>

Public Member Functions

 diagram ()
 
 diagram (const diagram &)=delete
 
 diagram (diagram &&) noexcept
 
diagramoperator= (const diagram &)=delete
 
diagramoperator= (diagram &&) noexcept
 
virtual ~diagram ()
 
virtual diagram_t type () const =0
 Return type of the diagram.
 
virtual opt_ref< clanguml::common::model::diagram_elementget (const std::string &full_name) const =0
 
virtual common::optional_ref< clanguml::common::model::diagram_elementget (eid_t id) const =0
 
virtual common::optional_ref< clanguml::common::model::diagram_elementget_with_namespace (const std::string &name, const namespace_ &ns) const
 
void set_name (const std::string &name)
 
std::string name () const
 
void set_filter (std::unique_ptr< diagram_filter > filter)
 
const diagram_filterfilter () const
 
void set_complete (bool complete)
 Set diagram in a complete state.
 
bool complete () const
 Whether the diagram is complete.
 
virtual void finalize ()
 Once the diagram is complete, run any final processing.
 
bool should_include (const element &e) const
 
bool should_include (const namespace_ &ns) const
 
bool should_include (const source_file &path) const
 
bool should_include (relationship r) const
 
bool should_include (relationship_t r) const
 
bool should_include (access_t s) const
 
bool should_include (const std::string &s) const =delete
 
virtual bool has_element (const eid_t) const
 
virtual bool should_include (const namespace_ &ns, const std::string &name) const
 
virtual inja::json context () const =0
 
virtual bool is_empty () const =0
 Check whether the diagram is empty.
 
virtual void apply_filter ()
 

Private Attributes

std::string name_
 
std::unique_ptr< diagram_filterfilter_
 
bool complete_ {false}
 
bool filtered_ {false}
 

Constructor & Destructor Documentation

◆ diagram() [1/3]

clanguml::common::model::diagram::diagram ( )
default

◆ diagram() [2/3]

clanguml::common::model::diagram::diagram ( const diagram )
delete

◆ diagram() [3/3]

clanguml::common::model::diagram::diagram ( diagram &&  )
defaultnoexcept

◆ ~diagram()

clanguml::common::model::diagram::~diagram ( )
virtualdefault

Member Function Documentation

◆ apply_filter()

virtual void clanguml::common::model::diagram::apply_filter ( )
inlinevirtual

◆ complete()

bool clanguml::common::model::diagram::complete ( ) const

Whether the diagram is complete.

This flag is set to true, when all translation units for this diagram have been visited.

Returns
Diagram completion status.

Definition at line 60 of file diagram.cc.

60{ return complete_; }

◆ context()

virtual inja::json clanguml::common::model::diagram::context ( ) const
pure virtual

◆ filter()

const diagram_filter & clanguml::common::model::diagram::filter ( ) const
inline

Get diagram filter

Returns
Reference to the diagrams element filter

Definition at line 113 of file diagram.h.

113{ return *filter_; }

◆ finalize()

void clanguml::common::model::diagram::finalize ( )
virtual

Once the diagram is complete, run any final processing.

This method should be overriden by specific diagram models to do some final tasks like cleaning up the model (e.g. some filters only work on completed diagrams).

Reimplemented in clanguml::sequence_diagram::model::diagram.

Definition at line 62 of file diagram.cc.

63{
64 // Remove elements that do not match the filter
66 filtered_ = true;
67}

◆ get() [1/2]

virtual opt_ref< clanguml::common::model::diagram_element > clanguml::common::model::diagram::get ( const std::string &  full_name) const
pure virtual

Return optional reference to a diagram_element by name.

Parameters
full_nameFully qualified name of a diagram element.
Returns
Optional reference to a diagram element.

Implemented in clanguml::class_diagram::model::diagram, clanguml::include_diagram::model::diagram, clanguml::package_diagram::model::diagram, and clanguml::sequence_diagram::model::diagram.

◆ get() [2/2]

virtual common::optional_ref< clanguml::common::model::diagram_element > clanguml::common::model::diagram::get ( eid_t  id) const
pure virtual

Return optional reference to a diagram_element by id.

Parameters
idId of a diagram element.
Returns
Optional reference to a diagram element.

Implemented in clanguml::class_diagram::model::diagram, clanguml::include_diagram::model::diagram, clanguml::package_diagram::model::diagram, and clanguml::sequence_diagram::model::diagram.

◆ get_with_namespace()

common::optional_ref< clanguml::common::model::diagram_element > clanguml::common::model::diagram::get_with_namespace ( const std::string &  name,
const namespace_ ns 
) const
virtual

Return optional reference to a diagram_element by name and namespace.

Parameters
nameName of the diagram element (e.g. a class name)
nsNamespace of the element.
Returns
Optional reference to a diagram element.

Reimplemented in clanguml::include_diagram::model::diagram.

Definition at line 35 of file diagram.cc.

36{
37 auto element_opt = get(name);
38
39 if (!element_opt) {
40 // If no element matches, try to prepend the 'using_namespace'
41 // value to the element and search again
42 auto fully_qualified_name = ns | name;
43 element_opt = get(fully_qualified_name.to_string());
44 }
45
46 return element_opt;
47}

◆ has_element()

virtual bool clanguml::common::model::diagram::has_element ( const eid_t  ) const
inlinevirtual

Reimplemented in clanguml::class_diagram::model::diagram.

Definition at line 155 of file diagram.h.

155{ return false; }

◆ is_empty()

virtual bool clanguml::common::model::diagram::is_empty ( ) const
pure virtual

◆ name()

std::string clanguml::common::model::diagram::name ( ) const

Return the name of the diagram.

Returns
Name of the diagram.

Definition at line 49 of file diagram.cc.

49{ return name_; }

◆ operator=() [1/2]

diagram & clanguml::common::model::diagram::operator= ( const diagram )
delete

◆ operator=() [2/2]

diagram & clanguml::common::model::diagram::operator= ( diagram &&  )
defaultnoexcept

◆ set_complete()

void clanguml::common::model::diagram::set_complete ( bool  complete)

Set diagram in a complete state.

This must be called after the diagram's 'translation_unit_visitor' has completed for all translation units, in order to apply filters which can only work after the diagram is complete.

Parameters
completeStatus of diagram visitor completion.

Definition at line 58 of file diagram.cc.

◆ set_filter()

void clanguml::common::model::diagram::set_filter ( std::unique_ptr< diagram_filter filter)

Set diagram filter for this diagram.

Parameters
filterdiagram_filter instance
See also
clanguml::common::model::diagram_filter

Definition at line 53 of file diagram.cc.

54{
55 filter_ = std::move(filter);
56}

◆ set_name()

void clanguml::common::model::diagram::set_name ( const std::string &  name)

Set diagram name.

Parameters
nameName of the diagram.

Definition at line 51 of file diagram.cc.

51{ name_ = name; }

◆ should_include() [1/8]

bool clanguml::common::model::diagram::should_include ( access_t  s) const

Definition at line 110 of file diagram.cc.

111{
112 if (filter_.get() == nullptr)
113 return true;
114
115 return filter_->should_include(s);
116}

◆ should_include() [2/8]

bool clanguml::common::model::diagram::should_include ( const element e) const

Definition at line 69 of file diagram.cc.

70{
71 if (filtered_)
72 return true;
73
74 if (filter_.get() == nullptr)
75 return true;
76
77 if (!complete()) {
78 return filter_->should_include(
79 dynamic_cast<const source_location &>(e));
80 }
81
82 return filter_->should_include(e) &&
83 filter_->should_include(dynamic_cast<const source_location &>(e));
84}

◆ should_include() [3/8]

bool clanguml::common::model::diagram::should_include ( const namespace_ ns) const

Definition at line 86 of file diagram.cc.

87{
88 if (filtered_)
89 return true;
90
91 if (filter_.get() == nullptr)
92 return true;
93
94 return filter_->should_include(ns);
95}

◆ should_include() [4/8]

bool clanguml::common::model::diagram::should_include ( const namespace_ ns,
const std::string &  name 
) const
virtual

Definition at line 118 of file diagram.cc.

120{
121 if (filter_.get() == nullptr)
122 return true;
123
124 return filter_->should_include(ns, name);
125}

◆ should_include() [5/8]

bool clanguml::common::model::diagram::should_include ( const source_file path) const

Definition at line 127 of file diagram.cc.

128{
129 if (filter_.get() == nullptr)
130 return true;
131
132 return filter_->should_include(f);
133}

◆ should_include() [6/8]

bool clanguml::common::model::diagram::should_include ( const std::string &  s) const
delete

◆ should_include() [7/8]

bool clanguml::common::model::diagram::should_include ( relationship  r) const

Definition at line 97 of file diagram.cc.

98{
99 return should_include(r.type());
100}

◆ should_include() [8/8]

bool clanguml::common::model::diagram::should_include ( relationship_t  r) const

Definition at line 102 of file diagram.cc.

103{
104 if (filter_.get() == nullptr)
105 return true;
106
107 return filter_->should_include(r);
108}

◆ type()

virtual diagram_t clanguml::common::model::diagram::type ( ) const
pure virtual

Member Data Documentation

◆ complete_

bool clanguml::common::model::diagram::complete_ {false}
private

Definition at line 179 of file diagram.h.

◆ filter_

std::unique_ptr<diagram_filter> clanguml::common::model::diagram::filter_
private

Definition at line 178 of file diagram.h.

◆ filtered_

bool clanguml::common::model::diagram::filtered_ {false}
private

Definition at line 180 of file diagram.h.

◆ name_

std::string clanguml::common::model::diagram::name_
private

Definition at line 177 of file diagram.h.


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