NDEVR
API Documentation
ModelFactory.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: IOFactory
28File: ModelFactory
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/IOFactory.h>
34#include <NDEVR/File.h>
35#include <NDEVR/FactoryOptions.h>
36namespace NDEVR
37{
49 {
50 protected:
55
60 public:
66
72 void addToFormatPriority(UUID format, sint04 priority);
73
79 void addToFormatPriority(const StringView& extension, sint04 priority);
80
87 virtual void getSupportedFormats(Buffer<FileFormat>& formats, bool is_read) override;
88
95 virtual void getSupportedFormats(Buffer<FileFormat>& formats, const File& file) override;
96
103 virtual void getSupportedFormatsByModelType(Buffer<FileFormat>& formats, bool is_read, const StringView& model_type) override;
104
111 virtual void getSupportedFormats(Buffer<FileFormat>& formats, DesignObjectLookup* lookup, const Buffer<UUID>& models) override;
112
118 virtual String getIcon(const File& file) override;
119
125 virtual bool canRead(const FactoryParameters& file) override;
126
132 virtual bool canWrite(const FactoryParameters& file) override;
133
140 virtual bool determineExtension(const File& file, String& extension) override;
141
147 virtual FactoryOptions defaultReadOptions(const FactoryParameters& file) const override;
148
154 virtual FactoryOptions defaultWriteOptions(const FactoryParameters& file) const override;
155
163 virtual Buffer<UUID> filterModelsToExport(Buffer<UUID> models_to_check, const DesignObjectLookup* lookup, const FileFormat& export_format) const override;
164
171 FactoryFeatures factoryFeatures(const FactoryParameters& file, bool is_import) const override;
172
178 virtual bool canRead(const File& file) override;
179
185 virtual bool canWrite(const File& file) override;
186
192 virtual bool readFile(FactoryParameters& file) override;
193
200 virtual bool updateFromFile(const FactoryParameters& file, const FactoryOptions& old_options) override;
201
207 virtual bool writeFile(FactoryParameters& file) override;
208
213 void addFactory(IOFactory* factory);
214
220 void addFactory(StringView extension, IOFactory* factory);
221
228 void enableExtension(StringView extension, const StringView& read_password, const StringView& write_password);
229
236 void enableFactory(IOFactory* factory, const StringView& read_password, const StringView& write_password);
237
244 void enableFactory(const StringView& factory, const StringView& read_password, const StringView& write_password);
245
250
256 protected:
263 };
264}
#define NDEVR_FACTORY_API
GCC/Clang symbol visibility — marks symbols as visible in the shared library.
Definition DLLInfo.h:92
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core class where all Design Objects including models, materials, and geometries are stored.
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Allows IOFactories to report what features they support to make the import/export dialogs easier to s...
User-defined options that define preferences for importing and exporting using IOFactory objects.
Data that describes a particular file format and how to use the format with the program.
Definition FileFormat.h:45
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
IOFactory(const StringView &factory_name)
Constructs an IOFactory with the given factory name.
void addToFormatPriority(UUID format, sint04 priority)
Adjusts the priority of a file format identified by its UUID.
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 Buffer< UUID > filterModelsToExport(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.
void clearFactories()
Removes all registered IOFactory instances from this ModelFactory.
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 regist...
Dictionary< String, String > m_extension_read_passwords
Read passwords keyed by file extension.
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.
virtual void getSupportedFormats(Buffer< FileFormat > &formats, const File &file) override
Populates a buffer with all supported file formats that can handle the given file,...
void addToFormatPriority(const StringView &extension, sint04 priority)
Adjusts the priority of a file format identified by its file extension.
virtual bool canRead(const File &file) override
Checks whether any registered factory can read the given file.
void addFactory(StringView extension, IOFactory *factory)
Registers an IOFactory for a specific file extension.
Dictionary< String, IOFactory * > m_named_factories
Factories indexed by factory name.
virtual bool canWrite(const FactoryParameters &file) override
Checks whether any registered factory can write the given file described by FactoryParameters.
void sortFormats(Buffer< FileFormat > &formats)
Sorts the given buffer of file formats according to the current priority settings.
virtual FactoryOptions defaultReadOptions(const FactoryParameters &file) const override
Retrieves the default read options for the given file from the appropriate registered factory.
Dictionary< String, String > m_extension_write_passwords
Write passwords keyed by file extension.
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 addFactory(IOFactory *factory)
Registers an IOFactory to be used for import/export operations.
virtual bool canRead(const FactoryParameters &file) override
Checks whether any registered factory can read the given file described by FactoryParameters.
virtual bool readFile(FactoryParameters &file) override
Reads the given file by delegating to the appropriate registered IOFactory.
virtual bool canWrite(const File &file) override
Checks whether any registered factory can write the given file.
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 String getIcon(const File &file) override
Retrieves the icon name associated with the given file type.
static ModelFactory & DefaultFactory()
Retrieves the singleton ModelFactory instance.
Buffer< IOFactory * > * m_factory_objects
Collection of all registered IOFactory instances.
Dictionary< UUID, sint04 > m_id_priority_modification
Per-format priority adjustments keyed by format UUID.
virtual bool updateFromFile(const FactoryParameters &file, const FactoryOptions &old_options) override
Updates existing data from the file, using the previous options for context.
~ModelFactory()
Destructs the ModelFactory and releases all registered factory references.
ModelFactory()
Constructs the ModelFactory.
virtual bool writeFile(FactoryParameters &file) override
Writes the given file by delegating to the appropriate registered IOFactory.
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.
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.
FactoryFeatures factoryFeatures(const FactoryParameters &file, bool is_import) const override
Retrieves the feature flags describing the capabilities of the factory for the given file.
Dictionary< String, Buffer< IOFactory * > > m_extension_factories
Factories indexed by file extension string.
Software Service Managers take a Software service to modify the behavior of the software.
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
The primary namespace for the NDEVR SDK.
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
A container of input information that is to be filled with output information by an IOFactory.
Definition IOFactory.h:105