6#include <unordered_map>
19 template <
typename ObjectType>
20 using ObjectList = std::vector<std::shared_ptr<ObjectType>>;
23 template <
typename ObjectType, ObjectSelectivityType SelectivityType>
30 struct BasicVectorHolder
32 BasicVectorHolder() =
default;
33 BasicVectorHolder(
const BasicVectorHolder& ) =
default;
34 BasicVectorHolder( BasicVectorHolder&& ) =
default;
35 virtual ~BasicVectorHolder() =
default;
37 template <
typename ObjectType, ObjectSelectivityType SelectivityType>
38 struct VectorHolder : BasicVectorHolder
40 ObjectList<ObjectType> value;
42 std::unordered_map<std::type_index, std::shared_ptr<BasicVectorHolder>> cachedData_;
45template <
typename ObjectType, ObjectSelectivityType SelectivityType>
48 using ResultType = VectorHolder<ObjectType, SelectivityType>;
49 const auto typeIndex = std::type_index(
typeid( ResultType ) );
50 auto& cachedData = instance_().cachedData_;
51 if ( !cachedData.contains( typeIndex ) || !cachedData[typeIndex] )
55 std::shared_ptr<ResultType> newDataPtr = std::make_shared<ResultType>( std::move( newData ) );
56 cachedData[typeIndex] = std::dynamic_pointer_cast<BasicVectorHolder>( newDataPtr );
58 return std::dynamic_pointer_cast< ResultType >( cachedData[typeIndex] )->value;
Definition MRSceneCache.h:13
std::vector< std::shared_ptr< ObjectType > > ObjectList
Definition MRSceneCache.h:20
static MRVIEWER_API void invalidateAll()
static const ObjectList< ObjectType > & getAllObjects()
Definition MRSceneCache.h:46
static MRMESH_API SceneRootObject & get()
std::vector< std::shared_ptr< ObjectT > > getAllObjectsInTree(Object *root, const ObjectSelectivityType &type=ObjectSelectivityType::Selectable)
Definition MRCameraOrientationPlugin.h:8