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  void getKeywords(UT_String &keywords) const;
74  void getKeywords(UT_StringArray &keywords) const;
75  void setKeywords(const char *keywords);
76  void setKeywords(const UT_StringArray &keywords);
77 
78  void getCategories(UT_String &cats) const;
79  void getCategories(UT_StringArray &cats) const;
80  void setCategories(const char *cats);
81  void setCategories(const UT_StringArray &cats);
82 
83  bool hasContents() const;
84  bool applyContents(OP_Node *destnode) const;
85  void setContents(OP_Node *srcnode);
86 
87  bool hasParms() const;
88  bool applyParms(OP_Node *destnode) const;
89  void getParms(UT_String &script) const;
90  void setParms(OP_Node *srcnode);
91  void setParms(const UT_WorkBuffer &data);
92 
93  // When hidden, a gallery entry will not show up in the tools menu.
94  // By default hidden is false and the entry is shown.
95  void setHidden(bool hide);
96  bool isHidden() const;
97 
98  // Applies information other than parms and contents. Right now this
99  // means setting the node comment to the gallery entry description.
100  bool applyOther(OP_Node *destnode) const;
101 
102  // Applies the parms and contents from this gallery entry to the
103  // supplied node.
104  bool canApplyToNode(OP_Node *node) const;
105  bool applyToNode(OP_Node *node) const;
106 
107  // Finds the "natural" manager in which it can be instantiated:
108  OP_Network *getNaturalOpManager() const;
109 
110  // Creates a new node and applies this entry to that new node. The
111  // net parameter specifies the network that should be the parent of
112  // the new node. If no network is given, the node is created in the
113  // "natural" network type for that gallery entry.
114  bool canCreateChildNode(OP_Network *net=0) const;
115  OP_Node *createChildNode(OP_Network *net=0,
116  bool move_to_good_pos=true) const;
117 
118  // Finds the name of the best operator type acceptable to this entry.
119  void getBestOpType(UT_String &optype,
120  OP_Network *parent_net = NULL) const;
121 
122  // Uses the specified node to initialize the entry. All previous
123  // information is removed first.
124  void setInformationFromNode(OP_Node *node);
125 
126  // Clears all information from this entry.
127  void clearAllInformation();
128 
129  // Set one gallery entry equal to another. This copies the options, name,
130  // and index file contents, but not the gallery pointer.
131  const OP_GalleryEntry &operator=(const OP_GalleryEntry &src);
132 
133  // This compare function can be used with the various UT_ValArray
134  // sorting functions to sort gallery entries based on the entry name.
135  static int compareEntries(OP_GalleryEntry * const *a,
136  OP_GalleryEntry * const *b);
137 
138  /// Returns ture if the gallery entry is in the process of creating
139  /// a node, before it even applies the parameters, contents, or other
140  /// changes.
141  static bool isCreatingNode();
142 
143 protected:
144  // This constructor form is used by Gallery objects loading from the
145  // gallery file.
147  const char *entryname,
148  bool newentry);
149 
150  void clear();
151  bool getOption(const char *optionname,
152  UT_String &optionvalue) const;
153  bool getOption(const char *optionname,
154  UT_StringArray &optionvalues,
155  bool spaceisseparator) const;
156  bool getOptionBool(const char *optionname,
157  bool &optionvalue) const;
158  void setOption(const char *optionname,
159  const UT_String &optionvalue);
160  void setOption(const char *optionname,
161  const UT_StringArray &optionvalues);
162  void setOptionBool(const char *optionname,
163  bool optionvalue);
164 
165  void saveCompressedSection(const char *section,
166  const UT_WorkBuffer &data,
168  bool loadCompressedSection(const char *section,
169  char *&buffer,
170  int &buflen) const;
171  void allowEditing();
172 
173 private:
174  void createDefault();
175  void loadFromGallery();
176 
177  OP_Gallery *myGallery;
178  FS_IndexFile *myIndexFile;
179  UT_String myEntryName;
180  UT_Options myOptions;
181  bool myEditableIndexFile;
182  static bool theCreatingNodeFlag;
183 
184  friend class OP_Gallery;
185 };
186 
188 
189 #endif
190 
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
#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