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_Array.h>
18 #include <UT/UT_NonCopyable.h>
19 #include <UT/UT_Options.h>
20 
21 class UT_StringArray;
22 class UT_JSONWriter;
23 
25 {
26 public:
27  /// If the format is a null pointer, it will be inferred from the filename
28  IMG_TileOptions() = default;
29  virtual ~IMG_TileOptions() = default;
30 
32 
33  /// Create a new copy of myself
34  UT_UniquePtr<IMG_TileOptions> clone() const;
35 
36  void setPlaneInfo(const UT_StringHolder &filename,
37  const UT_StringHolder &channel,
38  const UT_StringHolder &format,
39  IMG_DataType dtype = IMG_DT_ANY,
40  IMG_ColorModel cmodel = IMG_CM_ANY,
41  IMG_TypeInfo tinfo = IMG_TI_COLOR);
42 
43  fpreal gamma() const { return myGamma; }
44  void setGamma(fpreal gamma) { myGamma = gamma; }
45  PXL_ColorSpace colorSpace() const;
46 
47  // Change the filename extension to match the format
48  bool changeFileExtension();
49 
50  /// There are sevaral ways to set format options:
51  /// 1) A sting (which is parsed into token/value pairs)
52  /// 2) A set of token/value pairs specified as a linear array
53  void clearOptions();
54  void setFormatOptions(const char *string);
55  void setFormatOptions(int argc, const char *const argv[]);
56  void setFormatOptions(const UT_StringArray &options);
57  void setFormatOption(const char *token, const char *value);
58  void setFormatOptions(const UT_Options &options);
59 
60  /// Get the IMG_Format associated with these options. This will possibly
61  /// return a null ptr.
62  virtual const IMG_Format *getFormat(IMG_Format::AccessType
64 
65  const char *getFilename() const;
66  const char *getChannel() const;
67  const char *getFormatName() const;
68  IMG_DataType getDataType() const;
69  IMG_ColorModel getColorModel() const;
70  IMG_TypeInfo getTypeInfo() const;
71  const UT_Options &getLocalOptions() const;
72 
73  /// Getting the option will return true/false based on whether the option
74  /// was defined. If the option was not defined, the value will not be
75  /// touched (i.e. it will remain unchanged).
76  virtual bool getOption(const char *token, UT_String &value) const;
77 
78  /// Texture options are only output for specific file formats. These
79  /// texture options are used to pass information from the calling
80  /// application to the device (where required).
81  /// The application can write directly to the UT_Options, which will
82  /// then be output in the file.
83  virtual void setTextureOptions(UT_Options &options);
84 
85  /// Pack all options into a single string. Returns the number of options
86  /// packed.
87  virtual int packOptionsString(UT_String &result) const;
88 
89  /// @{
90  /// Dump options
91  void dump(UT_JSONWriter &w) const;
92  void dump() const;
93  /// @}
94 
95 protected:
96  // Copy from the option source
97  void copy(const IMG_TileOptions &src);
98 
103  IMG_DataType myDataType = IMG_DT_ANY;
104  IMG_ColorModel myColorModel = IMG_CM_ANY;
106  fpreal myGamma = 1;
107 };
108 
110  : public UT_NonCopyable
111 {
112 public:
115 
116  /// WARNING: Using this class will delete all the contents, so you must
117  /// append clones if you're creating single lists from existing options.
118  int entries() const { return myOptions.size(); }
119  void append(UT_UniquePtr<IMG_TileOptions> opt) { myOptions.append(std::move(opt)); }
120  IMG_TileOptions *operator()(int i) { return myOptions[i].get(); }
121 
122  /// @{
123  /// Dump option list
124  void dump(UT_JSONWriter &w) const;
125  void dump() const;
126  /// @}
127 private:
129 };
130 
131 #endif
GT_API const UT_StringHolder filename
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
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:37
**But if you need a result
Definition: thread.h:613
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
#define IMG_API
Definition: IMG_API.h:10
UT_StringHolder myFilename
GLuint GLint GLboolean GLint GLenum access
Definition: glcorearb.h:2222
IMG_TileOptions * operator()(int i)
int entries() const
IMG_DataType
Definition: IMG_FileTypes.h:17
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
fpreal gamma() const
UT_StringHolder myFormatName
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:72
IMG_ColorModel
Definition: IMG_FileTypes.h:53
UT_Options myOptions
UT_StringHolder myChannel
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
Definition: core.h:1131
void append(UT_UniquePtr< IMG_TileOptions > opt)
GLenum src
Definition: glcorearb.h:1793