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