HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_RWAttributeRef< Attribute > Class Template Reference

#include <PDG_AttributeRef.h>

+ Inheritance diagram for PDG_RWAttributeRef< Attribute >:

Public Types

using Base = PDG_AttributeRefT< Attribute, PDG_AttributeHolder >
 
using Self = PDG_RWAttributeRef< Attribute >
 
- Public Types inherited from PDG_AttributeRefT< Attribute, PDG_AttributeHolder >
using Self = PDG_AttributeRefT< Attribute, PDG_AttributeHolder >
 

Public Member Functions

 PDG_RWAttributeRef (const UT_StringHolder &name, const PDG_AttributeOwner *owner)
 Constructs an uninitialized RW ref. More...
 
 PDG_RWAttributeRef (PDG_AttributeHolder *holder, const UT_StringHolder &name, const PDG_AttributeOwner *owner, PDG_AttributeError error=PDG_AttributeError::eNone)
 
 PDG_RWAttributeRef (const Self &other)
 
 PDG_RWAttributeRef (Self &&other)
 
 ~PDG_RWAttributeRef ()
 Emits data changed events if this attribute ref recorded a modification. More...
 
Selfoperator= (const Self &other)
 
Selfoperator= (Self &&other)
 
void emitEvents ()
 Emits pending events from the ref. More...
 
void clearEvents ()
 Clears any pending events. More...
 
Attributeattribute ()
 
Attributeoperator-> ()
 Returns a non-const pointer to the underlying attribute instance. More...
 
PDG_AttributeError setFlag (PDG_AttributeFlag flag, bool set, bool &changed)
 
PDG_AttributeError setFlag (PDG_AttributeFlag flag, bool set)
 Sets the specific flag on or off. More...
 
PDG_AttributeError setFlags (uint16 flags, bool &changed)
 Directly sets the flag bits to the specified flags. More...
 
PDG_AttributeError setFlags (uint16 flags)
 Sets all flags. More...
 
void truncate (int length)
 Truncates the array stored in the attribute. More...
 
- Public Member Functions inherited from PDG_AttributeRefT< Attribute, PDG_AttributeHolder >
 PDG_AttributeRefT (PDG_AttributeHolder *holder, const UT_StringHolder &name, const PDG_AttributeOwner *owner, PDG_AttributeError error=PDG_AttributeError::eNone)
 
PDG_AttributeHolderholder () const
 Returns the underlying attribute holder. More...
 
const Attributeattribute () const
 Returns a const pointer to the underlying attribute instance. More...
 
const TattributeT () const
 
const Attributeoperator-> () const
 Returns a const pointer to the underlying attribute instance. More...
 
bool hasData () const
 Returns true if the contained attribute has any data. More...
 
bool isOwner () const
 Returns true if the contained attribute holder owns its data. More...
 
PDG_AttributeType type () const
 Returns the type of the contained attribute. More...
 
uint16 flags () const
 Returns the flags on the contained holder. More...
 
bool hasAnyFlags () const
 Returns true if the contained holder has any flags set. More...
 
bool hasAnyFlags (uint16 flags) const
 Returns true if the contained holder has any of the specified flags set. More...
 
bool hasFlag (PDG_AttributeFlag flag) const
 Returns true if the contained holder has the specified flag set. More...
 
bool hasFlags (uint16 flags) const
 Returns true if the contained holder has all of the specified flags set. More...
 
bool isNumeric () const
 Returns true if the attribute is numeric. More...
 
bool isArray () const
 Returns true if the attribute is an array. More...
 
PDG_AttributeCast asNumber (fpreal &number, const PDG_AttributeQuery &query, int index, bool has_component) const
 
PDG_AttributeCast asNumber (fpreal &number, int index) const
 
PDG_AttributeCast asFile (PDG_File &file, int index, const UT_StringHolder &tag=UT_StringHolder::theEmptyString, PDG_File::Hash hash=0, bool own=false) const
 
PDG_AttributeCast asString (UT_WorkBuffer &buffer, const PDG_AttributeQuery &query, int index, int pad, bool has_component) const
 
PDG_AttributeCast asString (UT_WorkBuffer &buffer, int index, int pad=0) const
 
PDG_AttributeCast asStringValues (UT_WorkBuffer &buffer, int pad=0) const
 Prints the values contained in the attribute to space-separated string. More...
 
PDG_AttributeCast asOptions (UT_Options &options, PDG_AttributeOverwrite overwrite) const
 
PDG_AttributeCast asOptions (UT_Options &options, const UT_StringHolder &key, PDG_AttributeOverwrite overwrite) const
 
int size () const
 Returns the size of the data stored in the attribute. More...
 
- Public Member Functions inherited from PDG_AttributeRef
 PDG_AttributeRef (const UT_StringHolder &name, const PDG_AttributeOwner *owner, PDG_AttributeError error=PDG_AttributeError::eNone)
 
 operator bool () const
 Returns true if the handle is valid. More...
 
bool isValid () const
 Returns true if the handle is valid. More...
 
PDG_AttributeError error () const
 Returns the error state of the handle. More...
 
const UT_StringHoldername () const
 Returns the name of the attribute referenced by this attrib ref. More...
 
const PDG_AttributeOwnerowner () const
 Returns the PDG_AttributeOwner that owns the underlying attribute. More...
 
bool validate (UT_WorkBuffer &buffer) const
 
bool validate (const PDG_Node *node, bool report_errors=true, bool as_warning=false) const
 

Additional Inherited Members

- Static Public Member Functions inherited from PDG_AttributeRef
static bool attributeError (UT_WorkBuffer &buffer, PDG_AttributeError error, const UT_StringHolder &attrib_name, const PDG_AttributeOwner *owner=nullptr)
 
