| AAX SDK 2.6.1 Avid Audio Extensions Development Kit

- Welcome
- Manual
- Classes
- Files
- Lists
- Support

- Class List
- Class Index
- Class Hierarchy
- Class Members

Loading...
Searching...
No Matches
List of all members | Public Member Functions
AAX_IDisplayDelegate< T > Class Template Referenceabstract
AAX SDK Manual » AAX Library features » Parameter Manager » Display delegates

`#include <AAX_IDisplayDelegate.h>`

Inheritance diagram for AAX_IDisplayDelegate< T >:
[legend]
Collaboration diagram for AAX_IDisplayDelegate< T >:
[legend]

## Description

template<typename T>
class AAX_IDisplayDelegate< T >

Display delegate interface template

Classes for parameter value string conversion.

Display delegates are used to convert real parameter values to and from their formatted string representations. All display delegates implement the AAX_IDisplayDelegate interface, which contains two conversion functions:

virtual bool ValueToString(T value, std::string& valueString) const = 0;
virtual bool StringToValue(const std::string& valueString, T& value) const = 0;
AAX_IDisplayDelegate::ValueToString
virtual bool ValueToString(T value, AAX_CString *valueString) const =0
Converts a real parameter value to a string representation.
AAX_IDisplayDelegate::StringToValue
virtual bool StringToValue(const AAX_CString &valueString, T *value) const =0
Converts a string to a real parameter value.

# Display delegate decorators

The AAX SDK utilizes a decorator pattern in order to provide code re-use while accounting for a wide variety of possible parameter display formats. The SDK includes a number of sample display delegate decorator classes.

Each concrete display delegate decorator implements AAX_IDisplayDelegateDecorator and adheres to the decorator pattern. The decorator pattern allows multiple display behaviors to be composited or wrapped together at run time. For instance it is possible to implement a dBV (dB Volts) decorator, by wrapping an AAX_CDecibelDisplayDelegateDecorator with an AAX_CUnitDisplayDelegateDecorator.

## Display delegate decorator implementation

By implementing AAX_IDisplayDelegateDecorator, each concrete display delegate decorator class implements the full AAX_IDisplayDelegate interface. In addition, it retains a pointer to the AAX_IDisplayDelegateDecorator that it wraps. When the decorator performs a conversion, it calls into its wrapped class so that the wrapped decorator may apply its own conversion formatting. By repeating this pattern in each decorator, all of the decorator subclasses call into their "wrapper" in turn, resulting in a final string to which all of the decorators' conversions have been applied in sequence.

Here is the relevant implementation from AAX_IDisplayDelegateDecorator :

template <typename T>
AAX_IDisplayDelegateDecorator<T>::AAX_IDisplayDelegateDecorator(const AAX_IDisplayDelegate<T>& displayDelegate) :
AAX_IDisplayDelegate<T>(),
mWrappedDisplayDelegate(displayDelegate.Clone())
{
}
template <typename T>
bool AAX_IDisplayDelegateDecorator<T>::ValueToString(T value, AAX_CString* valueString) const
{
return mWrappedDisplayDelegate->ValueToString(value, valueString);
}
template <typename T>
bool AAX_IDisplayDelegateDecorator<T>::StringToValue(const AAX_CString& valueString, T* value) const
{
return mWrappedDisplayDelegate->StringToValue(valueString, value);
}
AAX_CString
A generic AAX string class with similar functionality to std::string
Definition: AAX_CString.h:44
AAX_IDisplayDelegate
Definition: AAX_IDisplayDelegate.h:66
AAX_IDisplayDelegate::Clone
virtual AAX_IDisplayDelegate * Clone() const =0
Constructs and returns a copy of the display delegate.
AAX_IDisplayDelegateDecorator
The base class for all concrete display delegate decorators.
Definition: AAX_IDisplayDelegateDecorator.h:41
AAX_IDisplayDelegateDecorator::StringToValue
bool StringToValue(const AAX_CString &valueString, T *value) const AAX_OVERRIDE
Converts a string to a real parameter value.
Definition: AAX_IDisplayDelegateDecorator.h:194
AAX_IDisplayDelegateDecorator::ValueToString
bool ValueToString(T value, AAX_CString *valueString) const AAX_OVERRIDE
Converts a string to a real parameter value.
Definition: AAX_IDisplayDelegateDecorator.h:182

## Decibel decorator example

Here is a concrete example of how a decibel decorator might be implemented

template <typename T>
bool AAX_CDecibelDisplayDelegateDecorator<T>::ValueToString(T value, AAX_CString* valueString) const
{
if (value <= 0)
{
*valueString = AAX_CString("--- dB");
return true;
}
value = 20*log10(value);
bool succeeded = AAX_IDisplayDelegateDecorator<T>::ValueToString(value, valueString);
*valueString += AAX_CString("dB");
return succeeded;
}
AAX_CDecibelDisplayDelegateDecorator::ValueToString
bool ValueToString(T value, AAX_CString *valueString) const AAX_OVERRIDE
Converts a real parameter value to a string representation.
Definition: AAX_CDecibelDisplayDelegateDecorator.h:84

Notice in this example that the ValueToString() method is called in the parent class, AAX_IDisplayDelegateDecorator. This results in a call into the wrapped class' implementation of ValueToString(), which converts the decorated value to a redecorated string, and so forth for additional decorators.

