HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_AttributeFile.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  * COMMENTS:
7  */
8 
9 #ifndef __PDG_ATTRIBUTE_FILE_H__
10 #define __PDG_ATTRIBUTE_FILE_H__
11 
12 #include "PDG_API.h"
13 
14 #include "PDG_AttributeArray.h"
15 #include "PDG_File.h"
16 
17 #include <UT/UT_StringHolder.h>
18 
20 class UT_JSONValue;
21 class UT_JSONWriter;
22 class UT_OptionsHolder;
23 
24 /**
25  * File array attribute type
26  */
28  PDG_AttributeType::eFileArray,
29  PDG_File,
30  PDG_File::Array>
31 {
32 public:
34  PDG_File,
36  using Base::Base;
37  using Base::values;
38  using Base::appendValue;
39 
40  /// Enumeration of different file types that can be queried from the
41  /// attribute
42  enum QueryType
43  {
44  /// Return any file type (real or expected)
46 
47  /// Only return actual files that have been reported back to the
48  /// task, not including any pending expected outputs
50 
51  /// Only return expected outputs, and skip real files
52  eQueryExpected
53  };
54 
55 public:
56 
57  ~PDG_AttributeFile() override;
58 
59  /// Returns the total memory usage of all data on this attribute
60  int64 getMemoryUsage(bool inclusive) const override;
61 
62  /// Constructs a new file attribute that copies the data from this
63  /// attribute
64  PDG_AttributeData* clone() const override;
65 
66  /// Writes the file data to the json writer, using the JSON serialization
67  /// logic from PDG_File itself
68  bool saveData(UT_JSONWriter& writer) const override;
69 
70  /// Writes the file data to the UT_OptionsHolder, using the serialization
71  /// logic from PDG_File itself
72  void saveData(
73  const UT_StringHolder& key,
74  UT_OptionsHolder& dict) const override;
75 
76  /// Reads the file data from the json value, using the deserialization
77  /// logic on PDG_File itself
78  bool loadData(const UT_JSONValue& value) override;
79 
80  /// Reads the file data from the dict
81  bool loadData(
82  const UT_StringHolder& key,
83  const UT_OptionsHolder& dict) override;
84 
85  /// Removes all expected files from the array
86  bool clearExpected();
87 
88  /// Removes all files that match the input filter set
89  void clearMatching(const PDG_File::Set& file_set);
90 
91 
92  /// Appends a file to the array, given the specified work item, path,
93  /// file tag, hash, file type, owernship flag. Optionally replaces any
94  /// matching expected outputs if they're found in the array
95  const Data& appendValue(
96  const PDG_WorkItem* work_item,
97  const UT_StringHolder& path,
98  const UT_StringHolder& tag,
99  PDG_File::Hash hash,
100  PDG_File::FileType file_type,
101  bool own,
102  bool replace_expected);
103 
104  /// Appends a file to the array using a reference to a file object.
105  /// Optionally replaces any expected outputs if they're found in the array
106  const Data& appendValue(
107  const Data&,
108  bool replace_expected);
109 
110  /// Returns all file paths that match the query type
111  void values(
112  Array& values,
113  QueryType query=eQueryReal) const;
114 
115  /// Returns all file paths with the specified tag that match the query
116  /// type
117  void valuesForTag(
118  Array& values,
119  const UT_StringHolder& tag,
120  QueryType query=eQueryReal) const;
121 
122  /// Returns the first matching file, starting from the specified index,
123  /// that has the requested tag and type
124  PDG_AttributeCast valueForTag(
125  Data& value,
126  int index,
127  const UT_StringHolder& tag,
128  QueryType query=eQueryReal) const;
129 
130  /// Returns all file values using the configuration of the attribute
131  /// evaluator object, filtered by the query type
132  PDG_AttributeCast valuesForEvaluator(
134  const PDG_AttributeEvaluator& evaluator,
135  QueryType query=eQueryReal) const;
136 };
137 
138 #endif
GLenum query
Definition: glad.h:2772
Definition: ImfArray.h:45
Return any file type (real or expected)
#define PDG_API
Definition: PDG_API.h:23
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
const ArrayType & values() const
virtual bool loadData(const UT_JSONValue &)=0
Loads data from a JSON value.
int64 Hash
The file hash/modtime type.
Definition: PDG_File.h:39
const DataType & appendValue(const DataType &value)
Definition: core.h:760
PDG_AttributeCast
Enumeration of attribute cast results.
virtual bool saveData(UT_JSONWriter &) const =0
Serializes the data to a JSON writer.
long long int64
Definition: SYS_Types.h:116
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
An array of PDG_File values, e.g. File info structs.
virtual int64 getMemoryUsage(bool inclusive) const =0
Returns the memory usage of the attribute and its data.
GLuint index
Definition: glcorearb.h:786
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:99
Definition: core.h:1131
virtual PDG_AttributeData * clone() const =0
Deep copies this attribute.