mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 11:24:19 +00:00
Virtual inheritance prototype for select
This commit is contained in:
+816
-816
File diff suppressed because it is too large
Load Diff
+966
-966
File diff suppressed because it is too large
Load Diff
+991
-991
File diff suppressed because it is too large
Load Diff
+1006
-1006
File diff suppressed because it is too large
Load Diff
+1075
-1075
File diff suppressed because it is too large
Load Diff
+1082
-1082
File diff suppressed because it is too large
Load Diff
+1071
-1071
File diff suppressed because it is too large
Load Diff
+1070
-1070
File diff suppressed because it is too large
Load Diff
+35
-24
@@ -33,14 +33,46 @@ class aggregate_of_instance;
|
||||
|
||||
namespace IfcUtil {
|
||||
|
||||
class IFC_PARSE_API IfcBaseClass {
|
||||
class IFC_PARSE_API IfcBaseInterface {
|
||||
protected:
|
||||
static bool is_null(const IfcBaseInterface* not_this) {
|
||||
return !not_this;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual const IfcEntityInstanceData& data() const = 0;
|
||||
virtual IfcEntityInstanceData& data() = 0;
|
||||
virtual const IfcParse::declaration& declaration() const = 0;
|
||||
|
||||
template <class T>
|
||||
T* as() {
|
||||
// @todo: do not allow this to be null in the first place
|
||||
if (is_null(this)) {
|
||||
return static_cast<T*>(0);
|
||||
}
|
||||
return declaration().is(T::Class())
|
||||
? dynamic_cast<T*>(this)
|
||||
: static_cast<T*>(0);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
const T* as() const {
|
||||
if (is_null(this)) {
|
||||
return static_cast<const T*>(0);
|
||||
}
|
||||
return declaration().is(T::Class())
|
||||
? dynamic_cast<const T*>(this)
|
||||
: static_cast<const T*>(0);
|
||||
}
|
||||
};
|
||||
|
||||
class IFC_PARSE_API IfcBaseClass : public virtual IfcBaseInterface {
|
||||
protected:
|
||||
IfcEntityInstanceData* data_;
|
||||
|
||||
static bool is_null(const IfcBaseClass* not_this) {
|
||||
return !not_this;
|
||||
}
|
||||
|
||||
}
|
||||
public:
|
||||
IfcBaseClass() : data_(0) {}
|
||||
IfcBaseClass(IfcEntityInstanceData* d) : data_(d) {}
|
||||
@@ -51,27 +83,6 @@ namespace IfcUtil {
|
||||
void data(IfcEntityInstanceData* d);
|
||||
|
||||
virtual const IfcParse::declaration& declaration() const = 0;
|
||||
|
||||
template <class T>
|
||||
T* as() {
|
||||
// @todo: do not allow this to be null in the first place
|
||||
if (is_null(this)) {
|
||||
return static_cast<T*>(0);
|
||||
}
|
||||
return declaration().is(T::Class())
|
||||
? static_cast<T*>(this)
|
||||
: static_cast<T*>(0);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
const T* as() const {
|
||||
if (is_null(this)) {
|
||||
return static_cast<const T*>(0);
|
||||
}
|
||||
return declaration().is(T::Class())
|
||||
? static_cast<const T*>(this)
|
||||
: static_cast<const T*>(0);
|
||||
}
|
||||
};
|
||||
|
||||
class IFC_PARSE_API IfcLateBoundEntity : public IfcBaseClass {
|
||||
|
||||
@@ -395,11 +395,13 @@ void IfcHierarchyHelper<Schema>::clipRepresentation(typename Schema::IfcRepresen
|
||||
typename Schema::IfcRepresentationItem::list::ptr items = rep->Items();
|
||||
typename Schema::IfcRepresentationItem::list::ptr new_items (new typename Schema::IfcRepresentationItem::list);
|
||||
for (typename Schema::IfcRepresentationItem::list::it i = items->begin(); i != items->end(); ++i) {
|
||||
typename Schema::IfcRepresentationItem* item = *i;
|
||||
typename Schema::IfcBooleanClippingResult* clip = new typename Schema::IfcBooleanClippingResult(
|
||||
Schema::IfcBooleanOperator::IfcBooleanOperator_DIFFERENCE, item, half_space);
|
||||
addEntity(clip);
|
||||
new_items->push(clip);
|
||||
auto item = dynamic_cast<typename Schema::IfcBooleanOperand*>(*i);
|
||||
if (item) {
|
||||
typename Schema::IfcBooleanClippingResult* clip = new typename Schema::IfcBooleanClippingResult(
|
||||
Schema::IfcBooleanOperator::IfcBooleanOperator_DIFFERENCE, item, half_space);
|
||||
addEntity(clip);
|
||||
new_items->push(clip);
|
||||
}
|
||||
}
|
||||
rep->setItems(new_items);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace {
|
||||
const std::array<std::basic_string<wchar_t>, 4> severity_strings<wchar_t>::value = { L"Debug", L"Notice", L"Warning", L"Error" };
|
||||
|
||||
template <typename T>
|
||||
void plain_text_message(T& os, const boost::optional<IfcUtil::IfcBaseClass*>& current_product, Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseClass* instance) {
|
||||
void plain_text_message(T& os, const boost::optional<IfcUtil::IfcBaseClass*>& current_product, Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
||||
os << "[" << severity_strings<typename T::char_type>::value[type] << "] ";
|
||||
if (current_product) {
|
||||
std::string global_id = *((IfcUtil::IfcBaseEntity*)*current_product)->get("GlobalId");
|
||||
@@ -71,7 +71,7 @@ namespace {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void json_message(T& os, const boost::optional<IfcUtil::IfcBaseClass*>& current_product, Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseClass* instance) {
|
||||
void json_message(T& os, const boost::optional<IfcUtil::IfcBaseClass*>& current_product, Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
||||
boost::property_tree::basic_ptree<std::basic_string<typename T::char_type>, std::basic_string<typename T::char_type> > pt;
|
||||
|
||||
// @todo this is crazy
|
||||
@@ -117,7 +117,7 @@ void Logger::SetOutput(std::wostream* l1, std::wostream* l2) {
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::Message(Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseClass* instance) {
|
||||
void Logger::Message(Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
||||
static std::mutex m;
|
||||
std::lock_guard<std::mutex> lk(m);
|
||||
|
||||
@@ -141,7 +141,7 @@ void Logger::Message(Logger::Severity type, const std::string& message, const If
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::Message(Logger::Severity type, const std::exception& exception, const IfcUtil::IfcBaseClass* instance) {
|
||||
void Logger::Message(Logger::Severity type, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance) {
|
||||
Message(type, std::string(exception.what()), instance);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,16 +72,16 @@ public:
|
||||
static Format OutputFormat();
|
||||
|
||||
/// Log a message to the output stream
|
||||
static void Message(Severity type, const std::string& message, const IfcUtil::IfcBaseClass* instance = 0);
|
||||
static void Message(Severity type, const std::exception& message, const IfcUtil::IfcBaseClass* instance = 0);
|
||||
static void Message(Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0);
|
||||
static void Message(Severity type, const std::exception& message, const IfcUtil::IfcBaseInterface* instance = 0);
|
||||
|
||||
static void Notice(const std::string& message, const IfcUtil::IfcBaseClass* instance = 0) { Message(LOG_NOTICE, message, instance); }
|
||||
static void Warning(const std::string& message, const IfcUtil::IfcBaseClass* instance = 0) { Message(LOG_WARNING, message, instance); }
|
||||
static void Error(const std::string& message, const IfcUtil::IfcBaseClass* instance = 0) { Message(LOG_ERROR, message, instance); }
|
||||
static void Notice(const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_NOTICE, message, instance); }
|
||||
static void Warning(const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_WARNING, message, instance); }
|
||||
static void Error(const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_ERROR, message, instance); }
|
||||
|
||||
static void Notice(const std::exception& exception, const IfcUtil::IfcBaseClass* instance = 0) { Message(LOG_NOTICE, exception, instance); }
|
||||
static void Warning(const std::exception& exception, const IfcUtil::IfcBaseClass* instance = 0) { Message(LOG_WARNING, exception, instance); }
|
||||
static void Error(const std::exception& exception, const IfcUtil::IfcBaseClass* instance = 0) { Message(LOG_ERROR, exception, instance); }
|
||||
static void Notice(const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_NOTICE, exception, instance); }
|
||||
static void Warning(const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_WARNING, exception, instance); }
|
||||
static void Error(const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_ERROR, exception, instance); }
|
||||
|
||||
static void Status(const std::string& message, bool new_line=true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user