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  // Retrieve all the file paths referenced by the given node, and
75  // any file referenced by subchildren (if recurse is true)
76  void getNodeInputFilesInParms(OP_Node &node, bool recurse,
77  SkipHFSOption skip_hfs_option,
78  TrackNodesOption track_nodes_option,
79  OpdefOption opdef_option,
80  OP_NodeFileNameArray &found_files,
81  OP_NodeFileNameArray &unknown_files) const;
82 
83  // Retrieves the OTL files which define any custom operators that
84  // are currently in use. Note that this method also returns other files
85  // needed by the otl files, such as vex files.
86  void getOTLFiles(UT_StringArray &files, OP_NodeList* otl_nodes_out,
87  SkipHFSOption skip_hfs_option=SKIP_HFS_FILES,
88  CondensePathOption condense_path_option = CONDENSE_HIP) const;
89 
90  // Retrieve the OTL file in the given node, or all the
91  // OTL files referenced by subchildren (if recurse is true)
92  void getNodeOTLFiles(OP_Node &node, bool recurse,
93  UT_StringArray &files, OP_NodeList* otl_nodes_out,
94  SkipHFSOption skip_hfs_option=SKIP_HFS_FILES,
95  CondensePathOption condense_path_option = CONDENSE_HIP) const;
96 
97  // Merges 2 NodeFileNameArray objects. Removes duplicate entries.
98  void mergeDependencyLists(const OP_NodeFileNameArray &src_refs1,
99  const OP_NodeFileNameArray &src_refs2,
100  OP_NodeFileNameArray &dest_refs,
101  TrackNodesOption track_nodes_option) const;
102 
103  // Attempts to add a file dependency to the specified node and parm.
104  // Returns true if successful. False otherwise.
105  // If false, then `resultMsg` is populated with an error message.
106  bool addFileDependency(UT_String node_path,
107  UT_String str_parm,
108  UT_String file_path,
109  UT_String resultMsg) const;
110 
111  // Attempts to remove a specified file dependency.
112  // Returns true if successful. False otherwise.
113  // If false, then `resultMsg` is populated with an error message.
114  bool removeFileDependency(UT_String node_path,
115  UT_String str_parm,
116  UT_String resultMsg) const;
117 
118  // Attempts to hide a specified file dependency.
119  // Returns true if successful. False otherwise.
120  // If false, then `resultMsg` is populated with an error message.
121  bool hideFileDependency(UT_String node_path,
122  UT_String str_parm,
123  UT_String resultMsg) const;
124 
125  // Get/set the set of file patterns that the user explicitly unselected
126  // from the file dependency dialog. By default, all file references that
127  // are created are implicitly selected, so we explicitly store the
128  // unselected ones instead of the selected ones.
129  void setUnselectedFilePatterns(const UT_StringArray &unselected_patterns)
130  { myUnselectedFilePatterns = unselected_patterns; }
132  { result = myUnselectedFilePatterns; }
133 
134 private:
135  // Retrieves the OTL files which define any custom operators that are
136  // currently in use. Recursive version of getOTLFiles().
137  void getOTLFiles(
138  OP_Node &node, UT_StringArray &files, OP_NodeList* otl_nodes_out,
139  SkipHFSOption skip_hfs_option=SKIP_HFS_FILES,
140  CondensePathOption condense_path_option = CONDENSE_HIP,
141  bool recurse=true) const;
142 
143  // Returns true if the given file. Returns false otherwise.
144  // Uses Houdini search paths to locate the file.
145  bool findPathToFileName(UT_String &file_name) const;
146 
147  // Returns true if the given parameter references an external file.
148  // Returns false otherwise.
149  bool parmReferencesInputFile(OP_Node *owner,
150  PRM_Parm &parm,
151  OpdefOption opdef_option) const;
152 
153  // Returns true if the $HFS path appears in the given file path.
154  // Returns false otherwise.
155  bool fileIsInHFS(const char *file_name) const;
156 
157  // Retrieves all the input files referenced by the network's children.
158  // Recursive version of getInputFilesInParms().
159  // Files that are found are placed in `found_files`.
160  // Missing files are placed in `unknown_files`.
161  void getInputFilesInParms(OP_Node &network,
162  SkipHFSOption skip_hfs_option,
163  TrackNodesOption track_nodes_option,
164  OpdefOption opdef_option,
165  OP_NodeFileNameArray &found_files,
166  OP_NodeFileNameArray &unknown_files) const;
167 
168  // Retrieves all the input files referenced by parameters in
169  // the given parameter list.
170  // Files that are found are placed in `found_files`.
171  // Missing files are placed in `unknown_files`.
172  void getInputFilesInParmList(PRM_ParmList *parm_list,
173  OP_Node *owner,
174  SkipHFSOption skip_hfs_option,
175  OpdefOption opdef_option,
176  OP_NodeFileNameArray &found_files,
177  OP_NodeFileNameArray &unknown_files) const;
178 
179  // Clean up unwanted and extra file references in the result after retriving
180  void cleanupInputFilesResult(TrackNodesOption track_nodes_option,
181  OP_NodeFileNameArray &found_files,
182  OP_NodeFileNameArray &unknown_files) const;
183 
184  // Removes duplicate entries from `files`.
185  void removeDuplicatesFromNodeFileNameArray
186  (OP_NodeFileNameArray &files,
187  TrackNodesOption track_nodes_option)
188  const;
189 
190  // Removes duplicate entries from the string array.
191  void removeDuplicatesFromStringArray(UT_StringArray &string_array) const;
192 
193  // Removes any objects from set1 that appear in set2.
194  void subtractSets (OP_NodeFileNameArray &set1,
195  const OP_NodeFileNameArray &set2) const;
196 
197  /// Determines whether there are more references in found parms to paths
198  /// starting with $HIP or whether there are more references to the paths
199  /// beginning with $JOB.
200  bool determineRootType(
201  OP_NodeFileNameArray &found_files,
202  OP_NodeFileNameArray &unknown_files) const;
203 
204  // Given an absolute or relative path, modify the string to contain a
205  // a condensed path relative to a variable (e.g. the result will start
206  // with "$HIP/" or "$JOB/".
207  void condensePath(
208  UT_String &path, CondensePathOption condense_path_option) const;
209 
210  // Try to get the unembedded vex file corresponding to a operator type.
211  // Returns false if there isn't one.
212  bool getUnembeddedVexFileForOpType(
213  OP_Operator &op_type, UT_String &result) const;
214 
215  // Some file references, such as FBX and Collada, may store extra
216  // information in the path. This is done by appending a hash and then
217  // a string with options after the file exention. This function removes
218  // all such information from the file names passed in.
219  void cleanupExtraFileInfo(OP_NodeFileNameArray& file_names) const;
220 
221  UT_StringArray myUnselectedFilePatterns;
222 };
223 
224 // Use OPsetFileDependencyMgr() to set the dependency manager to a subclass
225 // of OP_FileDependencyMgr. The function takes ownership of the object
226 // passed into it.
228 OP_API void OPsetFileDependencyMgr(OP_FileDependencyMgr &file_dependency_mgr);
229 
230 #endif
OP_API void OPsetFileDependencyMgr(OP_FileDependencyMgr &file_dependency_mgr)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
**But if you need a result
Definition: thread.h:613
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()