vsg 1.1.3
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
67 {
68 CHECK_ORIGINAL_FILENAME_EXISTS_FIRST,
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
104
107
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
Definition CommandLine.h:44
Definition Inherit.h:28
Definition Input.h:44
Definition Object.h:60
Class for passing IO related options to vsg::read/write calls.
Definition Options.h:37
std::map< Path, CoordinateConvention > formatCoordinateConventions
Coordinate convention to assume for specified lower case file formats extensions.
Definition Options.h:88
ref_ptr< FindDynamicObjects > findDynamicObjects
mechanism for finding dynamic objects in loaded scene graph
Definition Options.h:106
FindFileHint
Hint to use when searching for Paths with vsg::findFile(filename, options);.
Definition Options.h:67
@ 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
virtual bool readOptions(CommandLine &arguments)
read command line options, assign values to this options object to later use with reading/writing fil...
ref_ptr< Instrumentation > instrumentation
Hook for assigning Instrumentation to enable profiling of record traversal.
Definition Options.h:103
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,...
StateCommands inheritedState
Definition Options.h:100
ref_ptr< PropagateDynamicObjects > propagateDynamicObjects
mechanism for propogating dynamic objects classification up parental chain so that cloning is done on...
Definition Options.h:109
std::map< std::string, ref_ptr< ShaderSet > > shaderSets
Definition Options.h:96
Definition Output.h:41
Definition Path.h:34
Definition ref_ptr.h:22