HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_GalleryEntry.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: OP_GalleryEntry.h ( OP Library, C++)
7  *
8  * COMMENTS: Class that defines an OP_Gallery entry.
9  */
10 
11 #ifndef __OP_GalleryEntry__
12 #define __OP_GalleryEntry__
13 
14 #include "OP_API.h"
15 #include <UT/UT_Options.h>
16 #include <UT/UT_ValArray.h>
17 #include <UT/UT_Compression.h>
18 #include <FS/FS_IndexFile.h>
19 
20 #define OP_GALLERY_ENTRY_PREFIX "gallery::"
21 
22 class UT_StringArray;
23 class OP_Gallery;
24 class OP_Node;
25 class OP_Network;
26 
28 {
29 public:
30  // This simple constructor creates a gallery entry in memory only. It
31  // has no connection to the Gallery Manager or any Gallery.
33  virtual ~OP_GalleryEntry();
34 
35  bool getEntryIsValid() const;
36  bool match(const char *namepattern,
37  const char *labelpattern,
38  const char *keywordpattern,
39  const char *category,
40  const char *optable,
41  const char *optype) const;
42 
43  const UT_String &getFilePath() const;
44  const UT_String &getEntryName() const;
45  void setEntryName(const char *entryname);
46 
47  void getLabel(UT_String &label) const;
48  void setLabel(const char *label);
49 
50  void getDescription(UT_String &description) const;
51  void setDescription(const char *description);
52 
53  void getIcon(UT_String &icon) const;
54  void setIcon(const char *icon);
55 
56  bool getAllowIconRegeneration() const;
57  void setAllowIconRegeneration(bool flag);
58 
59  void getHelpUrl(UT_String &helpurl) const;
60  void setHelpUrl(const char *helpurl);
61 
62  void getOTLPath(UT_String &otlpath) const;
63  void setOTLPath(const char *otlpath);
64 
65  void getOpTable(UT_String &optable) const;
66  void setOpTable(const char *optable);
67 
68  void getOpTypes(UT_String &optypes) const;
69  void getOpTypes(UT_StringArray &optypes) const;
70  void setOpTypes(const char *optypes);
71  void setOpTypes(const UT_StringArray &optypes);
72 
73  // Just like getOpTypes() but it resolves any aliases to installed optypes.
74  void getResolvedOpTypes(
75  UT_StringArray &optypes) const;
76 
77  void getKeywords(UT_String &keywords) const;
78  void getKeywords(UT_StringArray &keywords) const;
79  void setKeywords(const char *keywords);
80  void setKeywords(const UT_StringArray &keywords);
81 
82  void getCategories(UT_String &cats) const;
83  void getCategories(UT_StringArray &cats) const;
84  void setCategories(const char *cats);
85  void setCategories(const UT_StringArray &cats);
86 
87  bool hasContents() const;
88  bool applyContents(OP_Node *destnode) const;
89  void setContents(OP_Node *srcnode);
90 
91  bool hasParms() const;
92  bool applyParms(OP_Node *destnode) const;
93  void getParms(UT_String &script) const;
94  void setParms(OP_Node *srcnode);
95  void setParms(const UT_WorkBuffer &data);
96 
97  // When hidden, a gallery entry will not show up in the tools menu.
98  // By default hidden is false and the entry is shown.
99  void setHidden(bool hide);
100  bool isHidden() const;
101 
102  // Applies information other than parms and contents. Right now this
103  // means setting the node comment to the gallery entry description.
104  bool applyOther(OP_Node *destnode) const;
105 
106  // Applies the parms and contents from this gallery entry to the
107  // supplied node.
108  bool canApplyToNode(OP_Node *node) const;
109  bool applyToNode(OP_Node *node) const;
110 
111  // Finds the "natural" manager in which it can be instantiated:
112  OP_Network *getNaturalOpManager() const;
113 
114  // Creates a new node and applies this entry to that new node. The
115  // net parameter specifies the network that should be the parent of
116  // the new node. If no network is given, the node is created in the
117  // "natural" network type for that gallery entry.
118  bool canCreateChildNode(OP_Network *net=0) const;
119  OP_Node *createChildNode(OP_Network *net=0,
120  bool move_to_good_pos=true) const;
121 
122  // Finds the name of the best operator type acceptable to this entry.
123  void getBestOpType(UT_String &optype,
124  OP_Network *parent_net = NULL) const;
125 
126  // Uses the specified node to initialize the entry. All previous
127  // information is removed first.
128  void setInformationFromNode(OP_Node *node);
129 
130  // Clears all information from this entry.
131  void clearAllInformation();
132 
133  // Set one gallery entry equal to another. This copies the options, name,
134  // and index file contents, but not the gallery pointer.
136 
137  // This compare function can be used with the various UT_ValArray
138  // sorting functions to sort gallery entries based on the entry name.
139  static int compareEntries(OP_GalleryEntry * const *a,
140  OP_GalleryEntry * const *b);
141 
142  /// Returns ture if the gallery entry is in the process of creating
143  /// a node, before it even applies the parameters, contents, or other
144  /// changes.
145  static bool isCreatingNode();
146 
147 protected:
148  // This constructor form is used by Gallery objects loading from the
149  // gallery file.
151  const char *entryname,
152  bool newentry);
153 
154  void clear();
155  bool getOption(const char *optionname,
156  UT_String &optionvalue) const;
157  bool getOption(const char *optionname,
158  UT_StringArray &optionvalues,
159  bool spaceisseparator) const;
160  bool getOptionBool(const char *optionname,
161  bool &optionvalue) const;
162  void setOption(const char *optionname,
163  const UT_String &optionvalue);
164  void setOption(const char *optionname,
165  const UT_StringArray &optionvalues);
166  void setOptionBool(const char *optionname,
167  bool optionvalue);
168 
169  void saveCompressedSection(const char *section,
170  const UT_WorkBuffer &data,
172  bool loadCompressedSection(const char *section,
173  char *&buffer,
174  int &buflen) const;
175  void allowEditing();
176 
177 private:
178  void createDefault();
179  void loadFromGallery();
180 
181  OP_Gallery *myGallery;
182  FS_IndexFile *myIndexFile;
183  UT_String myEntryName;
184  UT_Options myOptions;
185  bool myEditableIndexFile;
186  static bool theCreatingNodeFlag;
187 
188  friend class OP_Gallery;
189 };
190 
192 
193 #endif
194 
PXL_API const char * getDescription(const ColorSpace *space)
Return the description of the color space.
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
Definition: core.h:760
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
A map of string to various well defined value types.
Definition: UT_Options.h:84
UT_CompressionType
LeafData & operator=(const LeafData &)=delete
#define OP_API
Definition: OP_API.h:10
UT_ValArray< OP_GalleryEntry * > OP_GalleryEntryList
type
Definition: core.h:1059
Definition: format.h:895
GLenum src
Definition: glcorearb.h:1793