<commit_before>//
//  yas_db_object_event.cpp
//

#include "yas_db_object_event.h"

#include "yas_db_object.h"

using namespace yas;
using namespace yas::db;

namespace yas::db {
static db::object_ptr const _empty_object = nullptr;
static db::object_id const _empty_object_id = nullptr;
static std::string const _empty_string;
static std::vector<std::size_t> const _empty_indices;
static db::value const _empty_value = nullptr;

struct object_fetched_event {
    static object_event_type const type = object_event_type::fetched;
    db::object_ptr const &object;
};

struct object_loaded_event {
    static object_event_type const type = object_event_type::loaded;
    db::object_ptr const &object;
};

struct object_cleared_event {
    static object_event_type const type = object_event_type::cleared;
    db::object_ptr const &object;
};

struct object_attribute_updated_event {
    static object_event_type const type = object_event_type::attribute_updated;
    db::object_ptr const &object;
    std::string const name;
    db::value const &value;
};

struct object_relation_inserted_event {
    static object_event_type const type = object_event_type::relation_inserted;
    db::object_ptr const &object;
    std::string const name;
    std::vector<std::size_t> const indices;
};

struct object_relation_removed_event {
    static object_event_type const type = object_event_type::relation_removed;
    db::object_ptr const &object;
    std::string const name;
    std::vector<std::size_t> const indices;
};

struct object_relation_replaced_event {
    static object_event_type const type = object_event_type::relation_replaced;
    db::object_ptr const &object;
    std::string const name;
};

struct object_erased_event {
    static object_event_type const type = object_event_type::erased;
    std::string const &entity_name;
    db::object_id const &object_id;
};
}  // namespace yas::db

object_event db::object_event::make_fetched(db::object_ptr const &object) {
    return object_event{object_fetched_event{.object = object}};
}

object_event db::object_event::make_loaded(db::object_ptr const &object) {
    return object_event{object_loaded_event{.object = object}};
}

object_event db::object_event::make_cleared(db::object_ptr const &object) {
    return object_event{object_cleared_event{.object = object}};
}

object_event db::object_event::make_attribute_updated(db::object_ptr const &object, std::string const &name,
                                                      db::value const &value) {
    return object_event{object_attribute_updated_event{.object = object, .name = name, .value = value}};
}

object_event db::object_event::make_relation_inserted(db::object_ptr const &object, std::string const &name,
                                                      std::vector<std::size_t> &&indices) {
    return object_event{object_relation_inserted_event{.object = object, .name = name, .indices = std::move(indices)}};
}

object_event db::object_event::make_relation_removed(db::object_ptr const &object, std::string const &name,
                                                     std::vector<std::size_t> &&indices) {
    return object_event{object_relation_removed_event{.object = object, .name = name, .indices = std::move(indices)}};
}

object_event db::object_event::make_relation_replaced(db::object_ptr const &object, std::string const &name) {
    return object_event{object_relation_replaced_event{.object = object, .name = name}};
}

object_event db::object_event::make_erased(std::string const &entity_name, db::object_id const &object_id) {
    return object_event{object_erased_event{.entity_name = entity_name, .object_id = object_id}};
}

struct object_event::impl_base {
    virtual object_event_type type() {
        throw std::runtime_error("type() must be overridden");
    }
};

template <typename Event>
struct object_event::impl : object_event::impl_base {
    Event const event;

    impl(Event &&event) : event(std::move(event)) {
    }

    object_event_type type() override {
        return Event::type;
    }
};

object_event::object_event(std::shared_ptr<impl_base> &&impl)
    : _impl(std::move(impl)),
      _type(object_event_type::fetched),
      _object(_empty_object),
      _object_id(_empty_object_id),
      _name(_empty_string),
      _entity_name(_empty_string),
      _indices(_empty_indices),
      _value(_empty_value) {
}

object_event::object_event(object_fetched_event &&event)
    : _type(object_event_type::fetched),
      _object(event.object),
      _object_id(_empty_object_id),
      _name(_empty_string),
      _entity_name(_empty_string),
      _indices(_empty_indices),
      _value(_empty_value) {
}

object_event::object_event(object_loaded_event &&event)
    : object_event(std::make_shared<impl<object_loaded_event>>(std::move(event))) {
}

object_event::object_event(object_cleared_event &&event)<commit_msg>loaded_event<commit_after>//
//  yas_db_object_event.cpp
//

#include "yas_db_object_event.h"

#include "yas_db_object.h"

using namespace yas;
using namespace yas::db;

