File indexing completed on 2024-05-19 05:42:10

0001 // ct_lvtmdb_methodobject.cpp                                         -*-C++-*-
0002 
0003 /*
0004 // Copyright 2023 Codethink Ltd <codethink@codethink.co.uk>
0005 // SPDX-License-Identifier: Apache-2.0
0006 //
0007 // Licensed under the Apache License, Version 2.0 (the "License");
0008 // you may not use this file except in compliance with the License.
0009 // You may obtain a copy of the License at
0010 //
0011 //     http://www.apache.org/licenses/LICENSE-2.0
0012 //
0013 // Unless required by applicable law or agreed to in writing, software
0014 // distributed under the License is distributed on an "AS IS" BASIS,
0015 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0016 // See the License for the specific language governing permissions and
0017 // limitations under the License.
0018 */
0019 
0020 #include <ct_lvtmdb_methodobject.h>
0021 
0022 #include <ct_lvtmdb_util.h>
0023 
0024 namespace Codethink::lvtmdb {
0025 
0026 MethodObject::MethodObject(std::string qualifiedName,
0027                            std::string name,
0028                            std::string signature,
0029                            std::string returnType,
0030                            std::string templateParameters,
0031                            lvtshr::AccessSpecifier access,
0032                            bool isVirtual,
0033                            bool isPure,
0034                            bool isStatic,
0035                            bool isConst,
0036                            TypeObject *parent):
0037     FunctionBase(std::move(qualifiedName),
0038                  std::move(name),
0039                  std::move(signature),
0040                  std::move(returnType),
0041                  std::move(templateParameters)),
0042     d_access(access),
0043     d_isVirtual(isVirtual),
0044     d_isPure(isPure),
0045     d_isStatic(isStatic),
0046     d_isConst(isConst),
0047     d_parent_p(parent)
0048 {
0049 }
0050 
0051 MethodObject::~MethodObject() noexcept = default;
0052 
0053 MethodObject::MethodObject(MethodObject&&) noexcept = default;
0054 
0055 MethodObject& MethodObject::operator=(MethodObject&&) noexcept = default;
0056 
0057 lvtshr::AccessSpecifier MethodObject::access() const
0058 {
0059     assertReadable();
0060     return d_access;
0061 }
0062 
0063 bool MethodObject::isVirtual() const
0064 {
0065     assertReadable();
0066     return d_isVirtual;
0067 }
0068 
0069 bool MethodObject::isPure() const
0070 {
0071     assertReadable();
0072     return d_isPure;
0073 }
0074 
0075 bool MethodObject::isStatic() const
0076 {
0077     assertReadable();
0078     return d_isStatic;
0079 }
0080 
0081 bool MethodObject::isConst() const
0082 {
0083     assertReadable();
0084     return d_isConst;
0085 }
0086 
0087 TypeObject *MethodObject::parent() const
0088 {
0089     assertReadable();
0090     return d_parent_p;
0091 }
0092 
0093 const std::vector<TypeObject *>& MethodObject::argumentTypes() const
0094 {
0095     assertReadable();
0096     return d_argumentTypes;
0097 }
0098 
0099 void MethodObject::addArgumentType(TypeObject *type)
0100 {
0101     assertWritable();
0102     MdbUtil::pushBackUnique(d_argumentTypes, type);
0103 }
0104 
0105 } // namespace Codethink::lvtmdb