PeriDyno 1.2.1
Loading...
Searching...
No Matches
FList.h
Go to the documentation of this file.
1
16#pragma once
17
18#include <list>
19
20#include "FBase.h"
21
22#include "Array/Array.h"
23
24namespace dyno {
29 template<typename T>
30 class FList : public FBase
31 {
32 public:
33 typedef T VarType;
34 typedef std::list<T> DataType;
36
37 FList() : FBase("", "") {}
38 FList(std::string name, std::string description, FieldTypeEnum fieldType, OBase* parent)
39 : FBase(name, description, fieldType, parent) {}
40
41 ~FList() override;
42
43 const std::string getTemplateName() override { return std::string(typeid(VarType).name()); }
44 const std::string getClassName() override { return "FList"; }
45
46 uint size() override { return mList.size(); }
47
48 inline std::string serialize() override { return "Unknown"; }
49 inline bool deserialize(const std::string& str) override { return false; }
50
51 void insert(T val);
52
53 bool isEmpty() override {
54 auto& data = this->constData();
55 return data.size() == 0;
56 }
57
59 {
60 FBase* topField = this->getTopField();
61 FieldType* derived = dynamic_cast<FieldType*>(topField);
62 return derived->mList;
63 }
64
65 bool bind(FieldType* dst)
66 {
68 return false;
69
70 this->connectField(dst);
71 return true;
72 }
73
74 protected:
75 bool connect(FBase* dst) override {
76 FieldType* derived = dynamic_cast<FieldType*>(dst);
77 if (derived == nullptr) return false;
78 return this->bind(derived);
79 }
80
81 private:
82 std::list<T> mList;
83 };
84
85 template<typename T>
87 {
88 std::shared_ptr<T>& data = this->getDataPtr();
89 if (data == nullptr)
90 {
91 data = std::make_shared<T>(val);
92 }
93 else
94 {
95 *data = val;
96 }
97
98 this->update();
99
100 this->tick();
101 }
102
103 template<typename T>
105 {
106 };
107
108#define DEF_LIST(T, name, desc) \
109private: \
110 FList<T> var_##name = FList<T>(std::string(#name), desc, FieldTypeEnum::Param, this); \
111public: \
112 inline FList<T>* var##name() {return &var_##name;}
113}
114
115#include "FList.inl"
FieldTypeEnum getFieldType()
Definition FBase.cpp:388
OBase * parent()
Definition FBase.cpp:41
void tick()
Definition FBase.cpp:340
FBase * getTopField()
Definition FBase.cpp:264
virtual void update()
Definition FBase.cpp:269
bool connectField(FBase *dst)
Definition FBase.cpp:230
FList< T > FieldType
Definition FList.h:35
bool connect(FBase *dst) override
Definition FList.h:75
~FList() override
Definition FList.h:104
const std::string getTemplateName() override
Definition FList.h:43
bool isEmpty() override
Definition FList.h:53
bool deserialize(const std::string &str) override
Definition FList.h:49
uint size() override
Definition FList.h:46
FList(std::string name, std::string description, FieldTypeEnum fieldType, OBase *parent)
Definition FList.h:38
std::string serialize() override
Definition FList.h:48
void insert(T val)
Definition FList.h:86
const DataType & constData()
Definition FList.h:58
bool bind(FieldType *dst)
Definition FList.h:65
std::list< T > mList
Definition FList.h:82
const std::string getClassName() override
Definition FList.h:44
std::list< T > DataType
Definition FList.h:34
T VarType
Definition FList.h:33
#define T(t)
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
FieldTypeEnum
Definition FBase.h:30
@ Param
Definition FBase.h:34
unsigned int uint
Definition VkProgram.h:14