Refactored common diagram methods to common class

This commit is contained in:
Bartek Kryza
2022-02-16 21:13:58 +01:00
parent e7afdba19a
commit 3b6aa48b82
8 changed files with 69 additions and 33 deletions

View File

@@ -23,10 +23,6 @@
namespace clanguml::class_diagram::model {
std::string diagram::name() const { return name_; }
void diagram::set_name(const std::string &name) { name_ = name; }
const std::vector<class_> diagram::classes() const { return classes_; }
const std::vector<enum_> diagram::enums() const { return enums_; }

View File

@@ -18,6 +18,7 @@
#pragma once
#include "class.h"
#include "common/model/diagram.h"
#include "enum.h"
#include "type_alias.h"
@@ -26,12 +27,8 @@
namespace clanguml::class_diagram::model {
class diagram {
class diagram : public clanguml::common::model::diagram {
public:
std::string name() const;
void set_name(const std::string &name);
const std::vector<class_> classes() const;
const std::vector<enum_> enums() const;
@@ -47,7 +44,6 @@ public:
std::string to_alias(const std::string &full_name) const;
private:
std::string name_;
std::vector<class_> classes_;
std::vector<enum_> enums_;
std::map<std::string, type_alias> type_aliases_;

View File

@@ -0,0 +1,27 @@
/**
* src/common/model/diagram.cc
*
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
*
* 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.
*/
#include "diagram.h"
namespace clanguml::common::model {
std::string diagram::name() const { return name_; }
void diagram::set_name(const std::string &name) { name_ = name; }
}

View File

@@ -0,0 +1,34 @@
/**
* src/common/model/diagram.h
*
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
*
* 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 <string>
namespace clanguml::common::model {
class diagram {
public:
std::string name() const;
void set_name(const std::string &name);
private:
std::string name_;
};
}

View File

@@ -23,10 +23,6 @@
namespace clanguml::package_diagram::model {
std::string diagram::name() const { return name_; }
void diagram::set_name(const std::string &name) { name_ = name; }
std::string diagram::to_alias(const std::string &full_name) const
{
LOG_DBG("Looking for alias for {}", full_name);

View File

@@ -17,6 +17,7 @@
*/
#pragma once
#include "common/model/diagram.h"
#include "package.h"
#include <type_safe/optional_ref.hpp>
@@ -26,17 +27,12 @@
namespace clanguml::package_diagram::model {
class diagram : public detail::package_trait<package, std::vector> {
class diagram : public clanguml::common::model::diagram,
public detail::package_trait<package, std::vector> {
public:
std::string name() const;
void set_name(const std::string &name);
std::string to_alias(const std::string &full_name) const;
private:
std::string name_;
std::vector<std::unique_ptr<package>> packages_;
};
}

View File

@@ -29,10 +29,6 @@
namespace clanguml::sequence_diagram::model {
std::string diagram::name() const { return name_; }
void diagram::set_name(const std::string &name) { name_ = name; }
std::string diagram::to_alias(const std::string &full_name) const
{
return full_name;

View File

@@ -18,25 +18,20 @@
#pragma once
#include "activity.h"
#include "common/model/diagram.h"
#include <map>
#include <string>
namespace clanguml::sequence_diagram::model {
struct diagram {
std::string name() const;
void set_name(const std::string &name);
class diagram : public clanguml::common::model::diagram {
public:
std::string to_alias(const std::string &full_name) const;
bool started{false};
std::map<std::uint_least64_t, activity> sequences;
private:
std::string name_;
};
}