1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_DISTRIBUTED_DATA_INTERFACE_GDB_GRAPH_PATH_SEGMENT_H 17 #define OHOS_DISTRIBUTED_DATA_INTERFACE_GDB_GRAPH_PATH_SEGMENT_H 18 #include <cstdint> 19 #include <functional> 20 #include <memory> 21 #include <string> 22 #include <variant> 23 #include <vector> 24 25 #include "edge.h" 26 #include "rdb_visibility.h" 27 #include "vertex.h" 28 29 namespace OHOS::DistributedDataAip { 30 class PathSegment { 31 public: 32 API_EXPORT PathSegment(); 33 API_EXPORT PathSegment(std::shared_ptr<Vertex> sourceVertex, std::shared_ptr<Vertex> targetVertex, 34 std::shared_ptr<Edge> edge); 35 static std::shared_ptr<PathSegment> Parse(const nlohmann::json &json, int32_t &errCode); 36 37 API_EXPORT std::shared_ptr<Vertex> GetSourceVertex() const; 38 API_EXPORT void SetSourceVertex(std::shared_ptr<Vertex> vertex); 39 40 API_EXPORT std::shared_ptr<Edge> GetEdge() const; 41 API_EXPORT void SetEdge(std::shared_ptr<Edge> edge); 42 43 API_EXPORT std::shared_ptr<Vertex> GetTargetVertex() const; 44 API_EXPORT void SetTargetVertex(std::shared_ptr<Vertex> vertex); 45 46 static constexpr const char *SOURCE_VERTEX = "start"; 47 static constexpr const char *TARGET_VERTEX = "end"; 48 static constexpr const char *EDGE = "relationship"; 49 50 private: 51 std::shared_ptr<Vertex> sourceVertex_; 52 std::shared_ptr<Edge> edge_; 53 std::shared_ptr<Vertex> targetVertex_; 54 }; 55 } // namespace OHOS::DistributedDataAip 56 #endif //OHOS_DISTRIBUTED_DATA_INTERFACE_GDB_GRAPH_PATH_SEGMENT_H 57