File indexing completed on 2024-05-19 05:42:06
0001 // ct_lvtldr_freefunctionnode.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_FREEFUNCTIONNODE_H 0021 #define DIAGRAM_SERVER_CT_LVTLDR_FREEFUNCTIONNODE_H 0022 0023 #include <ct_lvtldr_databasehandler.h> 0024 #include <ct_lvtldr_freefunctionnodefields.h> 0025 #include <ct_lvtldr_lakosiannode.h> 0026 0027 namespace Codethink::lvtldr { 0028 0029 // ========================== 0030 // class FreeFunctionNode 0031 // ========================== 0032 0033 class LVTLDR_EXPORT FreeFunctionNode : public LakosianNode { 0034 private: 0035 // DATA 0036 std::optional<std::reference_wrapper<DatabaseHandler>> d_dbHandler = std::nullopt; 0037 FreeFunctionNodeFields d_fields; 0038 std::vector<std::string> d_qualifiedNameParts; 0039 0040 protected: 0041 explicit FreeFunctionNode(NodeStorage& store); 0042 0043 public: 0044 explicit FreeFunctionNode(NodeStorage& store, 0045 std::optional<std::reference_wrapper<DatabaseHandler>> dbHandler = std::nullopt, 0046 std::optional<FreeFunctionNodeFields> d_fields = std::nullopt); 0047 0048 ~FreeFunctionNode() noexcept override; 0049 0050 static inline FreeFunctionNode *from(LakosianNode *other) 0051 { 0052 return dynamic_cast<FreeFunctionNode *>(other); 0053 } 0054 0055 inline FreeFunctionNodeFields const& getFields() 0056 { 0057 return d_fields; 0058 } 0059 0060 // MODIFIERS 0061 void loadParent() override; 0062 0063 void loadChildren() override 0064 { 0065 d->childrenLoaded = true; 0066 // There are no expected children for free functions. 0067 } 0068 0069 void loadProviders() override; 0070 void loadClients() override; 0071 0072 // ACCESSORS 0073 [[nodiscard]] lvtshr::DiagramType type() const override; 0074 [[nodiscard]] std::string qualifiedName() const override; 0075 [[nodiscard]] std::string parentName() override; 0076 [[nodiscard]] long long id() const override; 0077 [[nodiscard]] lvtshr::UniqueId uid() const override; 0078 [[nodiscard]] IsLakosianResult isLakosian() override; 0079 [[nodiscard]] cpp::result<void, AddChildError> addChild(LakosianNode *) override 0080 { 0081 // We don't currently support adding childs to free functions (what does that even mean?) 0082 return {}; 0083 } 0084 }; 0085 0086 template<> 0087 struct LakosianNodeType<Codethink::lvtldr::FreeFunctionNode> { 0088 static auto constexpr diagramType = lvtshr::DiagramType::FreeFunctionType; 0089 }; 0090 0091 } // namespace Codethink::lvtldr 0092 0093 #endif // DIAGRAM_SERVER_CT_LVTLDR_FREEFUNCTIONNODE_H