## Public Member Functions
virtual AAX_IDisplayDelegate * | Clone () const =0
| Constructs and returns a copy of the display delegate.
virtual bool | ValueToString (T value, AAX_CString *valueString) const =0
| Converts a real parameter value to a string representation.
virtual bool | ValueToString (T value, int32_t maxNumChars, AAX_CString *valueString) const =0
| Converts a real parameter value to a string representation using a size hint, useful for control surfaces and other character limited displays.
virtual bool | StringToValue (const AAX_CString &valueString, T *value) const =0
| Converts a string to a real parameter value.
Public Member Functions inherited from AAX_IDisplayDelegateBase
virtual | ~AAX_IDisplayDelegateBase ()
| Virtual destructor.

## Member Function Documentation

## ◆ Clone()

template<typename T >

virtual AAX_IDisplayDelegate * AAX_IDisplayDelegate< T >::Clone | ( |  | ) | const
| pure virtual

Constructs and returns a copy of the display delegate.

In general, this method's implementation can use a simple copy constructor:

template <typename T>
AAX_CSubclassDisplayDelegate<T>* AAX_CSubclassDisplayDelegate<T>::Clone() const
{
return new AAX_CSubclassDisplayDelegate(*this);
}

Implemented in AAX_CBinaryDisplayDelegate< T >, AAX_CDecibelDisplayDelegateDecorator< T >, AAX_CNumberDisplayDelegate< T, Precision, SpaceAfter >, AAX_CPercentDisplayDelegateDecorator< T >, AAX_CStateDisplayDelegate< T >, AAX_CStringDisplayDelegate< T >, AAX_CUnitDisplayDelegateDecorator< T >, AAX_CUnitPrefixDisplayDelegateDecorator< T >, and AAX_IDisplayDelegateDecorator< T >.

Referenced by AAX_CParameter< T >::SetDisplayDelegate().

Here is the caller graph for this function:

## ◆ ValueToString() [1/2]

template<typename T >

virtual bool AAX_IDisplayDelegate< T >::ValueToString | ( | T | value,
|  | AAX_CString * | valueString
| ) |  | const
| pure virtual

Converts a real parameter value to a string representation.

Parameters

  [in] | value | The real parameter value that will be converted
  [out] | valueString | A string corresponding to value

Return values

  true | The string conversion was successful
  false | The string conversion was unsuccessful

Implemented in AAX_CBinaryDisplayDelegate< T >, AAX_CDecibelDisplayDelegateDecorator< T >, AAX_CNumberDisplayDelegate< T, Precision, SpaceAfter >, AAX_CPercentDisplayDelegateDecorator< T >, AAX_CStateDisplayDelegate< T >, AAX_CStringDisplayDelegate< T >, AAX_CUnitDisplayDelegateDecorator< T >, AAX_CUnitPrefixDisplayDelegateDecorator< T >, and AAX_IDisplayDelegateDecorator< T >.

## ◆ ValueToString() [2/2]

template<typename T >

virtual bool AAX_IDisplayDelegate< T >::ValueToString | ( | T | value,
|  | int32_t | maxNumChars,
|  | AAX_CString * | valueString
| ) |  | const
| pure virtual

Converts a real parameter value to a string representation using a size hint, useful for control surfaces and other character limited displays.

Parameters

  [in] | value | The real parameter value that will be converted
  [in] | maxNumChars | Size hint for the desired maximum number of characters in the string (not including null termination)
  [out] | valueString | A string corresponding to value

Return values

  true | The string conversion was successful
  false | The string conversion was unsuccessful

Implemented in AAX_CBinaryDisplayDelegate< T >, AAX_CDecibelDisplayDelegateDecorator< T >, AAX_CNumberDisplayDelegate< T, Precision, SpaceAfter >, AAX_CPercentDisplayDelegateDecorator< T >, AAX_CStateDisplayDelegate< T >, AAX_CStringDisplayDelegate< T >, AAX_CUnitDisplayDelegateDecorator< T >, AAX_CUnitPrefixDisplayDelegateDecorator< T >, and AAX_IDisplayDelegateDecorator< T >.

## ◆ StringToValue()

template<typename T >

virtual bool AAX_IDisplayDelegate< T >::StringToValue | ( | const AAX_CString & | valueString,
|  | T * | value
| ) |  | const
| pure virtual

Converts a string to a real parameter value.

Parameters

  [in] | valueString | The string that will be converted
  [out] | value | The real parameter value corresponding to valueString

Return values

  true | The string conversion was successful
  false | The string conversion was unsuccessful

Implemented in AAX_CBinaryDisplayDelegate< T >, AAX_CDecibelDisplayDelegateDecorator< T >, AAX_CNumberDisplayDelegate< T, Precision, SpaceAfter >, AAX_CPercentDisplayDelegateDecorator< T >, AAX_CStateDisplayDelegate< T >, AAX_CStringDisplayDelegate< T >, AAX_CUnitDisplayDelegateDecorator< T >, AAX_CUnitPrefixDisplayDelegateDecorator< T >, and AAX_IDisplayDelegateDecorator< T >.

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

- AAX_IDisplayDelegate.h