5 #ifndef ODB_POLYMORPHIC_MAP_HXX
6 #define ODB_POLYMORPHIC_MAP_HXX
18 #include <odb/details/config.hxx>
19 #include <odb/details/type-info.hxx>
26 struct polymorphic_map
35 find (
const std::type_info& t)
const;
42 std::map<
const std::type_info*,
44 odb::details::type_info_comparator>
60 discriminator_comparator>
69 template <
typename R, database_
id DB>
90 typedef typename derived_traits::pointer_type derived_pointer_type;
91 typedef typename root_traits::pointer_type root_pointer_type;
93 derived_pointer_type p (
99 root_pointer_type r (std::move (p));
101 root_pointer_type r (p);
106 template <
typename T, database_
id DB,
typename R>
116 template <
typename R, database_
id DB>
126 template <
typename T, database_
id DB,
bool auto_
id>
138 template <
typename T, database_
id DB>
147 db, const_cast<T&> (obj),
true,
false);
151 template <
typename T, database_
id DB>
161 typedef typename derived_traits::root_type root_type;
163 typedef typename root_traits::id_type id_type;
170 case info_type::call_callback:
172 derived_traits::callback (
174 *const_cast<T*> (static_cast<const T*> (pobj)),
175 *static_cast<const callback_event*> (arg));
178 case info_type::call_persist:
182 *static_cast<const T*> (pobj));
185 case info_type::call_update:
187 derived_traits::update (
189 *static_cast<const T*> (pobj),
194 case info_type::call_find:
196 r = derived_traits::find (
198 *static_cast<const id_type*> (arg),
199 *const_cast<T*> (static_cast<const T*> (pobj)),
203 case info_type::call_reload:
205 r = derived_traits::reload (
207 *const_cast<T*> (static_cast<const T*> (pobj)),
211 case info_type::call_load:
215 *const_cast<T*> (static_cast<const T*> (pobj)),
216 *static_cast<const std::size_t*> (arg));
219 case info_type::call_erase:
222 derived_traits::erase (
224 *static_cast<const T*> (pobj),
228 derived_traits::erase (
230 *static_cast<const id_type*> (arg),
240 template <
typename T, database_
id DB,
typename ST>
247 typedef typename derived_traits::statements_type statements_type;
248 typedef typename statements_type::connection_type connection_type;
250 connection_type& c (static_cast<connection_type&> (conn));
251 statements_type& sts (c.statement_cache ().template find_object<T> ());
253 ST::load (sts.extra_statement_cache (),
static_cast<T&
> (obj), top);
256 template <
typename T, database_
id DB,
typename ST>
262 typedef typename derived_traits::statements_type statements_type;
263 typedef typename statements_type::connection_type connection_type;
265 connection_type& c (static_cast<connection_type&> (conn));
266 statements_type& sts (c.statement_cache ().template find_object<T> ());
268 ST::update (sts.extra_statement_cache (),
static_cast<const T&
> (obj));
272 #include <odb/polymorphic-map.ixx>
273 #include <odb/polymorphic-map.txx>
277 #endif // ODB_POLYMORPHIC_MAP_HXX
std::map< const discriminator_type *, const info_type *, discriminator_comparator > discriminator_map
Definition: polymorphic-map.hxx:61
Definition: polymorphic-info.hxx:103
object_traits< typename object_traits< T >::root_type >::pointer_type create_impl()
Definition: polymorphic-map.hxx:85
static void call(database &db, const T &obj)
Definition: polymorphic-map.hxx:142
static void insert(const info_type &)
info_type::discriminator_type discriminator_type
Definition: polymorphic-map.hxx:30
Definition: polymorphic-map.hxx:107
polymorphic_concrete_info< root_type > info_type
Definition: polymorphic-map.hxx:74
Definition: polymorphic-map.hxx:47
static void call(database &db, const T &obj)
Definition: polymorphic-map.hxx:130
Definition: forward.hxx:123
root_traits::discriminator_type discriminator_type
Definition: polymorphic-info.hxx:111
Definition: forward.hxx:101
Definition: forward.hxx:126
std::size_t ref_count_
Definition: polymorphic-map.hxx:64
type_map type_map_
Definition: polymorphic-map.hxx:65
bool operator()(const discriminator_type *x, const discriminator_type *y) const
Definition: polymorphic-map.hxx:50
static void call(database &db, T &obj, std::size_t d)
Definition: polymorphic-map.hxx:110
Definition: polymorphic-map.hxx:70
Definition: polymorphic-map.hxx:127
static void erase(const info_type &)
std::map< const std::type_info *, const info_type *, odb::details::type_info_comparator > type_map
Definition: polymorphic-map.hxx:45
Definition: database.hxx:38
const info_type & find(const std::type_info &t) const
Definition: connection.hxx:33
discriminator_map discriminator_map_
Definition: polymorphic-map.hxx:66
polymorphic_concrete_info< root_type > info_type
Definition: polymorphic-map.hxx:29
void section_update_impl(odb::connection &conn, const typename object_traits< T >::root_type &obj)
Definition: polymorphic-map.hxx:258
bool dispatch_impl(typename polymorphic_concrete_info< typename object_traits< T >::root_type >::call_type c, database &db, const typename object_traits< T >::root_type *pobj, const void *arg)
Definition: polymorphic-map.hxx:153
R root_type
Definition: polymorphic-map.hxx:72
static void call(database &, R &, std::size_t)
Definition: polymorphic-map.hxx:120
R root_type
Definition: polymorphic-map.hxx:28
polymorphic_map()
Definition: polymorphic-map.hxx:32
object_traits_impl< root_type, DB > root_traits
Definition: polymorphic-map.hxx:73
void section_load_impl(odb::connection &conn, typename object_traits< T >::root_type &obj, bool top)
Definition: polymorphic-map.hxx:242