namespace yas::db {
static db::object_ptr const _empty_object = nullptr;
static db::object_id const _empty_object_id = nullptr;
static std::string const _empty_string;
static std::vector<std::size_t> const _empty_indices;
static db::value const _empty_value = nullptr;

struct object_fetched_event {
    static object_event_type const type = object_event_type::fetched;
    db::object_ptr const &object;
};

struct object_loaded_event {
    static object_event_type const type = object_event_type::loaded;
    db::object_ptr const &object;
};

struct object_cleared_event {
    static object_event_type const type = object_event_type::cleared;
    db::object_ptr const &object;
};

struct object_attribute_updated_event {
    static object_event_type const type = object_event_type::attribute_updated;
    db::object_ptr const &object;
    std::string const name;
    db::value const &value;
};

struct object_relation_inserted_event {
    static object_event_type const type = object_event_type::relation_inserted;
    db::object_ptr const &object;
    std::string const name;
    std::vector<std::size_t> const indices;
};

struct object_relation_removed_event {
    static object_event_type const type = object_event_type::relation_removed;
    db::object_ptr const &object;
    std::string const name;
    std::vector<std::size_t> const indices;
};

struct object_relation_replaced_event {
    static object_event_type const type = object_event_type::relation_replaced;
    db::object_ptr const &object;
    std::string const name;
};

struct object_erased_event {
    static object_event_type const type = object_event_type::erased;
    std::string const &entity_name;
    db::object_id const &object_id;
};
}  // namespace yas::db

object_event db::object_event::make_fetched(db::object_ptr const &object) {
    return object_event{object_fetched_event{.object = object}};
}

object_event db::object_event::make_loaded(db::object_ptr const &object) {
    return object_event{object_loaded_event{.object = object}};
}

object_event db::object_event::make_cleared(db::object_ptr const &object) {
    return object_event{object_cleared_event{.object = object}};
}

object_event db::object_event::make_attribute_updated(db::object_ptr const &object, std::string const &name,
                                                      db::value const &value) {
    return object_event{object_attribute_updated_event{.object = object, .name = name, .value = value}};
}

object_event db::object_event::make_relation_inserted(db::object_ptr const &object, std::string const &name,
                                                      std::vector<std::size_t> &&indices) {
    return object_event{object_relation_inserted_event{.object = object, .name = name, .indices = std::move(indices)}};
}

object_event db::object_event::make_relation_removed(db::object_ptr const &object, std::string const &name,
                                                     std::vector<std::size_t> &&indices) {
    return object_event{object_relation_removed_event{.object = object, .name = name, .indices = std::move(indices)}};
}

object_event db::object_event::make_relation_replaced(db::object_ptr const &object, std::string const &name) {
    return object_event{object_relation_replaced_event{.object = object, .name = name}};
}

object_event db::object_event::make_erased(std::string const &entity_name, db::object_id const &object_id) {
    return object_event{object_erased_event{.entity_name = entity_name, .object_id = object_id}};
}

struct object_event::impl_base {
    virtual object_event_type type() {
        throw std::runtime_error("type() must be overridden");
    }
};

template <typename Event>
struct object_event::impl : object_event::impl_base {
    Event const event;

    impl(Event &&event) : event(std::move(event)) {
    }

    object_event_type type() override {
        return Event::type;
    }
};

object_event::object_event(std::shared_ptr<impl_base> &&impl)
    : _impl(std::move(impl)),
      _type(object_event_type::fetched),
      _object(_empty_object),
      _object_id(_empty_object_id),
      _name(_empty_string),
      _entity_name(_empty_string),
      _indices(_empty_indices),
      _value(_empty_value) {
}

object_event::object_event(object_fetched_event &&event)
    : _type(object_event_type::fetched),
      _object(event.object),
      _object_id(_empty_object_id),
      _name(_empty_string),
      _entity_name(_empty_string),
      _indices(_empty_indices),
      _value(_empty_value) {
}

object_event::object_event(object_loaded_event &&event)
    : _type(object_event_type::loaded),
      _object(event.object),
      _object_id(_empty_object_id),
      _name(_empty_string),
      _entity_name(_empty_string),
      _indices(_empty_indices),
      _value(_empty_value) {
}

object_event::object_event(object_cleared_event &&event)
{'fraction_non_alphanumeric': 0.11042883027984698, 'fraction_numerical': 0.0, 'mean_word_length': 4.677142857142857, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2547572', 'n_tokens_mistral': 3109, 'n_tokens_neox': 3071, 'n_words': 581}