36 #ifndef __OGRE_ANY_H__
37 #define __OGRE_ANY_H__
65 template<
typename ValueType>
66 explicit Any(
const ValueType & value)
89 template<
typename ValueType>
114 inline friend std::ostream&
operator <<
115 ( std::ostream& o,
const Any& v )
118 v.mContent->writeToStream(o);
140 virtual const std::type_info&
getType()
const = 0;
148 template<
typename ValueType>
160 virtual const std::type_info &
getType()
const
162 return typeid(ValueType);
187 template<
typename ValueType>
193 template<
typename ValueType>
199 "Bad cast from uninitialised Any",
202 else if(
getType() ==
typeid(ValueType))
209 str <<
"Bad cast from type '" <<
getType().name() <<
"' "
210 <<
"to '" <<
typeid(ValueType).name() <<
"'";
217 template <
typename ValueType>
218 ValueType
get(void)
const
223 "Bad cast from uninitialised Any",
226 else if(
getType() ==
typeid(ValueType))
233 str <<
"Bad cast from type '" <<
getType().name() <<
"' "
234 <<
"to '" <<
typeid(ValueType).name() <<
"'";
255 template<
typename ValueType>
283 template<
typename ValueType>
295 virtual const std::type_info &
getType()
const
297 return typeid(ValueType);
366 static_cast<numplaceholder*>(
mContent)->multiply(factor));
404 template<
typename ValueType>
407 return operand && (std::strcmp(operand->
getType().name(),
typeid(ValueType).name()) == 0)
412 template<
typename ValueType>
415 return any_cast<ValueType>(
const_cast<Any *
>(operand));
418 template<
typename ValueType>
421 const ValueType * result =
any_cast<ValueType>(&operand);
425 str <<
"Bad cast from type '" << operand.
getType().name() <<
"' "
426 <<
"to '" <<
typeid(ValueType).name() <<
"'";
Specialised Any class which has built in arithmetic operators, but can hold only types which support ...
Any & operator=(const Any &rhs)
virtual placeholder * divide(placeholder *rhs)=0
float Real
Software floating point type.
numholder(const ValueType &value)
friend ValueType * any_cast(Any *)
Variant type that can hold Any other type.
const std::type_info & getType() const
virtual void writeToStream(std::ostream &o)=0
StringStream StrStreamType
#define OGRE_NEW_T(T, category)
Allocate space for one primitive type, external type or non-virtual type with constructor parameters...
AnyNumeric & operator+=(const AnyNumeric &rhs)
virtual placeholder * subtract(placeholder *rhs)
AnyNumeric(const AnyNumeric &other)
virtual placeholder * add(placeholder *rhs)
virtual placeholder * add(placeholder *rhs)=0
AnyNumeric operator*(Real factor) const
virtual placeholder * multiply(placeholder *rhs)
AnyNumeric & operator=(const AnyNumeric &rhs)
AnyNumeric & operator/=(const AnyNumeric &rhs)
ValueType operator()() const
virtual placeholder * clone() const
AnyNumeric(placeholder *pholder)
Construct from holder.
ValueType * any_cast(Any *operand)
AnyNumeric operator-(const AnyNumeric &rhs) const
AnyNumeric & operator-=(const AnyNumeric &rhs)
virtual void writeToStream(std::ostream &o)
void swap(Ogre::SmallVectorImpl< T > &LHS, Ogre::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
AnyNumeric operator+(const AnyNumeric &rhs) const
#define OGRE_EXCEPT(code, desc, src)
virtual placeholder * multiply(placeholder *rhs)=0
AnyNumeric(const ValueType &value)
Any(const ValueType &value)
holder(const ValueType &value)
AnyNumeric operator/(const AnyNumeric &rhs) const
virtual placeholder * divide(placeholder *rhs)
virtual void writeToStream(std::ostream &o)
virtual placeholder * clone() const
virtual const std::type_info & getType() const
virtual placeholder * subtract(placeholder *rhs)=0
virtual placeholder * multiply(Real factor)
#define OGRE_DELETE_T(ptr, T, category)
Free the memory allocated with OGRE_NEW_T. Category is required to be restated to ensure the matching...
Any & operator=(const ValueType &rhs)
virtual const std::type_info & getType() const
AnyNumeric operator*(const AnyNumeric &rhs) const
virtual placeholder * clone() const =0
AnyNumeric & operator*=(const AnyNumeric &rhs)
virtual const std::type_info & getType() const =0