HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_OTLManager.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_OTLManager.h ( OTL Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __OP_OTLManager__
13 #define __OP_OTLManager__
14 
15 #include "OP_API.h"
16 #include <UT/UT_Compression.h>
17 #include <UT/UT_IntArray.h>
18 #include <UT/UT_Notifier.h>
19 #include <UT/UT_StringArray.h>
20 #include <UT/UT_SymbolTable.h>
21 #include <UT/UT_UniquePtr.h>
22 #include <iosfwd>
23 
24 class OP_Node;
25 class OP_Operator;
26 class OP_OperatorTable;
27 class OP_OTLManagerSink;
28 class OP_OTLManager;
29 class OP_OTLLibrary;
30 class OP_OTLDefinition;
32 class FS_IndexFile;
33 class UT_StringSet;
34 class UT_WorkBuffer;
35 
36 #define OP_TYPEBARMODE_FULLMENU "fullmenu"
37 #define OP_TYPEBARMODE_AUTOMENU "automenu"
38 #define OP_TYPEBARMODE_DISPLAYONLY "displayonly"
39 #define OP_TYPEBARMODE_NONE "none"
40 
41 // Note that the string is deliberately misleading,
42 // since the "compiled" flag might be just a little
43 // too obvious.
44 #define OP_IS_OTL_COMPILED "nodeconntype"
45 
46 // Black boxed assets are assets whose implementation details are hidden
47 // to the user. However, these need no licensing information and can be freely
48 // distributed. This flag is used to indicate if an asset is blackboxed and
49 // is purposefully obfuscated, simmilar to the flag above.
50 #define OP_IS_OTL_BLACKBOXED "nodeparmtype"
51 
52 // Functions get executed whenever we call OP_OTLManager::saveOpTypeFromNode.
54 
56 {
57 public:
58 
60  virtual ~OP_OTLLoadCallback() {}
61 
62  virtual bool onOTLLoadBegin(const char* otl_name,
63  const OP_OTLLibrary* opt_lib,
64  OP_Operator* opt_operator,
65  UT_String& error_message_out) = 0;
66 };
67 
69 {
70 public:
71  OP_OTLManager();
72  virtual ~OP_OTLManager();
73 
74  // Getting and setting of configuration information.
75  bool getSaveToHipFile() const;
76  void setSaveToHipFile(bool savetohip);
77  bool getSaveUnlockedToHipFile() const;
78  void setSaveUnlockedToHipFile(bool saveunlockedtohip);
79  bool getWarnOutOfDateOps() const;
80  void setWarnOutOfDateOps(bool warn);
81  bool getWarnDummyOpsOnLoad() const;
82  void setWarnDummyOpsOnLoad(bool warn);
83  bool getPreferLatestDate() const;
84  void setPreferLatestDate(bool preferlatest);
85  bool getPreferInternal() const;
86  void setPreferInternal(bool preferinternal);
87  bool getPreferIndexFile() const;
88  void setPreferIndexFile(bool preferindexfile);
89  bool getCreateBackups() const;
90  void setCreateBackups(bool createbackups);
91  bool getSafeguardOpDefs() const;
92  void setSafeguardOpDefs(bool safeguardopdefs);
93  bool getLeaveDefaultsUnchanged() const;
94  void setLeaveDefaultsUnchanged(bool leavedefaultsunchanged);
95  bool getUseOplibrariesFiles() const;
96  void setUseOplibrariesFiles(bool useoplibrariesfiles);
97  const UT_StringHolder&getOperatorTypeBarMode() const;
98  void setOperatorTypeBarMode(const UT_StringHolder &mode);
99  const UT_StringArray&getAllowedOperatorTypeBarModes() const;
100 
101  /// Register a new class to be used as a callback when an OTL library
102  /// is loaded.
103  static void registerOTLLoadCallback(OP_OTLLoadCallback * cb);
104 
105  /// Executes onOTLLoadBegin() for each registered callback and returns the result
106  bool runOTLCallbacks(const char* otl_name,
107  const OP_OTLLibrary* opt_lib,
108  OP_Operator* opt_operator,
109  UT_String& error_out);
110 
111  /// Gets the list of otls that have tried to load and failed.
112  UT_StringArray &getFailedOTLs();
113 
114  /// Reset the list of failed otls.
115  void clearFailedOTLList();
116 
117  /// Load in the contents of an OPlibraries file. This is public so that
118  /// when loading a hip file, the OP_Director can use this to parse the
119  /// .OPlibraries packet.
120  bool loadOpLibrariesFile(UT_IStream &is,
121  const char *metasrc, int &libpos);
122  /// Saves the .OPlibraries section that will be included in a .hip file.
123  /// This file must be different from the one above because it has to
124  /// skip the internal hip file library.
125  bool saveInternalMetaFile(std::ostream &os,
126  const char *prefix = 0) const;
127 
128  /// Picks a particular OTL to be the preferred library for a particular
129  /// operator type. Returns true if the operator type exists in an OTL.
130  /// Even if we return false, we keep the information in case this
131  /// operator type gets loaded later.
132  /// WARNING: This method may reload libraries, so holding OP_OTLLibrary
133  /// pointers across this call is unsafe.
134  void setLibraryPreference(const char *tablename,
135  const char *opname,
136  const char *libfile);
137  /// Sets the preference on all assets in the supplied library if
138  /// they are not already the current definition.
139  /// WARNING: This method may reload libraries, so holding OP_OTLLibrary
140  /// pointers across this call is unsafe.
141  void setLibraryPreferencesIfRequired(int index);
142  /// Gets the preferred library for a particular operator type. Returns
143  /// null if no preference is set, or the operator type is not known.
144  const char *getLibraryPreference(const char *tablename,
145  const char *opname) const;
146  /// Clear all explicit preferences.
147  void clearLibraryPreferences(bool refreshlibs);
148  /// Functions to save and load the preferred OTL information.
149  bool loadLibraryPreferences(UT_IStream &is);
150  void saveLibraryPreferences(std::ostream &os,
151  bool includeinternal = true,
152  bool protectstrings = false) const;
153 
154  /// Returns the descriptive name for a particular meta source.
155  const UT_StringHolder &getMetaSourceName(OP_OTLLibrary *lib,
156  bool withpath = true) const;
157  void getMetaSourceName(const char *metasrc,
158  UT_String &metasrcname,
159  bool withpath = true) const;
160  bool setMetaSourceName(const char *metasrc,
161  const char *metasrcname);
162 
163  /// Returns true if we are adding a new instance of an existing library,
164  /// followed immediately be removing the old copy. If so, we can do some
165  /// optimizations in OP_Director::definitionsAdded.
166  bool getIsPerformingAtomicAddRemove() const;
167 
168  /// Returns true if we are in the middle of a call to refreshAll. If we
169  /// are, we can optimize out a whole bunch of calls that can be done
170  /// once at the end of the refresh.
171  bool getIsPerformingRefreshAll() const;
172 
173  /// Returns true if the manager is in teh process of creating a new HDA.
174  bool getIsCreatingNewHDA() const;
175 
176  /// Basic operations of adding and removing libraries.
177  void loadAutoOTLs();
178  int findLibrary(const char *libfile,
179  const char *metasrc = 0) const;
180  int findNextLibrary(const char *libfile,
181  int after) const;
182  bool refreshLibrary(int index, bool force = true);
183  bool removeLibrary(const char *libfile,
184  const char *metasrc,
185  bool changeoplibraries);
186  bool removeMetaSource(const char *metasrc);
187  void refreshAll(bool reloadOpLibraries);
188 
189  /// This function adds the libfile to the specified metasrc if it
190  /// isn't there already (or moves it to the specified position if
191  /// it is there). This is the function external callers should
192  /// always use.
193  OP_OTLLibrary *addLibrary(const char *libfile,
194  const char *metasrc,
195  bool changeoplibraries,
196  bool installinternaliffail,
197  UT_WorkBuffer &errors);
198 
199  // Get basic library information.
200  int getNumLibraries() const;
201  int getPreferredLibrary(const char *tablename,
202  const char *opname);
203  OP_OTLLibrary *getLibrary(int index) const;
204 
205  /// Returns the library that contains the latest (by date) definition
206  /// for the specified operator.
207  int getLatestLibrary(const char *tablename,
208  const char *opname,
209  OP_OTLLibrary *tiegoesto = 0);
210  bool getOutOfDateInternalOps(UT_StringArray &ops);
211 
212  /// Returns the next library with a definition for the specified operator.
213  /// This function loops around to the start of the library list.
214  int getNextLibrary(const char *tablename,
215  const char *opname,
216  OP_OTLLibrary *startat);
217 
218  /// Adds an operator definition to an existing library, or creates
219  /// a new library file if necessary.
220  static bool addToLibrary(OP_OTLLibrary *lib,
221  OP_OTLDefinition &definition,
222  FS_IndexFile *deffile,
223  bool dummydefinition = false);
224  bool addToLibrary(const char *libfile,
225  OP_OTLDefinition &definition,
226  FS_IndexFile *deffile,
227  bool dummydefinition = false,
228  bool create_op_type=false,
229  bool create_backup=true);
230 
231  bool saveCreateBackup(const UT_String &libfile,
232  OP_OTLLibrary *newlib);
233 
234  /// Take the secondary library and merge it into the primary library,
235  /// and save the combined file out to the primary library.
236  bool mergeLibraries(const char *primary,
237  const char *secondary,
238  bool overwrite);
239 
240  /// These functions are for maintaining our one "internal" library.
241  /// This library is where we keep op definitions that have been loaded
242  /// form the hip file, or definitions that we want to uninstall but
243  /// couldn't because of existing operators of that type.
244  bool addToInternalLibrary(OP_OTLLibrary *newlib);
245  bool addToInternalLibrary(UT_IStream &is, int modtime);
246 
247  /// Removes some operator definitions from an existing library. We
248  /// check the file name to determine if we are removing from the
249  /// internal library, or an external library file.
250  bool removeFromLibrary(const char *libfile,
251  const UT_StringArray &ops);
252 
253  /// Update the date stamp for the specified definition to be the current
254  /// date. Do a refresh of the library if it is loaded.
255  bool touchDefinition(const char *libfile,
256  const char *tablename,
257  const char *opname,
258  int newtime = -1);
259 
260  /// This functions modifies the data in the OTLDefinition so that it
261  /// will refer to the given index file so that both these elements can
262  /// be embedded into an OTLLibrary.
263  static void modifyDefinitionToInternalPaths(
264  OP_OTLDefinition &def,
265  FS_IndexFile *deffile);
266 
267  /// A utility function for saving the operator definition for a given node.
268  void saveOpTypeFromNode( OP_Node *node, UT_String &errors );
269 
270  /// A utility function for updating the Contents section of an asset
271  /// definition based on a particular OP_Node. The compile flags can be
272  /// used to control whether the contents are compiled
273  void updateContentsFromNode(FS_IndexFile *deffile,
274  OP_Node *node,
275  UT_CompressionType compressionType,
276  bool compilebasic,
277  bool compilevopnets,
278  bool compilechannels,
279  bool compilenodenames,
280  const char *library,
281  bool blackbox = false);
282 
283  /// A utility function for updating an operator definition based on
284  /// a particular OP_Node.
285  void updateDefinitionFromNode(FS_IndexFile *deffile,
286  OP_Node *node,
287  bool lockcontents,
288  bool usedsparms,
289  UT_CompressionType compressionType,
290  bool savespareparms,
291  bool compile_asset,
292  const char *library,
293  bool blackbox = false);
294 
295  /// A utility functino to make sure that the Contents section of the
296  /// given file is either compressed or not, as set by gzipcontents.
297  void setContentsCompression(FS_IndexFile *deffile,
298  UT_CompressionType compressionType);
299  /// Utility functions for getting/setting the comment and version data in an
300  /// operator type definition index file.
301  bool getComment(FS_IndexFile *deffile, UT_String &result);
302  void setComment(FS_IndexFile *deffile, const char *comment);
303  bool getVersion(FS_IndexFile *deffile, UT_String &result);
304  void setVersion(FS_IndexFile *deffile, const char *version);
305 
306  /// Functions for listing information about libraries and ops.
307  void listLibraries(std::ostream &os) const;
308  void listLibrariesWithDefinition(const char *tablename,
309  const char *opname,
310  std::ostream &os) const;
311  void listOperators(const char *libfile,
312  std::ostream &os) const;
313  void listOperator(const char *libfile,
314  const char *tablename,
315  const char *opname,
316  const char *format,
317  std::ostream &os) const;
318 
319  /// Function to get a list of the libraries containing a definition for
320  /// the specified type.
321  void getLibrariesWithDefinition(
322  const char *tablename,
323  const char *opname,
325 
326  /// Get a list of all operators (in tablename/optypenae form) that match
327  /// the passed in mask, which may contain wildcards. Before adding a result
328  /// to the array, it checks the symbol table to see if the result has
329  /// already been found. The tablename/optype string is added to the results
330  /// array. If a library pointer is passed in, only that library is searched.
331  /// Optypes found in that library do not need to be installed or current in
332  /// the Houdini session. If no library is passed in all current definitions
333  /// are searched, and all non-current definitions are ignored (so there
334  /// can be no confusion about which instance of an optype definition
335  /// was found. Returns true if some matching optype was found (even if
336  /// that optype wasn't added because of it already being in the symbol
337  /// table).
338  bool getAllMatchingOperators(const char *opmask,
339  const OP_OTLLibrary *library,
340  bool onlyotlops,
341  UT_StringArray &results,
342  UT_StringSet &resultstable) const;
343 
344  /// Functions for handling our interests.
345  void addManagerSink(OP_OTLManagerSink *sink);
346  void removeManagerSink(OP_OTLManagerSink *sink);
347 
348  /// Checks if the given table and operator type name are valid.
349  bool checkValidNodeName(const char *name,
351  UT_WorkBuffer &errors);
352  /// Creates a new operator type in an OTL, and installs that OTL.
353  bool createOptype(OP_OTLDefinition &def,
354  const char *installpath,
355  const char *extradsinfo,
356  const char *installmetasrc,
357  const UT_StringMap<UT_StringHolder> &extrasections,
358  UT_WorkBuffer &errors,
359  bool create_backup=true);
360 
361 
362  /// Creates a new operator type in an OTL, and installs that OTL.
363  bool createOptype(const char *tablename,
364  const char *opname,
365  const char *oplabel,
366  const char *installpath,
367  int min_input, int max_input,
368  int max_outputs,
369  const char *extradsinfo,
370  const char *installmetasrc,
371  const char *extrainfo,
372  bool subnet,
373  UT_WorkBuffer &errors,
374  bool create_backup=true);
375 
376  static bool getHelpTemplateFile(UT_String &helptemplatefile);
377  static void createDefaultOptypeName(OP_Node *fromnode,
378  UT_String &name,
379  UT_String &label);
380  static void createOptypeLabelFromName(UT_String name,
381  UT_String &label);
382  static void createOptypeNameFromLabel(UT_String label,
383  UT_String &name);
384  static void fullyQualifyLibFileName(const char *libfilebase,
385  UT_String &libfile,
386  const char *basedir = 0);
387  void fullyQualifyMetaSrcName(const char *libfilebase,
388  UT_String &libfile) const;
389  void getSimplifiedPath(UT_String &destpath,
390  const char *srcpath,
391  const char *srcmeta) const;
392 
393  bool canSavePreferences() const;
394 
395  /// Functions for managing fallback libraries. These are libraries that
396  /// are automatically loaded (as a last resort) if a particular type
397  /// definition is missing.
398  ///
399  /// The manager maintains a stack of fallback contexts. In general, each
400  /// fallback context contains the fallback paths specified in a particular
401  /// file fragment (hip file, digital asset contents section) and remains
402  /// active until that file fragment is processed by the loading mechanism.
403  void pushFallbackLibraryContext();
404  void popFallbackLibraryContext();
405  void saveFallbackLibraryPaths(std::ostream &os,
406  const OP_OperatorList &ops) const;
407  bool loadFallbackLibraryPaths(UT_IStream &is);
408  bool loadFallbackLibrary(const char *tablename,
409  const char *opname);
410 
411  /// Functions for managing the dummy definitions for each operator.
412  /// The dummy definition is just a dialog script copied from the last time
413  /// the operator was loaded. It is retrieved if no other definition for
414  /// the operator is available. It should be enough information to load
415  /// and re-save a hip file containing an unknown operator type without
416  /// losing any information.
417  void setDummyDefinition(const OP_OTLDefinition &definition,
418  const FS_IndexFile *deffile);
419  bool getDummyDefinition(const OP_Operator *op,
420  FS_IndexFile *deffile) const;
421  bool loadDummyDefinitions(UT_IStream &is, int modtime);
422  void saveDummyDefinitions(std::ostream &os,
423  const OP_OperatorList &ops) const;
424 
425  /// Saves an empty (but valid) dialog script to a stream.
426  static void saveDefaultDialogScript(std::ostream &os,
427  const char *opname,
428  const char *oplabel,
429  const char *extradsinfo);
430  /// Saves a default, do-nothing creation script to a stream.
431  static void saveDefaultCreationScript(std::ostream &os,
432  const char *op,
433  const char *table);
434 
435  /// Writes the index file 'contents' to the output stream 'os'. Ensures
436  /// that the filtering options (ie encryption) are set correctly on the
437  /// index file before it is written out.
438  static void writeOutDefinitionContents(
439  const OP_OTLDefinition &definition,
440  FS_IndexFile & contents,
441  std::ostream & os);
442 
443  /// Sets the encryption and decryption filters on the contents.
444  static void setFilters(const OP_OTLDefinition &definition,
445  FS_IndexFile &contents);
446 
447  /// Reload OTL license files, and notify interested parties of the
448  /// potential for change.
449  void refreshLicenses();
450 
451  /// Get the real file name that is presently being used for the Embedded
452  /// library. This should be used very carefully, and the value should not
453  /// be stored, because it will change anytime a definition is added to or
454  /// removed from the Embedded library.
455  const UT_String &getInternalTempFile() const;
456 
457  /// Checks if the library has a non-commercial (tainted) asset.
458  /// Note, the library does not have to be loaded yet.
459  bool hasNCAsset(const OP_OTLLibrary *lib);
460 
461  /// Returns an array of asset indices that are non-commercial
462  /// Note, the library does not have to be loaded yet.
463  void getNCAssets(const OP_OTLLibrary *lib,
464  UT_IntArray & nc_assets);
465 
466  /// Only called by FUSE_AssetsMenu to clean dirty flags of assets.
468  {mySaveOpTypeCallback = cb;}
469 
470  /// Convert libraries between different formats
471  bool convertLibraryToFile(const char *libfilebase,
472  const char *metasrcbase);
473  bool convertLibraryToDir(const char *libfilebase,
474  const char *metasrcbase);
475 
476 private:
477  struct OTLFallbackData
478  {
479  public:
480  UT_StringArray myPaths;
481  bool myFailFlag;
482  };
483  typedef UT_SymbolMap<OTLFallbackData *> FallbackContext;
484 
485  // Helper struct for doing bulk refresh operations
486  class RefreshScope;
487  friend class RefreshScope;
488 
489  // Functions for sending notifications to our interests.
490  void notifySinksOfAssetCreated(
491  const OP_OTLLibrary &library,
492  const OP_OTLDefinition &def);
493  void notifySinksOfAssetDeleted(
494  const OP_OTLLibrary &library,
495  const OP_OTLDefinition &def);
496  void notifySinksOfAssetSaved(
497  const OP_OTLLibrary &library,
498  const OP_OTLDefinition &def);
499  void notifySinksOfLibraryInstalled(OP_OTLLibrary *library);
500  void notifySinksOfLibraryUninstalled(
501  OP_OTLLibrary *library);
502  void notifySinksOfDefinitionsAdded(int libindex,
503  UT_IntArray &defarray);
504  void notifySinksOfDefinitionsRemoved(int libindex,
505  UT_IntArray &defarray,
507  void notifySinksOfSourceNamesChanged();
508  void notifySinksOfLibraryAdded(OP_OTLLibrary *library);
509  void notifySinksOfLibraryRemoved(OP_OTLLibrary *library);
510  void notifySinksOfConfigurationChanged();
511  void notifySinksOfLicensesChanged();
512  void writeSimplifiedPath(std::ostream &os,
513  const char *srcpath,
514  const char *srcmeta,
515  const char *prefix = 0) const;
516 
517  /// Sets meta source name data for a given meta source.
518  void setMetaSourceNameData(int pos, const char *metasrc,
519  const char *metasrcname);
520  /// Saves an OPlibraries file by looking through our libraries and
521  /// writing out any loaded library that uses that meta source. Optionally
522  /// we can also specify a single library that should not be written, or
523  /// an extra library that should be written.
524  bool saveMetaFile(const char *metafile,
525  const char *skiplib,
526  const char *addlib) const;
527  /// Adds a library to an OPlibraries file, and returns the index of
528  /// where in the overall list of libraries the new library should
529  /// be inserted. Used by addLibrary.
530  int addToMetaSource(const char *libfile,
531  const char *metasrc,
532  bool changeoplibraries);
533  /// Put a library into our list at a particular position. Used
534  /// internally to actually add libraries.
535  bool insertLibrary(OP_OTLLibrary *newlib, int before);
536  /// Internal removeLibrary used to actually remove a library.
537  bool removeLibrary(int index, bool external=false);
538  /// Functions for loading and saving our preferences file.
539  void loadPreferences();
540  void savePreferences();
541  /// Use this function to create a new temp file for our internal library.
542  void moveInternalToNewTempFile();
543  /// Removes from lib any definitions for which there is already a
544  /// non-dummy definition in existance.
545  void clearIfGoodDefinitionExists(OP_OTLLibrary *lib);
546  /// Removes some operator definitions from an existing library file.
547  bool removeFromExternalLibrary(const char *libfile,
548  const UT_StringArray &ops);
549  /// Removes some operator defintions from the internal library, but
550  /// only if it is safe to do so (either there is another library
551  /// ready to take over the definition, or the opertor is unused).
552  bool removeFromInternalLibrary(const UT_StringArray &ops);
553  /// backup a libfile before replacing it with the new one. NOTE this
554  /// deletes 'newlib' before returning in order to close any file pointers
555  bool backupAndWriteNewLibrary(const char *libfilebase,
556  const char *libfile,
557  OP_OTLLibrary *newlib);
558 
559  /// Helper functions for touchDefinition which set the modification
560  /// time for an operator definition in either the internal library or
561  /// an external library file.
562  bool touchExternalDefinition(const char *libfile,
563  const char *tablename,
564  const char *opname,
565  int newtime);
566  bool touchInternalDefinition(const char *tablename,
567  const char *opname,
568  int newtime);
569  /// Adds a library from an OPlibraries file.
570  void addFromOpLibrariesFile(const char *file,
571  const char *metasrc,
572  int &libpos);
573 
574  /// Private utility method for implementing the public method.
575  void setLibraryPreference(const char *tablename,
576  const char *opname,
577  const char *libfile,
578  UT_IntArray *libstorefresh);
579 
580  /// Some private utility methods for managing the fallback library tables.
581  void addFallbackLibraryPath(const char *tablename,
582  const char *opname,
583  const char *libfile);
584  bool loadFallbackLibrary(FallbackContext *context,
585  const char *opsymbol,
586  const char *tablename,
587  const char *opname);
588  void clearLibraryFallbacks(FallbackContext *table);
589 
590  /// Tests if the definition is for a non-commercial asset.
591  bool isNCAsset(const FS_IndexFile *lib_file,
592  const OP_OTLDefinition & def);
593 
594  /// This static exit callback is here in case we allocate an
595  /// OP_OTLManager then never free it (which we do, since we never
596  /// delete our OP_Director).
597  static void deleteLibraries(void *data);
598 
599 private: // data
600 
601  UT_ValArray<OP_OTLLibrary *> myLibraries;
602  UT_ValArray<OP_OTLManagerSink *> myManagerSinks;
603  UT_ValArray<OP_OTLLibrary *> myLibrariesBeingRemoved;
604  UT_String myInternalTempFile;
605  UT_String myNewInternalTempFile;
606  UT_StringArray myMetaSourcesWithNames;
607  UT_StringArray myMetaSourceNames;
608  UT_StringArray myMetaSourceNameWithPaths;
609  UT_SymbolMap<UT_StringHolder> myLibraryPreferences;
610  UT_ValArray<FallbackContext *> myLibraryFallbacks;
611  UT_UniquePtr<OP_OTLLibrary> myDummyDefinitions;
612  UT_StringHolder myOperatorTypeBarMode;
613  UT_StringArray myFailedOTLs;
614  OP_SaveOpTypeCallback mySaveOpTypeCallback;
615  int myPerformingRefreshAll;
616  bool myIsPerformingAtomicAddRemove;
617  bool mySaveToHipFile;
618  bool mySaveUnlockedToHipFile;
619  bool myWarnOutOfDateOps;
620  bool myWarnDummyOpsOnLoad;
621  bool myPreferLatestDateDefinition;
622  bool myPreferInternalDefinition;
623  bool myPreferIndexFileDefinition;
624  bool myCreateBackups;
625  bool mySafeguardOpDefs;
626  bool myLeaveDefaultsUnchanged;
627  bool myUseOplibrariesFiles;
628  bool myIsCreatingNewHDA;
629 
631  theOTLLoadCallbacks;
632 };
633 
635 {
636 public:
639  { removeAllManagerSinks(); }
640 
641  /// Called when an asset definition is created.
642  /// This differs from definitionsAdded() which is called even
643  /// when a library is refreshed.
644  virtual void assetCreated(
645  const OP_OTLLibrary &library,
646  const OP_OTLDefinition &def) {}
647 
648  /// Called when an asset definition is deleted from the library.
649  /// This differs from definitionsRemoved() which is called even
650  /// when a library is refreshed.
651  virtual void assetDeleted(
652  const OP_OTLLibrary &library,
653  const OP_OTLDefinition &def) {}
654 
655  /// Called when an asset definition is saved.
656  virtual void assetSaved(
657  const OP_OTLLibrary &library,
658  const OP_OTLDefinition &def) {}
659 
660  /// libraryInstalled() is called after an HDA library is installed.
661  /// This differs from libraryAdded() which is called after a library
662  /// is added to the manager's library list. The latter can be called
663  /// several times in a session due to a library being installed or updated.
664  virtual void libraryInstalled(const OP_OTLLibrary *library) {}
665 
666  /// libraryUinstalled() is called after an HDA library was uninstalled.
667  /// This differs from libraryRemoved() which is called after a library
668  /// is removed from the manager's library list. The latter can be
669  /// called several times in a session due to a library being uninstalled
670  /// or updated.
671  virtual void libraryUninstalled(const OP_OTLLibrary *library) {}
672 
673  virtual void definitionsAdded(int /*libindex*/,
674  UT_IntArray & /*defindex*/) { }
675  virtual void definitionsRemoved(int /*libindex*/,
676  UT_IntArray & /*defindex*/,
677  OP_OTLLibrary *& /*preserve*/){ }
678  virtual void sourceNamesChanged() { }
679  virtual void libraryAdded(OP_OTLLibrary * /*library*/) { }
680  virtual void libraryRemoved(OP_OTLLibrary * /*library*/) { }
681  virtual void configurationChanged() { }
682  virtual void licensesChanged() { }
683 
685  { removeManagerSink(manager); }
686 
687 protected:
689  {
690  if( !manager ) return;
691 
692  // Don't add if we have already added ourselves
693  // to the manager.
694  if (myManagers.find(manager) != -1)
695  return;
696 
697  manager->addManagerSink(this);
698  myManagers.append(manager, 1);
699  }
701  {
702  if( !manager ) return;
703  manager->removeManagerSink(this);
704  myManagers.findAndRemove(manager);
705  }
707  {
708  for( int i = myManagers.entries(); i --> 0; )
709  removeManagerSink(myManagers(i));
710  }
711 
712 private:
713  UT_ValArray<OP_OTLManager *> myManagers;
714 };
715 
716 #endif
717 
void removeManagerSink(OP_OTLManagerSink *sink)
int getVersion(int version)
Definition: ImfVersion.h:116
GLuint GLsizei const void GLenum preserve
Definition: glew.h:8474
GLuint const GLchar * name
Definition: glew.h:1814
void addManagerSink(OP_OTLManager *manager)
GLenum mode
Definition: glew.h:2163
GLuint index
Definition: glew.h:1814
GLsizei GLenum GLboolean sink
Definition: glew.h:4966
virtual void libraryInstalled(const OP_OTLLibrary *library)
virtual void libraryRemoved(OP_OTLLibrary *)
GLenum GLsizei GLenum GLenum const void * table
Definition: glew.h:4940
virtual ~OP_OTLLoadCallback()
Definition: OP_OTLManager.h:60
virtual void definitionsRemoved(int, UT_IntArray &, OP_OTLLibrary *&)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: glew.h:1254
virtual void licensesChanged()
void removeManagerSink(OP_OTLManager *manager)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:33
void removeAllManagerSinks()
virtual void libraryAdded(OP_OTLLibrary *)
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
void managerDeleted(OP_OTLManager *manager)
virtual ~OP_OTLManagerSink()
void setSaveOpTypeCallback(OP_SaveOpTypeCallback cb)
Only called by FUSE_AssetsMenu to clean dirty flags of assets.
void
Definition: png.h:1083
OPENVDB_API void setVersion(std::ios_base &, const VersionId &libraryVersion, uint32_t fileVersion)
Associate specific file format and library version numbers with the given stream. ...
virtual void assetSaved(const OP_OTLLibrary &library, const OP_OTLDefinition &def)
Called when an asset definition is saved.
void addManagerSink(OP_OTLManagerSink *sink)
Functions for handling our interests.
GLuint GLsizei GLsizei GLchar * label
Definition: glew.h:8986
virtual void configurationChanged()
GT_API const UT_StringHolder version
UT_CompressionType
#define OP_API
Definition: OP_API.h:10
virtual void assetDeleted(const OP_OTLLibrary &library, const OP_OTLDefinition &def)
void(* OP_SaveOpTypeCallback)(OP_Node *)
Definition: OP_OTLManager.h:53
virtual void libraryUninstalled(const OP_OTLLibrary *library)
GLuint64EXT * result
Definition: glew.h:14007
virtual void sourceNamesChanged()
virtual void assetCreated(const OP_OTLLibrary &library, const OP_OTLDefinition &def)
virtual void definitionsAdded(int, UT_IntArray &)