/*
 * Copyright (C) 2013 by
 *   MetraLabs GmbH (MLAB), GERMANY
 * and
 *   Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
 * All rights reserved.
 *
 * Contact: info@mira-project.org
 *
 * Commercial Usage:
 *   Licensees holding valid commercial licenses may use this file in
 *   accordance with the commercial license agreement provided with the
 *   software or, alternatively, in accordance with the terms contained in
 *   a written agreement between you and MLAB or NICR.
 *
 * GNU General Public License Usage:
 *   Alternatively, this file may be used under the terms of the GNU
 *   General Public License version 3.0 as published by the Free Software
 *   Foundation and appearing in the file LICENSE.GPL3 included in the
 *   packaging of this file. Please review the following information to
 *   ensure the GNU General Public License version 3.0 requirements will be
 *   met: http://www.gnu.org/copyleft/gpl.html.
 *   Alternatively you may (at your option) use any later version of the GNU
 *   General Public License if such license has been publicly approved by
 *   MLAB and NICR (or its successors, if any).
 *
 * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
 * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
 * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
 * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
 */

/**
 * @file unordered_map
 *    Serialization/Deserialization of STL unordered_map (a hash map).
 *
 *    The filename was chosen to match the STL standard.
 *    Instead of
 *      #include <unordered_map>
 *    use
 *      #include <serialization/adapters/std/unordered_map>
 *
 * @author Thanh Quang Trinh
 * @date   2013/07/27
 */

#ifndef _MIRA_SERIALIZATION_UNORDERED_MAP_
#define _MIRA_SERIALIZATION_UNORDERED_MAP_

#include <unordered_map>

#include <serialization/adapters/std/StlCollections.h>
#include <serialization/IsCollection.h>

namespace mira {

////////////////////////////////////////////////////////////////////////////////

// UNORDERED_MAP
template <typename Reflector, typename Key, typename T, typename Hash, typename Pred, typename Allocator>
void reflectRead(Reflector& r, std::unordered_map<Key, T, Hash, Pred, Allocator>& c)
{
	serialization::ReflectReadMap<Reflector, std::unordered_map <Key, T, Hash, Pred, Allocator> >::reflect(r, c);
}

template <typename Reflector, typename Key, typename T, typename Hash, typename Pred, typename Allocator>
void reflectWrite(Reflector& r, std::unordered_map<Key, T, Hash, Pred, Allocator>& c)
{
	serialization::ReflectWriteMap<Reflector, std::unordered_map<Key, T, Hash, Pred, Allocator> >::reflect(r, c);
}

template <typename Reflector, typename Key, typename T, typename Hash, typename Pred, typename Allocator>
void reflect(Reflector& r, std::unordered_map<Key, T, Hash, Pred, Allocator>& c)
{
	splitReflect(r, c);
}

template <typename Key, typename T, typename Hash, typename Pred, typename Allocator>
class IsCollection<std::unordered_map<Key, T, Hash, Pred, Allocator> > : public std::true_type {};

//////////////////////////////////////////////////////////////////////////////

// UNORDERED_MULTIMAP
template <typename Reflector, typename Key, typename T, typename Hash, typename Pred, typename Allocator>
void reflectRead(Reflector& r, std::unordered_multimap<Key, T, Hash, Pred, Allocator>& c)
{
	serialization::ReflectReadMap<Reflector, std::unordered_multimap<Key, T, Hash, Pred, Allocator> >::reflect(r, c);
}

template <typename Reflector, typename Key, typename T, typename Hash, typename Pred, typename Allocator>
void reflectWrite(Reflector& r, std::unordered_multimap<Key, T, Hash, Pred, Allocator>& c)
{
	serialization::ReflectWriteMap<Reflector, std::unordered_multimap<Key, T, Hash, Pred, Allocator> >::reflect(r, c);
}

template <typename Reflector, typename Key, typename T, typename Hash, typename Pred, typename Allocator>
void reflect(Reflector& r, std::unordered_multimap<Key, T, Hash, Pred, Allocator>& c)
{
	splitReflect(r, c);
}

template <typename Key, typename T, typename Hash, typename Pred, typename Allocator>
class IsCollection<std::unordered_multimap<Key, T, Hash, Pred, Allocator> > : public std::true_type {};

////////////////////////////////////////////////////////////////////////////////

} /* namespace mira */


#endif
