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  // Applies information other than parms and contents. Right now this
94  // means setting the node comment to the gallery entry description.
95  bool applyOther(OP_Node *destnode) const;
96 
97  // Applies the parms and contents from this gallery entry to the
98  // supplied node.
99  bool canApplyToNode(OP_Node *node) const;
100  bool applyToNode(OP_Node *node) const;
101 
102  // Finds the "natural" manager in which it can be instantiated:
103  OP_Network *getNaturalOpManager(void) const;
104 
105  // Creates a new node and applies this entry to that new node. The
106  // net parameter specifies the network that should be the parent of
107  // the new node. If no network is given, the node is created in the
108  // "natural" network type for that gallery entry.
109  bool canCreateChildNode(OP_Network *net=0) const;
110  OP_Node *createChildNode(OP_Network *net=0,
111  bool move_to_good_pos=true) const;
112 
113  // Finds the name of the best operator type acceptable to this entry.
114  void getBestOpType(UT_String &optype,
115  OP_Network *parent_net = NULL) const;
116 
117  // Uses the specified node to initialize the entry. All previous
118  // information is removed first.
119  void setInformationFromNode(OP_Node *node);
120 
121  // Clears all information from this entry.
122  void clearAllInformation();
123 
124  // Set one gallery entry equal to another. This copies the options, name,
125  // and index file contents, but not the gallery pointer.
126  const OP_GalleryEntry &operator=(const OP_GalleryEntry &src);
127 
128  // This compare function can be used with the various UT_ValArray
129  // sorting functions to sort gallery entries based on the entry name.
130  static int compareEntries(OP_GalleryEntry * const *a,
131  OP_GalleryEntry * const *b);
132 
133  /// Returns ture if the gallery entry is in the process of creating
134  /// a node, before it even applies the parameters, contents, or other
135  /// changes.
136  static bool isCreatingNode();
137 
138 protected:
139  // This constructor form is used by Gallery objects loading from the
140  // gallery file.
142  const char *entryname,
143  bool newentry);
144 
145  void clear();
146  bool getOption(const char *optionname,
147  UT_String &optionvalue) const;
148  bool getOption(const char *optionname,
149  UT_StringArray &optionvalues,
150  bool spaceisseparator) const;
151  bool getOptionBool(const char *optionname,
152  bool &optionvalue) const;
153  void setOption(const char *optionname,
154  const UT_String &optionvalue);
155  void setOption(const char *optionname,
156  const UT_StringArray &optionvalues);
157  void setOptionBool(const char *optionname,
158  bool optionvalue);
159 
160  void saveCompressedSection(const char *section,
161  const UT_WorkBuffer &data,
163  bool loadCompressedSection(const char *section,
164  char *&buffer,
165  int &buflen) const;
166  void allowEditing();
167 
168 private:
169  void createDefault();
170  void loadFromGallery();
171 
172  OP_Gallery *myGallery;
173  FS_IndexFile *myIndexFile;
174  UT_String myEntryName;
175  UT_Options myOptions;
176  bool myEditableIndexFile;
177  static bool theCreatingNodeFlag;
178 
179  friend class OP_Gallery;
180 };
181 
183 
184 #endif
185 
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
GLuint buffer
Definition: glcorearb.h:659
GLboolean * data
Definition: glcorearb.h:130
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
A map of string to various well defined value types.
Definition: UT_Options.h:42
UT_CompressionType
#define OP_API
Definition: OP_API.h:10
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
UT_ValArray< OP_GalleryEntry * > OP_GalleryEntryList
png_infop png_uint_32 flag
Definition: png.h:2242
GLenum src
Definition: glcorearb.h:1792