ufe 5.5
Universal Front End is a DCC-agnostic component that will allow a DCC to browse and edit data in multiple data models
Ufe::Attributes Class Referenceabstract

Abstract base class for Attributes interface. More...

#include <attributes.h>

Public Types

typedef std::shared_ptr< AttributesPtr
 
typedef std::vector< std::pair< std::string, std::string > > Enums
 

Public Member Functions

 Attributes ()
 Constructor. More...
 
 Attributes (const Attributes &)=default
 Default copy constructor. More...
 
virtual ~Attributes ()
 Destructor. More...
 
virtual SceneItem::Ptr sceneItem () const =0
 
virtual Attribute::Type attributeType (const std::string &name)=0
 
virtual Attribute::Ptr attribute (const std::string &name)=0
 
virtual std::vector< std::string > attributeNames () const =0
 
virtual bool hasAttribute (const std::string &name) const =0
 
virtual Attribute::Ptr addAttribute (const std::string &name, const Attribute::Type &type)
 
virtual AddAttributeUndoableCommand::Ptr addAttributeCmd (const std::string &name, const Attribute::Type &type)=0
 
virtual bool removeAttribute (const std::string &name)
 
virtual UndoableCommand::Ptr removeAttributeCmd (const std::string &name)=0
 
virtual Attribute::Ptr renameAttribute (const std::string &originalName, const std::string &newName)
 
virtual RenameAttributeUndoableCommand::Ptr renameAttributeCmd (const std::string &originalName, const std::string &newName)=0
 
virtual Enums getEnums (const std::string &attrName) const =0
 

Static Public Member Functions

static Ptr attributes (const SceneItem::Ptr &item)
 
static bool addObserver (const SceneItem::Ptr &item, const Observer::Ptr &obs)
 
static bool addObserver (const Observer::Ptr &obs)
 
static bool removeObserver (const SceneItem::Ptr &item, const Observer::Ptr &obs)
 
static bool removeObserver (const Observer::Ptr &obs)
 
static std::size_t nbObservers (const SceneItem::Ptr &item)
 
static std::size_t nbObservers ()
 
static bool hasObserver (const SceneItem::Ptr &item, const Observer::Ptr &obs)
 
static bool hasObserver (const Observer::Ptr &obs)
 
static bool hasObservers (const Path &path)
 
static bool hasObservers (Rtid runTimeId)
 
static void notify (const AttributeChanged &notification)
 

Detailed Description

Abstract base class for Attributes interface.

This base class defines an interface for factory objects that runtimes can implement to create attribute interface objects as well as query attribute names, attribute type and attribute existence. The Attributes interface object can be considered as a factory, because it provides an interface to create an Attribute object per attribute, given an attribute name. The Attribute object actually performs the work of reading from and writing to the attribute.

As with the rest of UFE, attribute observation is done through the Observer Pattern. Observers can be added to an individual scene item, to be notified when an attribute changes.

To avoid the memory-consuming "one proxy object per scene object" approach, attributes interface objects should be obtained and used within a local scope, and not stored.

Definition at line 51 of file attributes.h.

Member Typedef Documentation

◆ Enums

typedef std::vector< std::pair< std::string, std::string> > Ufe::Attributes::Enums

Definition at line 55 of file attributes.h.

◆ Ptr

typedef std::shared_ptr<Attributes> Ufe::Attributes::Ptr

Definition at line 54 of file attributes.h.

Constructor & Destructor Documentation

◆ Attributes() [1/2]

Ufe::Attributes::Attributes ( )

Constructor.

◆ Attributes() [2/2]

Ufe::Attributes::Attributes ( const Attributes )
default

Default copy constructor.

◆ ~Attributes()

virtual Ufe::Attributes::~Attributes ( )
virtual

Destructor.

Member Function Documentation

◆ addAttribute()

virtual Attribute::Ptr Ufe::Attributes::addAttribute ( const std::string &  name,
const Attribute::Type type 
)
virtual

Adds an attribute to the SceneItem this Attributes interface refers to.

Parameters
nameThe name of the new attribute.
typeThe type of the new attribute.
Returns
Interface on the new attribute. Returns a null pointer if attribute creation is not available or if adding the attribute fails.

◆ addAttributeCmd()

virtual AddAttributeUndoableCommand::Ptr Ufe::Attributes::addAttributeCmd ( const std::string &  name,
const Attribute::Type type 
)
pure virtual

Creates a command to add an attribute to the SceneItem this Attributes interface refers to. The command is not executed.

Parameters
nameThe name of the new attribute.
typeThe type of the new attribute.
Returns
Command whose execution will create the attribute. Returns a null pointer if attribute creation is not available on the SceneItem or if adding the attribute would fail.

◆ addObserver() [1/2]

static bool Ufe::Attributes::addObserver ( const Observer::Ptr obs)
static

Add observation for attribute changes on any item in the scene (global observation).

Parameters
obsObserver to add.
Returns
True if the observer is added. Add does nothing and returns false if the observer is already present.

◆ addObserver() [2/2]

static bool Ufe::Attributes::addObserver ( const SceneItem::Ptr item,
const Observer::Ptr obs 
)
static

Add observation on the argument item for attribute changes.

Parameters
itemSceneItem to observe.
obsObserver to add.
Returns
True if the observer is added. Add does nothing and returns false if the observer is already present.

◆ attribute()

virtual Attribute::Ptr Ufe::Attributes::attribute ( const std::string &  name)
pure virtual

Creates an Attribute interface for the given attribute name.

Parameters
nameName of the attribute to retrieve.
Returns
Attribute interface for the given name. Returns a null pointer if no attribute exists for the given name.

◆ attributeNames()

