#pragma once #include "barrier/common.hpp" // This namespace is holding header parts of barrier classes. Barrier class // object is in fact object from other class inside memgraph. Main purpose of // barrier classes is to hide real classes from outside viewers. This header // should be only to be included from memgraph into generated/compiled query. // And this header must ensure that it defines all classes and methods required // for querys. namespace barrier { // Every class which must be visible to outside the barrier should have there // barrier class defined here. // ************ Here should be forward declarations of Sized barrier classes // ACCESSORS class DbAccessor; class VertexAccessor; class EdgeAccessor; // GENERIC ITERATORS class VertexIterator; class EdgeIterator; // TYPED ITERATORS class VertexAccessIterator; class OutEdgesIterator; class InEdgesIterator; // PROPERTY class VertexPropertyKey; class EdgePropertyKey; template class VertexPropertyType; template class EdgePropertyType; // BOLT template class BoltSerializer; // ************ Here should be forward declarations of Unsized barrier classes // COMMON class Db; class Label; class EdgeType; // GENERIC INDEXES template class VertexIndex; template class EdgeIndex; // PROPERTY class VertexPropertyFamily; class EdgePropertyFamily; // ************* Here should be defined usings using label_ref_t = ReferenceWrapper; // ************ Here should be definitions of Sized barrier classes // Original class should have Sized barrier class if it can't be Unsized. // Sized barrier classes should: // --Have same name as original class. // --Inherit Sized class from common.hpp as private. Blueprint: // class class_name: Sized // --Sized template arguments must be hardcoded numbers equal to sizeof(T) and // alignof(T) where T is original class. // --It should have undefined public constructor which is specialized in .cpp // Blueprint: // public: // template class_name(T &&d); // --It should delete or specify following methods depending on the behavior of // the original class: // public: // class_name(const class_name &other); // class_name(class_name &&other); // ~class_name(); // class_name &operator=(const class_name &other); // class_name &operator=(class_name &&other); // --It should specify public methods which can be called on the original class. // // Blueprint: // class class_name : private Sized<,> // { // public: // template // class_name(T &&d); // // class_name(const class_name &other); // class_name(class_name &&other); // ~class_name(); // // class_name &operator=(const class_name &other); // class_name &operator=(class_name &&other); // // }; // TODO: Extract methods od RecordAccessor for VertexAccessor and EdgeAccessor // into joined class. class VertexAccessor : private Sized<24, 8> { public: template VertexAccessor(T &&d); VertexAccessor(VertexAccessor &other); VertexAccessor(const VertexAccessor &other); VertexAccessor(VertexAccessor &&other); VertexAccessor(VertexAccessor const &&other); ~VertexAccessor(); VertexAccessor &operator=(const VertexAccessor &other); VertexAccessor &operator=(VertexAccessor &&other); size_t out_degree() const; size_t in_degree() const; size_t degree() const; bool add_label(const Label &label); bool remove_label(const Label &label); bool has_label(const Label &label) const; const std::vector &labels() const; OutEdgesIterator out() const; InEdgesIterator in() const; bool in_contains(VertexAccessor const &other) const; bool empty() const; bool fill() const; const Id &id() const; VertexAccessor update() const; bool remove() const; const Property &at(VertexPropertyFamily &key) const; const Property &at(VertexPropertyKey &key) const; template OptionPtr at(VertexPropertyType &key) const; template void set(VertexPropertyType &key, Args &&... args); void set(VertexPropertyKey &key, Property::sptr value); void clear(VertexPropertyKey &key); void clear(VertexPropertyFamily &key); template void accept(Handler &handler) const; explicit operator bool() const; friend bool operator==(const VertexAccessor &a, const VertexAccessor &b); friend bool operator!=(const VertexAccessor &a, const VertexAccessor &b); }; class EdgeAccessor : private Sized<24, 8> { public: template EdgeAccessor(T &&d); EdgeAccessor(EdgeAccessor &other); EdgeAccessor(const EdgeAccessor &other); EdgeAccessor(EdgeAccessor &&other); EdgeAccessor(EdgeAccessor const &&other); ~EdgeAccessor(); EdgeAccessor &operator=(const EdgeAccessor &other); EdgeAccessor &operator=(EdgeAccessor &&other); void edge_type(const EdgeType &edge_type); const EdgeType &edge_type() const; const VertexAccessor from() const; const VertexAccessor to() const; bool empty() const; bool fill() const; const Id &id() const; EdgeAccessor update() const; bool remove() const; const Property &at(EdgePropertyFamily &key) const; const Property &at(EdgePropertyKey &key) const; template OptionPtr at(EdgePropertyType &key) const; template void set(EdgePropertyType &key, Args &&... args); void set(EdgePropertyKey &key, Property::sptr value); void clear(EdgePropertyKey &key); void clear(EdgePropertyFamily &key); template void accept(Handler &handler) const; explicit operator bool() const; friend bool operator==(const EdgeAccessor &a, const EdgeAccessor &b); friend bool operator!=(const EdgeAccessor &a, const EdgeAccessor &b); }; class DbAccessor : protected Sized<40, 8> { public: DbAccessor(Db &d); DbAccessor(const DbAccessor &other) = delete; DbAccessor(DbAccessor &&other) = delete; ~DbAccessor(); DbAccessor &operator=(const DbAccessor &other) = delete; DbAccessor &operator=(DbAccessor &&other) = delete; VertexAccessIterator vertex_access(); Option vertex_find(const Id &id); VertexAccessor vertex_insert(); Option edge_find(const Id &id); EdgeAccessor edge_insert(VertexAccessor const &from, VertexAccessor const &to); const Label &label_find_or_create(const char *name); bool label_contains(const char *name); const EdgeType &type_find_or_create(const char *name); bool type_contains(const char *name); VertexPropertyFamily &vertex_property_family_get(const std::string &name); EdgePropertyFamily &edge_property_family_get(const std::string &name); VertexPropertyKey vertex_property_key(const std::string &name, Type type); EdgePropertyKey edge_property_key(const std::string &name, Type type); template VertexPropertyType vertex_property_key(const std::string &name); template EdgePropertyType edge_property_key(const std::string &name); bool commit(); void abort(); }; class VertexIterator : private Sized<8, 8> { public: template VertexIterator(T &&d); VertexIterator(const VertexIterator &other) = delete; VertexIterator(VertexIterator &&other); ~VertexIterator(); VertexIterator &operator=(const VertexIterator &other) = delete; VertexIterator &operator=(VertexIterator &&other) = delete; Option next(); }; // TODO: Find reasons of such great size ant try to decrease it. class VertexAccessIterator : private Sized<552, 8> { public: template VertexAccessIterator(T &&d); VertexAccessIterator(const VertexAccessIterator &other) = delete; VertexAccessIterator(VertexAccessIterator &&other); ~VertexAccessIterator(); VertexAccessIterator &operator=(const VertexAccessIterator &other) = delete; VertexAccessIterator &operator=(VertexAccessIterator &&other) = delete; Option next(); }; class OutEdgesIterator : private Sized<40, 8> { public: template OutEdgesIterator(T &&d); OutEdgesIterator(const OutEdgesIterator &other) = delete; OutEdgesIterator(OutEdgesIterator &&other); ~OutEdgesIterator(); OutEdgesIterator &operator=(const OutEdgesIterator &other) = delete; OutEdgesIterator &operator=(OutEdgesIterator &&other) = delete; Option next(); }; class InEdgesIterator : private Sized<56, 8> { public: template InEdgesIterator(T &&d); InEdgesIterator(const InEdgesIterator &other) = delete; InEdgesIterator(InEdgesIterator &&other); ~InEdgesIterator(); InEdgesIterator &operator=(const InEdgesIterator &other) = delete; InEdgesIterator &operator=(InEdgesIterator &&other) = delete; Option next(); }; class EdgeIterator : private Sized<8, 8> { public: template EdgeIterator(T &&d); EdgeIterator(const EdgeIterator &other) = delete; EdgeIterator(EdgeIterator &&other); ~EdgeIterator(); EdgeIterator &operator=(const EdgeIterator &other) = delete; EdgeIterator &operator=(EdgeIterator &&other) = delete; Option next(); }; class VertexPropertyKey : private Sized<8, 8> { public: template VertexPropertyKey(T &&d); VertexPropertyKey(const VertexPropertyKey &other) = default; VertexPropertyKey(VertexPropertyKey &&other) = default; ~VertexPropertyKey(); VertexPropertyKey &operator=(const VertexPropertyKey &other) = default; VertexPropertyKey &operator=(VertexPropertyKey &&other) = default; }; class EdgePropertyKey : private Sized<8, 8> { public: template EdgePropertyKey(T &&d); EdgePropertyKey(const EdgePropertyKey &other) = default; EdgePropertyKey(EdgePropertyKey &&other) = default; ~EdgePropertyKey(); EdgePropertyKey &operator=(const EdgePropertyKey &other) = default; EdgePropertyKey &operator=(EdgePropertyKey &&other) = default; }; template class VertexPropertyType : private Sized<8, 8> { public: template VertexPropertyType(T &&d); VertexPropertyType(const VertexPropertyType &other) = default; VertexPropertyType(VertexPropertyType &&other) = default; ~VertexPropertyType(){}; VertexPropertyType &operator=(const VertexPropertyType &other) = default; VertexPropertyType &operator=(VertexPropertyType &&other) = default; }; template class EdgePropertyType : private Sized<8, 8> { public: template EdgePropertyType(T &&d); EdgePropertyType(const EdgePropertyType &other) = default; EdgePropertyType(EdgePropertyType &&other) = default; ~EdgePropertyType(){}; EdgePropertyType &operator=(const EdgePropertyType &other) = default; EdgePropertyType &operator=(EdgePropertyType &&other) = default; }; template class BoltSerializer : private Sized<8, 8> { public: template BoltSerializer(T &&d); BoltSerializer(const BoltSerializer &other) = default; BoltSerializer(BoltSerializer &&other) = default; ~BoltSerializer(); BoltSerializer &operator=(const BoltSerializer &other) = default; BoltSerializer &operator=(BoltSerializer &&other) = default; void write(const VertexAccessor &vertex); void write(const EdgeAccessor &edge); void write(const Property &prop); void write_null(); void write(const Bool &prop); void write(const Float &prop); void write(const Double &prop); void write(const Int32 &prop); void write(const Int64 &prop); void write(const std::string &value); void write(const String &prop); template void handle(const T &prop); }; // ************ Here should be definitions of Unsized barrier classes // Original class can be Unsized barrier class if they are only used outside the // barrier through reference/pointer. // Usized barrier classes should: // --Have same name as original class or somethin more specific if it is // partialy specialized. // --Inherit Unsized class from common.hpp as protected. Blueprint: // class class_name: protected Unsized // --It should specify public methods which can be called on the original class. // // Blueprint: // class class_name : protected Unsized // { // public: // // }; class VertexPropertyFamily : protected Unsized { public: OptionPtr> index(); }; class EdgePropertyFamily : protected Unsized { public: OptionPtr> index(); }; class Label : protected Unsized { public: VertexIndex &index() const; }; class EdgeType : protected Unsized { public: friend bool operator<(const EdgeType &lhs, const EdgeType &rhs); friend bool operator==(const EdgeType &lhs, const EdgeType &rhs); EdgeIndex &index() const; }; template class VertexIndex : protected Unsized { public: // TODO: This iterator sometimes has known type. It can be added to this // border to avoid dynamic dispatch VertexIterator for_range(DbAccessor &, Border from = Border(), Border to = Border()); bool unique(); Order order(); }; template class EdgeIndex : protected Unsized { public: // TODO: This iterator has known type. It can be added to this border to // avoid dynamic dispatch EdgeIterator for_range(DbAccessor &, Border from = Border(), Border to = Border()); bool unique(); Order order(); }; class Db : protected Unsized { }; }