property.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 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 
25 #ifndef PXR_USD_NDR_PROPERTY_H
26 #define PXR_USD_NDR_PROPERTY_H
27 
29 
30 #include "pxr/pxr.h"
31 #include "pxr/usd/ndr/api.h"
32 #include "pxr/base/tf/token.h"
33 #include "pxr/base/vt/value.h"
34 #include "pxr/usd/ndr/declare.h"
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
51 {
52 public:
54  NDR_API
56  const TfToken& name,
57  const TfToken& type,
58  const VtValue& defaultValue,
59  bool isOutput,
60  size_t arraySize,
61  bool isDynamicArray,
62  const NdrTokenMap& metadata
63  );
64 
66  NDR_API
67  virtual ~NdrProperty();
68 
71 
73  NDR_API
74  const TfToken& GetName() const { return _name; }
75 
77  NDR_API
78  const TfToken& GetType() const { return _type; }
79 
84  NDR_API
85  const VtValue& GetDefaultValue() const { return _defaultValue; }
86 
88  NDR_API
89  bool IsOutput() const { return _isOutput; }
90 
92  NDR_API
93  bool IsArray() const { return (_arraySize > 0) || _isDynamicArray; }
94 
96  NDR_API
97  bool IsDynamicArray() const { return _isDynamicArray; };
98 
107  NDR_API
108  int GetArraySize() const { return _arraySize; }
109 
112  NDR_API
113  virtual std::string GetInfoString() const;
114 
116 
117 
124 
126  NDR_API
127  virtual const NdrTokenMap& GetMetadata() const { return _metadata; }
128 
130 
131 
134 
136  NDR_API
137  virtual bool IsConnectable() const;
138 
140  NDR_API
141  virtual bool CanConnectTo(const NdrProperty& other) const;
142 
144 
145 
148 
163  NDR_API
164  virtual const NdrSdfTypeIndicator GetTypeAsSdfType() const;
165 
173  NDR_API
174  virtual const VtValue& GetDefaultValueAsSdfType() const;
175 
177 
178 protected:
179  NdrProperty& operator=(const NdrProperty&) = delete;
180 
181  TfToken _name;
182  TfToken _type;
183  VtValue _defaultValue;
184  bool _isOutput;
185  size_t _arraySize;
186  bool _isDynamicArray;
187  bool _isConnectable;
188  NdrTokenMap _metadata;
189 };
190 
191 PXR_NAMESPACE_CLOSE_SCOPE
192 
193 #endif // PXR_USD_NDR_PROPERTY_H
virtual NDR_API const NdrTokenMap & GetMetadata() const
All of the metadata that came from the parse process.
Definition: property.h:127
NDR_API int GetArraySize() const
Gets this property's array size.
Definition: property.h:108
NDR_API const TfToken & GetType() const
Gets the type of the property.
Definition: property.h:78
virtual NDR_API const NdrSdfTypeIndicator GetTypeAsSdfType() const
Converts the property's type from GetType() into a SdfValueTypeName.
virtual NDR_API std::string GetInfoString() const
Gets a string with basic information about this property.
NDR_API bool IsOutput() const
Whether this property is an output.
Definition: property.h:89
virtual NDR_API ~NdrProperty()
Destructor.
NDR_API NdrProperty(const TfToken &name, const TfToken &type, const VtValue &defaultValue, bool isOutput, size_t arraySize, bool isDynamicArray, const NdrTokenMap &metadata)
Constructor.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
Represents a property (input or output) that is part of a NdrNode instance.
Definition: property.h:50
NDR_API const TfToken & GetName() const
Gets the name of the property.
Definition: property.h:74
NDR_API const VtValue & GetDefaultValue() const
Gets this property's default value associated with the type of the property.
Definition: property.h:85
NDR_API bool IsArray() const
Whether this property's type is an array type.
Definition: property.h:93
virtual NDR_API bool CanConnectTo(const NdrProperty &other) const
Determines if this property can be connected to the specified property.
NDR_API bool IsDynamicArray() const
Whether this property's array type is dynamically-sized.
Definition: property.h:97
virtual NDR_API bool IsConnectable() const
Whether this property can be connected to other properties.
virtual NDR_API const VtValue & GetDefaultValueAsSdfType() const
Provides default value corresponding to the SdfValueTypeName returned by GetTypeAsSdfType.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:166
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...