Sane C++ Libraries
C++ Platform Abstraction Libraries
SC::Reflection::TypeInfo Struct Reference

[reflectionSnippet3] More...

#include <Reflection.h>

Classes

struct  ArrayInfo
 Holds extended type info for array-like types. More...
 
struct  EmptyInfo
 Holds no extended type info. More...
 
struct  MemberInfo
 Holds extended type info for members of struct. More...
 
struct  StructInfo
 Holds extended type info for structs. More...
 

Public Member Functions

constexpr TypeInfo ()
 [reflectionSnippet4] More...
 
constexpr TypeInfo (TypeCategory type, uint16_t sizeInBytes, StructInfo structInfo)
 Constructs a TypeInfo used by Struct Types. More...
 
constexpr TypeInfo (TypeCategory type, uint16_t sizeInBytes, MemberInfo member)
 Constructs a TypeInfo used by Struct Members (children of Struct Type) More...
 
constexpr TypeInfo (TypeCategory type, uint16_t sizeInBytes, uint8_t numberOfChildren, ArrayInfo arrayInfo)
 Constructs a TypeInfo used by Array-like Types (T[N], Array<T, N> and Vector<T>) More...
 
constexpr TypeInfo (TypeCategory type, uint16_t sizeInBytes)
 Constructs a TypeInfo of given type and size. More...
 
constexpr auto getNumberOfChildren () const
 Get number of children (if any) of this info. Only valid when hasLink == false More...
 
constexpr bool setNumberOfChildren (size_t numChildren)
 Sets the number of children of this typeinfo. More...
 
constexpr bool hasValidLinkIndex () const
 Check if this type info has a valid link index. More...
 
constexpr bool needsLinking () const
 Check if this type info needs to be linked. More...
 
constexpr auto getLinkIndex () const
 Obtains link valid index (assuming hasLink == true and needsLinking() == false) More...
 
constexpr bool setLinkIndex (ssize_t newLinkIndex)
 Change Link index for this type. More...
 
constexpr bool isPrimitiveType () const
 Check if type is primitive. More...
 
constexpr bool isPrimitiveOrPackedStruct () const
 Check if type is primitive or it's a struct with isPacked property == true More...
 

Static Public Member Functions

static constexpr bool isPrimitiveCategory (TypeCategory category)
 

Public Attributes

bool hasLink: 1
 Contains a link to another type. More...
 
TypeCategory type: 7
 Type of typeinfo. More...
 
union {
   uint8_t   numberOfChildren
 Only valid when TypeInfo::hasLink == false More...
 
   uint8_t   linkIndex
 Only valid when TypeInfo::hasLink == true More...
 
}; 
 
uint16_t sizeInBytes
 Size in bytes of the described type. More...
 
union {
   EmptyInfo   emptyInfo
 
   MemberInfo   memberInfo
 
   StructInfo   structInfo
 
   ArrayInfo   arrayInfo
 
}; 
 

Detailed Description

[reflectionSnippet3]

A single 8 bytes union holding most important information about a reflected type This structure is expected to be stored in an flat array. Children items are always following parent items in the flat array. For example when a struct is defined, its members are defined as its children. When one of these children is simple primitive type, this type is stored inline with the type itself. When instead a complex type is needed, a linkID is provided. Such link is as offset in the flat array where detailed definition of the complex type exists. [reflectionSnippet4]

Constructor & Destructor Documentation

◆ TypeInfo() [1/5]

constexpr SC::Reflection::TypeInfo::TypeInfo ( )
inlineconstexpr

[reflectionSnippet4]

Constructs an invalid type info.

◆ TypeInfo() [2/5]

constexpr SC::Reflection::TypeInfo::TypeInfo ( TypeCategory  type,
uint16_t  sizeInBytes,
StructInfo  structInfo 
)
inlineconstexpr

Constructs a TypeInfo used by Struct Types.

◆ TypeInfo() [3/5]

constexpr SC::Reflection::TypeInfo::TypeInfo ( TypeCategory  type,
uint16_t  sizeInBytes,
MemberInfo  member 
)
inlineconstexpr

Constructs a TypeInfo used by Struct Members (children of Struct Type)

◆ TypeInfo() [4/5]

constexpr SC::Reflection::TypeInfo::TypeInfo ( TypeCategory  type,
uint16_t  sizeInBytes,
uint8_t  numberOfChildren,
ArrayInfo  arrayInfo 
)
inlineconstexpr

Constructs a TypeInfo used by Array-like Types (T[N], Array<T, N> and Vector<T>)

◆ TypeInfo() [5/5]

constexpr SC::Reflection::TypeInfo::TypeInfo ( TypeCategory  type,
uint16_t  sizeInBytes 
)
inlineconstexpr

Constructs a TypeInfo of given type and size.

Member Function Documentation

◆ getLinkIndex()

constexpr auto SC::Reflection::TypeInfo::getLinkIndex ( ) const
inlineconstexpr

Obtains link valid index (assuming hasLink == true and needsLinking() == false)

Returns
The link index for this type that indicates the linked type

◆ getNumberOfChildren()

constexpr auto SC::Reflection::TypeInfo::getNumberOfChildren ( ) const
inlineconstexpr

Get number of children (if any) of this info. Only valid when hasLink == false

◆ hasValidLinkIndex()

constexpr bool SC::Reflection::TypeInfo::hasValidLinkIndex ( ) const
inlineconstexpr

Check if this type info has a valid link index.

◆ isPrimitiveOrPackedStruct()

constexpr bool SC::Reflection::TypeInfo::isPrimitiveOrPackedStruct ( ) const
inlineconstexpr

Check if type is primitive or it's a struct with isPacked property == true

◆ isPrimitiveType()

constexpr bool SC::Reflection::TypeInfo::isPrimitiveType ( ) const
inlineconstexpr

Check if type is primitive.

◆ needsLinking()

constexpr bool SC::Reflection::TypeInfo::needsLinking ( ) const
inlineconstexpr

Check if this type info needs to be linked.

◆ setLinkIndex()

constexpr bool SC::Reflection::TypeInfo::setLinkIndex ( ssize_t  newLinkIndex)
inlineconstexpr

Change Link index for this type.

Parameters
newLinkIndexNew Link Index
Returns
true if the link index has been changed successfully

◆ setNumberOfChildren()

constexpr bool SC::Reflection::TypeInfo::setNumberOfChildren ( size_t  numChildren)
inlineconstexpr

Sets the number of children of this typeinfo.

Parameters
numChildrenNew number of children
Returns
true if it has been changed successfully

Member Data Documentation

◆ hasLink

bool SC::Reflection::TypeInfo::hasLink

Contains a link to another type.

◆ linkIndex

uint8_t SC::Reflection::TypeInfo::linkIndex

Only valid when TypeInfo::hasLink == true

◆ numberOfChildren

uint8_t SC::Reflection::TypeInfo::numberOfChildren

Only valid when TypeInfo::hasLink == false

◆ sizeInBytes

uint16_t SC::Reflection::TypeInfo::sizeInBytes

Size in bytes of the described type.

◆ type

TypeCategory SC::Reflection::TypeInfo::type

Type of typeinfo.


The documentation for this struct was generated from the following file: