#pragma once #include #include namespace erebos { using std::optional; using std::vector; template class Signed; struct IdentityData; struct StoredIdentityPart; class Identity { public: Identity(const Identity &) = default; Identity(Identity &&) = default; Identity & operator=(const Identity &) = default; Identity & operator=(Identity &&) = default; static std::optional load(const Ref &); static std::optional load(const std::vector &); static std::optional load(const std::vector>> &); static std::optional load(const std::vector &); std::vector store() const; std::vector store(const Storage & st) const; vector>> data() const; vector extData() const; std::optional name() const; std::optional owner() const; const Identity & finalOwner() const; Stored keyIdentity() const; Stored keyMessage() const; bool sameAs(const Identity &) const; bool operator==(const Identity & other) const; bool operator!=(const Identity & other) const; std::optional ref() const; std::vector refs() const; std::vector updates() const; class Builder { public: Identity commit() const; void name(const std::string &); void owner(const Identity &); private: friend class Identity; struct Priv; const std::shared_ptr p; Builder(Priv * p); }; static Builder create(const Storage &); Builder modify() const; Identity update(const vector>> &) const; Identity update(const vector &) const; private: struct Priv; std::shared_ptr p; Identity(const Priv * p); Identity(std::shared_ptr && p); }; struct IdentityData; struct IdentityExtension; struct StoredIdentityPart { using Part = variant< Stored>, Stored>>; StoredIdentityPart(Part p): part(move(p)) {} static StoredIdentityPart load(const Ref &); Ref store(const Storage & st) const; bool operator==(const StoredIdentityPart & other) const { return part == other.part; } bool operator<(const StoredIdentityPart & other) const { return part < other.part; } const Ref & ref() const; const Stored> & base() const; vector previous() const; vector roots() const; optional name() const; optional owner() const; bool isSignedBy(const Stored &) const; Part part; }; DECLARE_SHARED_TYPE(optional) }