16#ifndef SIMICS_TYPES_ANY_TYPE_H
17#define SIMICS_TYPES_ANY_TYPE_H
27 class ValueInterface {
29 virtual ValueInterface *copy()
const = 0;
30 virtual ~ValueInterface() {}
34 class Value :
public ValueInterface {
36 explicit Value(
const T &value) : value_(value) {}
37 virtual ValueInterface *copy()
const {
38 return new Value<T>(value_);
50 value_ = other.value_ ? other.value_->copy() : NULL;
53 value_ = other.value_;
66 value_ = other.value_;
77 value_ = other.value_ ? other.value_->copy() : NULL;
85 value_ =
new Value<T>(
value);
91 throw std::runtime_error(
"value_ is not set");
93 return static_cast<Value<T> *
>(value_)->
value();
104 ValueInterface *value_;
Generic type class.
Definition: any_type.h:26
AnyType(const T &value)
Definition: any_type.h:57
bool isSet()
Definition: any_type.h:95
~AnyType()
Definition: any_type.h:98
AnyType(AnyType &&other)
Definition: any_type.h:52
AnyType & operator=(const T &value)
Definition: any_type.h:82
AnyType & operator=(AnyType &&other)
Definition: any_type.h:59
AnyType & operator=(const AnyType &other)
Definition: any_type.h:70
AnyType(const AnyType &other)
Definition: any_type.h:49
AnyType()
Definition: any_type.h:48
T value()
Definition: any_type.h:89