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::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 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_; }

◆ 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::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

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 116 of file diagram.cc.

117{
118 if (filter_.get() == nullptr)
119 return true;
120
121 return filter_->should_include(s);
122}

◆ 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 // In the basic mode, apply the paths filter as soon as possible
78 // to limit processing unnecessary files
79 if (filter_->mode() == filter_mode_t::basic) {
80 return filter_->should_include(e);
81 }
82
83 // In advanced mode, we have to wait until the diagram model is complete
84 // before we can filter anything out
85 if (filter_->mode() == filter_mode_t::advanced && !complete()) {
86 return true;
87 }
88
89 return filter_->should_include(e);
90}

◆ should_include() [3/8]

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

Definition at line 92 of file diagram.cc.

93{
94 if (filtered_)
95 return true;
96
97 if (filter_.get() == nullptr)
98 return true;
99
100 return filter_->should_include(ns);
101}

◆ should_include() [4/8]

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

Definition at line 124 of file diagram.cc.

126{
127 if (filter_.get() == nullptr)
128 return true;
129
130 return filter_->should_include(ns, name);
131}

◆ should_include() [5/8]

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

Definition at line 133 of file diagram.cc.

134{
135 if (filter_.get() == nullptr)
136 return true;
137
138 return filter_->should_include(f);
139}

◆ 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 103 of file diagram.cc.

104{
105 return should_include(r.type());
106}

◆ should_include() [8/8]

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

Definition at line 108 of file diagram.cc.

109{
110 if (filter_.get() == nullptr)
111 return true;
112
113 return filter_->should_include(r);
114}

◆ 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 172 of file diagram.h.

◆ filter_

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

Definition at line 171 of file diagram.h.

◆ filtered_

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

Definition at line 173 of file diagram.h.

◆ name_

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

Definition at line 170 of file diagram.h.


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