ufe 7.0
Universal Front End is a DCC-agnostic component that will allow a DCC to browse and edit data in multiple data models
attribute.h
Go to the documentation of this file.
1#line 1 "D:/Jenkins/workspace/EMS/ECG/ufe/full/ufe-full-python3.13-windows/ufe/include/attribute.h"
2#ifndef UFE_ATTRIBUTE_H
3#define UFE_ATTRIBUTE_H
4
5// ===========================================================================
6// Copyright 2025 Autodesk, Inc. All rights reserved.
7//
8// The use of this software is subject to the Autodesk Terms of Use or other
9// license agreement provided at the time of installation or download, or
10// which otherwise accompanies this software.
11// ===========================================================================
12
13#include "common/ufeExport.h"
14#include "sceneItem.h"
15#include "observer.h"
16#include "types.h"
17#include "undoableCommand.h" // For UndoableCommand::Ptr
18#include "value.h"
19#include "array.h"
20
21#include <memory>
22#include <vector>
23#include <string>
24
26
36class UFE_SDK_DECL Attribute : public std::enable_shared_from_this<Attribute>
37{
38public:
39 typedef std::shared_ptr<Attribute> Ptr;
41
44 static constexpr char kInvalid[] = "Invalid";
45 static constexpr char kBool[] = "Bool";
46 static constexpr char kInt[] = "Int";
47 static constexpr char kUInt[] = "UInt";
48 static constexpr char kFloat[] = "Float";
49 static constexpr char kDouble[] = "Double";
50 static constexpr char kString[] = "String";
51 static constexpr char kColorFloat3[] = "ColorFloat3";
52 static constexpr char kColorFloat4[] = "ColorFloat4";
53 static constexpr char kFilename[] = "Filename";
54 static constexpr char kEnumString[] = "EnumString";
55 static constexpr char kInt3[] = "Int3";
56 static constexpr char kFloat2[] = "Float2";
57 static constexpr char kFloat3[] = "Float3";
58 static constexpr char kFloat4[] = "Float4";
59 static constexpr char kDouble3[] = "Double3";
60 static constexpr char kMatrix3d[] = "Matrix3d";
61 static constexpr char kMatrix4d[] = "Matrix4d";
62 static constexpr char kBoolArray[] = "BoolArray";
63 static constexpr char kIntArray[] = "IntArray";
64 static constexpr char kUIntArray[] = "UIntArray";
65 static constexpr char kFloatArray[] = "FloatArray";
66 static constexpr char kDoubleArray[] = "DoubleArray";
67 static constexpr char kStringArray[] = "StringArray";
68 static constexpr char kInt2Array[] = "Int2Array";
69 static constexpr char kFloat2Array[] = "Float2Array";
70 static constexpr char kDouble2Array[] = "Double2Array";
71 static constexpr char kInt3Array[] = "Int3Array";
72 static constexpr char kFloat3Array[] = "Float3Array";
73 static constexpr char kDouble3Array[] = "Double3Array";
74 static constexpr char kInt4Array[] = "Int4Array";
75 static constexpr char kFloat4Array[] = "Float4Array";
76 static constexpr char kDouble4Array[] = "Double4Array";
77 static constexpr char kColorFloat3Array[] = "ColorFloat3Array";
78 static constexpr char kColorFloat4Array[] = "ColorFloat4Array";
79 static constexpr char kMatrixDouble3Array[] = "MatrixDouble3Array";
80 static constexpr char kMatrixDouble4Array[] = "MatrixDouble4Array";
81 static constexpr char kGeneric[] = "Generic";
83
86 virtual ~Attribute();
87
90 Attribute(const Attribute&) = delete;
91 Attribute& operator=(const Attribute&) = delete;
92 Attribute(Attribute&&) = delete;
95
100 bool operator==(const Attribute& rhs) const;
101 bool operator!=(const Attribute& rhs) const;
103
106
108 virtual bool hasValue() const = 0;
109
111 virtual std::string name() const = 0;
112
114 virtual std::string displayName() const;
115
117 virtual std::string documentation() const = 0;
118
120 virtual Type type() const = 0;
121
123 virtual std::string string() const = 0;
124
126 virtual Value value() const = 0;
127
134 virtual UndoableCommand::Ptr setCmd(const Value& value) = 0;
135
136 // --------------------------------------------------------------------- //
139 // --------------------------------------------------------------------- //
140
145 static constexpr char kLocked[] = "Locked";
146
147 // --------------------------------------------------------------------- //
149 // --------------------------------------------------------------------- //
150
151
152 // --------------------------------------------------------------------- //
155 // --------------------------------------------------------------------- //
156
162 virtual Value getMetadata(const std::string& key) const = 0;
163
170 virtual bool setMetadata(const std::string& key, const Value& value) = 0;
171
177 virtual UndoableCommand::Ptr setMetadataCmd(const std::string& key, const Value& value);
178
184 virtual bool clearMetadata(const std::string& key) = 0;
185
193
195 virtual bool hasMetadata(const std::string& key) const = 0;
196
197 // --------------------------------------------------------------------- //
199 // --------------------------------------------------------------------- //
200
201private:
203
204}; // end class Attribute
205
208{
209public:
210 typedef std::shared_ptr<AttributeGeneric> Ptr;
211
212 using Attribute::Attribute;
213
214 // Ufe::Attribute overrides
215 Type type() const final;
216 Value value() const override;
217 UndoableCommand::Ptr setCmd(const Value& value) override;
218
220 virtual std::string nativeType() const = 0;
221};
222
225 public Attribute
226{
227public:
228 typedef std::shared_ptr<AttributeFilename> Ptr;
229
230 using Attribute::Attribute;
231
232 // Ufe::Attribute overrides
233 Type type() const final;
234 Value value() const override;
235 UndoableCommand::Ptr setCmd(const Value& value) override;
236
238 virtual std::string get() const = 0;
239
242 virtual bool isDefault() const = 0;
243
245 virtual void set(const std::string& value) = 0;
246
248 virtual void reset() = 0;
249
256 virtual UndoableCommand::Ptr setCmd(const std::string& value);
257
264 virtual UndoableCommand::Ptr resetCmd();
265};
266
269 public Attribute
270{
271public:
272 typedef std::shared_ptr<AttributeEnumString> Ptr;
273 typedef std::vector< std::string > EnumValues;
274
275 using Attribute::Attribute;
276
277 // Ufe::Attribute overrides
278 Type type() const final;
279 Value value() const override;
280 UndoableCommand::Ptr setCmd(const Value& value) override;
281
283 virtual std::string get() const = 0;
284
287 virtual bool isDefault() const = 0;
288
290 virtual void set(const std::string& value) = 0;
291
293 virtual void reset() = 0;
294
301 virtual UndoableCommand::Ptr setCmd(const std::string& value);
302
309 virtual UndoableCommand::Ptr resetCmd();
310
312 virtual EnumValues getEnumValues() const = 0;
313};
314
316template<typename T>
318 public Attribute
319{
320public:
321 typedef std::shared_ptr<TypedAttribute<T>> Ptr;
322
323 using Attribute::Attribute;
324
325 // Ufe::Attribute overrides
326 Type type() const final;
327 Value value() const override;
328 UndoableCommand::Ptr setCmd(const Value& value) override;
329
331 virtual T get() const = 0;
332
335 virtual bool isDefault() const = 0;
336
338 virtual void set(const T& value) = 0;
339
341 virtual void reset() = 0;
342
347 virtual UndoableCommand::Ptr setCmd(const T& value);
348
355 virtual UndoableCommand::Ptr resetCmd();
356};
357
361
365
368typedef TypedAttribute<unsigned int> AttributeUInt;
369
373
377
381
385
389
393
397
401
405
409
412
417
420
425
429
433
437
441
445
449
453
457
461
465
469
473
477
481
485
489
493
497
501
502} // end namespace
503
504#endif /* UFE_ATTRIBUTE_H */
Array is a container class that encapsulates dynamic sized arrays.
Definition: array.h:64
Attribute which has a list of strings as enumerated values.
Definition: attribute.h:270
std::shared_ptr< AttributeEnumString > Ptr
Definition: attribute.h:272
Type type() const final
std::vector< std::string > EnumValues
Definition: attribute.h:273
Attribute which represents a filename.
Definition: attribute.h:226
std::shared_ptr< AttributeFilename > Ptr
Definition: attribute.h:228
Type type() const final
Generic attribute which doesn't match any defined type.
Definition: attribute.h:208
Type type() const final
std::shared_ptr< AttributeGeneric > Ptr
Definition: attribute.h:210
Abstract base class for Attribute interface.
Definition: attribute.h:37
virtual UndoableCommand::Ptr clearMetadataCmd(const std::string &key)
virtual std::string documentation() const =0
SceneItem::Ptr sceneItem() const
virtual std::string displayName() const
virtual bool setMetadata(const std::string &key, const Value &value)=0
Attribute & operator=(const Attribute &)=delete
virtual UndoableCommand::Ptr setCmd(const Value &value)=0
const SceneItem::Ptr fItem
Definition: attribute.h:202
virtual std::string string() const =0
bool operator!=(const Attribute &rhs) const
virtual UndoableCommand::Ptr setMetadataCmd(const std::string &key, const Value &value)
Attribute(const SceneItem::Ptr &)
Constructor.
virtual std::string name() const =0
virtual Value getMetadata(const std::string &key) const =0
Attribute & operator=(Attribute &&)=delete
std::string Type
Definition: attribute.h:40
virtual Type type() const =0
std::shared_ptr< Attribute > Ptr
Definition: attribute.h:39
Attribute(Attribute &&)=delete
virtual bool clearMetadata(const std::string &key)=0
virtual ~Attribute()
bool operator==(const Attribute &rhs) const
virtual bool hasValue() const =0
virtual Value value() const =0
virtual bool hasMetadata(const std::string &key) const =0
Returns true if metadata key has a non-empty value.
Attribute(const Attribute &)=delete
std::shared_ptr< SceneItem > Ptr
Definition: sceneItem.h:45
Typed attribute template for creating a specialized type.
Definition: attribute.h:319
std::shared_ptr< TypedAttribute< T > > Ptr
Definition: attribute.h:321
Type type() const final
Abstract base class for undoable commands.
std::shared_ptr< UndoableCommand > Ptr
Value class that can hold a wide set of types.
Definition: value.h:66
const Ptr & get()
std::string string(const Path &path)
Definition: path.h:202
Typed square matrix template.
Definition: types.h:268
Typed vector template for creating a specialized vector with N elements.
Definition: types.h:44
#define UFE_NS_DEF
Definition: ufe.h:36
Definition of macros for symbol visibility.
#define UFE_SDK_DECL
Definition: ufeExport.h:35