File indexing completed on 2024-05-19 05:42:06
0001 // ct_lvtldr_componentnode.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_COMPONENTNODE_H 0021 #define DIAGRAM_SERVER_CT_LVTLDR_COMPONENTNODE_H 0022 0023 #include <ct_lvtldr_databasehandler.h> 0024 #include <ct_lvtldr_lakosiannode.h> 0025 #include <ct_lvtldr_packagenode.h> 0026 #include <ct_lvtldr_typenode.h> 0027 0028 namespace Codethink::lvtldr { 0029 0030 // ========================== 0031 // class ComponentNode 0032 // ========================== 0033 0034 class LVTLDR_EXPORT ComponentNode : public LakosianNode { 0035 // Implementation of LakosianNode for components 0036 0037 private: 0038 // DATA 0039 // TODO: Decide if optional should be removed after refactoring is done. 0040 std::optional<std::reference_wrapper<DatabaseHandler>> d_dbHandler = std::nullopt; 0041 ComponentNodeFields d_fields; 0042 std::vector<std::string> d_qualifiedNameParts; 0043 0044 protected: 0045 explicit ComponentNode(NodeStorage& store); 0046 0047 // MODIFIERS 0048 void loadParent() override; 0049 void loadChildren() override; 0050 void loadProviders() override; 0051 void loadClients() override; 0052 0053 public: 0054 explicit ComponentNode(NodeStorage& store, 0055 std::optional<std::reference_wrapper<DatabaseHandler>> dbHandler = std::nullopt, 0056 std::optional<ComponentNodeFields> fields = std::nullopt); 0057 0058 ~ComponentNode() noexcept override; 0059 0060 static inline ComponentNode *from(LakosianNode *other) 0061 { 0062 return dynamic_cast<ComponentNode *>(other); 0063 } 0064 0065 inline ComponentNodeFields const& getFields() 0066 { 0067 return d_fields; 0068 } 0069 0070 // ACCESSORS 0071 void setParentPackageId(Codethink::lvtshr::UniqueId::RecordNumberType id); 0072 void addConcreteDependency(ComponentNode *other); 0073 void removeConcreteDependency(ComponentNode *other); 0074 void removeChild(LakosianNode *child); 0075 0076 [[nodiscard]] lvtshr::DiagramType type() const override; 0077 cpp::result<void, AddChildError> addChild(LakosianNode *child) override; 0078 0079 [[nodiscard]] std::string qualifiedName() const override; 0080 [[nodiscard]] std::string parentName() override; 0081 [[nodiscard]] long long id() const override; 0082 [[nodiscard]] lvtshr::UniqueId uid() const override; 0083 0084 [[nodiscard]] IsLakosianResult isLakosian() override; 0085 }; 0086 0087 template<> 0088 struct LakosianNodeType<Codethink::lvtldr::ComponentNode> { 0089 static auto constexpr diagramType = lvtshr::DiagramType::ComponentType; 0090 }; 0091 0092 } // namespace Codethink::lvtldr 0093 0094 #endif // DIAGRAM_SERVER_CT_LVTLDR_COMPONENTNODE_H