#pragma once #include #include #include #include #include #include #include #include #include #include #include #include "PrintConfig.hpp" namespace Slic3r { class PresetBundle; namespace PresetBundleCache { // ---- Vendor profile structures ---- struct CachedPrinterVariant { std::string name; template void serialize(Archive& ar) { ar(name); } }; struct CachedPrinterModel { std::string id, name, model_id, family; int technology = 0; std::vector variants; std::vector default_materials; std::vector not_support_bed_types; std::string bed_model, bed_texture, image_bed_type; std::string bottom_texture_end_name, use_double_extruder_default_texture; std::string bottom_texture_rect, middle_texture_rect, hotend_model; template void serialize(Archive& ar) { ar(id, name, model_id, family, technology, variants, default_materials, not_support_bed_types, bed_model, bed_texture, image_bed_type, bottom_texture_end_name, use_double_extruder_default_texture, bottom_texture_rect, middle_texture_rect, hotend_model); } }; struct CachedVendorProfile { std::string id, name, config_version, config_update_url, changelog_url; std::vector models; std::vector default_filaments; std::vector default_sla_materials; template void serialize(Archive& ar) { ar(id, name, config_version, config_update_url, changelog_url, models, default_filaments, default_sla_materials); } }; // ---- Per-preset cache entry ---- struct CachedPreset { int type = 0; std::string name, alias, file, version; std::string vendor_id; std::string filament_id, setting_id, description; std::string base_id, user_id, sync_info; long long updated_time = 0; std::vector renamed_from; bool is_system = true; bool is_visible = true; bool m_from_orca_filament_lib = false; DynamicPrintConfig config; template void serialize(Archive& ar) { ar(type, name, alias, file, version, vendor_id, filament_id, setting_id, description, base_id, user_id, sync_info, updated_time, renamed_from, is_system, is_visible, m_from_orca_filament_lib, config); } }; // ---- System preset cache ---- // Single blob at /system/system_presets_cache.cache // Covers all vendor profiles and system presets. // Invalidated when any vendor version string changes or config option count changes. struct SystemPresetsCache { static constexpr uint32_t FORMAT_VERSION = 2; uint32_t format_version = FORMAT_VERSION; size_t config_options_count = 0; std::map vendor_versions; std::vector vendor_profiles; std::vector print_presets; std::vector filament_presets; std::vector printer_presets; std::vector sla_print_presets; std::vector sla_material_presets; std::map config_maps; std::map filament_id_maps; template void serialize(Archive& ar) { ar(format_version, config_options_count, vendor_versions, vendor_profiles, print_presets, filament_presets, printer_presets, sla_print_presets, sla_material_presets, config_maps, filament_id_maps); } static std::string cache_path(); static std::string bundled_cache_path(); bool is_valid(const std::string& system_dir) const; // Returns false on structural mismatch (full re-parse required). // On true, populates out_dirty with vendor IDs whose version strings changed. // Empty out_dirty means fully valid (cache hit, no re-parse needed). bool get_dirty_vendors(const std::string& system_dir, std::set& out_dirty) const; void capture(const PresetBundle& bundle, const std::string& system_dir); void apply(PresetBundle& bundle) const; // Same as apply() but skips vendors listed in skip_vendor_ids and their presets. void apply_partial(PresetBundle& bundle, const std::set& skip_vendor_ids) const; bool load(const std::string& path); void save(const std::string& path) const; }; } // namespace PresetBundleCache } // namespace Slic3r