mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-30 00:23:14 +00:00
tree and document plug-ins
This commit is contained in:
@@ -1,19 +1,27 @@
|
||||
file(GLOB SERIALIZERS_S_H_FILES *.h)
|
||||
file(GLOB SERIALIZERS_S_CPP_FILES *.cpp)
|
||||
set(SERIALIZERS_S_FILES ${SERIALIZERS_S_H_FILES} ${SERIALIZERS_S_CPP_FILES})
|
||||
set(document_serializer_plugin_runtime_dir "${CMAKE_BINARY_DIR}/serializers/$<CONFIG>")
|
||||
|
||||
foreach(schema ${SCHEMA_VERSIONS})
|
||||
add_library(Serializers_ifc${schema} OBJECT ${SERIALIZERS_S_FILES})
|
||||
set(SERIALIZER_SCHEMA_LIBRARIES ${SERIALIZER_SCHEMA_LIBRARIES} Serializers_ifc${schema})
|
||||
set_target_properties(Serializers_ifc${schema} PROPERTIES COMPILE_FLAGS "-DSERIALIZERS_EXPORTS -DIfcSchema=Ifc${schema}")
|
||||
if(WASM_BUILD)
|
||||
target_link_libraries(Serializers_ifc${schema} ${HDF5_LIBRARIES})
|
||||
else()
|
||||
target_link_libraries(Serializers_ifc${schema} IfcGeom ${OpenCASCADE_LIBRARIES} ${HDF5_LIBRARIES})
|
||||
endif()
|
||||
add_library(document_serializer_xml_ifc${schema} SHARED XmlSerializer.cpp xml_plugin.cpp)
|
||||
target_link_libraries(document_serializer_xml_ifc${schema} PRIVATE plugin Serializers IfcGeom IfcParse)
|
||||
set_target_properties(document_serializer_xml_ifc${schema} PROPERTIES
|
||||
COMPILE_FLAGS "-DIfcSchema=Ifc${schema}"
|
||||
OUTPUT_NAME "document.xml.ifc${schema}"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${document_serializer_plugin_runtime_dir}"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${document_serializer_plugin_runtime_dir}"
|
||||
)
|
||||
list(APPEND document_serializer_libraries document_serializer_xml_ifc${schema})
|
||||
|
||||
install(TARGETS Serializers_ifc${schema})
|
||||
if(WITH_GLTF)
|
||||
add_library(document_serializer_json_ifc${schema} SHARED JsonSerializer.cpp json_plugin.cpp)
|
||||
target_link_libraries(document_serializer_json_ifc${schema} PRIVATE plugin Serializers IfcGeom IfcParse)
|
||||
set_target_properties(document_serializer_json_ifc${schema} PROPERTIES
|
||||
COMPILE_FLAGS "-DIfcSchema=Ifc${schema}"
|
||||
OUTPUT_NAME "document.json.ifc${schema}"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${document_serializer_plugin_runtime_dir}"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${document_serializer_plugin_runtime_dir}"
|
||||
)
|
||||
list(APPEND document_serializer_libraries document_serializer_json_ifc${schema})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
||||
set(SERIALIZER_SCHEMA_LIBRARIES ${SERIALIZER_SCHEMA_LIBRARIES} PARENT_SCOPE)
|
||||
set(document_serializer_libraries ${document_serializer_libraries} PARENT_SCOPE)
|
||||
|
||||
@@ -32,22 +32,6 @@
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
namespace {
|
||||
struct POSTFIX_SCHEMA(factory_t) {
|
||||
JsonSerializer* operator()(ifcopenshell::file* file, const std::string& json_filename, JsonSerializer::Dialect dialect) const {
|
||||
POSTFIX_SCHEMA(JsonSerializer)* s = new POSTFIX_SCHEMA(JsonSerializer)(file, json_filename, dialect);
|
||||
s->setFile(file);
|
||||
return s;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void MAKE_INIT_FN(JsonSerializer)(JsonSerializerFactory::Factory* mapping) {
|
||||
static const std::string schema_name = STRINGIFY(IfcSchema);
|
||||
POSTFIX_SCHEMA(factory_t) factory;
|
||||
mapping->bind(schema_name, factory);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class format_value_visitor : public boost::static_visitor<std::string> {
|
||||
@@ -598,4 +582,4 @@ void POSTFIX_SCHEMA(JsonSerializer)::finalize() {
|
||||
f << output.dump(4);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -32,24 +32,6 @@
|
||||
|
||||
using boost::property_tree::ptree;
|
||||
|
||||
#include "XmlSerializer.h"
|
||||
|
||||
namespace {
|
||||
struct POSTFIX_SCHEMA(factory_t) {
|
||||
XmlSerializer* operator()(ifcopenshell::file* file, const std::string& xml_filename) const {
|
||||
POSTFIX_SCHEMA(XmlSerializer)* s = new POSTFIX_SCHEMA(XmlSerializer)(file, xml_filename);
|
||||
s->setFile(file);
|
||||
return s;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void MAKE_INIT_FN(XmlSerializer)(XmlSerializerFactory::Factory* mapping) {
|
||||
static const std::string schema_name = STRINGIFY(IfcSchema);
|
||||
POSTFIX_SCHEMA(factory_t) factory;
|
||||
mapping->bind(schema_name, factory);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// TODO: Make this a member of XmlSerializer?
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the Lesser GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the Lesser GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#ifdef WITH_GLTF
|
||||
|
||||
#include "../document_serializer_plugin.h"
|
||||
#include "JsonSerializer.h"
|
||||
|
||||
#include "../../ifcparse/macros.h"
|
||||
|
||||
#include <boost/dll/alias.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
struct factory_t {
|
||||
JsonSerializer* operator()(ifcopenshell::file* file, const std::string& json_filename, JsonSerializer::Dialect dialect) const {
|
||||
auto* serializer = new POSTFIX_SCHEMA(JsonSerializer)(file, json_filename, dialect);
|
||||
serializer->setFile(file);
|
||||
return serializer;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace ifcopenshell {
|
||||
namespace serializers {
|
||||
namespace json_document_serializer_plugin {
|
||||
|
||||
plugin::abi_info plugin_abi() {
|
||||
return plugin::host_abi();
|
||||
}
|
||||
|
||||
plugin::metadata plugin_metadata() {
|
||||
return document_serializer_plugin_metadata("json", STRINGIFY(IfcSchema));
|
||||
}
|
||||
|
||||
void register_plugin(JsonSerializerFactory::Factory& registry, const plugin::module& module) {
|
||||
factory_t factory;
|
||||
registry.bind(STRINGIFY(IfcSchema), factory, module);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_DLL_ALIAS(ifcopenshell::serializers::json_document_serializer_plugin::plugin_abi, ifcopenshell_plugin_abi_v1)
|
||||
BOOST_DLL_ALIAS(ifcopenshell::serializers::json_document_serializer_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1)
|
||||
BOOST_DLL_ALIAS(ifcopenshell::serializers::json_document_serializer_plugin::register_plugin, ifcopenshell_register_document_serializer_plugin_v1)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,62 @@
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the Lesser GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the Lesser GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#include "../document_serializer_plugin.h"
|
||||
#include "XmlSerializer.h"
|
||||
|
||||
#include "../../ifcparse/macros.h"
|
||||
|
||||
#include <boost/dll/alias.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
struct factory_t {
|
||||
XmlSerializer* operator()(ifcopenshell::file* file, const std::string& xml_filename) const {
|
||||
auto* serializer = new POSTFIX_SCHEMA(XmlSerializer)(file, xml_filename);
|
||||
serializer->setFile(file);
|
||||
return serializer;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace ifcopenshell {
|
||||
namespace serializers {
|
||||
namespace xml_document_serializer_plugin {
|
||||
|
||||
plugin::abi_info plugin_abi() {
|
||||
return plugin::host_abi();
|
||||
}
|
||||
|
||||
plugin::metadata plugin_metadata() {
|
||||
return document_serializer_plugin_metadata("xml", STRINGIFY(IfcSchema));
|
||||
}
|
||||
|
||||
void register_plugin(XmlSerializerFactory::Factory& registry, const plugin::module& module) {
|
||||
factory_t factory;
|
||||
registry.bind(STRINGIFY(IfcSchema), factory, module);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_DLL_ALIAS(ifcopenshell::serializers::xml_document_serializer_plugin::plugin_abi, ifcopenshell_plugin_abi_v1)
|
||||
BOOST_DLL_ALIAS(ifcopenshell::serializers::xml_document_serializer_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1)
|
||||
BOOST_DLL_ALIAS(ifcopenshell::serializers::xml_document_serializer_plugin::register_plugin, ifcopenshell_register_document_serializer_plugin_v1)
|
||||
Reference in New Issue
Block a user