By properly implementing the table interface, less object specific code is needed to provide the data to the user. Generic Simics commands (associated with the table interface) allows the data to sorted on the desired column and printed in a uniform way. Similarly, the data can be exported to a comma separated value (.csv) file, making it possible to process the result in a spreadsheet program.
The data() method returns the data as an
attr_value_t
array where the outer list contains each row and
the inner list contains the columns for that row. The number of columns in
each row must be exactly the same. The data only holds the actual data, not
the headers for each column, which instead is specified in the
properties() method. The data can be unsorted, it is up to the
user of the interface to sort it in a suitable way.
The data itself is sufficient for producing a table, but to customize the table layout the properties method can return hints on how the table should be presented more in detail. For example, specifying which column the table should be sorted on by default, or if a column preferably should be printed with hexadecimal numbers instead of decimals. In addition, the properties also contains the name of the columns as well as additional meta-data such as what each column represents, or what the entire table represents.
The properties also returns an attr_value_t
type
as a list of key/value pairs. Thus, each list-entry should be exactly
two elements long, but the value part can itself be a new list of key/value
pairs for some keys.
The table property keys are of table_key_t
type:
typedef enum { /* Table property keys */ Table_Key_Name = 1, Table_Key_Description, Table_Key_Default_Sort_Column, Table_Key_Columns, Table_Key_Extra_Headers, Table_Key_Stream_Header_Repeat, /* Additional properties might be added in the future. Thus, unknown values should be silently ignored. */ } table_key_t;
This is the definition for each table property:
Table_Key_Name
StringTable_Key_Description
StringTable_Key_Default_Sort_Column
StringTable_Key_Extra_Headers
List of additional header
rows
The format is: list of additional header rows, each identified as a
Extra_Header_Key_Row
.
Each row is defined by a list of the header-elements where each element
is a list of the header's key/value pair properties.
The header property keys are of extra_header_key_t
type,
this is the definition for each extra header property:
typedef enum { /* Header property keys */ Extra_Header_Key_Row = 2000, Extra_Header_Key_Name, Extra_Header_Key_Description, Extra_Header_Key_First_Column, Extra_Header_Key_Last_Column, } extra_header_key_t;
Extra_Header_Key_Row
List of header elementsExtra_Header_Key_Name
StringExtra_Header_Key_Description
StringExtra_Header_Key_First_Column
StringExtra_Header_Key_Last_Column
StringExtra_Header_Key_First_Column
and
Extra_Header_Key_Last_Column
are set, the header will span the
entire table, even if additional columns has been added by the system. In
all other cases first/last column always needs to be specified.
Table_Key_Columns
List of columns, with key/value pairs
The column property keys are of column_key_t
type:
typedef enum { /* Column property keys */ Column_Key_Name = 1000, /* Other number series than table-keys */ Column_Key_Description, Column_Key_Alignment, Column_Key_Int_Radix, Column_Key_Float_Percent, Column_Key_Float_Decimals, Column_Key_Sort_Descending, Column_Key_Hide_Homogeneous, Column_Key_Generate_Percent_Column, Column_Key_Generate_Acc_Percent_Column, Column_Key_Footer_Sum, Column_Key_Footer_Mean, Column_Key_Int_Grouping, Column_Key_Int_Pad_Width, Column_Key_Metric_Prefix, Column_Key_Binary_Prefix, Column_Key_Time_Format, Column_Key_Unique_Id, Column_Key_Width, Column_Key_Word_Delimiters, /* Additional properties might be added in the future. Thus, unknown values should be silently ignored. */ } column_key_t;
This is the definition for each column property:
Column_Key_Name
StringColumn_Key_Description
StringColumn_Key_Alignment
String: ["left", "right", "center"]
Column_Key_Word_Delimiters
String" -_:,."
.Column_Key_Int_Radix
Integer: [2,10,16]]Column_Key_Int_Grouping
BooleanColumn_Key_Pad_Width
IntegerColumn_Key_Float_Percent
BooleanColumn_Key_Float_Decimals
IntegerColumn_Key_Metric_Prefix
StringColumn_Key_Binary_Prefix
StringColumn_Key_Time_Format
BooleanHH:MM:SS.ss
,
where only the used parts are shown.
The number of seconds decimals formatted is can be controlled by
Column_Key_Float_Decimals
property.
To compact the width, decimals are dropped when hours are displayed.
Column_Key_Unique_Id
StringColumn_Key_Sort_Descending
BooleanColumn_Key_Hide_Homogeneous
Integer/Float/StringColumn_Key_Generate_Percent_Column
List of key/value pairs for new column.Column_Key_Generate_Acc_Percent_Column
List of key/value pairs for new column.SIM_INTERFACE(table) { /* Returns all rows and columns in the following format: [[[i|f|s|o|n*]*]] where the outer list is the row and the inner list is the data for each column. */ attr_value_t (*data)(conf_object_t *obj); /* Defines the table structure and meta-data for the table using a list of key/value pairs. [[[ia]*]*] where the integer is the key taken from the table_properties_t. The value is key-specific. */ attr_value_t (*properties)(conf_object_t *obj); }; #define TABLE_INTERFACE "table"