All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
crateData.h
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef USD_CRATEDATA_H
25 #define USD_CRATEDATA_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/sdf/abstractData.h"
29 
30 #include "pxr/base/tf/declarePtrs.h"
31 #include "pxr/base/tf/token.h"
32 #include "pxr/base/vt/value.h"
33 
34 #include <memory>
35 #include <vector>
36 #include <set>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 
43 class Usd_CrateData : public SdfAbstractData
44 {
45 public:
46 
47  Usd_CrateData();
48  virtual ~Usd_CrateData();
49 
50  static TfToken const &GetSoftwareVersionToken();
51 
52  static bool CanRead(const std::string &assetPath);
53  bool Save(const std::string &fileName);
54  bool Open(const std::string &assetPath);
55 
56  virtual bool StreamsData() const;
57  virtual void CreateSpec(const SdfPath &path,
58  SdfSpecType specType);
59  virtual bool HasSpec(const SdfPath &path) const;
60  virtual void EraseSpec(const SdfPath &path);
61  virtual void MoveSpec(const SdfPath& oldPath,
62  const SdfPath& newPath);
63  virtual SdfSpecType GetSpecType(const SdfPath &path) const;
64 
65  virtual bool Has(const SdfPath& path, const TfToken& fieldName,
66  SdfAbstractDataValue* value) const;
67  virtual bool Has(const SdfPath& path, const TfToken& fieldName,
68  VtValue *value=nullptr) const;
69  virtual VtValue Get(const SdfPath& path,
70  const TfToken& fieldName) const;
71  virtual void Set(const SdfPath& path, const TfToken& fieldName,
72  const VtValue& value);
73  virtual void Set(const SdfPath& path, const TfToken& fieldName,
74  const SdfAbstractDataConstValue& value);
75  virtual void Erase(const SdfPath& path,
76  const TfToken& fieldName);
77  virtual std::vector<TfToken> List(const SdfPath& path) const;
78 
81 
82  virtual std::set<double>
83  ListAllTimeSamples() const;
84 
85  virtual std::set<double>
86  ListTimeSamplesForPath(const SdfPath& path) const;
87 
88  virtual bool
89  GetBracketingTimeSamples(double time, double* tLower, double* tUpper) const;
90 
91  virtual size_t
92  GetNumTimeSamplesForPath(const SdfPath& path) const;
93 
94  virtual bool
95  GetBracketingTimeSamplesForPath(const SdfPath& path,
96  double time,
97  double* tLower, double* tUpper) const;
98 
99  virtual bool
100  QueryTimeSample(const SdfPath& path, double time,
101  SdfAbstractDataValue *value) const;
102  virtual bool
103  QueryTimeSample(const SdfPath& path, double time,
104  VtValue *value) const;
105 
106  virtual void
107  SetTimeSample(const SdfPath& path, double time,
108  const VtValue & value);
109 
110  virtual void
111  EraseTimeSample(const SdfPath& path, double time);
112 
114 
115 private:
116 
117  // SdfAbstractData overrides
118  virtual void _VisitSpecs(SdfAbstractDataSpecVisitor* visitor) const;
119 
120  friend class Usd_CrateDataImpl;
121  std::unique_ptr<class Usd_CrateDataImpl> _impl;
122 };
123 
124 
125 PXR_NAMESPACE_CLOSE_SCOPE
126 
127 #endif // USD_CRATEDATA_H
virtual SDF_API void EraseSpec(const SdfPath &path)=0
Erase the spec at path and any fields that are on it.
Base class for objects used to visit specs in an SdfAbstractData object.
Definition: abstractData.h:561
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:472
A type-erased container for a field value in an SdfAbstractData.
Definition: abstractData.h:394
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:91
virtual SDF_API bool HasSpec(const SdfPath &path) const =0
Return true if this data has a spec for path.
virtual SDF_API void CreateSpec(const SdfPath &path, SdfSpecType specType)=0
Create a new spec at path with the given specType.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
virtual SdfSpecType GetSpecType(const SdfPath &path) const =0
Return the spec type for the spec at path.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
virtual SDF_API VtValue Get(const SdfPath &path, const TfToken &fieldName) const =0
Return the value for the given path and fieldName.
virtual SDF_API bool Has(const SdfPath &path, const TfToken &fieldName, SdfAbstractDataValue *value) const =0
Returns whether a value exists for the given path and fieldName.
virtual SDF_API void MoveSpec(const SdfPath &oldPath, const SdfPath &newPath)=0
Move the spec at oldPath to newPath, including all the fields that are on it.
virtual SDF_API void _VisitSpecs(SdfAbstractDataSpecVisitor *visitor) const =0
Visits every spec in this SdfAbstractData object with the given visitor.
virtual SDF_API void Set(const SdfPath &path, const TfToken &fieldName, const VtValue &value)=0
Set the value of the given path and fieldName.
virtual SDF_API bool StreamsData() const =0
Returns true if this data object streams its data to and from its serialized data store on demand...
virtual SDF_API void Erase(const SdfPath &path, const TfToken &fieldName)=0
Remove the field at path and fieldName, if one exists.
virtual SDF_API std::vector< TfToken > List(const SdfPath &path) const =0
Return the names of all the fields that are set at path.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182
Interface for scene description data storage.
Definition: abstractData.h:73