Fixed template
This commit is contained in:
@@ -683,6 +683,22 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Reflection"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\source\Reflection\ReflectionDataTable.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="DataModelV3"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\source\DataModelV3\Instance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
@@ -956,6 +972,34 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Reflection"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\Reflection\Reflection.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\Reflection\ReflectionDataTable.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\Reflection\ReflectionProperty.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\ReflectionProperty_imp.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="DataModelV3"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\DataModelV3\Instance.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
|
|||||||
49
src/include/DataModelV3/Instance.h
Normal file
49
src/include/DataModelV3/Instance.h
Normal 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;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -4,14 +4,13 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include "ReflectionProperty.h"
|
#include "ReflectionProperty.h"
|
||||||
namespace B3D{
|
namespace B3D{
|
||||||
namespace Instance{
|
|
||||||
class Instance;
|
class Instance;
|
||||||
}
|
|
||||||
namespace Reflection{
|
namespace Reflection{
|
||||||
class ReflectionDataTable
|
class ReflectionDataTable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ReflectionDataTable(Instance::Instance * parentInstance, std::string className);
|
ReflectionDataTable(Instance * parentInstance, std::string className);
|
||||||
ReflectionDataTable::ReflectionDataTable(void);
|
ReflectionDataTable::ReflectionDataTable(void);
|
||||||
~ReflectionDataTable(void);
|
~ReflectionDataTable(void);
|
||||||
|
|
||||||
@@ -20,7 +19,7 @@ namespace B3D{
|
|||||||
//Perhaps not stored here?
|
//Perhaps not stored here?
|
||||||
std::string className;
|
std::string className;
|
||||||
std::map<std::string, B3D::Reflection::ReflectionProperty<void*>*> propertyTable;
|
std::map<std::string, B3D::Reflection::ReflectionProperty<void*>*> propertyTable;
|
||||||
Instance::Instance * parentInstance;
|
Instance * parentInstance;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ namespace B3D{
|
|||||||
namespace Reflection{
|
namespace Reflection{
|
||||||
class ReflectionDataTable;
|
class ReflectionDataTable;
|
||||||
|
|
||||||
template<typename T>
|
template<class T>
|
||||||
class ReflectionProperty
|
class ReflectionProperty
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
T * value;
|
T * value;
|
||||||
ReflectionType type;
|
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);
|
||||||
~ReflectionProperty(void);
|
~ReflectionProperty(void);
|
||||||
private:
|
private:
|
||||||
@@ -26,3 +26,6 @@ namespace B3D{
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//***really*** wanted to avoid implementing this inside of the header
|
||||||
|
#include "ReflectionProperty_imp.h"
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
#include "Reflection\ReflectionProperty.h"
|
|
||||||
using namespace B3D::Reflection;
|
using namespace B3D::Reflection;
|
||||||
|
|
||||||
template<typename T>
|
template<class T>
|
||||||
ReflectionProperty<T>::ReflectionProperty(T * value, ReflectionType type, ReflectionDataTable * containerTable, bool archivable = true, bool locked = false, bool propertyHidden = false)
|
ReflectionProperty<T>::ReflectionProperty(T * value, ReflectionType type, ReflectionDataTable * containerTable)
|
||||||
{
|
{
|
||||||
this->value = value;
|
this->value = value;
|
||||||
this->type = type;
|
this->type = type;
|
||||||
@@ -12,12 +11,12 @@ ReflectionProperty<T>::ReflectionProperty(T * value, ReflectionType type, Reflec
|
|||||||
this->propertyHidden = propertyHidden;
|
this->propertyHidden = propertyHidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<class T>
|
||||||
ReflectionProperty<T>::ReflectionProperty(void)
|
ReflectionProperty<T>::ReflectionProperty(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<class T>
|
||||||
ReflectionProperty<T>::~ReflectionProperty(void)
|
ReflectionProperty<T>::~ReflectionProperty(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
135
src/source/DataModelV3/Instance.cpp
Normal file
135
src/source/DataModelV3/Instance.cpp
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
#include "DataModelV3/Instance.h"
|
||||||
|
|
||||||
|
using namespace B3D;
|
||||||
|
|
||||||
|
Instance::Instance(std::string className)
|
||||||
|
{
|
||||||
|
this->parent = NULL;
|
||||||
|
this->dataTable = new Reflection::ReflectionDataTable(this, className);
|
||||||
|
this->name = Reflection::ReflectionProperty<std::string>(new std::string("Default Game Instance"), Reflection::TYPE_STRING, dataTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance::Instance(void)
|
||||||
|
{
|
||||||
|
Instance::Instance("BaseInstance");
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance::~Instance(void)
|
||||||
|
{
|
||||||
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
delete children.at(i);
|
||||||
|
}
|
||||||
|
delete dataTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance::Instance(const Instance &oinst)
|
||||||
|
{
|
||||||
|
//CLONE WITH REFLECTION!!!
|
||||||
|
}
|
||||||
|
|
||||||
|
//Perhaps should be separated
|
||||||
|
void Instance::render(RenderDevice* rd)
|
||||||
|
{
|
||||||
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
children[i]->render(rd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Instance::renderName(RenderDevice* rd)
|
||||||
|
{
|
||||||
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
children[i]->renderName(rd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Instance::update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Instance::setName(std::string newName)
|
||||||
|
{
|
||||||
|
*name.value = newName;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Instance::getClassName()
|
||||||
|
{
|
||||||
|
return dataTable->getClassName();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Instance* > Instance::getChildren()
|
||||||
|
{
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Instance* > Instance::getAllChildren()
|
||||||
|
{
|
||||||
|
if(!children.empty())
|
||||||
|
{
|
||||||
|
std::vector<Instance* > totalchildren = children;
|
||||||
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
std::vector<Instance* > subchildren = children.at(i)->getAllChildren();
|
||||||
|
if(!subchildren.empty())
|
||||||
|
totalchildren.insert(totalchildren.end(), subchildren.begin(), subchildren.end());
|
||||||
|
}
|
||||||
|
return totalchildren;
|
||||||
|
}
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Instance::setParent(Instance* newParent)
|
||||||
|
{
|
||||||
|
if(parent != NULL)
|
||||||
|
{
|
||||||
|
parent->removeChild(this);
|
||||||
|
}
|
||||||
|
parent = newParent;
|
||||||
|
if(newParent != NULL)
|
||||||
|
{
|
||||||
|
newParent->addChild(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance* Instance::getParent()
|
||||||
|
{
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Instance::addChild(Instance* newChild)
|
||||||
|
{
|
||||||
|
children.push_back(newChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Instance::clearChildren()
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
delete children.at(i);
|
||||||
|
}
|
||||||
|
children.clear();
|
||||||
|
}
|
||||||
|
void Instance::removeChild(Instance* oldChild)
|
||||||
|
{
|
||||||
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
if(children.at(i) == oldChild)
|
||||||
|
{
|
||||||
|
children.erase(children.begin() + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance* Instance::findFirstChild(std::string searchName)
|
||||||
|
{
|
||||||
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
if(children.at(i)->name.value->compare(searchName) == 0)
|
||||||
|
{
|
||||||
|
return children.at(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#include "Reflection\ReflectionDataTable.h"
|
#include "Reflection/ReflectionDataTable.h"
|
||||||
|
|
||||||
using namespace B3D::Reflection;
|
using namespace B3D::Reflection;
|
||||||
|
|
||||||
ReflectionDataTable::ReflectionDataTable(B3D::Instance::Instance * parentInstance, std::string className)
|
ReflectionDataTable::ReflectionDataTable(B3D::Instance * parentInstance, std::string className)
|
||||||
{
|
{
|
||||||
this->parentInstance = parentInstance;
|
this->parentInstance = parentInstance;
|
||||||
this->className = className;
|
this->className = className;
|
||||||
|
|||||||
Reference in New Issue
Block a user