File indexing completed on 2024-05-19 05:42:09
0001 // ct_lvtldr_repositorynode.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 DIAGRAM_SERVER_CT_LVTLDR_REPOSITORYNODE_H 0021 #define DIAGRAM_SERVER_CT_LVTLDR_REPOSITORYNODE_H 0022 0023 #include <ct_lvtldr_lakosiannode.h> 0024 #include <ct_lvtldr_nodestorage.h> 0025 0026 namespace Codethink::lvtldr { 0027 0028 // ========================== 0029 // class RepositoryNode 0030 // ========================== 0031 0032 class LVTLDR_EXPORT RepositoryNode : public LakosianNode { 0033 private: 0034 // DATA 0035 // TODO: Decide if optional should be removed after refactoring is done. 0036 std::optional<std::reference_wrapper<DatabaseHandler>> d_dbHandler = std::nullopt; 0037 RepositoryNodeFields d_fields; 0038 0039 protected: 0040 // MODIFIERS 0041 void loadParent() override; 0042 void loadChildren() override; 0043 void loadProviders() override; 0044 void loadClients() override; 0045 0046 public: 0047 explicit RepositoryNode(NodeStorage& store, 0048 std::optional<std::reference_wrapper<DatabaseHandler>> dbHandler = std::nullopt, 0049 std::optional<RepositoryNodeFields> fields = std::nullopt); 0050 ~RepositoryNode() noexcept override; 0051 0052 static inline RepositoryNode *from(LakosianNode *other) 0053 { 0054 return dynamic_cast<RepositoryNode *>(other); 0055 } 0056 0057 inline RepositoryNodeFields const& getFields() 0058 { 0059 return d_fields; 0060 } 0061 0062 // ACCESSORS 0063 [[nodiscard]] lvtshr::DiagramType type() const override; 0064 [[nodiscard]] bool isPackageGroup() override; 0065 [[nodiscard]] std::string qualifiedName() const override; 0066 [[nodiscard]] std::string parentName() override; 0067 [[nodiscard]] long long id() const override; 0068 [[nodiscard]] lvtshr::UniqueId uid() const override; 0069 [[nodiscard]] IsLakosianResult isLakosian() override; 0070 [[nodiscard]] cpp::result<void, AddChildError> addChild(LakosianNode *child) override; 0071 }; 0072 0073 template<> 0074 struct LakosianNodeType<Codethink::lvtldr::RepositoryNode> { 0075 static auto constexpr diagramType = lvtshr::DiagramType::RepositoryType; 0076 }; 0077 0078 } // namespace Codethink::lvtldr 0079 0080 #endif // DIAGRAM_SERVER_CT_LVTLDR_REPOSITORYNODE_H