insert_query_builder progress
This commit is contained in:
@@ -33,7 +33,8 @@ public:
|
||||
object_proxy(std::weak_ptr<object_resolver<Type>> resolver, std::shared_ptr<Type> obj)
|
||||
: obj_(obj)
|
||||
, resolver_(resolver)
|
||||
, pk_(primary_key_resolver::resolve_object(*obj).pk) {
|
||||
, pk_(primary_key_resolver::resolve_object(*obj).pk)
|
||||
, state_(object_state::Persistent){
|
||||
}
|
||||
|
||||
// Transient
|
||||
@@ -60,8 +61,9 @@ public:
|
||||
bool is_transient() const { return state_ == object_state::Transient; }
|
||||
bool is_detached() const { return state_ == object_state::Detached; }
|
||||
bool is_removed() const { return state_ == object_state::Removed; }
|
||||
|
||||
void change_state(const object_state state) {
|
||||
state_ = state;
|
||||
state_.store(state, std::memory_order_release);
|
||||
}
|
||||
private:
|
||||
Type* resolve() const {
|
||||
@@ -86,7 +88,7 @@ private:
|
||||
std::shared_ptr<Type> obj_{};
|
||||
std::weak_ptr<object_resolver<Type>> resolver_{};
|
||||
utils::identifier pk_{};
|
||||
object_state state_{object_state::Transient};
|
||||
std::atomic<object_state> state_{object_state::Transient};
|
||||
mutable std::mutex mutex_{};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ public:
|
||||
|
||||
void reset() { proxy_.reset(); }
|
||||
|
||||
operator bool() { return valid(); }
|
||||
bool valid() { return proxy_ != nullptr; }
|
||||
operator bool() const { return valid(); }
|
||||
[[nodiscard]] bool valid() const { return proxy_ != nullptr; }
|
||||
|
||||
[[nodiscard]] bool has_primary_key() const { return proxy_->has_primary_key(); }
|
||||
[[nodiscard]] const utils::identifier &primary_key() const { return proxy_->primary_key(); }
|
||||
@@ -53,6 +53,11 @@ public:
|
||||
[[nodiscard]] bool is_detached() const { return !proxy_->is_detached(); }
|
||||
[[nodiscard]] bool is_removed() const { return !proxy_->is_removed(); }
|
||||
|
||||
void change_state(object_state s) {
|
||||
if (proxy_) {
|
||||
proxy_->change_state(s);
|
||||
}
|
||||
}
|
||||
private:
|
||||
std::shared_ptr<object_proxy<Type> > proxy_{};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user