2017-12-19 20:24:00 +01:00
|
|
|
#include "IteratorImplementation.h"
|
|
|
|
|
|
2017-12-21 14:14:04 +01:00
|
|
|
#include <boost/algorithm/string/case_conv.hpp>
|
|
|
|
|
|
2017-12-19 20:24:00 +01:00
|
|
|
template <typename P>
|
|
|
|
|
IteratorFactoryImplementation<P>& iterator_implementations() {
|
|
|
|
|
static IteratorFactoryImplementation<P> impl;
|
|
|
|
|
return impl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template IteratorFactoryImplementation<float>& iterator_implementations<float>();
|
|
|
|
|
template IteratorFactoryImplementation<double>& iterator_implementations<double>();
|
|
|
|
|
|
2017-12-21 14:14:04 +01:00
|
|
|
template <typename P>
|
|
|
|
|
extern void init_IteratorImplementation_Ifc2x3(IteratorFactoryImplementation<P>*);
|
|
|
|
|
|
|
|
|
|
template <typename P>
|
|
|
|
|
extern void init_IteratorImplementation_Ifc4(IteratorFactoryImplementation<P>*);
|
2017-12-19 20:24:00 +01:00
|
|
|
|
|
|
|
|
template <typename P>
|
|
|
|
|
IteratorFactoryImplementation<P>::IteratorFactoryImplementation() {
|
2017-12-21 14:14:04 +01:00
|
|
|
init_IteratorImplementation_Ifc2x3(this);
|
|
|
|
|
init_IteratorImplementation_Ifc4(this);
|
2017-12-19 20:24:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class P>
|
|
|
|
|
void IteratorFactoryImplementation<P>::bind(const std::string& schema_name, typename get_factory_type<P>::type fn) {
|
2017-12-21 14:14:04 +01:00
|
|
|
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
|
|
|
|
|
this->insert(std::make_pair(schema_name_lower, fn));
|
2017-12-19 20:24:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 11:10:27 +01:00
|
|
|
template <class P>
|
|
|
|
|
IfcGeom::IteratorImplementation<P>* IteratorFactoryImplementation<P>::construct(const std::string& schema_name, const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file) {
|
2017-12-21 14:14:04 +01:00
|
|
|
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
|
2017-12-29 12:09:07 +01:00
|
|
|
typename std::map<std::string, typename get_factory_type<P>::type>::const_iterator it;
|
2017-12-21 14:14:04 +01:00
|
|
|
it = this->find(schema_name_lower);
|
2017-12-29 12:09:07 +01:00
|
|
|
if (it == this->end()) {
|
2017-12-20 11:10:27 +01:00
|
|
|
throw IfcParse::IfcException("No geometry iterator registered for " + schema_name);
|
|
|
|
|
}
|
|
|
|
|
return it->second(settings, file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-12-29 12:09:07 +01:00
|
|
|
template class IteratorFactoryImplementation<float>;
|
|
|
|
|
template class IteratorFactoryImplementation<double>;
|