File indexing completed on 2024-05-19 05:42:10
0001 // ct_lvtmdb_namespaceobject.h -*-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 #ifndef INCLUDED_CT_LVTMDB_NAMESPACEOBJECT 0021 #define INCLUDED_CT_LVTMDB_NAMESPACEOBJECT 0022 0023 #include <lvtmdb_export.h> 0024 0025 #include <ct_lvtmdb_databaseobject.h> 0026 0027 #include <string> 0028 #include <vector> 0029 0030 namespace Codethink::lvtmdb { 0031 0032 // Forward Declarations 0033 class FileObject; 0034 class FunctionObject; 0035 class TypeObject; 0036 class VariableObject; 0037 0038 // ====================== 0039 // class NamespaceObject 0040 // ====================== 0041 0042 class LVTMDB_EXPORT NamespaceObject : public DatabaseObject { 0043 // See locking discipline in superclass. That applies here. 0044 0045 private: 0046 NamespaceObject *d_parent_p; 0047 // Null if this is a package group 0048 0049 std::vector<NamespaceObject *> d_children; 0050 // Child namespaces 0051 0052 std::vector<TypeObject *> d_typeChildren; 0053 0054 std::vector<FileObject *> d_files; 0055 0056 std::vector<FunctionObject *> d_functions; 0057 0058 std::vector<VariableObject *> d_variables; 0059 0060 public: 0061 // CREATORS 0062 NamespaceObject(std::string qualifiedName, std::string name, NamespaceObject *parent); 0063 0064 ~NamespaceObject() noexcept override; 0065 0066 NamespaceObject(NamespaceObject&& other) noexcept; 0067 0068 NamespaceObject& operator=(NamespaceObject&& other) noexcept; 0069 0070 // ACCESSORS 0071 [[nodiscard]] NamespaceObject *parent() const; 0072 0073 [[nodiscard]] const std::vector<NamespaceObject *>& children() const; 0074 0075 [[nodiscard]] const std::vector<TypeObject *>& typeChildren() const; 0076 0077 [[nodiscard]] const std::vector<FileObject *>& files() const; 0078 0079 [[nodiscard]] const std::vector<FunctionObject *>& functions() const; 0080 0081 [[nodiscard]] const std::vector<VariableObject *>& variables() const; 0082 0083 // MANIPULATORS 0084 void addChild(NamespaceObject *child); 0085 // child->parent() should already point to this 0086 // an exclusive lock on this is required before calling this method 0087 0088 void removeChild(NamespaceObject *child); 0089 0090 void addType(TypeObject *type); 0091 // The type should already know that it belongs to this namespace 0092 // an exclusive lock on this is required before calling this method 0093 0094 void removeType(TypeObject *type); 0095 0096 void addFile(FileObject *file); 0097 // The file should already know that it belongs to this namespace 0098 // an exclusive lock on this is required before calling this method 0099 0100 void removeFile(FileObject *file); 0101 // The file should already know that it belongs to this namespace 0102 // an exclusive lock on this is required before calling this method 0103 0104 void addFunction(FunctionObject *function); 0105 // The function should already know that it belongs to this namespace 0106 // an exclusive lock on this is required before calling this method 0107 0108 void removeFunction(FunctionObject *function); 0109 0110 void addVariable(VariableObject *variable); 0111 // The variable should already know that it belongs to this namespace 0112 // an exclusive lock on this is required before calling this method 0113 0114 void removeVariable(VariableObject *variable); 0115 }; 0116 0117 } // namespace Codethink::lvtmdb 0118 0119 #endif // INCLUDED_CT_LVTMDB_NAMESPACEOBJECT