[DEV] update to the new ejson verseion
This commit is contained in:
parent
1f8983c1b2
commit
cf4bdcf286
@ -140,7 +140,8 @@ void ege::Environement::addCreator(const std::string& _type, ege::createElement_
|
||||
EGE_DEBUG("Add creator: " << _type << " (done)");
|
||||
}
|
||||
|
||||
std::shared_ptr<ege::Element> ege::Environement::createElement(const std::string& _type, bool _autoAddElement, enum ege::property _property, std::shared_ptr<void> _value) {
|
||||
|
||||
std::shared_ptr<ege::Element> ege::Environement::createElement(const std::string& _type, const std::string& _description, bool _autoAddElement) {
|
||||
if (getHachTableCreating().exist(_type) == false) {
|
||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||
return nullptr;
|
||||
@ -155,7 +156,7 @@ std::shared_ptr<ege::Element> ege::Environement::createElement(const std::string
|
||||
EGE_ERROR("allocation error '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (false == tmpElement->init(_property, _value)) {
|
||||
if (false == tmpElement->initString(_description)) {
|
||||
EGE_ERROR("Init error ... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
@ -165,18 +166,105 @@ std::shared_ptr<ege::Element> ege::Environement::createElement(const std::string
|
||||
return tmpElement;
|
||||
}
|
||||
|
||||
std::shared_ptr<ege::Element> ege::Environement::createElement(const std::string& _type, std::shared_ptr<std::string> _description, bool _autoAddElement) {
|
||||
return createElement(_type, _autoAddElement, ege::typeString, std::static_pointer_cast<void>(_description));
|
||||
std::shared_ptr<ege::Element> ege::Environement::createElement(const std::string& _type, const ejson::Value& _value, bool _autoAddElement) {
|
||||
if (getHachTableCreating().exist(_type) == false) {
|
||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ege::createElement_tf creatorPointer = getHachTableCreating()[_type];
|
||||
if (creatorPointer == nullptr) {
|
||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<ege::Element> tmpElement = creatorPointer(std::dynamic_pointer_cast<ege::Environement>(shared_from_this()));
|
||||
if (tmpElement == nullptr) {
|
||||
EGE_ERROR("allocation error '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (false == tmpElement->initJSON(_value)) {
|
||||
EGE_ERROR("Init error ... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (_autoAddElement == true) {
|
||||
addElement(tmpElement);
|
||||
}
|
||||
return tmpElement;
|
||||
}
|
||||
|
||||
std::shared_ptr<ege::Element> ege::Environement::createElement(const std::string& _type, std::shared_ptr<ejson::Value> _value, bool _autoAddElement) {
|
||||
return createElement(_type, _autoAddElement, ege::typeJson, std::static_pointer_cast<void>(_value));
|
||||
std::shared_ptr<ege::Element> ege::Environement::createElement(const std::string& _type, const exml::Node& _node, bool _autoAddElement) {
|
||||
if (getHachTableCreating().exist(_type) == false) {
|
||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ege::createElement_tf creatorPointer = getHachTableCreating()[_type];
|
||||
if (creatorPointer == nullptr) {
|
||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<ege::Element> tmpElement = creatorPointer(std::dynamic_pointer_cast<ege::Environement>(shared_from_this()));
|
||||
if (tmpElement == nullptr) {
|
||||
EGE_ERROR("allocation error '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (false == tmpElement->initXML(_node)) {
|
||||
EGE_ERROR("Init error ... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (_autoAddElement == true) {
|
||||
addElement(tmpElement);
|
||||
}
|
||||
return tmpElement;
|
||||
}
|
||||
|
||||
std::shared_ptr<ege::Element> ege::Environement::createElement(const std::string& _type, std::shared_ptr<exml::Node> _node, bool _autoAddElement) {
|
||||
return createElement(_type, _autoAddElement, ege::typeXml, std::static_pointer_cast<void>(_node));
|
||||
std::shared_ptr<ege::Element> ege::Environement::createElement(const std::string& _type, void* _data, bool _autoAddElement) {
|
||||
if (getHachTableCreating().exist(_type) == false) {
|
||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ege::createElement_tf creatorPointer = getHachTableCreating()[_type];
|
||||
if (creatorPointer == nullptr) {
|
||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<ege::Element> tmpElement = creatorPointer(std::dynamic_pointer_cast<ege::Environement>(shared_from_this()));
|
||||
if (tmpElement == nullptr) {
|
||||
EGE_ERROR("allocation error '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (false == tmpElement->initVoid(_data)) {
|
||||
EGE_ERROR("Init error ... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (_autoAddElement == true) {
|
||||
addElement(tmpElement);
|
||||
}
|
||||
return tmpElement;
|
||||
}
|
||||
|
||||
std::shared_ptr<ege::Element> ege::Environement::createElement(const std::string& _type, bool _autoAddElement) {
|
||||
if (getHachTableCreating().exist(_type) == false) {
|
||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ege::createElement_tf creatorPointer = getHachTableCreating()[_type];
|
||||
if (creatorPointer == nullptr) {
|
||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<ege::Element> tmpElement = creatorPointer(std::dynamic_pointer_cast<ege::Environement>(shared_from_this()));
|
||||
if (tmpElement == nullptr) {
|
||||
EGE_ERROR("allocation error '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (false == tmpElement->init()) {
|
||||
EGE_ERROR("Init error ... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (_autoAddElement == true) {
|
||||
addElement(tmpElement);
|
||||
}
|
||||
return tmpElement;
|
||||
}
|
||||
|
||||
void ege::Environement::addElement(std::shared_ptr<ege::Element> _newElement) {
|
||||
// prevent memory allocation and un allocation ...
|
||||
|
@ -30,14 +30,6 @@ class btDynamicsWorld;
|
||||
#include <ege/physics/Engine.h>
|
||||
|
||||
namespace ege {
|
||||
enum property {
|
||||
typeNone, //!< no element property
|
||||
typeString, //!< type element static_cast<std::string*>(xxxxxxx)
|
||||
typeJson, //!< type element static_cast<ejson::Value*>(xxxxxxx)
|
||||
typeXml, //!< type element static_cast<exml::Node*>(xxxxxxx)
|
||||
typeUser1, //!< user type 1
|
||||
typeUser2 //!< User type 2
|
||||
};
|
||||
class Element;
|
||||
class Environement;
|
||||
typedef std::shared_ptr<ege::Element> (*createElement_tf)(const std::shared_ptr<ege::Environement>& _env);
|
||||
@ -144,10 +136,11 @@ namespace ege {
|
||||
* @return nullptr if an error occured OR the pointer on the element and it is already added on the system.
|
||||
* @note Pointer is return in case of setting properties on it...
|
||||
*/
|
||||
std::shared_ptr<ege::Element> createElement(const std::string& _type, bool _autoAddElement=true, enum ege::property _property=ege::typeNone, std::shared_ptr<void> _value=nullptr);
|
||||
std::shared_ptr<ege::Element> createElement(const std::string& _type, std::shared_ptr<std::string> _description, bool _autoAddElement=true);
|
||||
std::shared_ptr<ege::Element> createElement(const std::string& _type, std::shared_ptr<ejson::Value> _value, bool _autoAddElement=true);
|
||||
std::shared_ptr<ege::Element> createElement(const std::string& _type, std::shared_ptr<exml::Node> _node, bool _autoAddElement=true);
|
||||
std::shared_ptr<ege::Element> createElement(const std::string& _type, const std::string& _description, bool _autoAddElement=true);
|
||||
std::shared_ptr<ege::Element> createElement(const std::string& _type, const ejson::Value& _value, bool _autoAddElement=true);
|
||||
std::shared_ptr<ege::Element> createElement(const std::string& _type, const exml::Node& _node, bool _autoAddElement=true);
|
||||
std::shared_ptr<ege::Element> createElement(const std::string& _type, void* _data, bool _autoAddElement=true);
|
||||
std::shared_ptr<ege::Element> createElement(const std::string& _type, bool _autoAddElement=true);
|
||||
public:
|
||||
class ResultNearestElement {
|
||||
public:
|
||||
|
@ -25,8 +25,6 @@
|
||||
|
||||
#include <ege/CollisionShapeCreator.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Element"
|
||||
|
||||
const std::string& ege::Element::getType() const {
|
||||
static const std::string nameType("----");
|
||||
@ -45,15 +43,41 @@ ege::Element::Element(const std::shared_ptr<ege::Environement>& _env) :
|
||||
m_radius(0) {
|
||||
static uint32_t unique=0;
|
||||
m_uID = unique;
|
||||
EGE_DEBUG("Create element : uId=" << m_uID);
|
||||
EGE_DEBUG("Create element: uId=" << m_uID);
|
||||
m_debugText.setFontSize(12);
|
||||
unique++;
|
||||
}
|
||||
|
||||
ege::Element::~Element() {
|
||||
EGE_DEBUG("Destroy element : uId=" << m_uID);
|
||||
EGE_DEBUG("Destroy element: uId=" << m_uID);
|
||||
}
|
||||
|
||||
|
||||
bool ege::Element::init() {
|
||||
EGE_WARNING("init() not implemented: uId=" << m_uID);
|
||||
return false;
|
||||
}
|
||||
bool ege::Element::initString(const std::string& _description) {
|
||||
EGE_WARNING("String Init not implemented: uId=" << m_uID);
|
||||
return false;
|
||||
}
|
||||
bool ege::Element::initXML(const exml::Node& _node) {
|
||||
EGE_WARNING("xml Init not implemented: uId=" << m_uID);
|
||||
return false;
|
||||
}
|
||||
bool ege::Element::initJSON(const ejson::Value& _value) {
|
||||
EGE_WARNING("JSON Init not implemented: uId=" << m_uID);
|
||||
return false;
|
||||
}
|
||||
bool ege::Element::initVoid(void* _value) {
|
||||
EGE_WARNING("joid* Init not implemented: uId=" << m_uID);
|
||||
return false;
|
||||
}
|
||||
bool ege::Element::unInit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ege::Element::loadMesh(const std::string& _meshFileName) {
|
||||
std::shared_ptr<ege::resource::Mesh> tmpMesh = ege::resource::Mesh::create(_meshFileName);
|
||||
if(nullptr == tmpMesh) {
|
||||
|
@ -52,12 +52,12 @@ namespace ege {
|
||||
* @param[in] _value pointer on the value type
|
||||
* @return true, the element is corectly initialized.
|
||||
*/
|
||||
virtual bool init(enum property _property, std::shared_ptr<void> _value) {
|
||||
return false;
|
||||
};
|
||||
virtual bool unInit() {
|
||||
return true;
|
||||
};
|
||||
virtual bool init();
|
||||
virtual bool initString(const std::string& _description);
|
||||
virtual bool initXML(const exml::Node& _node);
|
||||
virtual bool initJSON(const ejson::Value& _value);
|
||||
virtual bool initVoid(void* _value);
|
||||
virtual bool unInit();
|
||||
private:
|
||||
uint32_t m_uID; //!< This is a reference on a basic element ID
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user