File indexing completed on 2024-05-19 05:42:14

0001 // ct_lvtplg_handlercontextmenuaction.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_LVTPLG_PLUGINDATATYPES_H
0021 #define DIAGRAM_SERVER_CT_LVTPLG_PLUGINDATATYPES_H
0022 
0023 #include <any>
0024 #include <functional>
0025 #include <optional>
0026 #include <string>
0027 
0028 struct Color {
0029     int r = 0;
0030     int g = 0;
0031     int b = 0;
0032     int a = 255;
0033 };
0034 
0035 enum class EdgeStyle { SolidLine, DashLine, DotLine, DashDotLine, DashDotDotLine };
0036 
0037 enum class EntityType { Unknown, PackageGroup, Package, Component };
0038 
0039 using RawDBData = std::optional<std::any>;
0040 using RawDBCols = std::vector<RawDBData>;
0041 using RawDBRows = std::vector<RawDBCols>;
0042 
0043 struct Entity {
0044     std::function<std::string()> const getName;
0045     std::function<std::string()> const getQualifiedName;
0046     std::function<EntityType()> const getType;
0047     std::function<void(Color rgbColor)> const setColor;
0048     std::function<void(std::string info)> const addHoverInfo;
0049     std::function<std::vector<Entity>()> const getDependencies;
0050 
0051     /**
0052      * Unloads the entity from the current scene.
0053      * Warning: The Entity instance becomes invalid after method this is called, and must *not* be used.
0054      */
0055     std::function<void()> const unloadFromScene;
0056 
0057     /**
0058      * Will return all the qualified names from all children from the database. Not only those loaded in the scene.
0059      */
0060     std::function<std::vector<std::string>()> const getDbChildrenQualifiedNames;
0061 
0062     std::function<std::optional<Entity>()> const getParent;
0063 
0064     std::function<void(bool v)> const setSelected;
0065     std::function<bool()> const isSelected;
0066 };
0067 
0068 struct Edge {
0069     std::function<void(Color rgbColor)> const setColor;
0070     std::function<void(EdgeStyle style)> const setStyle;
0071 };
0072 
0073 struct ProjectData {
0074     std::function<std::string()> const getSourceCodePath;
0075 };
0076 
0077 #endif