NDEVR
API Documentation

The core logic for importing and exporting files from the model hierarchy. More...

Inheritance diagram for ModelFactory:
[legend]
Collaboration diagram for ModelFactory:
[legend]

Public Member Functions

void addFactory (IOFactory *factory)
 Registers an IOFactory to be used for import/export operations.
void addFactory (StringView extension, IOFactory *factory)
 Registers an IOFactory for a specific file extension.
void addToFormatPriority (const StringView &extension, sint04 priority)
 Adjusts the priority of a file format identified by its file extension.
void addToFormatPriority (UUID format, sint04 priority)
 Adjusts the priority of a file format identified by its UUID.
virtual bool canRead (const FactoryParameters &file) override
 Checks whether any registered factory can read the given file described by FactoryParameters.
virtual bool canRead (const File &file) override
 Checks whether any registered factory can read the given file.
virtual bool canWrite (const FactoryParameters &file) override
 Checks whether any registered factory can write the given file described by FactoryParameters.
virtual bool canWrite (const File &file) override
 Checks whether any registered factory can write the given file.
void clearFactories ()
 Removes all registered IOFactory instances from this ModelFactory.
virtual FactoryOptions defaultReadOptions (const FactoryParameters &file) const override
 Retrieves the default read options for the given file from the appropriate registered factory.
virtual FactoryOptions defaultWriteOptions (const FactoryParameters &file) const override
 Retrieves the default write options for the given file from the appropriate registered factory.
virtual bool determineExtension (const File &file, String &extension) override
 Attempts to determine the file extension for the given file by querying registered factories.
void enableExtension (StringView extension, const StringView &read_password, const StringView &write_password)
 Enables read/write access for a specific file extension using password-based authorization.
void enableFactory (const StringView &factory, const StringView &read_password, const StringView &write_password)
 Enables read/write access for a named factory using password-based authorization.
void enableFactory (IOFactory *factory, const StringView &read_password, const StringView &write_password)
 Enables read/write access for a specific IOFactory instance using password-based authorization.
FactoryFeatures factoryFeatures (const FactoryParameters &file, bool is_import) const override
 Retrieves the feature flags describing the capabilities of the factory for the given file.
virtual Buffer< UUIDfilterModelsToExport (Buffer< UUID > models_to_check, const DesignObjectLookup *lookup, const FileFormat &export_format) const override
 Filters a set of model UUIDs to only those that can be exported in the given format.
virtual String getIcon (const File &file) override
 Retrieves the icon name associated with the given file type.
virtual void getSupportedFormats (Buffer< FileFormat > &formats, bool is_read) override
 Populates a buffer with all supported file formats for reading or writing, aggregated from all registered child IOFactory instances.
virtual void getSupportedFormats (Buffer< FileFormat > &formats, const File &file) override
 Populates a buffer with all supported file formats that can handle the given file, aggregated from all registered child IOFactory instances.
virtual void getSupportedFormats (Buffer< FileFormat > &formats, DesignObjectLookup *lookup, const Buffer< UUID > &models) override
 Populates a buffer with all supported file formats that can export the specified models.
virtual void getSupportedFormatsByModelType (Buffer< FileFormat > &formats, bool is_read, const StringView &model_type) override
 Populates a buffer with all supported file formats filtered by model type.
virtual bool readFile (FactoryParameters &file) override
 Reads the given file by delegating to the appropriate registered IOFactory.
void sortFormats (Buffer< FileFormat > &formats)
 Sorts the given buffer of file formats according to the current priority settings.
virtual bool updateFromFile (const FactoryParameters &file, const FactoryOptions &old_options) override
 Updates existing data from the file, using the previous options for context.
virtual bool writeFile (FactoryParameters &file) override
 Writes the given file by delegating to the appropriate registered IOFactory.
Public Member Functions inherited from IOFactory
 IOFactory (const StringView &factory_name)
 Constructs an IOFactory with the given factory name.
virtual ~IOFactory ()
 Virtual destructor.
virtual bool canRead (const FileFormat &file)
 Checks whether this factory can read the given file format.
virtual bool canWrite (const FileFormat &file)
 Checks whether this factory can write the given file format.
String factoryReadAppFeature () const
 Returns the application feature string required for read operations.
String factoryWriteAppFeature () const
 Returns the application feature string required for write operations.
