More work on isolating into plug-ins

This commit is contained in:
Thomas Krijnen
2026-04-18 15:46:21 +02:00
parent d2cc66fdf0
commit b599ee1040
34 changed files with 1818 additions and 606 deletions
+50 -13
View File
@@ -20,30 +20,67 @@
#ifndef IFCOPENSHELL_DOCUMENT_SERIALIZER_PLUGIN_H
#define IFCOPENSHELL_DOCUMENT_SERIALIZER_PLUGIN_H
#include "XmlSerializer.h"
#include "../serializers/serializers_api.h"
#include "../ifcgeom/Serializer.h"
#include "../ifcparse/file.h"
#include "../plugin/plugin.h"
#ifdef WITH_GLTF
#include "JsonSerializer.h"
#endif
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
#include <filesystem>
#include <map>
#include <string>
#include <vector>
namespace ifcopenshell {
namespace serializers {
typedef void register_xml_document_serializer_plugin_fn(XmlSerializerFactory::Factory&, const ifcopenshell::plugin::module&);
struct SERIALIZERS_API document_serializer_info {
std::string format;
std::string schema_name;
bool supports_ifc_file = true;
bool supports_input_filename = false;
bool writes_final_output = false;
};
struct SERIALIZERS_API document_serializer_context {
ifcopenshell::file* file = nullptr;
std::string input_filename;
std::string output_filename;
std::string schema_name;
bool stream = false;
int dialect = 0;
};
class SERIALIZERS_API document_serializer_registry {
public:
typedef boost::function<boost::shared_ptr<Serializer>(const document_serializer_context&)> create_fn;
void bind(const document_serializer_info& info, create_fn create, const ifcopenshell::plugin::module& module = ifcopenshell::plugin::module());
const document_serializer_info* find(const std::string& format, const std::string& schema_name = std::string()) const;
boost::shared_ptr<Serializer> create(const std::string& format, const document_serializer_context& context) const;
std::vector<document_serializer_info> serializers() const;
private:
struct entry {
document_serializer_info info_;
create_fn create_;
ifcopenshell::plugin::module module_;
};
const entry* find_entry_(const std::string& format, const std::string& schema_name) const;
std::map<std::string, std::vector<entry>> entries_;
};
typedef void register_document_serializer_plugin_fn(document_serializer_registry&, const ifcopenshell::plugin::module&);
SERIALIZERS_API const char* document_serializer_plugin_registration_symbol();
SERIALIZERS_API ifcopenshell::plugin::metadata document_serializer_plugin_metadata(const std::string& format, const std::string& schema_name);
SERIALIZERS_API ifcopenshell::plugin::metadata document_serializer_plugin_metadata(const std::string& format, const std::string& schema_name = std::string());
SERIALIZERS_API std::filesystem::path document_serializer_plugin_directory();
SERIALIZERS_API void load_document_serializer_plugins(XmlSerializerFactory::Factory& registry, const std::string& format);
#ifdef WITH_GLTF
typedef void register_json_document_serializer_plugin_fn(JsonSerializerFactory::Factory&, const ifcopenshell::plugin::module&);
SERIALIZERS_API void load_document_serializer_plugins(JsonSerializerFactory::Factory& registry, const std::string& format);
#endif
SERIALIZERS_API void load_document_serializer_plugins(document_serializer_registry& registry);
SERIALIZERS_API document_serializer_registry& document_serializer_registry_instance();
}
}