static void attributeModified (const PDG_AttributeOwner *owner, PDG_AttributeType attrib_type, const UT_StringHolder &attrib_name)
 Emits events when the attribute is modified. More...
 
- Protected Attributes inherited from PDG_AttributeRefT< Attribute, PDG_AttributeHolder >
PDG_AttributeHoldermyHolder
 
- Protected Attributes inherited from PDG_AttributeRef
UT_StringHolder myName
 
const PDG_AttributeOwnermyOwner
 
PDG_AttributeError myError
 

Detailed Description

template<typename Attribute>
class PDG_RWAttributeRef< Attribute >

Read/write attribute ref that permits modifications of holder flags as well as non-const access to the underlying data. Accessing the attribute using either the named accessor or the -> overload will result in a deep copy + ownership being taken, if the data is not already owned by the holder.

Definition at line 762 of file PDG_AttributeRef.h.

Member Typedef Documentation

Definition at line 766 of file PDG_AttributeRef.h.

template<typename Attribute>
using PDG_RWAttributeRef< Attribute >::Self = PDG_RWAttributeRef<Attribute>

Definition at line 767 of file PDG_AttributeRef.h.

Constructor & Destructor Documentation

template<typename Attribute>
PDG_RWAttributeRef< Attribute >::PDG_RWAttributeRef ( const UT_StringHolder name,
const PDG_AttributeOwner owner 
)
inline

Constructs an uninitialized RW ref.

Definition at line 770 of file PDG_AttributeRef.h.

template<typename Attribute>
PDG_RWAttributeRef< Attribute >::PDG_RWAttributeRef ( PDG_AttributeHolder holder,
const UT_StringHolder name,
const PDG_AttributeOwner owner,
PDG_AttributeError  error = PDG_AttributeError::eNone 
)
inline

Constructs a ref that can modify attribute data. We store the work item so we can emit events.

Definition at line 779 of file PDG_AttributeRef.h.

template<typename Attribute>
PDG_RWAttributeRef< Attribute >::PDG_RWAttributeRef ( const Self other)
inline

Explicitly defined copy constructor, since we don't want to copy the myModified flag from the source reference. Doing so would mean that we'd potentially by emitting an extra data change event on destruction.

Definition at line 792 of file PDG_AttributeRef.h.

template<typename Attribute>
PDG_RWAttributeRef< Attribute >::PDG_RWAttributeRef ( Self &&  other)
inline

Explicitly defined move constructor, since a copy constructor has been defined. When moving a ref we do want to preserve the myModified flag, unlike in the copy constructor.

Definition at line 801 of file PDG_AttributeRef.h.

template<typename Attribute>
PDG_RWAttributeRef< Attribute >::~PDG_RWAttributeRef ( )
inline

Emits data changed events if this attribute ref recorded a modification.

Definition at line 809 of file PDG_AttributeRef.h.

Member Function Documentation

template<typename Attribute>
Attribute* PDG_RWAttributeRef< Attribute >::attribute ( )
inline

Returns a non-const pointer to the underlying attribute instance. This induces a copy if the attribute is not already owned, and counts as a modification for the purpose of event handling.

Definition at line 864 of file PDG_AttributeRef.h.

template<typename Attribute>
void PDG_RWAttributeRef< Attribute >::clearEvents ( )
inline

Clears any pending events.

Definition at line 856 of file PDG_AttributeRef.h.

template<typename Attribute>
void PDG_RWAttributeRef< Attribute >::emitEvents ( )
inline

Emits pending events from the ref.

Definition at line 847 of file PDG_AttributeRef.h.

template<typename Attribute>
Attribute* PDG_RWAttributeRef< Attribute >::operator-> ( )
inline

Returns a non-const pointer to the underlying attribute instance.

Definition at line 874 of file PDG_AttributeRef.h.

template<typename Attribute>
Self& PDG_RWAttributeRef< Attribute >::operator= ( const Self other)
inline

Explicitly defined copy assignment operator, since the copy constructor is defined.

Definition at line 816 of file PDG_AttributeRef.h.

template<typename Attribute>
Self& PDG_RWAttributeRef< Attribute >::operator= ( Self &&  other)
inline

Explicitly defined move assignment operator, since the move constructor is defined.

Definition at line 831 of file PDG_AttributeRef.h.

template<typename Attribute>
PDG_AttributeError PDG_RWAttributeRef< Attribute >::setFlag ( PDG_AttributeFlag  flag,
bool  set,
bool &  changed 
)
inline

Sets the specific flag on or off, based on the set arugment, an returns whether or not the flag was changed.

Definition at line 882 of file PDG_AttributeRef.h.

template<typename Attribute>
PDG_AttributeError PDG_RWAttributeRef< Attribute >::setFlag ( PDG_AttributeFlag  flag,
bool  set 
)
inline

Sets the specific flag on or off.

Definition at line 898 of file PDG_AttributeRef.h.

template<typename Attribute>
PDG_AttributeError PDG_RWAttributeRef< Attribute >::setFlags ( uint16  flags,
bool &  changed 
)
inline

Directly sets the flag bits to the specified flags.

Definition at line 906 of file PDG_AttributeRef.h.

template<typename Attribute>
PDG_AttributeError PDG_RWAttributeRef< Attribute >::setFlags ( uint16  flags)
inline

Sets all flags.

Definition at line 920 of file PDG_AttributeRef.h.

template<typename Attribute>
void PDG_RWAttributeRef< Attribute >::truncate ( int  length)
inline

Truncates the array stored in the attribute.

Definition at line 927 of file PDG_AttributeRef.h.


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