Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/functions/FN_multi_function_context.hh')
-rw-r--r--source/blender/functions/FN_multi_function_context.hh26
1 files changed, 25 insertions, 1 deletions
diff --git a/source/blender/functions/FN_multi_function_context.hh b/source/blender/functions/FN_multi_function_context.hh
index 3a448cc2c6e..8492fd86742 100644
--- a/source/blender/functions/FN_multi_function_context.hh
+++ b/source/blender/functions/FN_multi_function_context.hh
@@ -29,15 +29,39 @@
#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), (const void *)context);
+ }
};
class MFContext {
+ private:
+ MFContextBuilder &builder_;
+
public:
- MFContext(MFContextBuilder &UNUSED(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 (const T *)context;
}
};