mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
cpp changes for latebound schema manipulation from Python
This commit is contained in:
@@ -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() {}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user