Loading...
Searching...
No Matches
property.h
Go to the documentation of this file.
1//
2// Copyright 2018 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7
8#ifndef PXR_USD_NDR_PROPERTY_H
9#define PXR_USD_NDR_PROPERTY_H
10
16
17#include "pxr/pxr.h"
18#include "pxr/usd/ndr/api.h"
20#include "pxr/base/tf/token.h"
21#include "pxr/base/vt/value.h"
22#include "pxr/usd/ndr/declare.h"
23
24PXR_NAMESPACE_OPEN_SCOPE
25
42{
43public:
45 NDR_API
47 const TfToken& name,
48 const TfToken& type,
49 const VtValue& defaultValue,
50 bool isOutput,
51 size_t arraySize,
52 bool isDynamicArray,
53 const NdrTokenMap& metadata
54 );
55
57 NDR_API
58 virtual ~NdrProperty();
59
62
64 NDR_API
65 const TfToken& GetName() const { return _name; }
66
68 NDR_API
69 const TfToken& GetType() const { return _type; }
70
75 NDR_API
76 const VtValue& GetDefaultValue() const { return _defaultValue; }
77
79 NDR_API
80 bool IsOutput() const { return _isOutput; }
81
83 NDR_API
84 bool IsArray() const { return (_arraySize > 0) || _isDynamicArray; }
85
87 NDR_API
88 bool IsDynamicArray() const { return _isDynamicArray; };
89
98 NDR_API
99 int GetArraySize() const { return _arraySize; }
100
103 NDR_API
104 virtual std::string GetInfoString() const;
105
107
108
115
117 NDR_API
118 virtual const NdrTokenMap& GetMetadata() const { return _metadata; }
119
121
122
125
127 NDR_API
128 virtual bool IsConnectable() const;
129
135 NDR_API
136 virtual bool CanConnectTo(const NdrProperty& other) const;
137
139
140
143
159 NDR_API
161
169 NDR_API
170 virtual const VtValue& GetDefaultValueAsSdfType() const;
171
173
174protected:
175 NdrProperty& operator=(const NdrProperty&) = delete;
176
177 TfToken _name;
178 TfToken _type;
179 VtValue _defaultValue;
180 bool _isOutput;
181 size_t _arraySize;
182 bool _isDynamicArray;
183 bool _isConnectable;
184 NdrTokenMap _metadata;
185};
186
187PXR_NAMESPACE_CLOSE_SCOPE
188
189#endif // PXR_USD_NDR_PROPERTY_H
Represents a property (input or output) that is part of a NdrNode instance.
Definition: property.h:42
virtual NDR_API NdrSdfTypeIndicator GetTypeAsSdfType() const
Converts the property's type from GetType() into a NdrSdfTypeIndicator.
NDR_API const VtValue & GetDefaultValue() const
Gets this property's default value associated with the type of the property.
Definition: property.h:76
NDR_API bool IsOutput() const
Whether this property is an output.
Definition: property.h:80
virtual NDR_API bool IsConnectable() const
Whether this property can be connected to other properties.
virtual NDR_API bool CanConnectTo(const NdrProperty &other) const
Determines if this property can be connected to the specified property.
virtual NDR_API const NdrTokenMap & GetMetadata() const
All of the metadata that came from the parse process.
Definition: property.h:118
NDR_API const TfToken & GetType() const
Gets the type of the property.
Definition: property.h:69
virtual NDR_API const VtValue & GetDefaultValueAsSdfType() const
Provides default value corresponding to the SdfValueTypeName returned by GetTypeAsSdfType.
virtual NDR_API std::string GetInfoString() const
Gets a string with basic information about this property.
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.
NDR_API bool IsDynamicArray() const
Whether this property's array type is dynamically-sized.
Definition: property.h:88
NDR_API int GetArraySize() const
Gets this property's array size.
Definition: property.h:99
NDR_API bool IsArray() const
Whether this property's type is an array type.
Definition: property.h:84
NDR_API const TfToken & GetName() const
Gets the name of the property.
Definition: property.h:65
Represents a mapping from an Ndr Property type to Sdf type.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
Common typedefs that are used throughout the NDR library.