// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source // License, and you may not use this file except in compliance with the Business Source License. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. #pragma once #include #include #include #include #include "query/exceptions.hpp" #include "query/v2/requests.hpp" #include "storage/v3/view.hpp" #include "utils/bound.hpp" #include "utils/exceptions.hpp" #include "utils/memory.hpp" #include "utils/memory_tracker.hpp" namespace memgraph::query::v2 { class RequestRouterInterface; } // namespace memgraph::query::v2 namespace memgraph::query::v2::accessors { using Value = msgs::Value; using Edge = msgs::Edge; using Vertex = msgs::Vertex; using Label = msgs::Label; using PropertyId = msgs::PropertyId; using EdgeTypeId = msgs::EdgeTypeId; class VertexAccessor; class EdgeAccessor final { public: explicit EdgeAccessor(Edge edge, const RequestRouterInterface *request_router); [[nodiscard]] EdgeTypeId EdgeType() const; [[nodiscard]] const std::vector> &Properties() const; [[nodiscard]] Value GetProperty(const std::string &prop_name) const; [[nodiscard]] const Edge &GetEdge() const; [[nodiscard]] bool IsCycle() const; [[nodiscard]] size_t CypherId() const; [[nodiscard]] VertexAccessor To() const; [[nodiscard]] VertexAccessor From() const; friend bool operator==(const EdgeAccessor &lhs, const EdgeAccessor &rhs) { return lhs.edge == rhs.edge; } friend bool operator!=(const EdgeAccessor &lhs, const EdgeAccessor &rhs) { return !(lhs == rhs); } private: Edge edge; const RequestRouterInterface *request_router_; }; class VertexAccessor final { public: using PropertyId = msgs::PropertyId; using Label = msgs::Label; using VertexId = msgs::VertexId; VertexAccessor(Vertex v, std::vector> props, const RequestRouterInterface *request_router); VertexAccessor(Vertex v, std::map &&props, const RequestRouterInterface *request_router); VertexAccessor(Vertex v, const std::map &props, const RequestRouterInterface *request_router); [[nodiscard]] Label PrimaryLabel() const; [[nodiscard]] const msgs::VertexId &Id() const; [[nodiscard]] std::vector