mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +00:00
Move late bound inverse access to IfcBaseEntity
This commit is contained in:
@@ -24,8 +24,12 @@
|
|||||||
|
|
||||||
#include "../ifcparse/IfcEntityInstanceData.h"
|
#include "../ifcparse/IfcEntityInstanceData.h"
|
||||||
#include "../ifcparse/IfcSchema.h"
|
#include "../ifcparse/IfcSchema.h"
|
||||||
|
#include "../ifcparse/utils.h"
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
class Argument;
|
class Argument;
|
||||||
|
class IfcEntityList;
|
||||||
|
|
||||||
namespace IfcUtil {
|
namespace IfcUtil {
|
||||||
|
|
||||||
@@ -78,6 +82,8 @@ namespace IfcUtil {
|
|||||||
virtual const IfcParse::entity& declaration() const = 0;
|
virtual const IfcParse::entity& declaration() const = 0;
|
||||||
|
|
||||||
Argument* get(const std::string& name) const;
|
Argument* get(const std::string& name) const;
|
||||||
|
|
||||||
|
boost::shared_ptr<IfcEntityList> get_inverse(const std::string& a) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Investigate whether these should be template classes instead
|
// TODO: Investigate whether these should be template classes instead
|
||||||
|
|||||||
@@ -205,6 +205,19 @@ Argument* IfcUtil::IfcBaseEntity::get(const std::string& name) const {
|
|||||||
return data().getArgument(declaration().attribute_index(name));
|
return data().getArgument(declaration().attribute_index(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IfcEntityList::ptr IfcUtil::IfcBaseEntity::get_inverse(const std::string& name) const {
|
||||||
|
const std::vector<const IfcParse::inverse_attribute*> attrs = declaration().as_entity()->all_inverse_attributes();
|
||||||
|
std::vector<const IfcParse::inverse_attribute*>::const_iterator it = attrs.begin();
|
||||||
|
for (; it != attrs.end(); ++it) {
|
||||||
|
if ((*it)->name() == name) {
|
||||||
|
return data().getInverse(
|
||||||
|
(*it)->entity_reference(),
|
||||||
|
(*it)->entity_reference()->attribute_index((*it)->attribute_reference()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw IfcParse::IfcException(name + " not found on " + declaration().name());
|
||||||
|
}
|
||||||
|
|
||||||
void IfcUtil::IfcBaseClass::data(IfcEntityInstanceData* d) {
|
void IfcUtil::IfcBaseClass::data(IfcEntityInstanceData* d) {
|
||||||
delete data_;
|
delete data_;
|
||||||
data_ = d;
|
data_ = d;
|
||||||
|
|||||||
@@ -266,16 +266,11 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas
|
|||||||
}
|
}
|
||||||
|
|
||||||
IfcEntityList::ptr get_inverse(const std::string& a) {
|
IfcEntityList::ptr get_inverse(const std::string& a) {
|
||||||
const std::vector<const IfcParse::inverse_attribute*> attrs = $self->declaration().as_entity()->all_inverse_attributes();
|
if ($self->declaration().as_entity()) {
|
||||||
std::vector<const IfcParse::inverse_attribute*>::const_iterator it = attrs.begin();
|
return ((IfcUtil::IfcBaseEntity*)$self)->get_inverse(a);
|
||||||
for (; it != attrs.end(); ++it) {
|
} else {
|
||||||
if ((*it)->name() == a) {
|
throw IfcParse::IfcException(a + " not found on " + $self->declaration().name());
|
||||||
return self->data().getInverse(
|
|
||||||
(*it)->entity_reference(),
|
|
||||||
(*it)->entity_reference()->attribute_index((*it)->attribute_reference()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
throw IfcParse::IfcException(a + " not found on " + $self->declaration().name());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* const get_argument_type(unsigned int i) const {
|
const char* const get_argument_type(unsigned int i) const {
|
||||||
|
|||||||
Reference in New Issue
Block a user