CommonLibVR
Loading...
Searching...
No Matches
ConcreteFormFactory.h
Go to the documentation of this file.
1#pragma once
2
3#include "RE/I/IFormFactory.h"
4#include "RE/T/TESForm.h"
5
6namespace RE
7{
8 template <class T, FormType FORM_TYPE>
10 {
11 public:
12 ~ConcreteFormFactory() override; // 00
13
14 protected:
15 // override (IFormFactory)
16 TESForm* CreateImpl() override; // 01
17
18 public:
19 const char* GetFormName() const override; // 02 - { return _name; }
20 [[nodiscard]] FormType GetFormType() const override; // 03 - { return FORM_TYPE; }
21
22 inline T* Create()
23 {
24 return static_cast<T*>(CreateImpl());
25 }
26
27 protected:
28 // members
29 const char* _name; // 08
30 };
31 static_assert(sizeof(ConcreteFormFactory<TESForm, FormType::None>) == 0x10);
32
33 template <class T>
38
39 template <class T>
40 [[nodiscard]] T* IFormFactory::Create()
41 {
42 auto factory = IFormFactory::GetConcreteFormFactoryByType<T>();
43 auto form = factory ? factory->Create() : nullptr;
44
45 return form ? form->As<T>() : nullptr;
46 }
47}
Definition ConcreteFormFactory.h:10
~ConcreteFormFactory() override
const char * GetFormName() const override
FormType GetFormType() const override
const char * _name
Definition ConcreteFormFactory.h:29
T * Create()
Definition ConcreteFormFactory.h:22
TESForm * CreateImpl() override
Definition IFormFactory.h:19
static IFormFactory * GetFormFactoryByType(FormType a_formType)
static ConcreteFormFactory< T, T::FORMTYPE > * GetConcreteFormFactoryByType()
Definition ConcreteFormFactory.h:34
TESForm * Create()
Definition TESForm.h:40
Definition AbsorbEffect.h:6
FormType
Definition FormTypes.h:139