API Documentation
Loading...
Searching...
No Matches
IOFactory.h
Go to the documentation of this file.
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: IOFactory
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/FactoryOptions.h>
35#include <NDEVR/Model.h>
36#include <NDEVR/File.h>
37#include <NDEVR/FileFormat.h>
38namespace NDEVR
39{
40 class Model;
41 class Log;
42 class SpatialObject;
43 class DesignObjectLookup;
44 class FactoryFeatures;
56 {
57 FactoryParameters(const File& file, const FileFormat& format, const String& name = "default")
58 {
59 requests.add(name, FileRequest(file, format));
60 }
61 FactoryParameters(const FileRequest& request, const String& name = "default")
62 {
63 requests.add(name, request);
64 }
65 const FileFormat& format(const String& name = "default") const
66 {
67 return requests.get(name).format;
68 }
69 FileFormat& format(const String& name = "default")
70 {
71 return requests.get(name).format;
72 }
73 const File& file(const String& name = "default") const
74 {
75 return requests.get(name).file;
76 }
77 bool shouldWriteModel(const Model& model) const
78 {
79 Model m = model;
80 while (m.isValid())
81 {
82 if (models.contains(m.uuid()))
83 return true;
84 m = m.getParent();
85 }
86 return false;
87 }
88 void addWarning(const FileFactoryWarning& warning);
94 DesignObjectLookup* lookup = nullptr;
95 ProgressInfo* log = nullptr;
96 };
97
99 {
100 public:
101 friend class ModelFactory;
102 IOFactory(const String& factory_name);
103 const String& name() const { return m_factory_name; }
104 virtual ~IOFactory();
105 bool writeScenesToFile(const File& file, const Buffer<Scene>& scene);
106 bool readFileWithDefaultSettings(const File& file, DesignObjectLookup* lookup);
107 void getSupportedFormats(Buffer<FileFormat>& formats);
108 virtual void getSupportedFormats(Buffer<FileFormat>& formats, bool is_read) = 0;
109 virtual void getSupportedFormats(Buffer<FileFormat>& formats, const File& file);
110 virtual void getSupportedFormats(Buffer<FileFormat>& formats, DesignObjectLookup* lookup, const Buffer<UUID>& models);
111 virtual void getSupportedFormatsForExtension(Buffer<FileFormat>& formats, bool is_read, const String& extension);
112 virtual void getSupportedFormatsByModelType(Buffer<FileFormat>& formats, bool is_read, const String& model_type);
113 virtual Buffer<UUID> filterModelsToExport(Buffer<UUID> models_to_check, const DesignObjectLookup* lookup, const FileFormat& export_format) const;
114 virtual bool isFactoryEnabled(bool is_read) const;
115 virtual bool canRead(const File& file);
116 virtual bool determineExtension(const File& file, String& extension);
117 virtual bool canWrite(const File& file);
118 virtual bool isAutoEnabled() const;
119 virtual String getIcon(const File& file);
120 virtual bool canRead(const FactoryParameters& file);
121 virtual bool canWrite(const FactoryParameters& file);
122 virtual bool canRead(const FileFormat& file);
123 virtual bool canWrite(const FileFormat& file);
124 Buffer<Scene> readScenesFromFile(const File& file);
125 virtual FactoryOptions defaultReadOptions(const FactoryParameters& file) const;
126 virtual FactoryOptions defaultWriteOptions(const FactoryParameters& file) const;
127 virtual bool updateFromFile(const FactoryParameters& file, const FactoryOptions& old_options);
128 virtual FactoryFeatures factoryFeatures(const FactoryParameters& file, bool is_import) const = 0;
129 String factoryReadAppFeature() const;
130 String factoryWriteAppFeature() const;
131 void throwIfNotEnabled(bool is_read);
132 static void EnableFactory(IOFactory* factory, const String& read_password, const String& write_password);
133 static void EnableFactory(const String& factory, const String& read_password, const String& write_password);
134 static void EnableExtension(const String& extension, const String& read_password, const String& write_password);
135 private:
136 virtual bool readFile(FactoryParameters& file) = 0;
137 virtual bool writeFile(FactoryParameters& file) = 0;
138 private:
139 String m_factory_name;
140 };
141}
#define NDEVR_FACTORY_API
Definition DLLInfo.h:79
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
decltype(auto) get(t_index_type index)
Definition Buffer.hpp:857
bool isValid() const
Definition DesignObject.h:362
UUID uuid() const
Definition DesignObject.cpp:533
Definition DesignObjectLookup.h:61
Definition Dictionary.h:48
Definition FactoryFeatures.h:40
Definition FactoryOptions.h:46
Definition FileFormat.h:38
Definition File.h:47
Definition IOFactory.h:99
virtual FactoryFeatures factoryFeatures(const FactoryParameters &file, bool is_import) const =0
const String & name() const
Definition IOFactory.h:103
virtual void getSupportedFormats(Buffer< FileFormat > &formats, bool is_read)=0
Definition ModelFactory.h:39
Definition Model.h:54
Model getParent() const
Definition Model.cpp:2057
Definition ProgressInfo.hpp:43
Definition String.h:40
Definition TranslatedString.h:9
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
Definition BaseValues.hpp:272
Definition IOFactory.h:56
Buffer< UUID > models
Definition IOFactory.h:92
const File & file(const String &name="default") const
Definition IOFactory.h:73
bool shouldWriteModel(const Model &model) const
Definition IOFactory.h:77
FactoryParameters(const FileRequest &request, const String &name="default")
Definition IOFactory.h:61
const FileFormat & format(const String &name="default") const
Definition IOFactory.h:65
FactoryParameters(const File &file, const FileFormat &format, const String &name="default")
Definition IOFactory.h:57
FileFormat & format(const String &name="default")
Definition IOFactory.h:69
FactoryOptions options
Definition IOFactory.h:90
Dictionary< String, FileRequest > requests
Definition IOFactory.h:89
Buffer< FileFactoryWarning > warnings
Definition IOFactory.h:91
Buffer< UUID > cameras
Definition IOFactory.h:93
Definition IOFactory.h:46
TranslatedString message
Definition IOFactory.h:53
FileFactoryWarning(const TranslatedString &title, const TranslatedString &message)
Definition IOFactory.h:47
TranslatedString title
Definition IOFactory.h:52
Definition FileFormat.h:67