Skip to content

Commit 12f2735

Browse files
authored
Merge pull request #124 from heinezen/feature/shared_ptr_object
Allow retrieving `nyan::Object` handle as `shared_ptr`
2 parents 19e742a + 666d317 commit 12f2735

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

nyan/view.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017-2020 the nyan authors, LGPLv3+. See copying.md for legal info.
1+
// Copyright 2017-2025 the nyan authors, LGPLv3+. See copying.md for legal info.
22

33
#include "view.h"
44

@@ -25,6 +25,13 @@ Object View::get_object(const fqon_t &fqon) {
2525
return Object{fqon, shared_from_this()};
2626
}
2727

28+
const std::shared_ptr<Object> View::get_object_ptr(const fqon_t &fqon) {
29+
// test for object existence
30+
this->get_info(fqon);
31+
32+
return std::make_shared<Object>(Object::Restricted{}, fqon, shared_from_this());
33+
}
34+
2835

2936
const std::shared_ptr<ObjectState> &View::get_raw(const fqon_t &fqon, order_t t) const {
3037
auto state = this->state.get_obj_state(fqon, t);

nyan/view.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017-2020 the nyan authors, LGPLv3+. See copying.md for legal info.
1+
// Copyright 2017-2025 the nyan authors, LGPLv3+. See copying.md for legal info.
22
#pragma once
33

44
#include <memory>
@@ -31,6 +31,7 @@ class View : public std::enable_shared_from_this<View> {
3131
View(const std::shared_ptr<Database> &database);
3232

3333
Object get_object(const fqon_t &fqon);
34+
const std::shared_ptr<Object> get_object_ptr(const fqon_t &fqon);
3435

3536
const std::shared_ptr<ObjectState> &get_raw(const fqon_t &fqon, order_t t = LATEST_T) const;
3637

0 commit comments

Comments
 (0)