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