#ifndef COMMANDMAP_H
#define COMMANDMAP_H

#include <unordered_map>
#include <vector>
#include <memory>

class CommandMap
{
public:
    CommandMap();
    std::shared_ptr<CommandMap> get(uint32_t entry)
    {
        return access(entry, false);
    }
    std::shared_ptr<CommandMap> get(const std::vector<uint32_t> entries)
    {
        return access(entries, false);
    }
    std::shared_ptr<CommandMap> put(uint32_t entry)
    {
        return access(entry, true);
    }
    std::shared_ptr<CommandMap> put(const std::vector<uint32_t> entries)
    {
        return access(entries, true);
    }
    uint32_t command() const;
    void set_command(uint32_t command, bool user_mapping);
    bool empty() const;

protected:
    uint32_t m_commands[2];
    std::unordered_map<uint32_t, std::shared_ptr<CommandMap>> m_children;

    std::shared_ptr<CommandMap> access(uint32_t entry, bool insert);
    std::shared_ptr<CommandMap> access(const std::vector<uint32_t> entries, bool insert);
};

#endif
