Missing introspection methods in Python

This commit is contained in:
Thomas Krijnen
2017-08-02 16:08:07 +02:00
parent b696df0da1
commit a58f23fae2
2 changed files with 19 additions and 2 deletions
@@ -120,8 +120,8 @@ class entity_instance(object):
def __dir__(self):
return sorted(set(itertools.chain(
dir(type(self)),
self.wrapped_data.get_attribute_names(),
self.wrapped_data.get_inverse_attribute_names()
map(str, self.wrapped_data.get_attribute_names()),
map(str, self.wrapped_data.get_inverse_attribute_names())
)))
def get_info(self, include_identifier=True, recursive=False):
+17
View File
@@ -109,9 +109,26 @@ private:
// id() is defined on IfcBaseEntity and not on IfcBaseClass, in order
// to expose it to the Python wrapper it is simply duplicated here.
// Same applies to the two methods reimplemented below.
int id() const {
return $self->entity->id();
}
std::vector<std::string> getAttributeNames() const {
if (IfcSchema::Type::IsSimple($self->type())) {
return std::vector<std::string>(1, "wrappedValue");
}
IfcUtil::IfcBaseEntity* self_ = (IfcUtil::IfcBaseEntity*) self;
return self_->getAttributeNames();
}
std::vector<std::string> getInverseAttributeNames() const {
if (IfcSchema::Type::IsSimple($self->type())) {
return std::vector<std::string>(0);
}
IfcUtil::IfcBaseEntity* self_ = (IfcUtil::IfcBaseEntity*) self;
return self_->getInverseAttributeNames();
}
bool is_a(const std::string& s) {
return self->is(IfcSchema::Type::FromString(boost::to_upper_copy(s)));