virtual std::vector< std::string > Ufe::Attributes::attributeNames ( ) const
pure virtual
Returns
List of all the attribute names for this object.

◆ attributes()

static Ptr Ufe::Attributes::attributes ( const SceneItem::Ptr item)
static

Convenience method that calls the attributes method on the attribute handler for the item. Returns a null pointer if the argument is null, or has an empty path.

Parameters
itemSceneItem's Attributes interface to retrieve.
Returns
Attributes interface of the given SceneItem.

◆ attributeType()

virtual Attribute::Type Ufe::Attributes::attributeType ( const std::string &  name)
pure virtual
Returns
The attribute type for the attribute matching the input name.

◆ getEnums()

virtual Enums Ufe::Attributes::getEnums ( const std::string &  attrName) const
pure virtual

Gets the enums associated with the named attribute

Parameters
attrNameThe name of the attribute to return the enums for.
Returns
The list of allowed enum label and value pairs for the named attribute. Returns empty Enums structure if there are no enums for this attribute.

◆ hasAttribute()

virtual bool Ufe::Attributes::hasAttribute ( const std::string &  name) const
pure virtual

Queries whether an attribute exists with the given name.

Parameters
nameThe attribute name to check.
Returns
True if the object contains an attribute matching the input name.

◆ hasObserver() [1/2]

static bool Ufe::Attributes::hasObserver ( const Observer::Ptr obs)
static

Query observation for attribute changes on any item in the scene (global observers).

Parameters
obsObserver to query.
Returns
True if the observer observes attribute changes on any item in the scene.

◆ hasObserver() [2/2]

static bool Ufe::Attributes::hasObserver ( const SceneItem::Ptr item,
const Observer::Ptr obs 
)
static

Query observation on argument item for attribute changes.

Parameters
itemSceneItem to check if has observation.
obsObserver to query.
Returns
True if there is observation on argument item for attribute changes.

◆ hasObservers() [1/2]

static bool Ufe::Attributes::hasObservers ( const Path path)
static
Parameters
pathPath to verify if being observed.
Returns
True if the given path is being observed.

◆ hasObservers() [2/2]

static bool Ufe::Attributes::hasObservers ( Rtid  runTimeId)
static

Helper query for runtimes, to determine if a path they are responsible for is being observed specifically. This only considers observation of that specific path, and does not consider observation of any item in the scene (global observation), which is in addition.

Parameters
runTimeIdruntime Id to find observers on.
Returns
True if any path of given runtime Id are being observed.

◆ nbObservers() [1/2]

static std::size_t Ufe::Attributes::nbObservers ( )
static

Number of observers for attribute changes on any item in the scene (global observers).

Returns
Number of observers.

◆ nbObservers() [2/2]

static std::size_t Ufe::Attributes::nbObservers ( const SceneItem::Ptr item)
static

Number of observers on the given SceneItem.

Parameters
itemSceneItem on which to count observers.
Returns
Number of observers on SceneItem.

◆ notify()

static void Ufe::Attributes::notify ( const AttributeChanged notification)
static

Notify all observers, including global observers. The order in which observers are notified is unspecified. If no observer exists, does nothing.

Parameters
notificationAttribute notification to send.

◆ removeAttribute()

virtual bool Ufe::Attributes::removeAttribute ( const std::string &  name)
virtual

Removes an attribute created via addAttribute.

Parameters
nameThe name of the attribute to remove.
Returns
true if the attribute was successfully removed, false if attribute removal is not supported by the SceneItem or if removing the attribute fails.

◆ removeAttributeCmd()

virtual UndoableCommand::Ptr Ufe::Attributes::removeAttributeCmd ( const std::string &  name)
pure virtual

Create a command to remove an attribute created via addAttribute. The command is not executed.

Parameters
nameThe name of the attribute to remove.
Returns
Command whose execution will remove the attribute. Returns a null pointer if attribute removal is not supported by the SceneItem or if removing the attribute would fail.

◆ removeObserver() [1/2]

static bool Ufe::Attributes::removeObserver ( const Observer::Ptr obs)
static

Remove observation for attribute changes on any item in the scene (global observation).

Parameters
obsObserver to remove.
Returns
True if the observer is removed. False if the observer isn't found.

◆ removeObserver() [2/2]

static bool Ufe::Attributes::removeObserver ( const SceneItem::Ptr item,
const Observer::Ptr obs 
)
static

Remove observation on the argument item for attribute changes.

Parameters
itemSceneItem to remove observation on.
obsObserver to remove.
Returns
True if the observer is removed. False if the observer isn't found.

◆ renameAttribute()

virtual Attribute::Ptr Ufe::Attributes::renameAttribute ( const std::string &  originalName,
const std::string &  newName 
)
virtual

Rename an attribute. If an attribute already exists with the newName name, a unique name from newName is generated.

Parameters
originalNameThe name of the attribute to rename.
newNameThe new name for the attribute
Returns
Interface on the renamed attribute. Returns a null pointer if attribute renaming is not available or if renaming the attribute fails.

◆ renameAttributeCmd()

virtual RenameAttributeUndoableCommand::Ptr Ufe::Attributes::renameAttributeCmd ( const std::string &  originalName,
const std::string &  newName 
)
pure virtual

Create a command to rename an attribute. The command is not executed.

Parameters
originalNameThe name of the attribute to rename.
newNameThe new name for the attribute
Returns
Command whose execution will rename the attribute. Returns a null pointer if attribute renaming is not available on the SceneItem.

◆ sceneItem()

virtual SceneItem::Ptr Ufe::Attributes::sceneItem ( ) const
pure virtual
Returns
The object's SceneItem.

The documentation for this class was generated from the following file: