ufe  3.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.9-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 kEnumString[] = "EnumString";
53  static constexpr char kInt3[] = "Int3";
54  static constexpr char kFloat3[] = "Float3";
55  static constexpr char kDouble3[] = "Double3";
56  static constexpr char kGeneric[] = "Generic";
58 
60  Attribute(const SceneItem::Ptr&);
61  virtual ~Attribute();
62 
64  Attribute(const Attribute&) = delete;
66  Attribute& operator=(const Attribute&) = delete;
67  Attribute(Attribute&&) = delete;
68  Attribute& operator=(Attribute&&) = delete;
70 
72  SceneItem::Ptr sceneItem() const;
73 
75  virtual bool hasValue() const = 0;
76 
78  virtual std::string name() const = 0;
79 
81  virtual std::string documentation() const = 0;
82 
84  virtual Type type() const = 0;
85 
87  virtual std::string string() const = 0;
88 
89  // --------------------------------------------------------------------- //
92  // --------------------------------------------------------------------- //
93 
98  static constexpr char kLocked[] = "Locked";
99 
100  // --------------------------------------------------------------------- //
102  // --------------------------------------------------------------------- //
103 
104 
105  // --------------------------------------------------------------------- //
108  // --------------------------------------------------------------------- //
109 
115  virtual Value getMetadata(const std::string& key) const = 0;
116 
123  virtual bool setMetadata(const std::string& key, const Value& value) = 0;
124 
127  virtual UndoableCommand::Ptr setMetadataCmd(const std::string& key, const Value& value);
128 
134  virtual bool clearMetadata(const std::string& key) = 0;
135 
137  virtual bool hasMetadata(const std::string& key) const = 0;
138 
139  // --------------------------------------------------------------------- //
141  // --------------------------------------------------------------------- //
142 
143 private:
145 
146 }; // end class Attribute
147 
150 {
151 public:
152  typedef std::shared_ptr<AttributeGeneric> Ptr;
153 
154  using Attribute::Attribute;
155 
156  // Ufe::Attribute overrides
157  Type type() const final;
158 
160  virtual std::string nativeType() const = 0;
161 };
162 
165  public Attribute
166 {
167 public:
168  typedef std::shared_ptr<AttributeEnumString> Ptr;
169  typedef std::vector< std::string > EnumValues;
170 
171  using Attribute::Attribute;
172 
173  // Ufe::Attribute overrides
174  Type type() const final;
175 
177  virtual std::string get() const = 0;
178 
180  virtual void set(const std::string& value) = 0;
181 
185  virtual UndoableCommand::Ptr setCmd(const std::string& value);
186 
188  virtual EnumValues getEnumValues() const = 0;
189 };
190 
192 template<typename T>
194  public Attribute
195 {
196 public:
197  typedef std::shared_ptr<TypedAttribute<T>> Ptr;
198 
199  using Attribute::Attribute;
200 
201  // Ufe::Attribute overrides
202  Type type() const final;
203 
205  virtual T get() const = 0;
206 
208  virtual void set(const T& value) = 0;
209 
211  virtual UndoableCommand::Ptr setCmd(const T& value);
212 };
213 
217 
221 
225 
229 
233 
237 
241 
245 
249 
250 } // end namespace
251 
252 #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:193
Attribute(const SceneItem::Ptr &)
Constructor.
Attribute which has a list of strings as enumerated values.
Definition: attribute.h:164
std::string string(const Path &path)
Definition of macros for symbol visibility.
Definition: path.h:197
std::shared_ptr< AttributeEnumString > Ptr
Definition: attribute.h:168
const SceneItem::Ptr fItem
Definition: attribute.h:144
std::shared_ptr< TypedAttribute< T > > Ptr
Definition: attribute.h:197
std::shared_ptr< AttributeGeneric > Ptr
Definition: attribute.h:152
Value class that can hold a wide set of types.
Definition: value.h:33
#define UFE_NS_DEF
Definition: ufe.h:35
Typed vector template for creating a specialized vector.
Definition: types.h:24
virtual Type type() const =0
Abstract base class for undoable commands.
Abstract base class for Attribute interface.
Definition: attribute.h:37
std::shared_ptr< SceneItem > Ptr
Definition: sceneItem.h:40
std::vector< std::string > EnumValues
Definition: attribute.h:169
const Ptr & get()
std::string Type
Definition: attribute.h:41
Generic attribute which doesn&#39;t match any defined type.
Definition: attribute.h:149
#define UFE_SDK_DECL
Definition: ufeExport.h:36