• 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_EDGE_H
17 #define OHOS_DISTRIBUTED_DATA_INTERFACE_GDB_GRAPH_EDGE_H
18 
19 #include <cstdint>
20 #include <functional>
21 #include <memory>
22 #include <string>
23 #include <variant>
24 #include <vector>
25 
26 #include "nlohmann/json.hpp"
27 #include "rdb_visibility.h"
28 #include "vertex.h"
29 
30 namespace OHOS::DistributedDataAip {
31 class Edge : public Vertex {
32 public:
33     API_EXPORT Edge();
34     API_EXPORT Edge(std::string id, std::string label, std::string sourceId, std::string targetId);
35     API_EXPORT Edge(const std::shared_ptr<Vertex> &element, std::string sourceId, std::string targetId);
36     static std::shared_ptr<Edge> Parse(const nlohmann::json &json, int32_t &errCode);
37     API_EXPORT std::string GetSourceId() const;
38     API_EXPORT void SetSourceId(std::string sourceId);
39 
40     API_EXPORT std::string GetTargetId() const;
41     API_EXPORT void SetTargetId(std::string targetId);
42 
43     static constexpr const char *SOURCEID = "start";
44     static constexpr const char *TARGETID = "end";
45 
46 private:
47     std::string sourceId_;
48     std::string targetId_;
49     static std::string GetIdFromJson(const std::string &key, const nlohmann::json &json, int32_t &errCode);
50 };
51 
52 }
53 #endif //OHOS_DISTRIBUTED_DATA_INTERFACE_GDB_GRAPH_EDGE_H
54