owlcpp  v0.3.3~
C++ library for working with OWL ontologies
 All Classes Namespaces Files Functions Macros Pages
map_triple_crtpb.hpp
Go to the documentation of this file.
1 
6 #ifndef MAP_TRIPLE_CRTPB_HPP_
7 #define MAP_TRIPLE_CRTPB_HPP_
8 #include "boost/assert.hpp"
9 #include "boost/concept/assert.hpp"
10 
11 #include "owlcpp/detail/map_traits.hpp"
12 
13 namespace owlcpp{
14 
18 template<class Super> class Map_triple_crtpb {
19  typedef detail::Map_traits<Super> traits;
20  typedef typename traits::map_triple_type map_triple_type;
21 
22  map_triple_type const& _map_triple() const {
23  return static_cast<Super const&>(*this).map_triple_;
24  }
25 
26  map_triple_type& _map_triple() {
27  return static_cast<Super&>(*this).map_triple_;
28  }
29 
30 public:
31 
32  template<class Subj, class Pred, class Obj, class Doc> struct result
33  : public map_triple_type::template result<Subj,Pred,Obj,Doc>{};
34 
35  template<bool Subj, bool Pred, bool Obj, bool Doc>struct result_b
36  : public map_triple_type::template result_b<Subj,Pred,Obj,Doc>{};
37 
66  template<class Subj, class Pred, class Obj, class Doc>
68  find_triple(const Subj subj, const Pred pred, const Obj obj, const Doc doc) const {
69  return _map_triple().find(subj, pred, obj, doc);
70  }
71 
75  const Node_id subj,
76  const Node_id pred,
77  const Node_id obj,
78  const Doc_id doc
79  ) {
80  BOOST_CONCEPT_ASSERT((Node_store<Super>));
81  BOOST_ASSERT(
82  static_cast<Super const&>(*this).find(subj) &&
83  "invalid subject ID"
84  );
85  BOOST_ASSERT(
86  static_cast<Super const&>(*this).find(pred) &&
87  "invalid predicate ID"
88  );
89  BOOST_ASSERT(
90  static_cast<Super const&>(*this).find(obj) &&
91  "invalid object ID"
92  );
93  BOOST_ASSERT( static_cast<Super const&>(*this).find(doc) &&
94  "invalid document ID"
95  );
96  _map_triple().insert(subj, pred, obj, doc);
97  }
98 
99 };
100 
101 }//namespace owlcpp
102 #endif /* MAP_TRIPLE_CRTPB_HPP_ */