MeshLib C++ Docs
Loading...
Searching...
No Matches
MRRenderWrapObject.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMesh/MRMeshFwd.h"
6
8{
9
10namespace detail
11{
13 template <typename ObjectType>
15 {
16 ObjectType subobject;
17 };
18
20 {
21 protected:
23 };
24}
25
27template <std::derived_from<Object> ObjectType>
29{
30protected:
32public:
33 const ObjectType* target_ = nullptr;
34};
35
38template <typename ObjectType, typename RenderObjectType>
39class Wrapper : public detail::SubobjectStorage<ObjectType>, public RenderObjectType
40{
41public:
42 Wrapper( const VisualObject& object )
43 : RenderObjectType( detail::SubobjectStorage<ObjectType>::subobject )
44 {
45 if constexpr ( std::derived_from<ObjectType, detail::BasicWrapperTargetUntyped> )
46 this->subobject.target_ = &dynamic_cast<decltype(*this->subobject.target_)>( object );
47 }
48
49 Wrapper( const Wrapper& ) = delete;
50 Wrapper& operator=( const Wrapper& ) = delete;
51};
52
53}
The first template argument of Wrapper can inherit from this to know the object we're wrapping.
Definition MRRenderWrapObject.h:29
const ObjectType * target_
Definition MRRenderWrapObject.h:33
Wrapper(const VisualObject &object)
Definition MRRenderWrapObject.h:42
Wrapper & operator=(const Wrapper &)=delete
Wrapper(const Wrapper &)=delete
Visual Object.
Definition MRVisualObject.h:116
Definition MRRenderWrapObject.h:11
Definition MRRenderWrapObject.h:8
Need this helper base class to make sure the subobject is initialized before the render object,...
Definition MRRenderWrapObject.h:15
ObjectType subobject
Definition MRRenderWrapObject.h:16