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

Base class for any element qualified by namespace. More...

Detailed Description

Base class for any element qualified by namespace.

Definition at line 38 of file element.h.

#include <element.h>

Public Member Functions

 element (namespace_ using_namespace, path_type pt=path_type::kNamespace)
 
 ~element () override=default
 
std::string name_and_ns () const
 
void set_namespace (const namespace_ &ns)
 
namespace_ get_namespace () const
 
namespace_ get_relative_namespace () const
 
const namespace_path () const
 
void set_module (const std::string &module)
 
std::optional< std::string > module () const
 
void set_module_private (const bool module_private)
 
bool module_private () const
 
std::string full_name (bool relative) const override
 
virtual std::string full_name_no_ns () const
 
const namespace_using_namespace () const
 
inja::json context () const override
 
- Public Member Functions inherited from clanguml::common::model::diagram_element
 diagram_element ()
 
 ~diagram_element () override=default
 
const eid_tid () const
 Returns diagram element id.
 
void set_id (eid_t id)
 
std::optional< eid_tparent_element_id () const
 
void set_parent_element_id (eid_t id)
 
virtual std::string alias () const
 Return elements' diagram alias.
 
void set_name (const std::string &name)
 
std::string name () const
 
virtual std::string type_name () const
 
virtual std::string full_name (bool) const
 Return the elements fully qualified name.
 
std::vector< relationship > & relationships ()
 
const std::vector< relationship > & relationships () const
 
void add_relationship (relationship &&cr)
 
void append (const decorated_element &e)
 
virtual inja::json context () const
 
bool is_nested () const
 
void nested (bool nested)
 
bool complete () const
 
void complete (bool completed)
 
virtual void apply_filter (const diagram_filter &filter, const std::set< eid_t > &removed)
 
- Public Member Functions inherited from clanguml::common::model::decorated_element
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
 
- Public Member Functions inherited from clanguml::common::model::source_location
 source_location ()=default
 
 source_location (std::string f, unsigned int l)
 
const std::string & file () const
 
void set_file (const std::string &file)
 
const std::string & file_relative () const
 
void set_file_relative (const std::string &file)
 
const std::string & translation_unit () const
 
void set_translation_unit (const std::string &translation_unit)
 
unsigned int line () const
 
void set_line (const unsigned line)
 
unsigned int column () const
 
void set_column (const unsigned column)
 
unsigned int location_id () const
 
void set_location_id (unsigned int h)
 

Private Attributes

namespace_ ns_
 
namespace_ using_namespace_
 
std::optional< std::string > module_
 
bool module_private_ {false}
 

Friends

bool operator== (const element &l, const element &r)
 
std::ostream & operator<< (std::ostream &out, const element &rhs)
 

Constructor & Destructor Documentation

◆ element()

clanguml::common::model::element::element ( namespace_  using_namespace,
path_type  pt = path_type::kNamespace 
)

Definition at line 28 of file element.cc.

29 : ns_{pt}
31{
32}

◆ ~element()

clanguml::common::model::element::~element ( )
overridedefault

Member Function Documentation

◆ context()

inja::json clanguml::common::model::element::context ( ) const
overridevirtual

Return elements inja JSON context.

Returns
Element context.

Reimplemented from clanguml::common::model::diagram_element.

Definition at line 36 of file element.cc.

37{
38 inja::json ctx = diagram_element::context();
39 ctx["namespace"] = get_namespace().to_string();
40 if (const auto maybe_comment = comment(); maybe_comment.has_value()) {
41 ctx["comment"] = maybe_comment.value();
42 }
43
44 return ctx;
45}

◆ full_name()

std::string clanguml::common::model::element::full_name ( bool  relative) const
inlineoverridevirtual

Return elements full name.

Returns
Fully qualified elements name.

Reimplemented from clanguml::common::model::diagram_element.

Reimplemented in clanguml::common::model::package, clanguml::sequence_diagram::model::method, clanguml::class_diagram::model::enum_, clanguml::sequence_diagram::model::function, and clanguml::sequence_diagram::model::function_template.

