[odb-users] access cached instances of a certain type?

Boris Kolpackov boris at codesynthesis.com
Thu Sep 24 11:50:48 EDT 2015


Hi Christian,

Christian Sell <christian at gsvitec.com> writes:

> I think would need a way to get all cached MyClass objects and check
> by id whether the passed-in objects match or not... I did not find
> such API on odb::session, so I thought I'd ask

Did you see this?

namespace odb
{
  class session
  {
    // Low-level object cache access (iteration, etc).
    //
  public:
    typedef std::map<const std::type_info*,
                     details::shared_ptr<object_map_base>,
                     details::type_info_comparator> type_map;

    typedef std::map<database_type*, type_map> database_map;

    database_map&
    map () {return db_map_;}

    const database_map&
    map () const {return db_map_;}

  };
}

This is the start of the rabbit hole and you can go as deep as you
would like.

Also note that you can provide a custom session implementation (see
odb-tests/common/session/custom/).

Boris



More information about the odb-users mailing list