Refactored template_builder to common namespace (#227)
This commit is contained in:
52
src/common/model/template_element.cc
Normal file
52
src/common/model/template_element.cc
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @file src/common/model/template_element.cc
|
||||
*
|
||||
* Copyright (c) 2021-2024 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 "template_element.h"
|
||||
|
||||
namespace clanguml::common::model {
|
||||
|
||||
bool template_element::is_template() const { return is_template_; }
|
||||
|
||||
void template_element::is_template(bool is_template)
|
||||
{
|
||||
is_template_ = is_template;
|
||||
}
|
||||
|
||||
int template_element::calculate_template_specialization_match(
|
||||
const template_element &other) const
|
||||
{
|
||||
int res{0};
|
||||
|
||||
if (name_and_ns() != other.name_and_ns()) {
|
||||
return res;
|
||||
}
|
||||
|
||||
return template_trait::calculate_template_specialization_match(other);
|
||||
}
|
||||
|
||||
void template_element::template_specialization_found(bool found)
|
||||
{
|
||||
template_specialization_found_ = found;
|
||||
}
|
||||
|
||||
bool template_element::template_specialization_found() const
|
||||
{
|
||||
return template_specialization_found_;
|
||||
}
|
||||
|
||||
} // namespace clanguml::common::model
|
||||
79
src/common/model/template_element.h
Normal file
79
src/common/model/template_element.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @file src/common/model/template_element.h
|
||||
*
|
||||
* Copyright (c) 2021-2024 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 "element.h"
|
||||
#include "template_trait.h"
|
||||
|
||||
namespace clanguml::common::model {
|
||||
|
||||
/**
|
||||
* @brief Base class for any element qualified by namespace.
|
||||
*/
|
||||
class template_element : public element, public template_trait {
|
||||
public:
|
||||
using element::element;
|
||||
|
||||
virtual ~template_element() = default;
|
||||
|
||||
/**
|
||||
* Whether or not the class is a template.
|
||||
*
|
||||
* @return True, if the class is a template.
|
||||
*/
|
||||
bool is_template() const;
|
||||
|
||||
/**
|
||||
* Set, whether the class is a template.
|
||||
*
|
||||
* @param is_struct True, if the class is a template.
|
||||
*/
|
||||
void is_template(bool is_template);
|
||||
|
||||
/**
|
||||
* @brief Calculate template specialization match with other class.
|
||||
*
|
||||
* This method is a wrapper over
|
||||
* @ref template_trait::calculate_template_specialization_match()
|
||||
*
|
||||
* @param other
|
||||
* @return
|
||||
*/
|
||||
int calculate_template_specialization_match(
|
||||
const template_element &other) const;
|
||||
|
||||
/**
|
||||
* Whether, a template specialization has already been found for this class.
|
||||
* @return True, if a template specialization has already been found.
|
||||
*/
|
||||
bool template_specialization_found() const;
|
||||
|
||||
/**
|
||||
* Set, whether a template specialization has already been found for this
|
||||
* class.
|
||||
*
|
||||
* @param found True, if a template specialization has already been found.
|
||||
*/
|
||||
void template_specialization_found(bool found);
|
||||
|
||||
private:
|
||||
bool template_specialization_found_{false};
|
||||
bool is_template_{false};
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user