Blender  V2.93
Classes | Public Member Functions | List of all members
blender::ResourceScope Class Reference

#include <BLI_resource_scope.hh>

Inherits blender::NonCopyable, and blender::NonMovable.

Public Member Functions

 ResourceScope ()=default
 
 ~ResourceScope ()
 
template<typename T >
Tadd (std::unique_ptr< T > resource, const char *name)
 
template<typename T >
Tadd (destruct_ptr< T > resource, const char *name)
 
void add (void *userdata, void(*free)(void *), const char *name)
 
template<typename T >
Tadd_value (T &&value, const char *name)
 
LinearAllocatorlinear_allocator ()
 
template<typename T , typename... Args>
Tconstruct (const char *name, Args &&... args)
 
void print (StringRef name) const
 

Detailed Description

Definition at line 48 of file BLI_resource_scope.hh.

Constructor & Destructor Documentation

◆ ResourceScope()

blender::ResourceScope::ResourceScope ( )
default

◆ ~ResourceScope()

blender::ResourceScope::~ResourceScope ( )
inline

Member Function Documentation

◆ add() [1/3]

template<typename T >
T* blender::ResourceScope::add ( destruct_ptr< T resource,
const char *  name 
)
inline

Pass ownership of the resource to the ResourceScope. It will be destructed when the collector is destructed.

Definition at line 96 of file BLI_resource_scope.hh.

References add(), data, ptr, and T.

◆ add() [2/3]

template<typename T >
T* blender::ResourceScope::add ( std::unique_ptr< T resource,
const char *  name 
)
inline

◆ add() [3/3]

void blender::ResourceScope::add ( void *  userdata,
void(*)(void *)  free,
const char *  name 
)
inline

Pass ownership of some resource to the ResourceScope. The given free function will be called when the collector is destructed.

Definition at line 121 of file BLI_resource_scope.hh.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), data, and free().

◆ add_value()

template<typename T >
T& blender::ResourceScope::add_value ( T &&  value,
const char *  name 
)
inline

Construct an object with the same value in the ResourceScope and return a reference to the new value.

Definition at line 134 of file BLI_resource_scope.hh.

◆ construct()

template<typename T , typename... Args>
T& blender::ResourceScope::construct ( const char *  name,
Args &&...  args 
)
inline

◆ linear_allocator()

LinearAllocator& blender::ResourceScope::linear_allocator ( )
inline

Returns a reference to a linear allocator that is owned by the ResourcesCollector. Memory allocated through this allocator will be freed when the collector is destructed.

Definition at line 143 of file BLI_resource_scope.hh.

Referenced by compute_geometry(), blender::nodes::MFNetworkBuilderBase::construct_fn(), blender::fn::mf_network_optimization::prepare_params_for_constant_folding(), and blender::nodes::socket_expand_in_mf_network().

◆ print()

void blender::ResourceScope::print ( StringRef  name) const
inline

Print the names of all the resources that are owned by this ResourceScope. This can be useful for debugging.

Definition at line 163 of file BLI_resource_scope.hh.

References data, and blender::Vector< T, InlineBufferCapacity, Allocator >::size().


The documentation for this class was generated from the following file: