| AAX SDK 2.6.1 Avid Audio Extensions Development Kit

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

- File List
- File Members

Loading...
Searching...
No Matches
AAX_CPercentDisplayDelegateDecorator.h
Go to the documentation of this file.
1/*================================================================================================*/
2/*
3 *
4 * Copyright 2014-2017, 2019, 2023 Avid Technology, Inc.
5 * All rights reserved.
6 *
7 * CONFIDENTIAL: this document contains confidential information of Avid. Do
8 * not disclose to any third party. Use of the information contained in this
9 * document is subject to an Avid SDK license.
10 *
11 */
12
19/*================================================================================================*/
20
21
22#pragma once
23
24#ifndef AAX_CPERCENTDISPLAYDELEGATEDECORATOR_H
25#define AAX_CPERCENTDISPLAYDELEGATEDECORATOR_H
26
27#include "AAX_IDisplayDelegateDecorator.h"
28
29#include <cmath>
30
31
54 template <typename T>
55 class AAX_CPercentDisplayDelegateDecorator : public AAX_IDisplayDelegateDecorator<T>
56{
57 public:
58 AAX_CPercentDisplayDelegateDecorator(const AAX_IDisplayDelegate<T>& displayDelegate);
59
60 //Virtual Overrides
61 AAX_CPercentDisplayDelegateDecorator<T>* Clone() const AAX_OVERRIDE;
62 bool ValueToString(T value, AAX_CString* valueString) const AAX_OVERRIDE;
63 bool ValueToString(T value, int32_t maxNumChars, AAX_CString* valueString) const AAX_OVERRIDE;
64 bool StringToValue(const AAX_CString& valueString, T* value) const AAX_OVERRIDE;
65};
66
67 template <typename T>
68 AAX_CPercentDisplayDelegateDecorator<T>::AAX_CPercentDisplayDelegateDecorator(const AAX_IDisplayDelegate<T>& displayDelegate) :
69 AAX_IDisplayDelegateDecorator<T>(displayDelegate)
70{
71}
72
73 template <typename T>
74 AAX_CPercentDisplayDelegateDecorator<T>* AAX_CPercentDisplayDelegateDecorator<T>::Clone() const
75{
76 return new AAX_CPercentDisplayDelegateDecorator(*this);
77}
78
79 template <typename T>
80 bool AAX_CPercentDisplayDelegateDecorator<T>::ValueToString(T value, AAX_CString* valueString) const
81{
82 value *= 100;
83 bool succeeded = AAX_IDisplayDelegateDecorator<T>::ValueToString(value, valueString);
84 *valueString += AAX_CString("%");
85 return succeeded;
86}
87
88 template <typename T>
89 bool AAX_CPercentDisplayDelegateDecorator<T>::ValueToString(T value, int32_t maxNumChars, AAX_CString* valueString) const
90{
91 value *= 100;
92 bool succeeded = AAX_IDisplayDelegateDecorator<T>::ValueToString(value, maxNumChars-1, valueString); //<DMT> Make room for percentage symbol.
93 *valueString += AAX_CString("%");
94 return succeeded;
95}
96
97
98 template <typename T>
99 bool AAX_CPercentDisplayDelegateDecorator<T>::StringToValue(const AAX_CString& valueString, T* value) const
100{
101 //Just call through if there is obviously no unit string.
102 if (valueString.Length() <= 2)
103 {
104 bool success = AAX_IDisplayDelegateDecorator<T>::StringToValue(valueString, value);
105 *value /= 100.0f;
106 return success;
107 }
108
109 //Just call through if the end of this string does not match the unit string.
110 AAX_CString unitSubString;
111 valueString.SubString(valueString.Length() - 1, 1, &unitSubString);
112 if (unitSubString != AAX_CString("%"))
113 {
114 bool success = AAX_IDisplayDelegateDecorator<T>::StringToValue(valueString, value);
115 *value /= 100.0f;
116 return success;
117 }
118
119 //Call through with the stripped down value string.
120 AAX_CString valueSubString;
121 valueString.SubString(0, valueString.Length() - 1, &valueSubString);
122 bool success = AAX_IDisplayDelegateDecorator<T>::StringToValue(valueSubString, value);
123 *value /= 100.0f;
124 return success;
125}
126
127
128#endif
129
AAX_OVERRIDE
#define AAX_OVERRIDE
override keyword macro
Definition: AAX.h:151
AAX_IDisplayDelegateDecorator.h
The base class for all concrete display delegate decorators.
AAX_CPercentDisplayDelegateDecorator
A percent decorator conforming to AAX_IDisplayDelegateDecorator.
Definition: AAX_CPercentDisplayDelegateDecorator.h:56
AAX_CPercentDisplayDelegateDecorator::ValueToString
bool ValueToString(T value, AAX_CString *valueString) const AAX_OVERRIDE
Converts a real parameter value to a string representation.
Definition: AAX_CPercentDisplayDelegateDecorator.h:80
AAX_CPercentDisplayDelegateDecorator::StringToValue
bool StringToValue(const AAX_CString &valueString, T *value) const AAX_OVERRIDE
Converts a string to a real parameter value.
Definition: AAX_CPercentDisplayDelegateDecorator.h:99
AAX_CPercentDisplayDelegateDecorator::AAX_CPercentDisplayDelegateDecorator
AAX_CPercentDisplayDelegateDecorator(const AAX_IDisplayDelegate< T > &displayDelegate)
Definition: AAX_CPercentDisplayDelegateDecorator.h:68
AAX_CPercentDisplayDelegateDecorator::Clone
AAX_CPercentDisplayDelegateDecorator< T > * Clone() const AAX_OVERRIDE
Constructs and returns a copy of the display delegate.
Definition: AAX_CPercentDisplayDelegateDecorator.h:74
AAX_CString
A generic AAX string class with similar functionality to std::string
Definition: AAX_CString.h:44
AAX_CString::Length
uint32_t Length() const AAX_OVERRIDE
AAX_CString::SubString
void SubString(uint32_t pos, uint32_t n, AAX_IString *outputStr) const
AAX_IDisplayDelegate
Definition: AAX_IDisplayDelegate.h:66
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