/*************************************************************************
 * odil - Copyright (C) Universite de Strasbourg
 * Distributed under the terms of the CeCILL-B license, as published by
 * the CEA-CNRS-INRIA. Refer to the LICENSE file or to
 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
 * for details.
 ************************************************************************/

#include "odil/registry.h"

#include <map>
#include <string>

#include "odil/ElementsDictionary.h"
#include "odil/Tag.h"
#include "odil/UIDsDictionary.h"

namespace odil
{

namespace registry
{

{% for group in groups %}
void update_{{ group }}(ElementsDictionary &, std::map<std::string, odil::Tag> &);
{% endfor %}

void update_uids_dictionary(UIDsDictionary & uids_dictionary)
{
{% for entry in uids %}
    uids_dictionary.emplace("{{ entry[0] }}", UIDsDictionaryEntry("{{ entry[1] }}", "{{ entry[2] }}",  "{{ entry[3] }}"));
{% endfor %}
}

bool update(
    odil::ElementsDictionary & public_dictionary,
    std::map<std::string, odil::Tag> & public_tags,
    odil::UIDsDictionary & uids_dictionary)
{
{% for group in groups %}
    update_{{ group }}(public_dictionary, public_tags);
{% endfor %}

    update_uids_dictionary(uids_dictionary);

    return true;
}

}

}

odil::ElementsDictionary odil::registry::public_dictionary = {};
std::map<std::string, odil::Tag> odil::registry::public_tags = {};
odil::UIDsDictionary odil::registry::uids_dictionary = {};
bool const odil::registry::dummy = odil::registry::update(
    odil::registry::public_dictionary,
    odil::registry::public_tags,
    odil::registry::uids_dictionary);
