C++ Device API Reference Manual
Reference documentation for the Simics C++ Device API.
 
Loading...
Searching...
No Matches
attribute-traits.h File Reference
#include <simics/base/attr-value.h>
#include <array>
#include <deque>
#include <limits>
#include <list>
#include <map>
#include <set>
#include <string>
#include <type_traits>
#include <tuple>
#include <utility>
#include <vector>
#include "simics/conf-object.h"
#include "simics/connect.h"

Go to the source code of this file.

Classes

struct  simics::detail::attr_from_std_helper< T >
 
struct  simics::detail::attr_to_std_helper< T >
 
struct  simics::detail::attr_from_std_helper< ConfObjectRef >
 
struct  simics::detail::attr_to_std_helper< ConfObjectRef >
 
struct  simics::detail::derived_from_connectbase_and_constructible_from_confobjectref< T >
 
struct  simics::detail::is_container_of_connectbase< T >
 
struct  simics::detail::is_container_of_connectbase< std::vector< T, Alloc > >
 
struct  simics::detail::is_container_of_connectbase< std::list< T, Alloc > >
 
struct  simics::detail::is_container_of_connectbase< std::deque< T, Alloc > >
 
struct  simics::detail::is_array_of_connectbase< T >
 
struct  simics::detail::is_array_of_connectbase< std::array< T, N > >
 
struct  simics::detail::attr_from_std_helper< std::string >
 
struct  simics::detail::attr_to_std_helper< std::string >
 
struct  simics::detail::attr_from_std_helper< const char * >
 
struct  simics::detail::attr_to_std_helper< const char * >
 
struct  simics::detail::attr_from_std_helper< bool >
 
struct  simics::detail::attr_to_std_helper< bool >
 
struct  simics::detail::attr_from_std_helper< attr_value_t >
 
struct  simics::detail::attr_to_std_helper< attr_value_t >
 
struct  simics::detail::attr_from_std_helper< std::array< V, N > >
 
struct  simics::detail::attr_from_std_helper< V[N]>
 
struct  simics::detail::attr_from_std_helper< char[N]>
 
struct  simics::detail::attr_from_std_helper< std::vector< V > >
 
struct  simics::detail::attr_from_std_helper< std::list< V > >
 
struct  simics::detail::attr_from_std_helper< std::deque< V > >
 
struct  simics::detail::attr_from_std_helper< std::set< V > >
 
struct  simics::detail::attr_from_std_helper< std::pair< X, Y > >
 
struct  simics::detail::attr_from_std_helper< std::map< X, Y > >
 
struct  simics::detail::attr_from_std_helper< std::tuple< Args... > >
 
struct  simics::detail::attr_to_std_helper< std::vector< V > >
 
struct  simics::detail::attr_to_std_helper< std::list< V > >
 
struct  simics::detail::attr_to_std_helper< std::deque< V > >
 
struct  simics::detail::attr_to_std_helper< std::set< V > >
 
struct  simics::detail::attr_to_std_helper< std::array< V, N > >
 
struct  simics::detail::attr_to_std_helper< std::pair< X, Y > >
 
struct  simics::detail::attr_to_std_helper< std::map< X, Y > >
 
struct  simics::detail::attr_to_std_helper< std::tuple< Args... > >
 
struct  simics::detail::attr_from_std_helper< data_attribute >
 
struct  simics::detail::attr_to_std_helper< data_attribute >
 

Namespaces

namespace  simics
 
namespace  simics::detail
 

Macros

#define _STD2ATTR_INT_HELPER(type)
 
#define _STD2ATTR_UINT_HELPER(type)
 
#define _ATTR2STD_INT_HELPER(type)
 
#define _ATTR2STD_UINT_HELPER(type)
 
#define _STD2ATTR_FLOAT_HELPER(type)
 
#define _ATTR2STD_FLOAT_HELPER(type)
 

Typedefs

using simics::detail::data_attribute = std::vector< uint8 >
 

Functions

void simics::checkSizeOverflowSimicsAttribute (size_t size)
 The maximum supported size for a Simics attribute dictionary/list/data is 2**32-1 bytes.
 
template<typename T >
std::enable_if< std::is_enum< T >::value, attr_value_t >::type simics::std_to_attr (const T &src)
 Function transforms C++ enum type T to Simics attr_value_t.
 
