6 #ifndef MAP_TRIPLE_HPP_
7 #define MAP_TRIPLE_HPP_
8 #include "boost/fusion/include/at.hpp"
9 #include "boost/fusion/include/for_each.hpp"
10 #include "boost/fusion/include/front.hpp"
11 #include "boost/fusion/include/mpl.hpp"
12 #include "boost/mpl/assert.hpp"
13 #include "boost/mpl/at.hpp"
14 #include "boost/mpl/fold.hpp"
15 #include "boost/mpl/if.hpp"
16 #include "boost/mpl/push_back.hpp"
17 #include "boost/mpl/vector.hpp"
18 #include "boost/mpl/vector_c.hpp"
20 #include "owlcpp/rdf/detail/map_triple_config.hpp"
21 #include "owlcpp/rdf/detail/triple_index.hpp"
27 template<
bool Index_subj,
bool Index_pred,
bool Index_obj,
bool Index_doc>
31 map_triple_detail::Store_config<Index_subj,Index_pred,Index_obj,Index_doc>
34 typedef typename config::store store;
35 typedef typename boost::mpl::front<store>::type main_store;
36 BOOST_MPL_ASSERT((boost::is_same<typename main_store::tag, map_triple_detail::Main_store_tag>));
40 Insert(
Triple const& t) : t_(t) {}
41 template<
class Ind>
void operator()(Ind& i)
const {i.add(t_);}
47 template<
class Ind>
void operator()(Ind& i)
const {i.clear();}
52 Erase(
Triple const& t) : t_(t) {}
53 template<
class Ind>
void operator()(Ind& i)
const {i.erase(t_);}
59 typedef typename main_store::const_iterator const_iterator;
60 typedef typename main_store::const_iterator iterator;
68 template<
class Subj,
class Pred,
class Obj,
class Doc>
struct result {
70 map_triple_detail::Search_config<config,Subj,Pred,Obj,Doc>::range
81 template<
bool Subj,
bool Pred,
bool Obj,
bool Doc>
83 typedef typename map_triple_detail::Deduce_args<Subj,Pred,Obj,Doc>::type
88 typename boost::mpl::at_c<q_args,0>::type,
89 typename boost::mpl::at_c<q_args,1>::type,
90 typename boost::mpl::at_c<q_args,2>::type,
91 typename boost::mpl::at_c<q_args,3>::type
97 std::size_t
size()
const {
return boost::fusion::front(store_).get_range().size();}
98 bool empty()
const {
return boost::fusion::front(store_).get_range().empty();}
99 const_iterator begin()
const {
return boost::fusion::front(store_).get_range().begin();}
100 const_iterator end()
const {
return boost::fusion::front(store_).get_range().end();}
104 boost::fusion::for_each(store_, c);
113 boost::fusion::for_each(store_, e);
124 const Triple t = Triple::make(subj, pred, obj, doc);
126 boost::fusion::for_each(store_, ins);
155 template<
class Subj,
class Pred,
class Obj,
class Doc>
156 typename result<Subj,Pred,Obj,Doc>::type
157 find(
const Subj subj,
const Pred pred,
const Obj obj,
const Doc doc)
const {
164 typedef map_triple_detail::Search_config<config,Subj,Pred,Obj,Doc> search_config;
165 typedef typename search_config::index_num index_num;
166 typedef typename boost::mpl::at<store, index_num>::type index_t;
167 index_t
const& index = boost::fusion::at<index_num>(store_);
168 typedef typename index_t::const_range range1_t;
169 const range1_t r1 = map_triple_detail::Search_range1<index_t>::get(index,subj,pred,obj,doc);
170 return search_config::search::get(r1, subj, pred, obj, doc);