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