• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_H
17 #define OHOS_DISTRIBUTED_DATA_INTERFACE_GDB_GRAPH_PATH_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 "nlohmann/json.hpp"
27 #include "path_segment.h"
28 #include "rdb_visibility.h"
29 #include "vertex.h"
30 
31 namespace OHOS::DistributedDataAip {
32 class Path {
33 public:
34     API_EXPORT Path();
35     API_EXPORT Path(std::shared_ptr<Vertex> start, std::shared_ptr<Vertex> end);
36     API_EXPORT Path(std::shared_ptr<Vertex> start, std::shared_ptr<Vertex> end, uint32_t pathLen,
37         std::vector<std::shared_ptr<PathSegment>> segments);
38 
39     static std::shared_ptr<Path> Parse(const nlohmann::json &json, int32_t &errCode);
40 
41     API_EXPORT uint32_t GetPathLength() const;
42     API_EXPORT void SetPathLength(uint32_t pathLen);
43     API_EXPORT std::shared_ptr<Vertex> GetStart() const;
44     API_EXPORT void SetStart(std::shared_ptr<Vertex> start);
45     API_EXPORT std::shared_ptr<Vertex> GetEnd() const;
46     API_EXPORT void SetEnd(std::shared_ptr<Vertex> end);
47     API_EXPORT const std::vector<std::shared_ptr<PathSegment>> &GetSegments() const;
48 
49     static constexpr const char *PATHLEN = "length";
50     static constexpr const char *START = "start";
51     static constexpr const char *END = "end";
52     static constexpr const char *SEGMENTS = "segments";
53 
54 private:
55     uint32_t pathLen_;
56     std::shared_ptr<Vertex> start_;
57     std::shared_ptr<Vertex> end_;
58     std::vector<std::shared_ptr<PathSegment>> segments_;
59 };
60 
61 } // namespace OHOS::DistributedDataAip
62 #endif //OHOS_DISTRIBUTED_DATA_INTERFACE_GDB_GRAPH_PATH_H
63