cpp changes for latebound schema manipulation from Python

This commit is contained in:
Thomas Krijnen
2020-09-08 14:37:50 +02:00
parent 27f358b314
commit 95a29dec7b
6 changed files with 123 additions and 1 deletions
+12
View File
@@ -74,6 +74,18 @@ namespace IfcUtil {
}
};
class IFC_PARSE_API IfcLateBoundEntity : public IfcBaseClass {
private:
const IfcParse::declaration* decl_;
public:
IfcLateBoundEntity(const IfcParse::declaration* decl, IfcEntityInstanceData* data) : IfcBaseClass(data), decl_(decl) {}
virtual const IfcParse::declaration& declaration() const {
return *decl_;
}
};
class IFC_PARSE_API IfcBaseEntity : public IfcBaseClass {
public:
IfcBaseEntity() : IfcBaseClass() {}
+14
View File
@@ -1,4 +1,5 @@
#include "IfcSchema.h"
#include "../ifcparse/IfcBaseClass.h"
#include <map>
@@ -62,6 +63,19 @@ IfcParse::schema_definition::~schema_definition() {
}
}
IfcUtil::IfcBaseClass* IfcParse::schema_definition::instantiate(IfcEntityInstanceData * data) const {
if (factory_) {
return (*factory_)(data);
} else {
return new IfcUtil::IfcLateBoundEntity(data->type(), data);
}
}
void IfcParse::register_schema(schema_definition* s) {
schemas.insert({ s->name(), s });
}
#include "../ifcparse/Ifc2x3.h"
#include "../ifcparse/Ifc4.h"
#include "../ifcparse/Ifc4x1.h"
+3 -1
View File
@@ -443,10 +443,12 @@ namespace IfcParse {
const std::string& name() const { return name_; }
IfcUtil::IfcBaseClass* instantiate(IfcEntityInstanceData* data) const { return (*factory_)(data); }
IfcUtil::IfcBaseClass* instantiate(IfcEntityInstanceData* data) const;
};
const schema_definition* schema_by_name(const std::string&);
void register_schema(schema_definition*);
}
#endif