Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
1 /* Copyright 2003-2005 Joaquín M López Muñoz.
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
6 * See http://www.boost.org/libs/multi_index for library home page.
9 #ifndef BOOST_MULTI_INDEX_DETAIL_INDEX_LOADER_HPP
10 #define BOOST_MULTI_INDEX_DETAIL_INDEX_LOADER_HPP
12 #if defined(_MSC_VER)&&(_MSC_VER>=1200)
16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
18 #include <boost/archive/archive_exception.hpp>
19 #include <boost/noncopyable.hpp>
20 #include <boost/multi_index/detail/auto_space.hpp>
21 #include <boost/serialization/nvp.hpp>
22 #include <boost/throw_exception.hpp>
27 namespace multi_index{
31 /* Counterpart of index_saver (check index_saver.hpp for serialization
32 * details.)* multi_index_container is in charge of supplying the info about
33 * the base sequence, and each index can subsequently load itself using the
34 * const interface of index_loader.
37 template<typename Node,typename FinalNode,typename Allocator>
38 class index_loader:private noncopyable
41 index_loader(const Allocator& al,std::size_t size):
42 spc(al,size),size_(size),n(0),sorted(false)
46 template<class Archive>
47 void add(Node* node,Archive& ar,const unsigned int)
49 ar>>serialization::make_nvp("position",*node);
53 template<class Archive>
54 void add_track(Node* node,Archive& ar,const unsigned int)
56 ar>>serialization::make_nvp("position",*node);
59 /* A rearranger is passed two nodes, and is expected to
60 * reposition the second after the first.
61 * If the first node is 0, then the second should be moved
62 * to the beginning of the sequence.
65 template<typename Rearranger,class Archive>
66 void load(Rearranger r,Archive& ar,const unsigned int)const
68 FinalNode* prev=unchecked_load_node(ar);
72 std::sort(entries(),entries()+size_);
80 FinalNode* node=load_node(ar);
94 Node** entries()const{return spc.data();}
96 /* We try to delay sorting as much as possible just in case it
97 * is not necessary, hence this version of load_node.
100 template<class Archive>
101 FinalNode* unchecked_load_node(Archive& ar)const
104 ar>>serialization::make_nvp("pointer",node);
105 return static_cast<FinalNode*>(node);
108 template<class Archive>
109 FinalNode* load_node(Archive& ar)const
112 ar>>serialization::make_nvp("pointer",node);
114 return static_cast<FinalNode*>(node);
117 void check_node(Node* node)const
119 if(node!=0&&!std::binary_search(entries(),entries()+size_,node)){
121 archive::archive_exception(
122 archive::archive_exception::other_exception));
126 auto_space<Node*,Allocator> spc;
132 } /* namespace multi_index::detail */
134 } /* namespace multi_index */
136 } /* namespace boost */