Remove limited latebound schema representation in favour of full runtime schema representation

This commit is contained in:
Thomas Krijnen
2017-12-11 15:46:57 +01:00
parent 322dec6fd0
commit e7ccf7269a
12 changed files with 80 additions and 9637 deletions
+4
View File
@@ -17,6 +17,8 @@
* *
********************************************************************************/
#include "../ifcparse/IfcSchema.h"
#ifndef ARGUMENTTYPE_H
#define ARGUMENTTYPE_H
@@ -48,6 +50,8 @@ namespace IfcUtil {
Argument_UNKNOWN
};
ArgumentType from_parameter_type(const IfcParse::parameter_type*);
ArgumentType make_aggregate(ArgumentType elem_type);
}
#endif
File diff suppressed because it is too large Load Diff
-51
View File
@@ -1,51 +0,0 @@
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
/********************************************************************************
* *
* This file has been generated from IFC2X3_TC1.exp. Do not make modifications *
* but instead modify the python script that has been used to generate this. *
* *
********************************************************************************/
#ifndef IFC2X3RT_H
#define IFC2X3RT_H
#define IfcSchema Ifc2x3
#include "../ifcparse/ifc_parse_api.h"
#include "../ifcparse/IfcBaseClass.h"
#include "../ifcparse/IfcEntityDescriptor.h"
namespace Ifc2x3 {
namespace Type {
IFC_PARSE_API int GetAttributeCount(Enum t);
IFC_PARSE_API int GetAttributeIndex(Enum t, const std::string& a);
IFC_PARSE_API IfcUtil::ArgumentType GetAttributeType(Enum t, unsigned char a);
IFC_PARSE_API Enum GetAttributeEntity(Enum t, unsigned char a);
IFC_PARSE_API const std::string& GetAttributeName(Enum t, unsigned char a);
IFC_PARSE_API bool GetAttributeOptional(Enum t, unsigned char a);
IFC_PARSE_API bool GetAttributeDerived(Enum t, unsigned char a);
IFC_PARSE_API std::pair<const char*, int> GetEnumerationIndex(Enum t, const std::string& a);
IFC_PARSE_API std::pair<Enum, unsigned> GetInverseAttribute(Enum t, const std::string& a);
IFC_PARSE_API std::set<std::string> GetInverseAttributeNames(Enum t);
IFC_PARSE_API void PopulateDerivedFields(IfcEntityInstanceData* e);
}}
#endif
File diff suppressed because it is too large Load Diff
-51
View File
@@ -1,51 +0,0 @@
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
/********************************************************************************
* *
* This file has been generated from IFC4.exp. Do not make modifications *
* but instead modify the python script that has been used to generate this. *
* *
********************************************************************************/
#ifndef IFC4RT_H
#define IFC4RT_H
#define IfcSchema Ifc4
#include "../ifcparse/ifc_parse_api.h"
#include "../ifcparse/IfcBaseClass.h"
#include "../ifcparse/IfcEntityDescriptor.h"
namespace Ifc4 {
namespace Type {
IFC_PARSE_API int GetAttributeCount(Enum t);
IFC_PARSE_API int GetAttributeIndex(Enum t, const std::string& a);
IFC_PARSE_API IfcUtil::ArgumentType GetAttributeType(Enum t, unsigned char a);
IFC_PARSE_API Enum GetAttributeEntity(Enum t, unsigned char a);
IFC_PARSE_API const std::string& GetAttributeName(Enum t, unsigned char a);
IFC_PARSE_API bool GetAttributeOptional(Enum t, unsigned char a);
IFC_PARSE_API bool GetAttributeDerived(Enum t, unsigned char a);
IFC_PARSE_API std::pair<const char*, int> GetEnumerationIndex(Enum t, const std::string& a);
IFC_PARSE_API std::pair<Enum, unsigned> GetInverseAttribute(Enum t, const std::string& a);
IFC_PARSE_API std::set<std::string> GetInverseAttributeNames(Enum t);
IFC_PARSE_API void PopulateDerivedFields(IfcEntityInstanceData* e);
}}
#endif
+10 -31
View File
@@ -41,12 +41,6 @@
#include "../ifcparse/IfcSIPrefix.h"
#include "../ifcparse/IfcSchema.h"
#ifdef USE_IFC4
#include "../ifcparse/Ifc4-latebound.h"
#else
#include "../ifcparse/Ifc2x3-latebound.h"
#endif
#ifdef USE_MMAP
#include <boost/filesystem/path.hpp>
#endif
@@ -651,27 +645,7 @@ IfcUtil::ArgumentType ArgumentList::type() const {
}
const IfcUtil::ArgumentType elem_type = list[0]->type();
if (elem_type == IfcUtil::Argument_INT) {
return IfcUtil::Argument_AGGREGATE_OF_INT;
} else if (elem_type == IfcUtil::Argument_DOUBLE) {
return IfcUtil::Argument_AGGREGATE_OF_DOUBLE;
} else if (elem_type == IfcUtil::Argument_STRING) {
return IfcUtil::Argument_AGGREGATE_OF_STRING;
} else if (elem_type == IfcUtil::Argument_BINARY) {
return IfcUtil::Argument_AGGREGATE_OF_BINARY;
} else if (elem_type == IfcUtil::Argument_ENTITY_INSTANCE) {
return IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_INT) {
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_DOUBLE) {
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE) {
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE;
} else if (elem_type == IfcUtil::Argument_EMPTY_AGGREGATE) {
return IfcUtil::Argument_AGGREGATE_OF_EMPTY_AGGREGATE;
} else {
return IfcUtil::Argument_UNKNOWN;
}
return IfcUtil::make_aggregate(elem_type);
}
void ArgumentList::push(Argument* l) {
@@ -1147,12 +1121,17 @@ void IfcEntityInstanceData::setArgument(unsigned int i, Argument* a, IfcUtil::Ar
copy->set(attr_value);
break; }
case IfcUtil::Argument_ENUMERATION: {
IfcSchema::Type::Enum ty = IfcSchema::Type::GetAttributeEntity(type_, (unsigned char)i);
std::string enum_literal = a->toString();
// Remove leading and trailing '.'
enum_literal = enum_literal.substr(1, enum_literal.size() - 2);
std::pair<const char*, int> enum_ref = IfcSchema::Type::GetEnumerationIndex(ty, enum_literal);
copy->set(IfcWrite::IfcWriteArgument::EnumerationReference(enum_ref.second, enum_ref.first));
const IfcParse::enumeration_type* enum_type = get_schema().declaration_by_name(type())->as_entity()->all_attributes()[i]->type_of_attribute()->as_named_type()->declared_type()->as_enumeration_type();
std::vector<std::string>::const_iterator it = std::find(enum_type->enumeration_items().begin(), enum_type->enumeration_items().end(), enum_literal);
if (it == enum_type->enumeration_items().end()) {
throw IfcParse::IfcException(enum_literal + " does not name a valid item for " + enum_type->name());
}
copy->set(IfcWrite::IfcWriteArgument::EnumerationReference(it - enum_type->enumeration_items().begin(), it->c_str()));
break; }
case IfcUtil::Argument_ENTITY_INSTANCE: {
copy->set(static_cast<IfcUtil::IfcBaseClass*>(*a));
@@ -1187,7 +1166,7 @@ void IfcEntityInstanceData::setArgument(unsigned int i, Argument* a, IfcUtil::Ar
break; }
case IfcUtil::Argument_EMPTY_AGGREGATE:
case IfcUtil::Argument_AGGREGATE_OF_EMPTY_AGGREGATE: {
IfcUtil::ArgumentType t2 = IfcSchema::Type::GetAttributeType(type(), (unsigned char)i);
IfcUtil::ArgumentType t2 = IfcUtil::from_parameter_type(get_schema().declaration_by_name(type())->as_entity()->all_attributes()[i]->type_of_attribute());
delete copy;
copy = 0;
setArgument(i, a, t2);
+65 -6
View File
@@ -22,12 +22,6 @@
#include "../ifcparse/IfcException.h"
#include "../ifcparse/IfcEntityList.h"
#ifdef USE_IFC4
#include "../ifcparse/Ifc4-latebound.h"
#else
#include "../ifcparse/Ifc2x3-latebound.h"
#endif
#include <boost/algorithm/string/replace.hpp>
#include <boost/optional.hpp>
@@ -179,3 +173,68 @@ void IfcUtil::IfcBaseClass::data(IfcEntityInstanceData* d) {
delete data_;
data_ = d;
}
IfcUtil::ArgumentType IfcUtil::make_aggregate(IfcUtil::ArgumentType elem_type) {
if (elem_type == IfcUtil::Argument_INT) {
return IfcUtil::Argument_AGGREGATE_OF_INT;
} else if (elem_type == IfcUtil::Argument_DOUBLE) {
return IfcUtil::Argument_AGGREGATE_OF_DOUBLE;
} else if (elem_type == IfcUtil::Argument_STRING) {
return IfcUtil::Argument_AGGREGATE_OF_STRING;
} else if (elem_type == IfcUtil::Argument_BINARY) {
return IfcUtil::Argument_AGGREGATE_OF_BINARY;
} else if (elem_type == IfcUtil::Argument_ENTITY_INSTANCE) {
return IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_INT) {
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_DOUBLE) {
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE) {
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE;
} else if (elem_type == IfcUtil::Argument_EMPTY_AGGREGATE) {
return IfcUtil::Argument_AGGREGATE_OF_EMPTY_AGGREGATE;
} else {
return IfcUtil::Argument_UNKNOWN;
}
}
IfcUtil::ArgumentType IfcUtil::from_parameter_type(const IfcParse::parameter_type* pt) {
// TODO: How to detect derived types here without a reference to the refering entity?
const IfcParse::aggregation_type* at = pt->as_aggregation_type();
const IfcParse::named_type* nt = pt->as_named_type();
const IfcParse::simple_type* st = pt->as_simple_type();
if (at) {
return make_aggregate(from_parameter_type(at->type_of_element()));
} else if (nt) {
if (nt->declared_type()->as_entity()) {
return IfcUtil::Argument_ENTITY_INSTANCE;
} else if (nt->declared_type()->as_enumeration_type()) {
return IfcUtil::Argument_ENUMERATION;
} else if (nt->declared_type()->as_select_type()) {
return IfcUtil::Argument_ENTITY_INSTANCE;
} else if (nt->declared_type()->as_type_declaration()) {
return from_parameter_type(nt->declared_type()->as_type_declaration()->declared_type());
}
} else if (st) {
switch (st->declared_type()) {
case IfcParse::simple_type::binary_type:
return IfcUtil::Argument_BINARY;
case IfcParse::simple_type::boolean_type:
return IfcUtil::Argument_BOOL;
case IfcParse::simple_type::integer_type:
return IfcUtil::Argument_INT;
case IfcParse::simple_type::logical_type:
return IfcUtil::Argument_BOOL;
case IfcParse::simple_type::number_type:
return IfcUtil::Argument_DOUBLE;
case IfcParse::simple_type::real_type:
return IfcUtil::Argument_DOUBLE;
case IfcParse::simple_type::string_type:
return IfcUtil::Argument_STRING;
}
}
return IfcUtil::Argument_UNKNOWN;
}
-6
View File
@@ -28,12 +28,6 @@
#include "../ifcparse/IfcCharacterDecoder.h"
#include "../ifcparse/IfcFile.h"
#ifdef USE_IFC4
#include "../ifcparse/Ifc4-latebound.h"
#else
#include "../ifcparse/Ifc2x3-latebound.h"
#endif
using namespace IfcWrite;
class SizeVisitor : public boost::static_visitor<int> {