HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_ShotBuilderConfig.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_ShotBuilderConfig.h ( UT Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UT_SHOTBUILDERCONFIG_H__
13 #define __UT_SHOTBUILDERCONFIG_H__
14 
15 #include "FS_API.h"
16 #include "UT/UT_Color.h"
17 #include "UT/UT_Function.h"
18 #include "UT/UT_JSONValueMap.h"
19 #include "UT/UT_SharedPtr.h"
20 #include "UT/UT_StringMap.h"
21 #include <UT/UT_StringArray.h>
22 #include <UT/UT_Vector3.h>
23 
25 {
28 };
29 
31 
34 
35 static float theDefaultFPS = 24.0;
36 static float theDefaultStartFrame = 1001;
37 static float theDefaultEndFrame = 1024;
38 static UT_StringHolder theDefaultExtension = "usda";
39 static UT_StringHolder theDefaultTypeIcon = "SHOTBUILDER_unittype_generic";
40 static UT_StringHolder theDefaultSublayerIcon = "SHOTBUILDER_sublayer";
41 
43 {
44  UT_ShotBuilderLayerConfig() = default;
45  UT_ShotBuilderLayerConfig(const UT_JSONValue* layerInfo);
46 
50 };
51 
53 {
54  UT_ShotBuilderUnitConfig() = default;
55  UT_ShotBuilderUnitConfig(const UT_JSONValue* unitInfo);
56 
57  UT_ShotBuilderLayerConfig* layerConfig(const UT_StringRef& layerIdentifier);
58 
63  fpreal myFPS = theDefaultFPS;
64  fpreal myStartFrame = theDefaultStartFrame;
65  fpreal myEndFrame = theDefaultEndFrame;
69 };
70 
72 {
73  UT_ShotBuilderProjectConfig(const UT_JSONValue& projectInfo);
74  UT_ShotBuilderProjectConfig(const char* configPath);
75 
76  void save() const;
77 
78  void reload();
79 
86  fpreal myFPS = theDefaultFPS;
87  fpreal myStartFrame = theDefaultStartFrame;
88  fpreal myEndFrame = theDefaultEndFrame;
91 
93 
94 private:
95  void initFromJSON(const UT_JSONValue& projectInfo);
96 };
97 
99 {
100 public:
102  UT_ShotBuilderConfig(const char* projectConfigPath);
103 
104  // Project methods
105  UT_StringHolder projectDirectory() const;
106  UT_StringHolder projectPath() const;
107  bool isValid() const;
108  int versionPadding() const;
109  UT_Vector3D defaultFrameData() const;
110  UT_StringHolder unitContextOption() const;
111 
112  // Unit Type methods
113  UT_StringArray unitTypes() const;
114  UT_StringArray unitsForType(const UT_StringRef &unittype) const;
115  UT_StringArray subLayersForType(const UT_StringRef &unitType) const;
116  UT_StringArray placeholdersForType(const UT_StringRef &unittype) const;
117  UT_StringRef subLayerFormatForType(const UT_StringRef &unitType) const;
118  UT_StringRef nameTemplateForType(const UT_StringRef &unitType) const;
119  UT_StringRef iconForType(const UT_StringRef &unittype) const;
120  UT_StringRef extensionForType(const UT_StringRef &unitType) const;
121 
122  bool isValidUnitType(const UT_StringRef &unitType) const;
123  bool isValidUnit(const UT_StringHolder &unitContext) const;
124  bool isValidUnit(const UT_StringRef &unitType,
125  const UT_StringRef &unit) const;
126 
127  // Unit methods
128  UT_StringArray units(const UT_StringRef &pattern = "*") const;
129 
130  UT_StringRef unitLayerPath(const UT_StringRef &unit) const;
131  UT_StringRef unitLayerPath(const UT_StringRef &unitType,
132  const UT_StringRef &unitName) const;
133 
134  // Sublayer methods
135  bool mayBeVersionedFile(const UT_StringHolder &dir,
136  const UT_StringHolder &filename) const;
137  UT_StringRef iconForSubLayer(const UT_StringRef &unitType,
138  const UT_StringRef &subLayer) const;
139 
140  // Write methods
141  bool setIconForType(const UT_StringRef &unitType,
142  const UT_StringHolder &label);
143  void save() const;
144 
145  void reload() const;
146  static void reload(const UT_StringRef &configPath);
147 
148  // Callback methods
149  static int addProjectChangedCallback(const UT_ProjectCallbackFn &callback);
150  static void removeProjectChangedCallback(int);
151  static void projectChangedCallback(UT_ProjectChangedType changeType);
152 
153 private:
154  static UT_StringMap<UT_ShotBuilderProjectConfigPtr> theProjectConfigMap;
155 
156  UT_ShotBuilderProjectConfigPtr myProjectConfig;
157 
158  static UT_SortedMap<int, UT_ProjectCallbackFn> myProjectChangedCallbacks;
159  static int myNextProjectChangedCallbackId;
160 
161  // private access to unit / layer configs
163  unitConfig(const UT_StringRef& unitType) const;
164 
166  layerConfig(const UT_StringRef& unitType,
167  const UT_StringRef& subLayer) const;
168 };
169 
170 #endif
UT_Function< void(int)> UT_ProjectCallbackFn
PXL_API void reload()
Reload the configuration.
GT_API const UT_StringHolder filename
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
UT_SharedPtr< UT_ShotBuilderProjectConfig > UT_ShotBuilderProjectConfigPtr
UT_ShotBuilderLayerConfig()=default
UT_StringMap< UT_ShotBuilderUnitConfig > myUnitConfigs
UT_ProjectChangedType
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
png_const_structrp png_const_inforp int * unit
Definition: png.h:2161
GLushort pattern
Definition: glad.h:2583
std::function< T > UT_Function
Definition: UT_Function.h:37
UT_StringMap< UT_ShotBuilderLayerConfig > mySubLayers
GLfloat units
Definition: glcorearb.h:408
UT_ShotBuilderUnitConfig()=default
fpreal64 fpreal
Definition: SYS_Types.h:278
UT_ShotBuilderLayerConfig * layerConfig(const UT_StringRef &layerIdentifier)
UT_ShotBuilderProjectConfig(const UT_JSONValue &projectInfo)
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:99
#define FS_API
Definition: FS_API.h:10