2#ifndef _TINYPBRT_OBJECT_HPP_
3#define _TINYPBRT_OBJECT_HPP_
21 struct object : detail::wrapper<object, tpbrt_object_t> {
23 using wrapper::wrapper;
26 [[nodiscard]]
constexpr string name() const noexcept {
return _native->name; }
35 [[nodiscard]]
constexpr auto end() const noexcept {
return children().
end(); }
38 [[nodiscard]]
constexpr object_idx_t idx() const noexcept {
return _native->idx; }
48 struct object_handle : detail::wrapper<object_handle, tpbrt_object_handle_t> {
50 using wrapper::wrapper;
56 [[nodiscard]]
constexpr auto reflect() const noexcept {
return std::make_tuple(
object_idx()); }
73 using array::operator[];
83 detail::to_native_string(name));
101 return list.at(handle);
112 return list.at(name);
tpbrt_object_idx_t object_idx_t
Object index type.
Definition fwd.hpp:293
result< object > get_object(const objects_list list, const object_handle handle) noexcept
Returns object to which handle is provided.
Definition object.hpp:100
tpbrt_error_t tpbrt_get_object_by_name(const tpbrt_objects_list_t *objects, tpbrt_string_t name, const tpbrt_object_t **object)
Returns pointer to object with given name.
tpbrt_error_t tpbrt_get_object_by_handle(const tpbrt_objects_list_t *objects, tpbrt_object_handle_t handle, const tpbrt_object_t **object)
Returns pointer to object to which handle is provided.
Definition accelerator.hpp:14
Generic C++ array view with type conversion (a non owning view on memory owned by the C library).
Definition common.hpp:448
constexpr iterator end() const noexcept
Returns end iterator.
Definition common.hpp:507
constexpr iterator begin() const noexcept
Returns begin iterator.
Definition common.hpp:501
constexpr result< element_type > at(const size_t index) const noexcept
Returns element on given index or error::INDEX_OUT_OF_RANGE.
Definition common.hpp:519
C++ wrapper for tpbrt_object_handle_t.
Definition object.hpp:48
constexpr object_idx_t object_idx() const noexcept
Returns object_idx value.
Definition object.hpp:53
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition object.hpp:56
C++ wrapper for tpbrt_object_t.
Definition object.hpp:21
constexpr shapes_list children() const noexcept
Returns children value.
Definition object.hpp:29
constexpr auto end() const noexcept
Returns end iterator for children.
Definition object.hpp:35
constexpr string name() const noexcept
Returns name value.
Definition object.hpp:26
constexpr auto begin() const noexcept
Returns begin iterator for children.
Definition object.hpp:32
constexpr object_idx_t idx() const noexcept
Returns idx value.
Definition object.hpp:38
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition object.hpp:41
C++ wrapper for tpbrt_objects_list_t.
Definition object.hpp:65
result< element_type > at(const std::string_view name) const noexcept
Returns object with given name.
Definition object.hpp:81
result< element_type > operator[](const std::string_view name) const noexcept
Returns object with given name.
Definition object.hpp:90
result< element_type > at(const object_handle handle) const noexcept
Returns object pointed by given handle.
Definition object.hpp:76
result< element_type > operator[](const object_handle handle) const noexcept
Returns object pointed by given handle.
Definition object.hpp:87
Result of an operation: either a value or an error code (similar to C++23 std::expected).
Definition error.hpp:165
C++ wrapper for tpbrt_shapes_list_t.
Definition shape.hpp:511