ufe  4.2
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 "S:/jenkins/workspace/ECP/ufe/ufe-full-python3.10-windows/ufe/include/attribute.h"
2 #ifndef _ufe_attribute
3 #define _ufe_attribute
4 
5 // =======================================================================
6 // Copyright 2019 Autodesk, Inc. All rights reserved.
7 //
8 // This computer source code and related instructions and comments are the
9 // unpublished confidential and proprietary information of Autodesk, Inc.
10 // and are protected under applicable copyright and trade secret law. They
11 // may not be disclosed to, copied or used by any third party without the
12 // prior written consent of Autodesk, Inc.
13 // =======================================================================
14 
15 #include "common/ufeExport.h"
16 #include "sceneItem.h"
17 #include "observer.h"
18 #include "types.h"
19 #include "undoableCommand.h" // For UndoableCommand::Ptr
20 #include "value.h"
21 
22 #include <memory>
23 #include <vector>
24 #include <string>
25 
27 
37 class UFE_SDK_DECL Attribute : public std::enable_shared_from_this<Attribute>
38 {
39 public:
40  typedef std::shared_ptr<Attribute> Ptr;
41  typedef std::string Type;
42 
45  static constexpr char kInvalid[] = "Invalid";
46  static constexpr char kBool[] = "Bool";
47  static constexpr char kInt[] = "Int";
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 kGeneric[] = "Generic";
64 
66  Attribute(const SceneItem::Ptr&);
67  virtual ~Attribute();
68 
70  Attribute(const Attribute&) = delete;
72  Attribute& operator=(const Attribute&) = delete;
73  Attribute(Attribute&&) = delete;
74  Attribute& operator=(Attribute&&) = delete;
76 
78  bool operator==(const Attribute& rhs) const;
82  bool operator!=(const Attribute& rhs) const;
84 
86  SceneItem::Ptr sceneItem() const;
87 
89  virtual bool hasValue() const = 0;
90 
92  virtual std::string name() const = 0;
93 
95  virtual std::string documentation() const = 0;
96 
98  virtual Type type() const = 0;
99 
101  virtual std::string string() const = 0;
102 
103  // --------------------------------------------------------------------- //
106  // --------------------------------------------------------------------- //
107 
112  static constexpr char kLocked[] = "Locked";
113 
114  // --------------------------------------------------------------------- //
116  // --------------------------------------------------------------------- //
117 
118 
119  // --------------------------------------------------------------------- //
122  // --------------------------------------------------------------------- //
123 
129  virtual Value getMetadata(const std::string& key) const = 0;
130 
137  virtual bool setMetadata(const std::string& key, const Value& value) = 0;
138 
141  virtual UndoableCommand::Ptr setMetadataCmd(const std::string& key, const Value& value);
142 
148  virtual bool clearMetadata(const std::string& key) = 0;
149 
151  virtual bool hasMetadata(const std::string& key) const = 0;
152 
153  // --------------------------------------------------------------------- //
155  // --------------------------------------------------------------------- //
156 
157 private:
159 
160 }; // end class Attribute
161 
164 {
165 public:
166  typedef std::shared_ptr<AttributeGeneric> Ptr;
167 
168  using Attribute::Attribute;
169 
170  // Ufe::Attribute overrides
171  Type type() const final;
172 
174  virtual std::string nativeType() const = 0;
175 };
176 
179  public Attribute
180 {
181 public:
182  typedef std::shared_ptr<AttributeFilename> Ptr;
183 
184  using Attribute::Attribute;
185 
186  // Ufe::Attribute overrides
187  Type type() const final;
188 
190  virtual std::string get() const = 0;
191 
193  virtual void set(const std::string& value) = 0;
194 
198  virtual UndoableCommand::Ptr setCmd(const std::string& value);
199 };
200 
203  public Attribute
204 {
205 public:
206  typedef std::shared_ptr<AttributeEnumString> Ptr;
207  typedef std::vector< std::string > EnumValues;
208 
209  using Attribute::Attribute;
210 
211  // Ufe::Attribute overrides
212  Type type() const final;
213 
215  virtual std::string get() const = 0;
216 
218  virtual void set(const std::string& value) = 0;
219 
223  virtual UndoableCommand::Ptr setCmd(const std::string& value);
224 
226  virtual EnumValues getEnumValues() const = 0;
227 };
228 
230 template<typename T>
232  public Attribute
233 {
234 public:
235  typedef std::shared_ptr<TypedAttribute<T>> Ptr;
236 
237  using Attribute::Attribute;
238 
239  // Ufe::Attribute overrides
240  Type type() const final;
241 
243  virtual T get() const = 0;
244 
246  virtual void set(const T& value) = 0;
247 
249  virtual UndoableCommand::Ptr setCmd(const T& value);
250 };
251 
255 
259 
263 
267 
271 
275 
279 
283 
287 
291 
295 
299 
302 
307 
310 
315 
316 } // end namespace
317 
318 #endif /* _ufe_attribute */
std::shared_ptr< Attribute > Ptr
Definition: attribute.h:40
std::shared_ptr< UndoableCommand > Ptr
Typed attribute template for creating a specialized type.
Definition: attribute.h:231
Attribute(const SceneItem::Ptr &)
Constructor.
Attribute which has a list of strings as enumerated values.
Definition: attribute.h:202
std::string string(const Path &path)
Attribute which represents a filename.
Definition: attribute.h:178
Definition of macros for symbol visibility.
Definition: path.h:197
std::shared_ptr< AttributeEnumString > Ptr
Definition: attribute.h:206
const SceneItem::Ptr fItem
Definition: attribute.h:158
Typed vector template for creating a specialized vector with N elements.
Definition: types.h:24
std::shared_ptr< TypedAttribute< T > > Ptr
Definition: attribute.h:235
std::shared_ptr< AttributeGeneric > Ptr
Definition: attribute.h:166
std::shared_ptr< AttributeFilename > Ptr
Definition: attribute.h:182
Value class that can hold a wide set of types.
Definition: value.h:34
#define UFE_NS_DEF
Definition: ufe.h:35
virtual Type type() const =0
Abstract base class for undoable commands.
Abstract base class for Attribute interface.
Definition: attribute.h:37
Typed square matrix template.
Definition: types.h:201
std::shared_ptr< SceneItem > Ptr
Definition: sceneItem.h:40
std::vector< std::string > EnumValues
Definition: attribute.h:207
const Ptr & get()
std::string Type
Definition: attribute.h:41
Generic attribute which doesn&#39;t match any defined type.
Definition: attribute.h:163
#define UFE_SDK_DECL
Definition: ufeExport.h:36