/** * src/class_diagram/model/diagram.h * * Copyright (c) 2021-2022 Bartek Kryza * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "class.h" #include "common/model/diagram.h" #include "common/model/nested_trait.h" #include "common/model/package.h" #include "common/types.h" #include "enum.h" #include "type_alias.h" #include #include #include namespace clanguml::class_diagram::model { class diagram : public clanguml::common::model::diagram, public clanguml::common::model::nested_trait< clanguml::common::model::element, clanguml::common::model::namespace_> { public: diagram() = default; diagram(const diagram &) = delete; diagram(diagram &&) = default; diagram &operator=(const diagram &) = delete; diagram &operator=(diagram &&) = default; common::model::diagram_t type() const override; std::optional< std::reference_wrapper> get(const std::string &full_name) const override; std::optional< std::reference_wrapper> get(const clanguml::common::model::diagram_element::id_t id) const override; const std::vector> &classes() const; const std::vector> &enums() const; bool has_class(const class_ &c) const; bool has_enum(const enum_ &e) const; std::optional> get_class( const std::string &name) const; std::optional> get_class( clanguml::common::model::diagram_element::id_t id) const; std::optional> get_enum( const std::string &name) const; std::optional> get_enum( clanguml::common::model::diagram_element::id_t id) const; void add_type_alias(std::unique_ptr &&ta); bool add_class(std::unique_ptr &&c); bool add_enum(std::unique_ptr &&e); bool add_package(std::unique_ptr &&p); std::string to_alias( clanguml::common::model::diagram_element::id_t id) const; void get_parents(clanguml::common::reference_set &parents) const; friend void print_diagram_tree(const diagram &d, const int level); bool has_element( const clanguml::common::model::diagram_element::id_t id) const override; private: std::vector> classes_; std::vector> enums_; std::map> type_aliases_; }; } namespace clanguml::common::model { template <> bool check_diagram_type(diagram_t t); }