template<typename T >
std::enable_if< std::is_base_of< ConnectBase, T >::value, attr_value_t >::type simics::std_to_attr (const T &src)
 Function transforms C++ ConnectBase type T to Simics attr_value_t.
 
template<typename T >
std::enable_if< std::is_pointer< T >::value, attr_value_t >::type simics::std_to_attr (const T &src)
 Function transforms C++ pointer type T to Simics attr_value_t.
 
template<typename T >
std::enable_if<!std::is_enum< T >::value &&!std::is_base_of< ConnectBase, T >::value &&!std::is_pointer< T >::value, attr_value_t >::type simics::std_to_attr (const T &src)
 Function transforms C++ standard type T to Simics attr_value_t.
 
template<typename T >
std::enable_if< std::is_enum< T >::value, T >::type simics::attr_to_std (attr_value_t src)
 Function transforms Simics attr_value_t to C++ enum type.
 
template<typename T >
std::enable_if< std::is_base_of< ConnectBase, T >::value, T >::type simics::attr_to_std (attr_value_t src)
 Function transforms Simics attr_value_t to C++ ConnectBase derived type.
 
template<typename T >
std::enable_if< std::is_pointer< T >::value, T >::type simics::attr_to_std (attr_value_t src)
 Function transforms Simics attr_value_t to C++ pointer.
 
template<typename T >
std::enable_if<!std::is_enum< T >::value &&!std::is_base_of< ConnectBase, T >::value &&!std::is_pointer< T >::value, T >::type simics::attr_to_std (attr_value_t src)
 Function transforms Simics attr_value_t to C++ standard type.
 
template<typename C , typename T = typename C::value_type>
attr_value_t simics::detail::from_container (const C &src)
 
template<typename C , typename T = typename C::value_type>
simics::detail::to_container (const attr_value_t &src)
 

Macro Definition Documentation

◆ _ATTR2STD_FLOAT_HELPER

#define _ATTR2STD_FLOAT_HELPER (   type)
Value:
template <> \
struct attr_to_std_helper<type> { \
static type f(const attr_value_t &src) { \
if (!SIM_attr_is_floating(src)) { \
throw SetIllegalType { \
"Expected Simics floating type" \
}; \
} \
return (type) SIM_attr_floating(src); \
} \
};

◆ _ATTR2STD_INT_HELPER

#define _ATTR2STD_INT_HELPER (   type)
Value:
template <> \
struct attr_to_std_helper<type> { \
static type f(const attr_value_t &src) { \
if (!SIM_attr_is_integer(src)) { \
throw SetIllegalType { \
"Expected Simics integer type" \
}; \
} \
intmax_t i = SIM_attr_integer(src); \
if (sizeof(type) != 8 \
&& (i > (std::numeric_limits<type>::max)() \
|| i < (std::numeric_limits<type>::min)())) { \
throw SetIllegalValue { \
"Value does not fit in type" \
}; \
} \
return (type) i; \
} \
};

◆ _ATTR2STD_UINT_HELPER

#define _ATTR2STD_UINT_HELPER (   type)
Value:
template <> \
struct attr_to_std_helper<type> { \
static type f(const attr_value_t &src) { \
if (!SIM_attr_is_integer(src)) { \
throw SetIllegalType { \
"Expected Simics integer type" \
}; \
} \
uintmax_t i = static_cast<uintmax_t>( \
SIM_attr_integer(src)); \
if (sizeof(type) != 8 \
&& i > (std::numeric_limits<type>::max)()) { \
throw SetIllegalValue { \
"Value does not fit in type" \
}; \
} \
return (type) i; \
} \
};

◆ _STD2ATTR_FLOAT_HELPER

#define _STD2ATTR_FLOAT_HELPER (   type)
Value:
template <> \
struct attr_from_std_helper<type> { \
static attr_value_t f(const type &src) { \
return SIM_make_attr_floating(src); \
} \
};

◆ _STD2ATTR_INT_HELPER

#define _STD2ATTR_INT_HELPER (   type)
Value:
template <> \
struct attr_from_std_helper<type> { \
static attr_value_t f(const type &src) { \
return SIM_make_attr_int64(src); \
} \
};

◆ _STD2ATTR_UINT_HELPER

#define _STD2ATTR_UINT_HELPER (   type)
Value:
template <> \
struct attr_from_std_helper<type> { \
static attr_value_t f(const type &src) { \
return SIM_make_attr_uint64(src); \
} \
};