mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Mark abstract entities in latebound schema
This commit is contained in:
@@ -122,6 +122,7 @@ actions = {
|
||||
'select_type' : "lambda t: SelectType(t)",
|
||||
'binary_type' : "lambda t: BinaryType(t)",
|
||||
'subtype_declaration' : "lambda t: SubTypeExpression(t)",
|
||||
'supertype_constraint' : "lambda t: SuperTypeExpression(t)",
|
||||
'derive_clause' : "lambda t: AttributeList('derive', t)",
|
||||
'derived_attr' : "lambda t: DerivedAttribute(t)",
|
||||
'inverse_clause' : "lambda t: AttributeList('inverse', t)",
|
||||
|
||||
@@ -127,7 +127,8 @@ __attribute__((optnone))
|
||||
def write_entity(schema_name, name, type):
|
||||
if len(type.supertypes) == 0 or set(map(lambda s: s.lower(), type.supertypes)) < emitted:
|
||||
supertype = '0' if len(type.supertypes) == 0 else '%s_%s_type' % (schema_name, type.supertypes[0])
|
||||
statements.append(' %(schema_name)s_%(name)s_type = new entity("%(name)s", %%(index_in_schema_%(name)s)d, %(supertype)s);' % locals())
|
||||
is_abstract = "true" if type.abstract else "false"
|
||||
statements.append(' %(schema_name)s_%(name)s_type = new entity("%(name)s", %(is_abstract)s, %%(index_in_schema_%(name)s)d, %(supertype)s);' % locals())
|
||||
else: return False
|
||||
|
||||
def write_select(schema_name, name, type):
|
||||
|
||||
+653
-653
File diff suppressed because it is too large
Load Diff
+776
-776
File diff suppressed because it is too large
Load Diff
@@ -240,6 +240,7 @@ namespace IfcParse {
|
||||
|
||||
class entity : public declaration {
|
||||
protected:
|
||||
bool is_abstract_;
|
||||
const entity* supertype_; /* NB: IFC explicitly allows only single inheritance */
|
||||
std::vector<const entity*> subtypes_;
|
||||
|
||||
@@ -274,8 +275,9 @@ namespace IfcParse {
|
||||
}
|
||||
|
||||
public:
|
||||
entity(const std::string& name, int index_in_schema, entity* supertype)
|
||||
entity(const std::string& name, bool is_abstract, int index_in_schema, entity* supertype)
|
||||
: declaration(name, index_in_schema)
|
||||
, is_abstract_(is_abstract)
|
||||
, supertype_(supertype)
|
||||
{}
|
||||
|
||||
@@ -291,6 +293,8 @@ namespace IfcParse {
|
||||
else return false;
|
||||
}
|
||||
|
||||
bool is_abstract() const { return is_abstract_; }
|
||||
|
||||
void set_subtypes(const std::vector<const entity*>& subtypes) {
|
||||
subtypes_ = subtypes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user