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