void getSupportedFormats (Buffer< FileFormat > &formats)
 Populates the given buffer with all supported file formats (both read and write).
virtual void getSupportedFormatsForExtension (Buffer< FileFormat > &formats, bool is_read, const StringView &extension)
 Populates the given buffer with formats matching a specific file extension.
virtual bool isAutoEnabled () const
 Checks whether this factory is automatically enabled without requiring a password.
virtual bool isFactoryEnabled (bool is_read) const
 Checks whether this factory is enabled for reading or writing.
const Stringname () const
 Returns the name of this factory.
Buffer< UUIDreadFileWithDefaultSettings (const File &file, DesignObjectLookup *lookup)
 Reads a file using default settings and returns the UUIDs of the created models.
Buffer< ScenereadScenesFromFile (const File &file)
 Reads scenes from a file and returns them as a buffer of Scene objects.
void throwIfNotEnabled (bool is_read)
 Throws an exception if the factory is not enabled for the given operation direction.
bool writeScenesToFile (const File &file, const Buffer< Scene > &scene)
 Writes a buffer of scenes to a file.

Static Public Member Functions

static ModelFactoryDefaultFactory ()
 Retrieves the singleton ModelFactory instance.
Static Public Member Functions inherited from IOFactory
static void EnableExtension (const StringView &extension, const StringView &read_password, const StringView &write_password)
 Enables a specific file extension with the given read and write passwords.
static void EnableFactory (const StringView &factory, const StringView &read_password, const StringView &write_password)
 Enables a factory by name with the given read and write passwords.
static void EnableFactory (IOFactory *factory, const StringView &read_password, const StringView &write_password)
 Registers an IOFactory instance with the system, enabling it for read and/or write.

Protected Member Functions

 ModelFactory ()
 Constructs the ModelFactory.
 ~ModelFactory ()
 Destructs the ModelFactory and releases all registered factory references.

Protected Attributes

Dictionary< String, Buffer< IOFactory * > > m_extension_factories
 Factories indexed by file extension string.
Dictionary< String, Stringm_extension_read_passwords
 Read passwords keyed by file extension.
Dictionary< String, Stringm_extension_write_passwords
 Write passwords keyed by file extension.
Buffer< IOFactory * > * m_factory_objects
 Collection of all registered IOFactory instances.
Dictionary< UUID, sint04m_id_priority_modification
 Per-format priority adjustments keyed by format UUID.
Dictionary< String, IOFactory * > m_named_factories
 Factories indexed by factory name.

Detailed Description

The core logic for importing and exporting files from the model hierarchy.


Stores a series of IOFactory children that can define when and how they are able to export or import data.

Based on options will select the proper IOFactory to perform the import or export task. Acts as a central registry and dispatcher for all registered IOFactory instances, delegating read/write operations to the appropriate factory based on file format, extension, and priority settings.

See also
IOFactory, FactoryOptions, File, FileFormat

Definition at line 48 of file ModelFactory.h.

Constructor & Destructor Documentation

◆ ModelFactory()

ModelFactory::ModelFactory ( )
protected

Constructs the ModelFactory.


Protected to enforce singleton access via DefaultFactory().

Referenced by DefaultFactory().

◆ ~ModelFactory()

ModelFactory::~ModelFactory ( )
protected

Destructs the ModelFactory and releases all registered factory references.


Member Function Documentation

◆ addFactory() [1/2]

void ModelFactory::addFactory ( IOFactory * factory)

Registers an IOFactory to be used for import/export operations.


Parameters
[in]factoryThe IOFactory instance to register. Ownership is not transferred.

References IOFactory::IOFactory().

◆ addFactory() [2/2]

void ModelFactory::addFactory ( StringView extension,
IOFactory * factory )

Registers an IOFactory for a specific file extension.


Parameters
[in]extensionThe file extension to associate with the factory.
[in]factoryThe IOFactory instance to register. Ownership is not transferred.

References IOFactory::IOFactory().

◆ addToFormatPriority() [1/2]

void ModelFactory::addToFormatPriority ( const StringView & extension,
sint04 priority )

Adjusts the priority of a file format identified by its file extension.


Parameters
[in]extensionThe file extension (e.g., "obj", "stl") whose priority should be modified.
[in]priorityThe priority adjustment value. Higher values indicate higher priority.

◆ addToFormatPriority() [2/2]

