option to disable guid map and lazy loading

This commit is contained in:
Thomas Krijnen
2021-09-13 13:17:08 +02:00
parent 7440321b30
commit 99a27fbfef
2 changed files with 26 additions and 2 deletions
+8
View File
@@ -112,6 +112,14 @@ public:
}
};
static bool lazy_load_;
static bool lazy_load() { return lazy_load_; }
static void lazy_load(bool b) { lazy_load_ = b; }
static bool guid_map_;
static bool guid_map() { return guid_map_; }
static void guid_map(bool b) { guid_map_ = b; }
private:
typedef std::map<uint32_t, IfcUtil::IfcBaseClass*> entity_entity_map_t;
+18 -2
View File
@@ -1077,7 +1077,16 @@ void IfcEntityInstanceData::load() const {
if (type_ != 0) {
tmp_data = new Argument*[getArgumentCount()]{};
}
file->seek_to(*this);
if (file->parsing_complete()) {
// only when parsing is fully complete we need to seek to the instance, otherwise
// we know the token cursor is currently at the keyword token
file->seek_to(*this);
} else {
// Apparently the load() function assumes one token later after the opening parenthesis
file->tokens->Next();
}
size_t n = file->load(id(), type_ ? type_->as_entity() : nullptr, tmp_data, getArgumentCount());
if (n != getArgumentCount()) {
Logger::Error("Wrong number of attributes on instance with id #" + boost::lexical_cast<std::string>(id_));
@@ -1487,6 +1496,10 @@ void IfcFile::initialize_(IfcParse::IfcSpfStream* s) {
Logger::Status(ss.str(), false);
}
if (!lazy_load_) {
data->load();
}
if (instance->declaration().is(*ifcroot_type_)) {
try {
const std::string guid = *instance->data().getArgument(0);
@@ -2400,4 +2413,7 @@ void IfcParse::IfcFile::build_inverses() {
}
}
std::atomic_uint32_t IfcUtil::IfcBaseClass::counter_(0);
std::atomic_uint32_t IfcUtil::IfcBaseClass::counter_(0);
bool IfcParse::IfcFile::lazy_load_ = true;
bool IfcParse::IfcFile::guid_map_ = true;