Skip to content

src/storage/trie/supergenius_trie/supergenius_trie_factory.hpp

Namespaces

Name
sgns
sgns::storage
sgns::storage::trie

Classes

Name
class sgns::storage::trie::SuperGeniusTrieFactory

Source code

#ifndef SUPERGENIUS_STORAGE_TRIE_IMPL_SUPERGENIUS_TRIE_FACTORY
#define SUPERGENIUS_STORAGE_TRIE_IMPL_SUPERGENIUS_TRIE_FACTORY

#include "storage/trie/supergenius_trie/supergenius_trie.hpp"
#include "singleton/IComponent.hpp"

namespace sgns::storage::trie {

  class SuperGeniusTrieFactory : public IComponent {
   public:
    using ChildRetrieveFunctor =
        std::function<outcome::result<SuperGeniusTrie::NodePtr>(
            SuperGeniusTrie::BranchPtr, uint8_t)>;

   protected:
    static outcome::result<SuperGeniusTrie::NodePtr> defaultChildRetriever(
        const SuperGeniusTrie::BranchPtr& branch, uint8_t idx) {
      return branch->children.at(idx);
    };

   public:
    virtual std::unique_ptr<SuperGeniusTrie> createEmpty(
        ChildRetrieveFunctor f = defaultChildRetriever) const = 0;

    virtual std::unique_ptr<SuperGeniusTrie> createFromRoot(
        SuperGeniusTrie::NodePtr root,
        ChildRetrieveFunctor f = defaultChildRetriever) const = 0;

    ~SuperGeniusTrieFactory() override = default;
  };

}  // namespace sgns::storage::trie

#endif  // SUPERGENIUS_STORAGE_TRIE_IMPL_SUPERGENIUS_TRIE_FACTORY

Updated on 2026-03-04 at 13:10:45 -0800