18 #ifndef INCLUDE_RCF_ANY_HPP 19 #define INCLUDE_RCF_ANY_HPP 23 #include <RCF/Exception.hpp> 24 #include <RCF/Tools.hpp> 29 typedef std::unique_ptr<AnyHolderBase> AnyHolderPtr;
34 virtual ~AnyHolderBase() {}
35 virtual AnyHolderPtr clone()
const = 0;
39 class AnyHolder :
public AnyHolderBase
42 AnyHolder(
const T& any) : mAny(any)
48 virtual AnyHolderPtr clone()
const 50 return AnyHolderPtr(
new AnyHolder<T>(mAny));
74 Any(
const T& t) : mAnyPtr(new AnyHolder<T>(t))
83 mAnyPtr = rhs.mAnyPtr->clone();
95 mAnyPtr = rhs.mAnyPtr->clone();
108 RCF_THROW(
Exception(
"Any cast failed. Null value."));
110 AnyHolder<T> * pHolder =
dynamic_cast<AnyHolder<T> *
>(mAnyPtr.get());
114 RCF_THROW(
Exception(
"Any cast failed. Type mismatch."));
116 return pHolder->get();
120 AnyHolderPtr mAnyPtr;
125 #endif // ! INCLUDE_RCF_ANY_HPP Generic container type used to hold arbitrary objects.
Definition: RCF/Any.hpp:63
Any(const T &t)
Constructs an Any instance holding a copy of t.
Definition: RCF/Any.hpp:74
Any(const Any &rhs)
Copy constructs an Any instance.
Definition: RCF/Any.hpp:79
Base class for all RCF exceptions.
Definition: Exception.hpp:67
Any()
Constructs an empty Any instance.
Definition: RCF/Any.hpp:68
Any & operator=(const Any &rhs)
Assigns an Any instance.
Definition: RCF/Any.hpp:88
Definition: AmiIoHandler.hpp:23