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