void ModelFactory::addToFormatPriority ( UUID format,
sint04 priority )

Adjusts the priority of a file format identified by its UUID.


Parameters
[in]formatThe UUID of the format whose priority should be modified.
[in]priorityThe priority adjustment value. Higher values indicate higher priority.

◆ canRead() [1/2]

virtual bool ModelFactory::canRead ( const FactoryParameters & file)
overridevirtual

Checks whether any registered factory can read the given file described by FactoryParameters.


Parameters
[in]fileThe factory parameters describing the file to check.
Returns
True if at least one registered factory can read the file.

Reimplemented from IOFactory.

◆ canRead() [2/2]

virtual bool ModelFactory::canRead ( const File & file)
overridevirtual

Checks whether any registered factory can read the given file.


Parameters
[in]fileThe file to check readability for.
Returns
True if at least one registered factory can read the file.

Reimplemented from IOFactory.

◆ canWrite() [1/2]

virtual bool ModelFactory::canWrite ( const FactoryParameters & file)
overridevirtual

Checks whether any registered factory can write the given file described by FactoryParameters.


Parameters
[in]fileThe factory parameters describing the file to check.
Returns
True if at least one registered factory can write the file.

Reimplemented from IOFactory.

◆ canWrite() [2/2]

virtual bool ModelFactory::canWrite ( const File & file)
overridevirtual

Checks whether any registered factory can write the given file.


Parameters
[in]fileThe file to check writability for.
Returns
True if at least one registered factory can write the file.

Reimplemented from IOFactory.

◆ clearFactories()

void ModelFactory::clearFactories ( )

Removes all registered IOFactory instances from this ModelFactory.


◆ DefaultFactory()

ModelFactory & ModelFactory::DefaultFactory ( )
static

Retrieves the singleton ModelFactory instance.


Returns
A reference to the global default ModelFactory.

References ModelFactory().

◆ defaultReadOptions()

virtual FactoryOptions ModelFactory::defaultReadOptions ( const FactoryParameters & file) const
overridevirtual

Retrieves the default read options for the given file from the appropriate registered factory.


Parameters
[in]fileThe factory parameters describing the file to query options for.
Returns
The default FactoryOptions for reading the specified file.

Reimplemented from IOFactory.

◆ defaultWriteOptions()

virtual FactoryOptions ModelFactory::defaultWriteOptions ( const FactoryParameters & file) const
overridevirtual

Retrieves the default write options for the given file from the appropriate registered factory.


Parameters
[in]fileThe factory parameters describing the file to query options for.
Returns
The default FactoryOptions for writing the specified file.

Reimplemented from IOFactory.

◆ determineExtension()

virtual bool ModelFactory::determineExtension ( const File & file,
String & extension )
overridevirtual

Attempts to determine the file extension for the given file by querying registered factories.


Parameters
[in]fileThe file whose extension should be determined.
[in]extensionOutput string that receives the determined extension.
Returns
True if the extension was successfully determined.

Reimplemented from IOFactory.

◆ enableExtension()

void ModelFactory::enableExtension ( StringView extension,
const StringView & read_password,
const StringView & write_password )

Enables read/write access for a specific file extension using password-based authorization.


Parameters
[in]extensionThe file extension to enable.
[in]read_passwordThe password required to enable read access for this extension.
[in]write_passwordThe password required to enable write access for this extension.

◆ enableFactory() [1/2]

void ModelFactory::enableFactory ( const StringView & factory,
const StringView & read_password,
const StringView & write_password )

Enables read/write access for a named factory using password-based authorization.


Parameters
[in]factoryThe name of the factory to enable.
[in]read_passwordThe password required to enable read access.
[in]write_passwordThe password required to enable write access.

◆ enableFactory() [2/2]

void ModelFactory::enableFactory ( IOFactory * factory,
const StringView & read_password,
const StringView & write_password )

Enables read/write access for a specific IOFactory instance using password-based authorization.


Parameters
[in]factoryThe IOFactory instance to enable.
[in]read_passwordThe password required to enable read access.
[in]write_passwordThe password required to enable write access.

References IOFactory::IOFactory().

◆ factoryFeatures()

FactoryFeatures ModelFactory::factoryFeatures ( const FactoryParameters & file,
bool is_import ) const
overridevirtual

Retrieves the feature flags describing the capabilities of the factory for the given file.


