vsg: include/vsg/io/Options.h Source File

vsg 1.1.9 VulkanSceneGraph library |

Loading...
Searching...
No Matches
Options.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2018 Robert Osfield
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
13</editor-fold> */
14
15#include <vsg/core/Inherit.h>
16#include <vsg/core/observer_ptr.h>
17#include <vsg/io/FileSystem.h>
18#include <vsg/maths/transform.h>
19#include <vsg/state/StateCommand.h>
20#include <vsg/utils/Instrumentation.h>
21
22namespace vsg
23{
24
25 class SharedObjects;
26 class ReaderWriter;
27 class OperationThreads;
28 class CommandLine;
29 class ShaderSet;
30 class FindDynamicObjects;
31 class PropagateDynamicObjects;
32
33 using ReaderWriters = std::vector<ref_ptr<ReaderWriter>>;
34
36 class VSG_DECLSPEC Options : public Inherit<Object, Options>
37 {
38 public:
39 Options();
40 explicit Options(const Options& options);
41
42 template<typename... Args>
43 explicit Options(Args... args)
44 {
45 (add(args), ...);
46 }
47
48 Options& operator=(const Options& rhs) = delete;
49
50 int compare(const Object& rhs) const override;
51
53 virtual bool readOptions(CommandLine& arguments);
54
55 void read(Input& input) override;
56 void write(Output& output) const override;
57
58 void add(ref_ptr<ReaderWriter> rw = {});
59 void add(const ReaderWriters& rws);
60
61 ref_ptr<SharedObjects> sharedObjects;
62 ReaderWriters readerWriters;
63 ref_ptr<OperationThreads> operationThreads;
64
66 enum FindFileHint
67 {
68 CHECK_ORIGINAL_FILENAME_EXISTS_FIRST,
69 CHECK_ORIGINAL_FILENAME_EXISTS_LAST,
70 ONLY_CHECK_PATHS
71 };
72 FindFileHint checkFilenameHint = CHECK_ORIGINAL_FILENAME_EXISTS_FIRST;
73
74 Paths paths;
75
76 using FindFileCallback = std::function<Path(const Path& filename, const Options* options)>;
77 FindFileCallback findFileCallback;
78
79 Path fileCache;
80
81 Path extensionHint;
82 bool mapRGBtoRGBAHint = true;
83
85 CoordinateConvention sceneCoordinateConvention = CoordinateConvention::Z_UP;
86
88 std::map<Path, CoordinateConvention> formatCoordinateConventions;
89
96 std::map<std::string, ref_ptr<ShaderSet>> shaderSets;
97
100 StateCommands inheritedState;
101
103 ref_ptr<Instrumentation> instrumentation;
104
106 ref_ptr<FindDynamicObjects> findDynamicObjects;
107
109 ref_ptr<PropagateDynamicObjects> propagateDynamicObjects;
110
111 protected:
112 virtual ~Options();
113 };
114 VSG_type_name(vsg::Options);
115
117 extern VSG_DECLSPEC ref_ptr<const vsg::Options> prependPathToOptionsIfRequired(const vsg::Path& filename, ref_ptr<const vsg::Options> options);
118
120 template<typename... Args>
121 bool compatibleExtension(const vsg::Path& filename, const vsg::Options* options, const Args&... args)
122 {
123 if (options && options->extensionHint && contains(options->extensionHint, args...)) return true;
124 return contains(vsg::lowerCaseFileExtension(filename), args...);
125 }
126
128 template<typename... Args>
129 bool compatibleExtension(const vsg::Options* options, const Args&... args)
130 {
131 return options && options->extensionHint && contains(options->extensionHint, args...);
132 }
133
134} // namespace vsg
vsg::CommandLine
Definition CommandLine.h:44
vsg::FindDynamicObjects
Find all the objects that should be treated as dynamic (their values change.)
Definition FindDynamicObjects.h:25
vsg::Input
Definition Input.h:44
vsg::Object
Definition Object.h:60
vsg::OperationThreads
Definition OperationThreads.h:26
vsg::Options
Class for passing IO related options to vsg::read/write calls.
Definition Options.h:37
vsg::Options::formatCoordinateConventions
std::map< Path, CoordinateConvention > formatCoordinateConventions
Coordinate convention to assume for specified lower case file formats extensions.
Definition Options.h:88
vsg::Options::findDynamicObjects
ref_ptr< FindDynamicObjects > findDynamicObjects
mechanism for finding dynamic objects in loaded scene graph
Definition Options.h:106
vsg::Options::FindFileHint
FindFileHint
Hint to use when searching for Paths with vsg::findFile(filename, options);.
Definition Options.h:67
vsg::Options::CHECK_ORIGINAL_FILENAME_EXISTS_LAST
@ CHECK_ORIGINAL_FILENAME_EXISTS_LAST
check the filename exists with its original path before trying to find it in Options::paths.
Definition Options.h:69
vsg::Options::ONLY_CHECK_PATHS
@ ONLY_CHECK_PATHS
check the filename exists with its original path after failing to find it in Options::paths.
Definition Options.h:70
vsg::Options::sceneCoordinateConvention
CoordinateConvention sceneCoordinateConvention
Coordinate convention to use for scene graph.
Definition Options.h:85
vsg::Options::readOptions
virtual bool readOptions(CommandLine &arguments)
read command line options, assign values to this options object to later use with reading/writing fil...
vsg::Options::instrumentation
ref_ptr< Instrumentation > instrumentation
Hook for assigning Instrumentation to enable profiling of record traversal.
Definition Options.h:103
vsg::Options::compare
int compare(const Object &rhs) const override
compare two objects, return -1 if this object is less than rhs, return 0 if it's equal,...
vsg::Options::inheritedState
StateCommands inheritedState
Definition Options.h:100
vsg::Options::propagateDynamicObjects
ref_ptr< PropagateDynamicObjects > propagateDynamicObjects
mechanism for propogating dynamic objects classification up parental chain so that cloning is done on...
Definition Options.h:109
vsg::Options::shaderSets
std::map< std::string, ref_ptr< ShaderSet > > shaderSets
Definition Options.h:96
vsg::Output
Definition Output.h:41
vsg::Path
Definition Path.h:34
vsg::PropagateDynamicObjects
Propagate classification of objects as dynamic to all parents.
Definition PropagateDynamicObjects.h:25
vsg::ReaderWriter
Base class for providing support for reading and/or writing various file formats and IO protocols.
Definition ReaderWriter.h:35
vsg::ShaderSet
ShaderSet provides a collection of shader related settings to provide a form of shader introspection.
Definition ShaderSet.h:112
vsg::SharedObjects
class for facilitating the sharing of instances of objects that have the same properties.
Definition SharedObjects.h:32
vsg::ref_ptr
Definition ref_ptr.h:22