Fixed template

This commit is contained in:
Vulpovile
2023-11-03 23:56:59 -07:00
parent 25d34d28ee
commit 26398f0586
7 changed files with 245 additions and 16 deletions

View File

@@ -0,0 +1,49 @@
#pragma once
#define WINVER 0x0400
#include "Reflection/Reflection.h"
#include "Reflection/ReflectionDataTable.h"
#include "Reflection/ReflectionProperty.h"
#include <G3DAll.h>
namespace B3D
{
class Instance
{
public:
//Constructors
Instance(void);
Instance(const Instance&);
virtual ~Instance(void);
//Virtual Functions
virtual void render(RenderDevice*);
virtual void renderName(RenderDevice*);
virtual void update();
virtual void setParent(Instance*);
virtual Instance* clone() const { return new Instance(*this); }
//Functions
std::vector<Instance*> children; // All children.
std::string getClassName();
Instance* findFirstChild(std::string);
std::vector<Instance* > getChildren();
std::vector<Instance* > getAllChildren();
void setName(std::string newName);
void addChild(Instance*);
void removeChild(Instance*);
void clearChildren();
Instance* getParent();
//Variables
Reflection::ReflectionProperty<std::string> name;
protected:
//Constructor
//Used specifically to identify an instance class by an instance class,
//NOT for use outside of Instance and decendants!
Instance(std::string className);
//Variables
Reflection::ReflectionDataTable * dataTable;
Instance * parent;
};
}

View File

@@ -4,14 +4,13 @@
#include <map>
#include "ReflectionProperty.h"
namespace B3D{
namespace Instance{
class Instance;
}
class Instance;
namespace Reflection{
class ReflectionDataTable
{
public:
ReflectionDataTable(Instance::Instance * parentInstance, std::string className);
ReflectionDataTable(Instance * parentInstance, std::string className);
ReflectionDataTable::ReflectionDataTable(void);
~ReflectionDataTable(void);
@@ -20,7 +19,7 @@ namespace B3D{
//Perhaps not stored here?
std::string className;
std::map<std::string, B3D::Reflection::ReflectionProperty<void*>*> propertyTable;
Instance::Instance * parentInstance;
Instance * parentInstance;
};
}
}

View File

@@ -8,13 +8,13 @@ namespace B3D{
namespace Reflection{
class ReflectionDataTable;
template<typename T>
template<class T>
class ReflectionProperty
{
public:
T * value;
ReflectionType type;
ReflectionProperty(T * value, ReflectionType type, ReflectionDataTable * containerTable, bool archivable = true, bool locked = false, bool propertyHidden = false);
ReflectionProperty(T * value, ReflectionType type, ReflectionDataTable * containerTable);
ReflectionProperty(void);
~ReflectionProperty(void);
private:
@@ -25,4 +25,7 @@ namespace B3D{
ReflectionDataTable * containerTable;
};
}
}
}
//***really*** wanted to avoid implementing this inside of the header
#include "ReflectionProperty_imp.h"

View File

@@ -0,0 +1,22 @@
using namespace B3D::Reflection;
template<class T>
ReflectionProperty<T>::ReflectionProperty(T * value, ReflectionType type, ReflectionDataTable * containerTable)
{
this->value = value;
this->type = type;
this->containerTable = containerTable;
this->locked = locked;
this->archivable = archivable;
this->propertyHidden = propertyHidden;
}
template<class T>
ReflectionProperty<T>::ReflectionProperty(void)
{
}
template<class T>
ReflectionProperty<T>::~ReflectionProperty(void)
{
}