mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-19 11:43:53 +00:00
Silence obvious compiler warnings
Generated with the assistance of an AI coding tool.
This commit is contained in:
@@ -79,11 +79,16 @@ namespace {
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
throw std::logic_error("RocksDB storage is unavailable");
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool dispatch_has_(attribute_value::pointer_type array_, uint8_t storage_model_, size_t instance_name_, const ifcopenshell::declaration* entity_or_type, uint8_t index_)
|
||||
{
|
||||
#ifndef IFOPSH_WITH_ROCKSDB
|
||||
(void)instance_name_;
|
||||
(void)entity_or_type;
|
||||
#endif
|
||||
if (storage_model_ == 0) {
|
||||
return array_.storage_ptr->has<T>(index_);
|
||||
}
|
||||
@@ -103,10 +108,15 @@ namespace {
|
||||
return str[0] == type_encoder::encode_type<T>();
|
||||
}
|
||||
#endif
|
||||
throw std::logic_error("RocksDB storage is unavailable");
|
||||
}
|
||||
|
||||
inline size_t dispatch_index_(attribute_value::pointer_type array_, uint8_t storage_model_, size_t instance_name_, const ifcopenshell::declaration* entity_or_type, uint8_t index_)
|
||||
{
|
||||
#ifndef IFOPSH_WITH_ROCKSDB
|
||||
(void)instance_name_;
|
||||
(void)entity_or_type;
|
||||
#endif
|
||||
if (storage_model_ == 0) {
|
||||
return array_.storage_ptr->index(index_);
|
||||
}
|
||||
@@ -123,6 +133,7 @@ namespace {
|
||||
return (size_t) str[0] - 'A';
|
||||
}
|
||||
#endif
|
||||
throw std::logic_error("RocksDB storage is unavailable");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,6 +207,7 @@ attribute_value::operator enumeration_reference() const
|
||||
return enumeration_reference(decl, v);
|
||||
}
|
||||
#endif
|
||||
throw std::logic_error("RocksDB storage is unavailable");
|
||||
}
|
||||
|
||||
attribute_value::operator boost::dynamic_bitset<>() const
|
||||
@@ -229,6 +241,7 @@ attribute_value::operator express::base () const
|
||||
}
|
||||
}
|
||||
#endif
|
||||
throw std::logic_error("RocksDB storage is unavailable");
|
||||
}
|
||||
|
||||
attribute_value::operator std::vector<int64_t>() const
|
||||
|
||||
@@ -266,7 +266,6 @@ typename std::conditional_t<
|
||||
std::vector<T>>
|
||||
cast_vector(const std::vector<U>& values) {
|
||||
if constexpr (is_std_vector<U>::value) {
|
||||
using value_type = typename U::value_type;
|
||||
std::vector<std::vector<T>> result;
|
||||
result.reserve(values.size());
|
||||
for (const auto& value : values) {
|
||||
|
||||
+19
-6
@@ -33,6 +33,10 @@ ifcopenshell::impl::rocks_db_file_storage::rocksdb_types_iterator::value_type co
|
||||
}
|
||||
|
||||
express::base ifcopenshell::impl::rocks_db_file_storage::assert_existance(size_t number, instance_ref r) {
|
||||
#ifndef IFOPSH_WITH_ROCKSDB
|
||||
(void)number;
|
||||
(void)r;
|
||||
#endif
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
std::lock_guard<std::mutex> lock(instance_cache_mutex_);
|
||||
|
||||
@@ -81,6 +85,10 @@ express::base ifcopenshell::impl::rocks_db_file_storage::assert_existance(size_t
|
||||
|
||||
namespace {
|
||||
std::unique_ptr<rocksdb::DB> init_db(const std::string& filepath, bool readonly) {
|
||||
#ifndef IFOPSH_WITH_ROCKSDB
|
||||
(void)filepath;
|
||||
(void)readonly;
|
||||
#endif
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
rocksdb::Options options;
|
||||
// options.disable_auto_compactions = true;
|
||||
@@ -93,7 +101,7 @@ namespace {
|
||||
|
||||
/*
|
||||
tbo.block_size = 16 * 1024;
|
||||
tbo.filter_policy.reset(rocksdb::NewBloomFilterPolicy(10 /*bits/key/, false));
|
||||
tbo.filter_policy.reset(rocksdb::NewBloomFilterPolicy(10, false)); // bits/key
|
||||
tbo.partition_filters = true;
|
||||
tbo.index_type = rocksdb::BlockBasedTableOptions::kHashSearch;
|
||||
tbo.cache_index_and_filter_blocks = true;
|
||||
@@ -143,14 +151,14 @@ namespace {
|
||||
|
||||
// @todo naming
|
||||
ifcopenshell::impl::rocks_db_file_storage::rocks_db_file_storage(const std::string& filepath, ifcopenshell::file* ffile, bool readonly)
|
||||
: file(ffile)
|
||||
, db(init_db(filepath, readonly))
|
||||
// @todo streaming serializer does not populate the byguid map
|
||||
, byguid_internal_(db.get(), "g|"),
|
||||
byguid_(&byguid_internal_, [this](size_t v) { return assert_existance(v, entityinstance_ref); }, [](const express::base& v) { return v.identity(); })
|
||||
: db(init_db(filepath, readonly))
|
||||
, file(ffile)
|
||||
, instance_ids_(db.get(), "i|")
|
||||
, instance_by_name_(&instance_ids_, [this](size_t v) { return assert_existance(v, entityinstance_ref); })
|
||||
, bytype_(db.get(), "t|")
|
||||
// @todo streaming serializer does not populate the byguid map
|
||||
, byguid_internal_(db.get(), "g|"),
|
||||
byguid_(&byguid_internal_, [this](size_t v) { return assert_existance(v, entityinstance_ref); }, [](const express::base& v) { return v.identity(); })
|
||||
, byref_excl_(db.get(), "v|")
|
||||
// @todo by_identity is probably not correct here, this mapping is Name -> Identity, so Fn should have access to full pair?
|
||||
// , byidentity_(&byid_, [this](size_t v) { return assert_existance(v, by_identity); }, [](ifcopenshell::IfcBaseClass* v) { return v->identity(); })
|
||||
@@ -192,6 +200,9 @@ express::base ifcopenshell::impl::rocks_db_file_storage::instance_by_id(int id)
|
||||
|
||||
void ifcopenshell::impl::rocks_db_file_storage::process_deletion_inverse(const express::base& inst)
|
||||
{
|
||||
#ifndef IFOPSH_WITH_ROCKSDB
|
||||
(void)inst;
|
||||
#endif
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
auto id = inst.id();
|
||||
|
||||
@@ -337,6 +348,8 @@ ifcopenshell::filetype ifcopenshell::guess_file_type(const std::string& fn) {
|
||||
}
|
||||
|
||||
express::base ifcopenshell::impl::rocks_db_file_storage::create(const ifcopenshell::declaration* decl, int id) {
|
||||
(void)decl;
|
||||
(void)id;
|
||||
return express::base{};
|
||||
/*
|
||||
if (decl->as_entity() || decl->as_type_declaration()) {
|
||||
|
||||
@@ -95,6 +95,7 @@ void expand(const std::string& s, std::vector<unsigned char>& v) {
|
||||
#endif
|
||||
|
||||
ifcopenshell::global_id::global_id(logger& logger) {
|
||||
(void)logger;
|
||||
uuid_data_ = gen();
|
||||
std::vector<unsigned char> v(uuid_data_.size());
|
||||
std::copy(uuid_data_.begin(), uuid_data_.end(), v.begin());
|
||||
@@ -118,6 +119,7 @@ ifcopenshell::global_id::global_id(logger& logger) {
|
||||
|
||||
ifcopenshell::global_id::global_id(const std::string& string, logger& logger)
|
||||
: string_data_(string) {
|
||||
(void)logger;
|
||||
std::vector<unsigned char> result;
|
||||
expand(string_data_, result);
|
||||
std::copy(result.begin(), result.end(), uuid_data_.begin());
|
||||
|
||||
@@ -245,10 +245,6 @@ class IFC_PARSE_API mutable_attribute_value {
|
||||
uint8_t index_;
|
||||
};
|
||||
|
||||
namespace impl {
|
||||
class IFC_PARSE_API rocks_db_file_storage;
|
||||
}
|
||||
|
||||
} // namespace ifcopenshell
|
||||
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
@@ -579,12 +575,15 @@ class IFC_PARSE_API instance_data {
|
||||
void set_attribute_value(std::size_t attribute_index, T&& value) {
|
||||
if (storage_) {
|
||||
storage_->set(attribute_index, value);
|
||||
return;
|
||||
}
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
else {
|
||||
rocks_db_attribute_storage{}.set(get_storage_of_type<ifcopenshell::impl::rocks_db_file_storage>(), declaration_, id_ ? id_ : identity_, attribute_index, value);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
throw std::logic_error("RocksDB storage is unavailable");
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -597,6 +596,7 @@ class IFC_PARSE_API instance_data {
|
||||
return rocks_db_attribute_storage{}.has<T>(get_storage_of_type<ifcopenshell::impl::rocks_db_file_storage>(), declaration_, id_ ? id_ : identity_, attribute_index);
|
||||
}
|
||||
#endif
|
||||
throw std::logic_error("RocksDB storage is unavailable");
|
||||
}
|
||||
|
||||
void to_string(std::ostream& stream, bool uppercase = false) const;
|
||||
|
||||
+23
-7
@@ -1074,6 +1074,12 @@ namespace {
|
||||
}
|
||||
|
||||
void ifcopenshell::impl::rocks_db_file_storage::register_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, int inst_id, int attribute_index) {
|
||||
#ifndef IFOPSH_WITH_ROCKSDB
|
||||
(void)id_from;
|
||||
(void)from_entity;
|
||||
(void)inst_id;
|
||||
(void)attribute_index;
|
||||
#endif
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
static std::string s;
|
||||
uint32_t v = id_from;
|
||||
@@ -1096,6 +1102,12 @@ void ifcopenshell::impl::rocks_db_file_storage::register_inverse(unsigned id_fro
|
||||
}
|
||||
|
||||
void ifcopenshell::impl::rocks_db_file_storage::unregister_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, const express::base& inst, int attribute_index) {
|
||||
#ifndef IFOPSH_WITH_ROCKSDB
|
||||
(void)id_from;
|
||||
(void)from_entity;
|
||||
(void)inst;
|
||||
(void)attribute_index;
|
||||
#endif
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
static std::string s;
|
||||
auto inst_id = inst.id();
|
||||
@@ -1118,6 +1130,9 @@ void ifcopenshell::impl::rocks_db_file_storage::unregister_inverse(unsigned id_f
|
||||
|
||||
void ifcopenshell::impl::rocks_db_file_storage::add_type_ref(const express::base& new_entity)
|
||||
{
|
||||
#ifndef IFOPSH_WITH_ROCKSDB
|
||||
(void)new_entity;
|
||||
#endif
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
size_t v;
|
||||
std::string s(sizeof(size_t), ' ');
|
||||
@@ -1148,6 +1163,9 @@ void ifcopenshell::impl::rocks_db_file_storage::add_type_ref(const express::base
|
||||
|
||||
void ifcopenshell::impl::rocks_db_file_storage::remove_type_ref(const express::base& new_entity)
|
||||
{
|
||||
#ifndef IFOPSH_WITH_ROCKSDB
|
||||
(void)new_entity;
|
||||
#endif
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
if (new_entity.declaration().as_entity()) {
|
||||
std::string s;
|
||||
@@ -1444,7 +1462,7 @@ unsigned ifcopenshell::IfcBaseEntity::set_id(const std::optional<unsigned>& i) {
|
||||
namespace {
|
||||
// @todo remove redundancy with python wrapper code (which is not identical due to
|
||||
// different handling of enumerations)
|
||||
ifcopenshell::argument_type get_argument_type(const ifcopenshell::declaration* decl, size_t i) {
|
||||
[[maybe_unused]] ifcopenshell::argument_type get_argument_type(const ifcopenshell::declaration* decl, size_t i) {
|
||||
const ifcopenshell::parameter_type* pt = 0;
|
||||
if (decl->as_entity() != nullptr) {
|
||||
pt = decl->as_entity()->attribute_by_index(i)->type_of_attribute();
|
||||
@@ -1613,10 +1631,7 @@ express::base::set_attribute_value(size_t i, const T& t) {
|
||||
apply_individual_instance_visitor(current_attribute, (int)i).apply(visitor);
|
||||
}
|
||||
|
||||
{
|
||||
void* const storage = std::visit([](const auto& m) { return (void*)&m; }, file()->storage_);
|
||||
data()->set_attribute_value(i, t);
|
||||
}
|
||||
data()->set_attribute_value(i, t);
|
||||
auto new_attribute = get_attribute_value(i);
|
||||
|
||||
// Register inverse indices in file
|
||||
@@ -2820,12 +2835,10 @@ void file::process_deletion_(const express::base& entity) {
|
||||
} break;
|
||||
case ifcopenshell::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE: {
|
||||
std::vector<std::vector<express::base>> instance_list_list = attr;
|
||||
bool updated = false;
|
||||
for (auto& li : instance_list_list) {
|
||||
auto it = std::remove(li.begin(), li.end(), entity);
|
||||
if (it != li.end()) {
|
||||
li.erase(it, li.end());
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
related_instance.set_attribute_value(i, instance_list_list);
|
||||
@@ -3432,6 +3445,9 @@ attribute_value instance_data::get_attribute_value(size_t index) const
|
||||
}
|
||||
|
||||
bool ifcopenshell::impl::rocks_db_file_storage::read_schema(const ifcopenshell::schema_definition*& schema) {
|
||||
#ifndef IFOPSH_WITH_ROCKSDB
|
||||
(void)schema;
|
||||
#endif
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
std::string value;
|
||||
auto key = "h|file_schema|0";
|
||||
|
||||
@@ -294,6 +294,9 @@ public:
|
||||
}
|
||||
|
||||
bool operator==(const iterator& other) const {
|
||||
#ifndef IFOPSH_WITH_ROCKSDB
|
||||
(void)other;
|
||||
#endif
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
if (!it_ && !other.it_) return true;
|
||||
if (it_ && other.it_)
|
||||
@@ -322,7 +325,10 @@ public:
|
||||
return iterator();
|
||||
}
|
||||
|
||||
iterator find(const key_type& key) const {
|
||||
iterator find(const key_type& key) const {
|
||||
#ifndef IFOPSH_WITH_ROCKSDB
|
||||
(void)key;
|
||||
#endif
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
std::string key_str = key_to_string(key);
|
||||
std::string full_key = prefix_ + key_str;
|
||||
@@ -334,7 +340,10 @@ public:
|
||||
return end();
|
||||
}
|
||||
|
||||
size_t erase(const key_type& key) {
|
||||
size_t erase(const key_type& key) {
|
||||
#ifndef IFOPSH_WITH_ROCKSDB
|
||||
(void)key;
|
||||
#endif
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
std::string key_str = key_to_string(key);
|
||||
std::string full_key = prefix_ + key_str;
|
||||
|
||||
@@ -163,6 +163,9 @@ public:
|
||||
}
|
||||
|
||||
bool operator==(const iterator& other) const {
|
||||
#ifndef IFOPSH_WITH_ROCKSDB
|
||||
(void)other;
|
||||
#endif
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
if (!it_ && !other.it_)
|
||||
return true;
|
||||
|
||||
@@ -35,7 +35,7 @@ double get_SI_equivalent(const typename Schema::IfcNamedUnit& named_unit) {
|
||||
if (auto conv_unit = named_unit.template as<typename Schema::IfcConversionBasedUnit>()) {
|
||||
auto factor = conv_unit.ConversionFactor();
|
||||
auto component = factor.UnitComponent();
|
||||
if (si_unit = component.concrete().template as<typename Schema::IfcSIUnit>()) {
|
||||
if ((si_unit = component.concrete().template as<typename Schema::IfcSIUnit>())) {
|
||||
auto value = factor.ValueComponent();
|
||||
scale = value.get_attribute_value(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user