49 : _valueHolder( NULL ) {}
51 template<
typename ValueType >
54 _valueHolder =
new _DspRtValue< ValueType >( value );
59 if( other._valueHolder != NULL )
61 _valueHolder = other._valueHolder->GetCopy();
77 std::swap( _valueHolder, rhs._valueHolder );
83 if( _valueHolder != NULL && rhs._valueHolder != NULL &&
84 _valueHolder->GetType() == rhs._valueHolder->GetType() )
86 _valueHolder->SetValue( rhs._valueHolder );
94 template<
typename ValueType >
97 if(
typeid( rhs ) == GetType() )
99 ( ( _DspRtValue< ValueType >* ) _valueHolder )->value = rhs;
117 return !_valueHolder;
120 const std::type_info& GetType()
const
122 if( _valueHolder != NULL )
124 return _valueHolder->GetType();
128 return typeid( void );
132 template<
typename ValueType >
133 static ValueType* RunTypeCast(
DspRunType* operand )
135 if( operand != NULL && operand->GetType() ==
typeid( ValueType ) )
137 return &
static_cast< DspRunType::_DspRtValue< ValueType >*
>( operand->_valueHolder )->value;
145 template<
typename ValueType >
146 static inline const ValueType* RunTypeCast(
const DspRunType* operand )
148 return RunTypeCast< ValueType >(
const_cast< DspRunType*
>( operand ) );
152 class _DspRtValueHolder
155 virtual ~_DspRtValueHolder() {}
158 virtual const std::type_info& GetType()
const = 0;
159 virtual _DspRtValueHolder* GetCopy()
const = 0;
160 virtual void SetValue( _DspRtValueHolder* valueHolder ) = 0;
163 template<
typename ValueType >
164 class _DspRtValue :
public _DspRtValueHolder
167 _DspRtValue(
const ValueType& value )
171 virtual const std::type_info& GetType()
const
173 return typeid( ValueType );
176 virtual _DspRtValueHolder* GetCopy()
const
178 return new _DspRtValue( value );
181 void SetValue( _DspRtValueHolder* valueHolder )
183 value = ( ( _DspRtValue< ValueType >* ) valueHolder )->value;
190 _DspRtValue& operator=(
const _DspRtValue& );
194 _DspRtValueHolder* _valueHolder;
199 #endif // DSPRUNTYPE_H