Definition at line 126 of file element.h.

127 {
128 if (relative)
129 return name();
130
131 return name_and_ns();
132 }

◆ full_name_no_ns()

virtual std::string clanguml::common::model::element::full_name_no_ns ( ) const
inlinevirtual

Return elements full name but without namespace.

Returns
Elements full name without namespace.

Reimplemented in clanguml::class_diagram::model::class_, clanguml::class_diagram::model::concept_, clanguml::sequence_diagram::model::class_, clanguml::sequence_diagram::model::function, and clanguml::sequence_diagram::model::function_template.

Definition at line 139 of file element.h.

139{ return name(); }

◆ get_namespace()

namespace_ clanguml::common::model::element::get_namespace ( ) const
inline

Return elements namespace.

Returns
Namespace.

Definition at line 68 of file element.h.

68{ return ns_; }

◆ get_relative_namespace()

namespace_ clanguml::common::model::element::get_relative_namespace ( ) const
inline

Return elements relative namespace.

Returns
Namespace.

Definition at line 75 of file element.h.

76 {
78 }

◆ module()

std::optional< std::string > clanguml::common::model::element::module ( ) const
inline

Return elements owning module, if any.

Returns
C++20 module.

Definition at line 102 of file element.h.

102{ return module_; }

◆ module_private()

bool clanguml::common::model::element::module_private ( ) const
inline

Check whether the element is in a private module.

Returns
C++20 module.

Definition at line 119 of file element.h.

119{ return module_private_; }

◆ name_and_ns()

std::string clanguml::common::model::element::name_and_ns ( ) const
inline

Return the elements fully qualified name, but without template arguments or function params.

Returns
Fully qualified element name.

Definition at line 50 of file element.h.

51 {
52 auto ns = ns_ | name();
53 return ns.to_string();
54 }

◆ path()

const namespace_ & clanguml::common::model::element::path ( ) const
inline

Return elements namespace as path.

Namespace is a nested path in diagrams where packages are generated from namespaces.

Returns
Namespace.

Definition at line 88 of file element.h.

88{ return ns_; }

◆ set_module()

void clanguml::common::model::element::set_module ( const std::string &  module)
inline

Set elements owning module.

Parameters
moduleC++20 module.

Definition at line 95 of file element.h.

95{ module_ = module; }

◆ set_module_private()

void clanguml::common::model::element::set_module_private ( const bool  module_private)
inline

Set whether the element is in a private module

Parameters
moduleC++20 module.

Definition at line 109 of file element.h.

110 {
112 }

◆ set_namespace()

void clanguml::common::model::element::set_namespace ( const namespace_ ns)
inline

Set elements namespace.

Parameters
nsNamespace.

Definition at line 61 of file element.h.

61{ ns_ = ns; }

◆ using_namespace()

const namespace_ & clanguml::common::model::element::using_namespace ( ) const

Return the relative namespace from config.

Returns
Namespace.

Definition at line 34 of file element.cc.

34{ return using_namespace_; }

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const element rhs 
)
friend

Definition at line 52 of file element.cc.

53{
54 out << "(" << rhs.name() << ", ns=[" << rhs.get_namespace().to_string()
55 << "], full_name=[" << rhs.full_name(true) << "])";
56
57 return out;
58}

◆ operator==

bool operator== ( const element l,
const element r 
)
friend

Definition at line 47 of file element.cc.

48{
49 return l.full_name(false) == r.full_name(false);
50}

Member Data Documentation

◆ module_

std::optional<std::string> clanguml::common::model::element::module_
private

Definition at line 157 of file element.h.

◆ module_private_

bool clanguml::common::model::element::module_private_ {false}
private

Definition at line 158 of file element.h.

◆ ns_

namespace_ clanguml::common::model::element::ns_
private

Definition at line 155 of file element.h.

◆ using_namespace_

namespace_ clanguml::common::model::element::using_namespace_
private

Definition at line 156 of file element.h.


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