File indexing completed on 2024-05-19 05:42:09
0001 // ct_lvtldr_physicalloader.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_LVTLDR_PHYSICALLOADER 0021 #define INCLUDED_CT_LVTLDR_PHYSICALLOADER 0022 0023 //@PURPOSE: Load physical graphs from the database 0024 // 0025 //@CLASSES: 0026 // lvtldr::PhysicalLoader: Load physical graphs from the database 0027 // This class implements the policy of the loading: controlling what is and 0028 // is not loaded according to the graph settings. See LakosianNode for the 0029 // interface with lvtcdb and IGraphLoader for the interface with lvtshr. 0030 0031 #include <lvtldr_export.h> 0032 0033 #include <ct_lvtldr_igraphloader.h> 0034 0035 #include <ct_lvtshr_graphenums.h> 0036 #include <ct_lvtshr_uniqueid.h> 0037 0038 #include <memory> 0039 #include <result/result.hpp> 0040 #include <string> 0041 0042 namespace Codethink::lvtshr { 0043 class LoaderInfo; 0044 } 0045 0046 namespace Codethink::lvtldr { 0047 0048 class NodeStorage; 0049 class LakosianEdge; 0050 class LakosianNode; 0051 0052 // ========================== 0053 // class PhysicalLoader 0054 // ========================== 0055 0056 struct GraphLoadError { 0057 std::string what; 0058 }; 0059 0060 class LVTLDR_EXPORT PhysicalLoader { 0061 public: 0062 // TYPES 0063 enum class ManualRuleKind { Children, Edges }; 0064 0065 void unvisitVertex(LakosianNode *node); 0066 // Sets a node as 'unvisited' so that the load algorithm can traverse the data again. 0067 0068 private: 0069 // TYPES 0070 struct Private; 0071 0072 // DATA 0073 std::unique_ptr<Private> d; 0074 0075 // MANIPULATORS 0076 void addVertex(LakosianNode *node, bool withParent, lvtshr::LoaderInfo info); 0077 // Add a vertex to the diagram 0078 0079 void visitVertex(LakosianNode *node, unsigned distance, lvtldr::NodeLoadFlags flags); 0080 // Recursive visitor for loading a graph 0081 0082 public: 0083 // CREATORS 0084 explicit PhysicalLoader(NodeStorage& nodeStorage); 0085 0086 ~PhysicalLoader() noexcept; 0087 0088 // MANIPULATORS 0089 void setGraph(IGraphLoader *graph); 0090 // Really this should be in the constructor, but that isn't how 0091 // lvtqtc::GraphicsScene works 0092 0093 void clear(); 0094 0095 void setMainNode(LakosianNode *node); 0096 // Set the main node of the graph 0097 0098 void setExtDeps(bool extDeps); 0099 // Control if dependencies of dependencies (...of dependencies...) are 0100 // loaded 0101 0102 bool isNodeFullyLoaded(LakosianNode *node, lvtldr::NodeLoadFlags flags) const; 0103 cpp::result<void, GraphLoadError> load(LakosianNode *node, lvtldr::NodeLoadFlags flags); 0104 // Load the graph from the code database 0105 }; 0106 0107 } // namespace Codethink::lvtldr 0108 0109 #endif // INCLUDED_CT_LVTLDR_PHYSICALLOADER