File indexing completed on 2024-05-19 05:42:10
0001 // ct_lvtmdb_componentobject.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_COMPONENTOBJECT 0021 #define INCLUDED_CT_LVTMDB_COMPONENTOBJECT 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 PackageObject; 0035 class TypeObject; 0036 0037 // ====================== 0038 // class ComponentObject 0039 // ====================== 0040 0041 class LVTMDB_EXPORT ComponentObject : public DatabaseObject { 0042 // See locking discipline in superclass. That applies here. 0043 0044 private: 0045 std::vector<FileObject *> d_files; 0046 0047 PackageObject *d_package_p; 0048 0049 std::vector<ComponentObject *> d_forwardDeps; 0050 // Components this components has physical dependency upon 0051 0052 std::vector<ComponentObject *> d_reverseDeps; 0053 // Components with physical dependency upon this component 0054 0055 std::vector<TypeObject *> d_types; 0056 // Types in this component 0057 0058 public: 0059 // CREATORS 0060 ComponentObject(std::string qualifiedName, std::string name, PackageObject *package); 0061 0062 ~ComponentObject() noexcept override; 0063 0064 ComponentObject(ComponentObject&& other) noexcept; 0065 0066 ComponentObject& operator=(ComponentObject&& other) noexcept; 0067 0068 // ACCESSORS 0069 [[nodiscard]] const std::vector<FileObject *>& files() const; 0070 0071 [[nodiscard]] PackageObject *package() const; 0072 0073 [[nodiscard]] const std::vector<ComponentObject *>& forwardDependencies() const; 0074 0075 [[nodiscard]] const std::vector<ComponentObject *>& reverseDependencies() const; 0076 0077 [[nodiscard]] const std::vector<TypeObject *>& types() const; 0078 0079 // MODIFIERS 0080 void addFile(FileObject *file); 0081 // Requires an exclusive lock on this component. Does not modify the file 0082 0083 void removeFile(FileObject *file); 0084 0085 void addType(TypeObject *type); 0086 // Requires an exclusive lock on this component. Does not modify the file 0087 0088 // CLASS METHODS 0089 static void addDependency(ComponentObject *source, ComponentObject *target); 0090 // On calling this function, neither source nor target should be locked 0091 // (readOnly or for writing). This function handles locking internally. 0092 }; 0093 0094 } // namespace Codethink::lvtmdb 0095 0096 #endif // INCLUDED_CT_LVTMDB_COMPONENTOBJECT