ifcparse refactoring (#190)

Unify attribute containers, provide latebound attribute access on IfcBaseEntity, more basic tests on Travis
This commit is contained in:
Thomas Krijnen
2017-06-05 17:26:58 +02:00
committed by GitHub
parent 9a43658716
commit 5e0da9725a
49 changed files with 9228 additions and 9416 deletions
+22 -16
View File
@@ -32,9 +32,13 @@
#include <boost/optional.hpp>
#include <boost/dynamic_bitset.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/type_traits/remove_pointer.hpp>
#include "ifc_parse_api.h"
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/IfcBaseClass.h"
#include "../ifcparse/IfcParse.h"
namespace IfcWrite {
@@ -111,17 +115,31 @@ namespace IfcWrite {
IfcEntityListList::ptr
> container;
public:
template <typename T> const T& as() const {
template <typename T>
const T& as() const {
if (const T* val = boost::get<T>(&container)) {
return *val;
} else {
throw IfcParse::IfcException("Invalid cast");
}
}
template <typename T> void set(const T& t) {
template <typename T>
typename boost::disable_if<boost::is_base_of<IfcUtil::IfcBaseClass, typename boost::remove_pointer<T>::type>, void>::type
set(const T& t) {
container = t;
}
// Overload to detect null values
void set(const IfcEntityList::ptr& v);
// Overload to detect null values
void set(const IfcEntityListList::ptr& v);
// Overload to detect null values
void set(IfcUtil::IfcBaseClass*const & v);
operator int() const;
operator bool() const;
operator double() const;
@@ -146,19 +164,7 @@ namespace IfcWrite {
IfcUtil::ArgumentType type() const;
};
// Accumulates all schema instances created from constructors
// This way they can be added in a single batch to the IfcFile
class IFC_PARSE_API EntityBuffer {
private:
IfcEntityList::ptr buffer;
static EntityBuffer* i;
static EntityBuffer* instance();
public:
static IfcEntityList::ptr Get();
static void Clear();
static void Add(IfcUtil::IfcBaseClass* e);
};
}
#endif