Changeset View
Changeset View
Standalone View
Standalone View
source/blender/functions/FN_multi_function_context.hh
| Show All 29 Lines | public: | ||||
| template<typename T> void add_global_context(std::string name, const T *context) | 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)); | global_contexts_.add_new(std::move(name), static_cast<const void *>(context)); | ||||
| } | } | ||||
| }; | }; | ||||
| class MFContext { | class MFContext { | ||||
| private: | private: | ||||
| MFContextBuilder &builder_; | MFContextBuilder const &builder_; | ||||
| public: | public: | ||||
| MFContext(MFContextBuilder &builder) : builder_(builder) | MFContext(MFContextBuilder const &builder) : builder_(builder) | ||||
| { | { | ||||
| } | } | ||||
| template<typename T> const T *get_global_context(StringRef name) const | template<typename T> const T *get_global_context(StringRef name) const | ||||
| { | { | ||||
| const void *context = builder_.global_contexts_.lookup_default_as(name, nullptr); | const void *context = builder_.global_contexts_.lookup_default_as(name, nullptr); | ||||
| /* TODO: Implement type checking. */ | /* TODO: Implement type checking. */ | ||||
| return static_cast<const T *>(context); | return static_cast<const T *>(context); | ||||
| } | } | ||||
| }; | }; | ||||
| } // namespace blender::fn | } // namespace blender::fn | ||||