/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2012 University of California, Los Angeles
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
 *         卞超轶 Chaoyi Bian <bcy@pku.edu.cn>
 *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
 */

#ifndef SYNC_STATE_LEAF_CONTAINER
#define SYNC_STATE_LEAF_CONTAINER

#include "sync-leaf.h"
#include "sync-name-info.h"

#include <boost/multi_index_container.hpp>
// #include <boost/multi_index/tag.hpp>
#include <boost/multi_index/ordered_index.hpp>
// #include <boost/multi_index/composite_key.hpp>
#include <boost/multi_index/hashed_index.hpp>
// #include <boost/multi_index/random_access_index.hpp>
// #include <boost/multi_index/member.hpp>
#include <boost/multi_index/mem_fun.hpp>

namespace mi = boost::multi_index;

namespace Sync {

struct NameInfoHash : public std::unary_function<NameInfo, std::size_t>
{
  std::size_t
  operator() (NameInfoConstPtr prefix) const
  {
    return prefix->getHashId ();
  }
};

struct NameInfoEqual : public std::unary_function<NameInfo, std::size_t>
{
  bool
  operator() (NameInfoConstPtr prefix1, NameInfoConstPtr prefix2) const
  {
    return *prefix1 == *prefix2;
  }
};

struct NameInfoCompare : public std::unary_function<NameInfo, std::size_t>
{
  bool
  operator() (NameInfoConstPtr prefix1, NameInfoConstPtr prefix2) const
  {
    return *prefix1 < *prefix2;
  }
};

/// @cond include_hidden 
struct hashed { };
struct ordered { };
/// @endcond

/**
 * \ingroup sync
 * @brief Container for SYNC leaves
 */
struct LeafContainer : public mi::multi_index_container<
  LeafPtr,
  mi::indexed_by<
    // For fast access to elements using NameInfo
    mi::hashed_unique<
      mi::tag<hashed>,
      mi::const_mem_fun<Leaf, NameInfoConstPtr, &Leaf::getInfo>,
      NameInfoHash,
      NameInfoEqual
      >,
        
    mi::ordered_unique<
      mi::tag<ordered>,
      mi::const_mem_fun<Leaf, NameInfoConstPtr, &Leaf::getInfo>,
      NameInfoCompare
      >
    >
  >
{
};

} // Sync

#endif // SYNC_STATE_LEAF_CONTAINER
