HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IMG_TileOptions.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: IMG_TileOptions.h ( IMG Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __IMG_TileOptions__
12 #define __IMG_TileOptions__
13 
14 #include "IMG_API.h"
15 #include "IMG_FileTypes.h"
16 #include "IMG_Format.h"
17 #include <UT/UT_Options.h>
18 #include <UT/UT_NonCopyable.h>
19 #include <UT/UT_Array.h>
20 
21 class UT_StringArray;
22 class UT_JSONWriter;
23 
25  : public UT_NonCopyable
26 {
27 public:
28  /// If the format is a null pointer, it will be inferred from the filename
29  IMG_TileOptions() = default;
30  virtual ~IMG_TileOptions() = default;
31 
32  /// Create a new copy of myself
33  UT_UniquePtr<IMG_TileOptions> clone() const;
34 
35  void setPlaneInfo(const UT_StringHolder &filename,
36  const UT_StringHolder &channel,
37  const UT_StringHolder &format,
38  IMG_DataType dtype = IMG_DT_ANY,
39  IMG_ColorModel cmodel = IMG_CM_ANY,
40  IMG_TypeInfo tinfo = IMG_TI_COLOR);
41  void setPlaneInfo(const char *filename,
42  const char *channel,
43  const char *format,
44  IMG_DataType dtype = IMG_DT_ANY,
45  IMG_ColorModel cmodel = IMG_CM_ANY,
46  IMG_TypeInfo tinfo = IMG_TI_COLOR)
47  {
48  setPlaneInfo(UT_StringHolder(filename),
49  UT_StringHolder(channel),
50  UT_StringHolder(format),
51  dtype, cmodel, tinfo);
52  }
53 
54  fpreal gamma() const { return myGamma; }
55  void setGamma(fpreal gamma) { myGamma = gamma; }
56  PXL_ColorSpace colorSpace() const;
57 
58  // Change the filename extension to match the format
59  bool changeFileExtension();
60 
61  /// There are sevaral ways to set format options:
62  /// 1) A sting (which is parsed into token/value pairs)
63  /// 2) A set of token/value pairs specified as a linear array
64  void clearOptions();
65  void setFormatOptions(const char *string);
66  void setFormatOptions(int argc, const char *const argv[]);
67  void setFormatOptions(const UT_StringArray &options);
68  void setFormatOption(const char *token, const char *value);
69  void setFormatOptions(const UT_Options &options);
70 
71  /// Get the IMG_Format associated with these options. This will possibly
72  /// return a null ptr.
73  virtual const IMG_Format *getFormat(IMG_Format::AccessType
75 
76  const char *getFilename() const;
77  const char *getChannel() const;
78  const char *getFormatName() const;
79  IMG_DataType getDataType() const;
80  IMG_ColorModel getColorModel() const;
81  IMG_TypeInfo getTypeInfo() const;
82  const UT_Options &getLocalOptions() const;
83 
84  /// Getting the option will return true/false based on whether the option
85  /// was defined. If the option was not defined, the value will not be
86  /// touched (i.e. it will remain unchanged).
87  virtual bool getOption(const char *token, UT_String &value) const;
88 
89  /// Texture options are only output for specific file formats. These
90  /// texture options are used to pass information from the calling
91  /// application to the device (where required).
92  /// The application can write directly to the UT_Options, which will
93  /// then be output in the file.
94  virtual void setTextureOptions(UT_Options &options);
95 
96  /// Pack all options into a single string. Returns the number of options
97  /// packed.
98  virtual int packOptionsString(UT_String &result) const;
99 
100  /// @{
101  /// Dump options
102  void dump(UT_JSONWriter &w) const;
103  void dump() const;
104  /// @}
105 
106 protected:
107  // Copy from the option source
108  void copy(const IMG_TileOptions &src);
109 
114  IMG_DataType myDataType = IMG_DT_ANY;
115  IMG_ColorModel myColorModel = IMG_CM_ANY;
117  fpreal myGamma = 1;
118 };
119 
121  : public UT_NonCopyable
122 {
123 public:
126 
127  /// WARNING: Using this class will delete all the contents, so you must
128  /// append clones if you're creating single lists from existing options.
129  int entries() const { return myOptions.size(); }
130  void append(UT_UniquePtr<IMG_TileOptions> opt) { myOptions.append(std::move(opt)); }
131  IMG_TileOptions *operator()(int i) { return myOptions[i].get(); }
132 
133  /// @{
134  /// Dump option list
135  void dump(UT_JSONWriter &w) const;
136  void dump() const;
137  /// @}
138 private:
140 };
141 
142 #endif
GT_API const UT_StringHolder filename
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
void setPlaneInfo(const char *filename, const char *channel, const char *format, IMG_DataType dtype=IMG_DT_ANY, IMG_ColorModel cmodel=IMG_CM_ANY, IMG_TypeInfo tinfo=IMG_TI_COLOR)
IMG_TypeInfo
How the channel data should be interpreted.
Definition: IMG_FileTypes.h:39
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:35
GLenum src
Definition: glcorearb.h:1793
void setGamma(fpreal gamma)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
#define IMG_API
Definition: IMG_API.h:10
GLuint64EXT * result
Definition: glew.h:14311
UT_StringHolder myFilename
IMG_TileOptions * operator()(int i)
int entries() const
IMG_DataType
Definition: IMG_FileTypes.h:17
fpreal gamma() const
GLuint GLint GLboolean GLint GLenum access
Definition: glcorearb.h:2222
UT_StringHolder myFormatName
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
A map of string to various well defined value types.
Definition: UT_Options.h:84
fpreal64 fpreal
Definition: SYS_Types.h:277
PXL_ColorSpace
Definition: PXL_Common.h:68
IMG_ColorModel
Definition: IMG_FileTypes.h:53
UT_Options myOptions
UT_StringHolder myChannel
Definition: core.h:1131
void append(UT_UniquePtr< IMG_TileOptions > opt)