HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_FileDependencyMgr.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_FileDependencyMgr.h
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __OP_FileDependencyMgr_h__
12 #define __OP_FileDependencyMgr_h__
13 
14 #include "OP_API.h"
15 #include "OP_Node.h"
16 #include <UT/UT_DeepString.h>
17 #include <UT/UT_Array.h>
18 class UT_StringArray;
19 class PRM_Parm;
20 class PRM_ParmList;
21 class OP_Node;
22 class OP_Network;
23 
24 // This class stores a a node and the name of a file referenced by that node.
25 // Note that the node may be null if node tracking is not wanted.
27 {
28 public:
29  OP_NodeFileNamePair(OP_Node *node, const char *file_name,
30  PRM_Parm *parm=NULL, PRM_Parm *ref_parm=NULL)
31  : myNode(node),
32  myFileName(file_name),
33  myParm(parm),
34  myRefParm(ref_parm)
35  {}
36 
37  // This constructor is needed for UT_Array.
39  : myNode(NULL),
40  myParm(NULL),
41  myRefParm(NULL)
42  {}
43 
48 };
49 
51 
52 
53 // Access this class by calling OPgetFileDependencyMgr().
55 {
56 public:
58 
59  enum SkipHFSOption { SKIP_HFS_FILES, KEEP_HFS_FILES };
60  enum TrackNodesOption { TRACK_NODES, SKIP_NODES };
61  enum CondensePathOption { CONDENSE_HIP, CONDENSE_JOB };
62  enum OpdefOption { EXCLUDE_OPDEFS, INCLUDE_OPDEFS };
63 
64  // Retrieves all the file paths referenced by any node
65  // in the current .hip file.
66  // Files that are found are placed in `found_files`.
67  // Missing files are placed in `unknown_files`.
68  void getInputFilesInParms(SkipHFSOption skip_hfs_option,
69  TrackNodesOption track_nodes_option,
70  OpdefOption opdef_option,
71  OP_NodeFileNameArray &found_files,
72  OP_NodeFileNameArray &unknown_files) const;
73 
74  // Retrieves the OTL files which define any custom operators that
75  // are currently in use. Note that this method also returns other files
76  // needed by the otl files, such as vex files.
77  void getOTLFiles(UT_StringArray &files, OP_NodeList* otl_nodes_out,
78  SkipHFSOption skip_hfs_option=SKIP_HFS_FILES,
79  CondensePathOption condense_path_option = CONDENSE_HIP) const;
80 
81  // Merges 2 NodeFileNameArray objects. Removes duplicate entries.
82  void mergeDependencyLists(const OP_NodeFileNameArray &src_refs1,
83  const OP_NodeFileNameArray &src_refs2,
84  OP_NodeFileNameArray &dest_refs,
85  TrackNodesOption track_nodes_option) const;
86 
87  // Attempts to add a file dependency to the specified node and parm.
88  // Returns true if successful. False otherwise.
89  // If false, then `resultMsg` is populated with an error message.
90  bool addFileDependency(UT_String node_path,
91  UT_String str_parm,
92  UT_String file_path,
93  UT_String resultMsg) const;
94 
95  // Attempts to remove a specified file dependency.
96  // Returns true if successful. False otherwise.
97  // If false, then `resultMsg` is populated with an error message.
98  bool removeFileDependency(UT_String node_path,
99  UT_String str_parm,
100  UT_String resultMsg) const;
101 
102  // Attempts to hide a specified file dependency.
103  // Returns true if successful. False otherwise.
104  // If false, then `resultMsg` is populated with an error message.
105  bool hideFileDependency(UT_String node_path,
106  UT_String str_parm,
107  UT_String resultMsg) const;
108 
109  // Get/set the set of file patterns that the user explicitly unselected
110  // from the file dependency dialog. By default, all file references that
111  // are created are implicitly selected, so we explicitly store the
112  // unselected ones instead of the selected ones.
113  void setUnselectedFilePatterns(const UT_StringArray &unselected_patterns)
114  { myUnselectedFilePatterns = unselected_patterns; }
116  { result = myUnselectedFilePatterns; }
117 
118 private:
119  // Retrieves the OTL files which define any custom operators that are
120  // currently in use. Recursive version of getOTLFiles().
121  void getOTLFiles(
122  OP_Node &node, UT_StringArray &files, OP_NodeList* otl_nodes_out,
123  SkipHFSOption skip_hfs_option=SKIP_HFS_FILES,
124  CondensePathOption condense_path_option = CONDENSE_HIP) const;
125 
126  // Returns true if the given file. Returns false otherwise.
127  // Uses Houdini search paths to locate the file.
128  bool findPathToFileName(UT_String &file_name) const;
129 
130  // Returns true if the given parameter references an external file.
131  // Returns false otherwise.
132  bool parmReferencesInputFile(OP_Node *owner,
133  PRM_Parm &parm,
134  OpdefOption opdef_option) const;
135 
136  // Returns true if the $HFS path appears in the given file path.
137  // Returns false otherwise.
138  bool fileIsInHFS(const char *file_name) const;
139 
140  // Retrieves all the input files referenced by the network and its children.
141  // Recursive version of getInputFilesInParms().
142  // Files that are found are placed in `found_files`.
143  // Missing files are placed in `unknown_files`.
144  void getInputFilesInParms(OP_Node &network,
145  SkipHFSOption skip_hfs_option,
146  TrackNodesOption track_nodes_option,
147  OpdefOption opdef_option,
148  OP_NodeFileNameArray &found_files,
149  OP_NodeFileNameArray &unknown_files) const;
150 
151  // Retrieves all the input files referenced by parameters in
152  // the given parameter list.
153  // Files that are found are placed in `found_files`.
154  // Missing files are placed in `unknown_files`.
155  void getInputFilesInParmList(PRM_ParmList *parm_list,
156  OP_Node *owner,
157  SkipHFSOption skip_hfs_option,
158  OpdefOption opdef_option,
159  OP_NodeFileNameArray &found_files,
160  OP_NodeFileNameArray &unknown_files) const;
161 
162  // Removes duplicate entries from `files`.
163  void removeDuplicatesFromNodeFileNameArray
164  (OP_NodeFileNameArray &files,
165  TrackNodesOption track_nodes_option)
166  const;
167 
168  // Removes duplicate entries from the string array.
169  void removeDuplicatesFromStringArray(UT_StringArray &string_array) const;
170 
171  // Removes any objects from set1 that appear in set2.
172  void subtractSets (OP_NodeFileNameArray &set1,
173  const OP_NodeFileNameArray &set2) const;
174 
175  /// Determines whether there are more references in found parms to paths
176  /// starting with $HIP or whether there are more references to the paths
177  /// beginning with $JOB.
178  bool determineRootType(
179  OP_NodeFileNameArray &found_files,
180  OP_NodeFileNameArray &unknown_files) const;
181 
182  // Given an absolute or relative path, modify the string to contain a
183  // a condensed path relative to a variable (e.g. the result will start
184  // with "$HIP/" or "$JOB/".
185  void condensePath(
186  UT_String &path, CondensePathOption condense_path_option) const;
187 
188  // Try to get the unembedded vex file corresponding to a operator type.
189  // Returns false if there isn't one.
190  bool getUnembeddedVexFileForOpType(
191  OP_Operator &op_type, UT_String &result) const;
192 
193  // Some file references, such as FBX and Collada, may store extra
194  // information in the path. This is done by appending a hash and then
195  // a string with options after the file exention. This function removes
196  // all such information from the file names passed in.
197  void cleanupExtraFileInfo(OP_NodeFileNameArray& file_names) const;
198 
199  UT_StringArray myUnselectedFilePatterns;
200 };
201 
202 // Use OPsetFileDependencyMgr() to set the dependency manager to a subclass
203 // of OP_FileDependencyMgr. The function takes ownership of the object
204 // passed into it.
206 OP_API void OPsetFileDependencyMgr(OP_FileDependencyMgr &file_dependency_mgr);
207 
208 #endif
OP_API void OPsetFileDependencyMgr(OP_FileDependencyMgr &file_dependency_mgr)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
OP_NodeFileNamePair(OP_Node *node, const char *file_name, PRM_Parm *parm=NULL, PRM_Parm *ref_parm=NULL)
void getUnselectedFilePatterns(UT_StringArray &result)
void setUnselectedFilePatterns(const UT_StringArray &unselected_patterns)
#define OP_API
Definition: OP_API.h:10
UT_Array< OP_NodeFileNamePair > OP_NodeFileNameArray
OP_API OP_FileDependencyMgr & OPgetFileDependencyMgr()