All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
children.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 PXR_USD_SDF_CHILDREN_H
25 #define PXR_USD_SDF_CHILDREN_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/sdf/api.h"
30 #include "pxr/usd/sdf/path.h"
31 
32 #include <boost/iterator/iterator_facade.hpp>
33 #include <vector>
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 SDF_DECLARE_HANDLES(SdfLayer);
38 class SdfSpec;
39 
50 template<class ChildPolicy>
51 class Sdf_Children
52 {
53 public:
54  typedef typename ChildPolicy::KeyPolicy KeyPolicy;
55  typedef typename ChildPolicy::KeyType KeyType;
56  typedef typename ChildPolicy::ValueType ValueType;
57  typedef typename ChildPolicy::FieldType FieldType;
58  typedef Sdf_Children<ChildPolicy> This;
59 
60  SDF_API
61  Sdf_Children();
62 
63  SDF_API
64  Sdf_Children(const Sdf_Children<ChildPolicy> &other);
65 
66  SDF_API
67  Sdf_Children(const SdfLayerHandle &layer,
68  const SdfPath &parentPath, const TfToken &childrenKey,
69  const KeyPolicy& keyPolicy = KeyPolicy());
70 
72  SDF_API
73  bool IsValid() const;
74 
76  SDF_API
77  size_t GetSize() const;
78 
80  SDF_API
81  ValueType GetChild(size_t index) const;
82 
84  SDF_API
85  size_t Find(const KeyType &key) const;
86 
89  SDF_API
90  KeyType FindKey(const ValueType &value) const;
91 
93  SDF_API
94  bool IsEqualTo(const This &other) const;
95 
97  SDF_API
98  bool Copy(const std::vector<ValueType> & values, const std::string &type);
99 
101  SDF_API
102  bool Insert(const ValueType& value, size_t index, const std::string &type);
103 
105  SDF_API
106  bool Erase(const KeyType& key, const std::string &type);
107 
108 private:
109  void _UpdateChildNames() const;
110 
111 private:
112  SdfLayerHandle _layer;
113  SdfPath _parentPath;
114  TfToken _childrenKey;
115  KeyPolicy _keyPolicy;
116 
117  mutable std::vector<FieldType> _childNames;
118  mutable bool _childNamesValid;
119 };
120 
121 PXR_NAMESPACE_CLOSE_SCOPE
122 
123 #endif // PXR_USD_SDF_CHILDREN_H
A unit of scene description that you combine with other units of scene description to form a shot...
Definition: layer.h:96
Base class for all Sdf spec classes.
Definition: spec.h:51
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288