#pragma once #include #include "storage/indexes/index_base.hpp" #include "utils/option.hpp" #include "utils/option_ptr.hpp" namespace tx { class Transaction; } // Holds onde index which can be changed. // TG - type group // K - key of index_records template class IndexHolder { public: IndexHolder() = default; IndexHolder(IndexHolder const &) = delete; IndexHolder(IndexHolder &&) = default; // Sets index for this property family. Treturns false if index is already // present. bool set_index(std::unique_ptr> inx); // Returns index for read only if it is present and it's valid for read. OptionPtr> get_read() const; // Returns index for write only if it's present and transaction is // responsibly for updating it. OptionPtr> get_write(const tx::Transaction &t) const; // Removes index if it is given index. Caller is now responsable of // disposing index in a safe way. Option>> remove_index(IndexBase *index); // Caller is now responsable of disposing index in a safe way. Option>> remove_index(); private: std::atomic *> index = {nullptr}; };