Parameters
[in]fileThe factory parameters describing the file to query features for.
[in]is_importWhether to query import features (true) or export features (false).
Returns
A FactoryFeatures object describing the supported capabilities.

Implements IOFactory.

◆ filterModelsToExport()

virtual Buffer< UUID > ModelFactory::filterModelsToExport ( Buffer< UUID > models_to_check,
const DesignObjectLookup * lookup,
const FileFormat & export_format ) const
overridevirtual

Filters a set of model UUIDs to only those that can be exported in the given format.


Parameters
[in]models_to_checkThe buffer of model UUIDs to filter.
[in]lookupThe design object lookup used to resolve model data.
[in]export_formatThe target export format to filter against.
Returns
A buffer containing only the UUIDs of models that can be exported in the given format.

Reimplemented from IOFactory.

◆ getIcon()

virtual String ModelFactory::getIcon ( const File & file)
overridevirtual

Retrieves the icon name associated with the given file type.


Parameters
[in]fileThe file to retrieve the icon for.
Returns
A String containing the icon identifier for the file type.

Reimplemented from IOFactory.

◆ getSupportedFormats() [1/3]

virtual void ModelFactory::getSupportedFormats ( Buffer< FileFormat > & formats,
bool is_read )
overridevirtual

Populates a buffer with all supported file formats for reading or writing, aggregated from all registered child IOFactory instances.


Parameters
[in]formatsThe buffer to populate with supported FileFormat entries.
[in]is_readWhether to query for read formats (true) or write formats (false).

Implements IOFactory.

◆ getSupportedFormats() [2/3]

virtual void ModelFactory::getSupportedFormats ( Buffer< FileFormat > & formats,
const File & file )
overridevirtual

Populates a buffer with all supported file formats that can handle the given file, aggregated from all registered child IOFactory instances.


Parameters
[in]formatsThe buffer to populate with supported FileFormat entries.
[in]fileThe file to check format support for.

Reimplemented from IOFactory.

◆ getSupportedFormats() [3/3]

virtual void ModelFactory::getSupportedFormats ( Buffer< FileFormat > & formats,
DesignObjectLookup * lookup,
const Buffer< UUID > & models )
overridevirtual

Populates a buffer with all supported file formats that can export the specified models.


Parameters
[in]formatsThe buffer to populate with supported FileFormat entries.
[in]lookupThe design object lookup used to resolve model data.
[in]modelsThe UUIDs of the models to check export support for.

Reimplemented from IOFactory.

◆ getSupportedFormatsByModelType()

virtual void ModelFactory::getSupportedFormatsByModelType ( Buffer< FileFormat > & formats,
bool is_read,
const StringView & model_type )
overridevirtual

Populates a buffer with all supported file formats filtered by model type.


Parameters
[in]formatsThe buffer to populate with supported FileFormat entries.
[in]is_readWhether to query for read formats (true) or write formats (false).
[in]model_typeThe model type string to filter formats by.

Reimplemented from IOFactory.

◆ readFile()

virtual bool ModelFactory::readFile ( FactoryParameters & file)
overridevirtual

Reads the given file by delegating to the appropriate registered IOFactory.


Parameters
[in]fileThe factory parameters describing the file to read. Populated with results on success.
Returns
True if the file was successfully read.

Implements IOFactory.

◆ sortFormats()

void ModelFactory::sortFormats ( Buffer< FileFormat > & formats)

Sorts the given buffer of file formats according to the current priority settings.


Parameters
[in]formatsThe buffer of FileFormat entries to sort in place.

◆ updateFromFile()

virtual bool ModelFactory::updateFromFile ( const FactoryParameters & file,
const FactoryOptions & old_options )
overridevirtual

Updates existing data from the file, using the previous options for context.


Parameters
[in]fileThe factory parameters describing the file to re-read.
[in]old_optionsThe previous options used when the file was originally read.
Returns
True if the update was successful.

Reimplemented from IOFactory.

◆ writeFile()

virtual bool ModelFactory::writeFile ( FactoryParameters & file)
overridevirtual

Writes the given file by delegating to the appropriate registered IOFactory.


Parameters
[in]fileThe factory parameters describing the file to write. May be updated with results.
Returns
True if the file was successfully written.

Implements IOFactory.


The documentation for this class was generated from the following file: