MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / apply_individual_instance_visitor

Class apply_individual_instance_visitor

src/ifcparse/IfcParse.cpp:1028–1086  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1026};
1027
1028class apply_individual_instance_visitor {
1029 private:
1030 boost::optional<AttributeValue> attribute_;
1031 int attribute_index_;
1032
1033 const IfcUtil::IfcBaseClass* inst_;
1034
1035
1036 template <typename T>
1037 void apply_attribute_(T& t, const AttributeValue& attr, int index) const {
1038 switch (attr.type()) {
1039 case IfcUtil::Argument_ENTITY_INSTANCE: {
1040 IfcUtil::IfcBaseClass* inst = attr;
1041 t(inst, index);
1042 break;
1043 }
1044 case IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE: {
1045 aggregate_of_instance::ptr entity_list_attribute = attr;
1046 for (aggregate_of_instance::it it = entity_list_attribute->begin(); it != entity_list_attribute->end(); ++it) {
1047 t(*it, index);
1048 }
1049 break;
1050 }
1051 case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE: {
1052 aggregate_of_aggregate_of_instance::ptr entity_list_attribute = attr;
1053 for (aggregate_of_aggregate_of_instance::outer_it it = entity_list_attribute->begin(); it != entity_list_attribute->end(); ++it) {
1054 for (aggregate_of_aggregate_of_instance::inner_it jt = it->begin(); jt != it->end(); ++jt) {
1055 t(*jt, index);
1056 }
1057 }
1058 break;
1059 }
1060 default:
1061 break;
1062 }
1063 }
1064 public:
1065 apply_individual_instance_visitor(const AttributeValue& attribute, int idx)
1066 : attribute_(attribute)
1067 , attribute_index_(idx)
1068 {}
1069
1070 apply_individual_instance_visitor(const IfcUtil::IfcBaseClass* data)
1071 : inst_(data)
1072 {}
1073
1074 template <typename T>
1075 void apply(T& t) const {
1076 if (attribute_) {
1077 apply_attribute_(t, *attribute_, attribute_index_);
1078 } else {
1079 const auto& decl = inst_->declaration();
1080 for (size_t i = 0; i < (decl.as_entity() ? decl.as_entity()->attribute_count() : 1); ++i) {
1081 auto attr = inst_->get_attribute_value(i);
1082 apply_attribute_(t, attr, (int) i);
1083 }
1084 }
1085 };

Callers 3

set_attribute_valueMethod · 0.85
traverse_Function · 0.85
build_inverses_Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected