This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
12
13#include "pxr/pxr.h"
14#include "pxr/usd/ndr/api.h"
16#include "pxr/base/tf/token.h"
17#include "pxr/base/vt/value.h"
18#include "pxr/usd/ndr/declare.h"
19
20PXR_NAMESPACE_OPEN_SCOPE
21
35{
36public:
38 NDR_API
40 const TfToken& name,
41 const TfToken& type,
42 const VtValue& defaultValue,
43 bool isOutput,
44 size_t arraySize,
45 bool isDynamicArray,
46 const NdrTokenMap& metadata
47 );
48
50 NDR_API
51 virtual ~NdrProperty();
52
55
57 NDR_API
58 const TfToken& GetName() const { return _name; }
59
61 NDR_API
62 const TfToken& GetType() const { return _type; }
63
68 NDR_API
69 const VtValue& GetDefaultValue() const { return _defaultValue; }
70
72 NDR_API
73 bool IsOutput() const { return _isOutput; }
74
76 NDR_API
77 bool IsArray() const { return (_arraySize > 0) || _isDynamicArray; }
78
80 NDR_API
81 bool IsDynamicArray() const { return _isDynamicArray; };
82
91 NDR_API
92 int GetArraySize() const { return _arraySize; }
93
96 NDR_API
97 virtual std::string GetInfoString() const;
98
100
101
108
110 NDR_API
111 virtual const NdrTokenMap& GetMetadata() const { return _metadata; }
112
114
115
118
120 NDR_API
121 virtual bool IsConnectable() const;
122
124 NDR_API
125 virtual bool CanConnectTo(const NdrProperty& other) const;
126
128
129
132
148 NDR_API
150
158 NDR_API
159 virtual const VtValue& GetDefaultValueAsSdfType() const;
160
162
163protected:
164 NdrProperty& operator=(const NdrProperty&) = delete;
165
166 TfToken _name;
167 TfToken _type;
168 VtValue _defaultValue;
169 bool _isOutput;
170 size_t _arraySize;
171 bool _isDynamicArray;
172 bool _isConnectable;
173 NdrTokenMap _metadata;
174};
175
176PXR_NAMESPACE_CLOSE_SCOPE
177
178#endif // PXR_USD_NDR_PROPERTY_H
Represents a property (input or output) that is part of a NdrNode instance.
Definition: property.h:35
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:69
NDR_API bool IsOutput() const
Whether this property is an output.
Definition: property.h:73
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:111
NDR_API const TfToken & GetType() const
Gets the type of the property.
Definition: property.h:62
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:81
NDR_API int GetArraySize() const
Gets this property's array size.
Definition: property.h:92
NDR_API bool IsArray() const
Whether this property's type is an array type.
Definition: property.h:77
NDR_API const TfToken & GetName() const
Gets the name of the property.
Definition: property.h:58
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.