Get the latest Blender, older versions, or experimental builds.
Stay up-to-date with the new features in the latest Blender releases.
Access production assets and knowledge from the open movies.
Documentation on the usage and features in Blender.
Latest development updates, by Blender developers.
Guidelines, release notes and development docs.
A platform to collect and share results of the Blender Benchmark.
The yearly event that brings the community together.
Support core development with a monthly contribution.
Perform a single donation with more payment options available.
Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.
/* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup fn
*
* An #MFContext is passed along with every call to a multi-function. Right now it does nothing,
* but it can be used for the following purposes:
* - Pass debug information up and down the function call stack.
* - Pass reusable memory buffers to sub-functions to increase performance.
* - Pass cached data to called functions.
*/
#include "BLI_utildefines.h"
#include "BLI_map.hh"
namespace blender::fn {
class MFContext;
class MFContextBuilder {
private:
Map<std::string, const void *> global_contexts_;
friend MFContext;
public:
template<typename T> void add_global_context(std::string name, const T *context)
{
global_contexts_.add_new(std::move(name), static_cast<const void *>(context));
}
};
class MFContext {
MFContextBuilder &builder_;
MFContext(MFContextBuilder &builder) : builder_(builder)
template<typename T> const T *get_global_context(StringRef name) const
const void *context = builder_.global_contexts_.lookup_default_as(name, nullptr);
/* TODO: Implement type checking. */
return static_cast<const T *>(context);
} // namespace blender::fn