TEMU  2
The Terma Emulator
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Objsys.h File Reference
#include "temu-c/Support/Attributes.h"
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
Include dependency graph for Objsys.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  temu_Buff
 
struct  temu_Object
 
struct  temu_IfaceRef
 
struct  temu_IfaceRefArray
 
struct  temu_Propref
 
struct  temu_PropName
 
struct  temu_Vector
 
struct  temu_List
 
struct  temu_Propval
 
struct  temu_CreateArg
 
struct  temu_PropInfo
 
struct  temu_ObjectIface
 

Macros

#define TEMU_PLUGIN_INIT   void temu_pluginInit(void)
 
#define TEMU_NO_WRAP
 
#define TEMU_BUFF_DEFINED
 
#define TEMU_COMPONENT_DEFINED
 
#define temu_Object_   void
 
#define TEMU_IFACE_REFERENCE_TYPE(N)
 
#define TEMU_DYN_ARRAY_TYPE(T, P)
 
#define PROP_ASSERT(p, t)
 
#define PROP_VAL_INITIALIZER(typ, suffix, typetag, valtag)
 
#define TEMU_NULL_ARG
 
#define TEMU_QUAL_NONE   0
 
#define TEMU_QUAL_CPU   1
 
#define TEMU_QUAL_MACHINE   2
 
#define TEMU_QUAL_EXTERNAL   3
 
#define TEMU_QUAL_MEMORY   4
 
#define TEMU_QUAL_COMPONENT   5
 
#define TEMU_QUAL_CLOCK   6
 
#define TEMU_QUAL_USER   65536
 
#define TEMU_OBJECT_IFACE_TYPE   "ObjectIface"
 

Typedefs

typedef struct temu_Component temu_Component
 
typedef void temu_Class
 
typedef void temu_MetaIface
 
typedef struct temu_IfaceRef temu_IfaceRef
 
typedef struct temu_IfaceRefArray temu_IfaceRefArray
 
typedef enum temu_Type temu_Type
 
typedef struct temu_Propref temu_Propref
 
typedef void temu_Dict
 
typedef void temu_ListNode
 
typedef struct temu_Propval temu_Propval
 
typedef void(* temu_PropWriter )(void *Obj, temu_Propval Pv, int Idx)
 
typedef temu_Propval(* temu_PropReader )(void *Obj, int Idx)
 
typedef struct temu_CreateArg temu_CreateArg
 
typedef void *(* temu_ObjectCreateFunc )(const char *Name, int Argc, const temu_CreateArg *Argv)
 
typedef void(* temu_ObjectDisposeFunc )(void *)
 

Enumerations

enum  temu_Type {
  teTY_Invalid, teTY_Intptr, teTY_Uintptr, teTY_Float,
  teTY_Double, teTY_U8, teTY_U16, teTY_U32,
  teTY_U64, teTY_I8, teTY_I16, teTY_I32,
  teTY_I64, teTY_Obj, teTY_InternalPtr, teTY_IfaceRef,
  teTY_IfaceRefArray, teTY_String, teTY_Buffer, teTY_Dict,
  teTY_Vector, teTY_List
}
 

Functions

TEMU_API temu_IfaceRefArray temu_ifaceRefArrayAlloc (unsigned Reserve)
 
TEMU_API void temu_ifaceRefArrayPush2 (temu_IfaceRefArray *Arr TEMU_NONNULL, void *Obj TEMU_NONNULL, void *Iface TEMU_NONNULL)
 
TEMU_API void temu_ifaceRefArrayPush (temu_IfaceRefArray *Arr TEMU_NONNULL, temu_IfaceRef Iface)
 
TEMU_API unsigned temu_ifaceRefArraySize (temu_IfaceRefArray *Arr)
 
TEMU_API void temu_ifaceRefArrayDispose (temu_IfaceRefArray *Arr)
 
TEMU_API temu_Dicttemu_dictCreate (void)
 
TEMU_API void temu_dictDispose (temu_Dict *Dict)
 
TEMU_API int temu_dictInsertValue (temu_Dict *Dict, const char *Name, temu_Propval Val)
 
TEMU_API temu_Propval temu_dictGetValue (temu_Dict *Dict, const char *Name)
 
TEMU_API int temu_dictRemoveValue (temu_Dict *Dict, const char *Name)
 
TEMU_API const char * temu_dictGetNextKey (temu_Dict *Dict, const char *Key)
 
TEMU_API temu_Vector temu_vecCreate (temu_Type Typ)
 
TEMU_API void temu_vecDispose (temu_Vector *Vec)
 
TEMU_API void temu_vecPush (temu_Vector *Vec, temu_Propval Val)
 
TEMU_API void * temu_vecGetData (temu_Vector *Vec)
 
TEMU_API size_t temu_vecGetSize (temu_Vector *Vec)
 
TEMU_API temu_List temu_listCreate (temu_Type Typ)
 
TEMU_API void temu_listDispose (temu_List *List)
 
TEMU_API void temu_listAppend (temu_List *List, temu_Propval Val)
 
TEMU_API void temu_listPrepend (temu_List *List, temu_Propval Val)
 
TEMU_API temu_Propval temu_listRemoveHead (temu_List *List)
 
TEMU_API temu_Propval temu_listRemoveTail (temu_List *List)
 
TEMU_API temu_ListNodetemu_listGetHead (temu_List *List)
 
TEMU_API temu_ListNodetemu_listGetTail (temu_List *List)
 
TEMU_API temu_ListNodetemu_listGetNext (temu_ListNode *Node)
 
TEMU_API temu_ListNodetemu_listGetPrev (temu_ListNode *Node)
 
TEMU_API temu_Propval temu_listNodeGetVal (temu_ListNode *Node)
 
TEMU_API temu_Propref temu_getPropref (const void *Obj, const char *PropName)
 
TEMU_API temu_PropName temu_getPropName (const void *Obj, const char *PropName)
 
TEMU_API int temu_getPropLength (const void *Obj, const char *PropName)
 
TEMU_API int temu_getPropDynLength (const void *Obj, const char *PropName)
 
TEMU_API temu_Type temu_getPropType (const void *Obj, const char *PropName)
 
TEMU_API int temu_objectHasProp (const void *Obj, const char *PropName)
 
TEMU_API int temu_objectHasIface (const void *Obj, const char *IfaceName)
 
TEMU_API int temu_isNumber (temu_Propval Pv)
 
TEMU_API int temu_isReal (temu_Propval Pv)
 
TEMU_API int temu_isDiscrete (temu_Propval Pv)
 
TEMU_API int temu_isUnsigned (temu_Propval Pv)
 
TEMU_API int temu_isSigned (temu_Propval Pv)
 
TEMU_API int temu_isString (temu_Propval Pv)
 
TEMU_API int64_t temu_asInteger (temu_Propval Pv)
 
TEMU_API uint64_t temu_asUnsigned (temu_Propval Pv)
 
TEMU_API double temu_asDouble (temu_Propval Pv)
 
TEMU_API temu_Propval temu_getValue (void *Obj, const char *PropName, int Idx) TEMU_NO_WRAP
 
TEMU_API uint8_t temu_getValueU8 (void *Obj, const char *PropName, int Idx)
 
TEMU_API uint16_t temu_getValueU16 (void *Obj, const char *PropName, int Idx)
 
TEMU_API uint32_t temu_getValueU32 (void *Obj, const char *PropName, int Idx)
 
TEMU_API uint64_t temu_getValueU64 (void *Obj, const char *PropName, int Idx)
 
TEMU_API int8_t temu_getValueI8 (void *Obj, const char *PropName, int Idx)
 
TEMU_API int16_t temu_getValueI16 (void *Obj, const char *PropName, int Idx)
 
TEMU_API int32_t temu_getValueI32 (void *Obj, const char *PropName, int Idx)
 
TEMU_API int64_t temu_getValueI64 (void *Obj, const char *PropName, int Idx)
 
TEMU_API temu_Propval temu_readValue (void *Obj, const char *PropName, int Idx) TEMU_NO_WRAP
 
TEMU_API uint8_t temu_readValueU8 (void *Obj, const char *PropName, int Idx)
 
TEMU_API uint16_t temu_readValueU16 (void *Obj, const char *PropName, int Idx)
 
TEMU_API uint32_t temu_readValueU32 (void *Obj, const char *PropName, int Idx)
 
TEMU_API uint64_t temu_readValueU64 (void *Obj, const char *PropName, int Idx)
 
TEMU_API int8_t temu_readValueI8 (void *Obj, const char *PropName, int Idx)
 
TEMU_API int16_t temu_readValueI16 (void *Obj, const char *PropName, int Idx)
 
TEMU_API int32_t temu_readValueI32 (void *Obj, const char *PropName, int Idx)
 
TEMU_API int64_t temu_readValueI64 (void *Obj, const char *PropName, int Idx)
 
TEMU_API void temu_setValue (void *Obj, const char *PropName, temu_Propval Val, int Idx) TEMU_NO_WRAP
 
TEMU_API void temu_setValueU8 (void *Obj, const char *PropName, uint8_t Val, int Idx)
 
TEMU_API void temu_setValueU16 (void *Obj, const char *PropName, uint16_t Val, int Idx)
 
TEMU_API void temu_setValueU32 (void *Obj, const char *PropName, uint32_t Val, int Idx)
 
TEMU_API void temu_setValueU64 (void *Obj, const char *PropName, uint64_t Val, int Idx)
 
TEMU_API void temu_setValueI8 (void *Obj, const char *PropName, int8_t Val, int Idx)
 
TEMU_API void temu_setValueI16 (void *Obj, const char *PropName, int16_t Val, int Idx)
 
TEMU_API void temu_setValueI32 (void *Obj, const char *PropName, int32_t Val, int Idx)
 
TEMU_API void temu_setValueI64 (void *Obj, const char *PropName, int64_t Val, int Idx)
 
TEMU_API void temu_writeValue (void *Obj, const char *PropName, temu_Propval Val, int Idx) TEMU_NO_WRAP
 
TEMU_API void temu_writeValueU8 (void *Obj, const char *PropName, uint8_t Val, int Idx)
 
TEMU_API void temu_writeValueU16 (void *Obj, const char *PropName, uint16_t Val, int Idx)
 
TEMU_API void temu_writeValueU32 (void *Obj, const char *PropName, uint32_t Val, int Idx)
 
TEMU_API void temu_writeValueU64 (void *Obj, const char *PropName, uint64_t Val, int Idx)
 
TEMU_API void temu_writeValueI8 (void *Obj, const char *PropName, int8_t Val, int Idx)
 
TEMU_API void temu_writeValueI16 (void *Obj, const char *PropName, int16_t Val, int Idx)
 
TEMU_API void temu_writeValueI32 (void *Obj, const char *PropName, int32_t Val, int Idx)
 
TEMU_API void temu_writeValueI64 (void *Obj, const char *PropName, int64_t Val, int Idx)
 
TEMU_API temu_Propval temu_getNamedObjectProp (const char *Obj, const char *PropName, int Idx) TEMU_NO_WRAP TEMU_DEPRECATED
 
TEMU_API temu_Propval temu_readNamedObjectProp (const char *Obj, const char *PropName, int Idx) TEMU_NO_WRAP TEMU_DEPRECATED
 
TEMU_API void temu_setNamedObjectProp (const char *Obj, const char *PropName, temu_Propval Val, int Idx) TEMU_NO_WRAP TEMU_DEPRECATED
 
TEMU_API void temu_writeNamedObjectProp (const char *Obj, const char *PropName, temu_Propval Val, int Idx) TEMU_NO_WRAP TEMU_DEPRECATED
 
TEMU_API temu_Classtemu_registerClass (const char *ClsName, temu_ObjectCreateFunc Create, temu_ObjectDisposeFunc Dispose)
 
TEMU_API temu_Classtemu_registerExternalClass (const char *ClsName) TEMU_DEPRECATED
 
TEMU_API void temu_addProperty (temu_Class *Cls, const char *PropName, int Offset, temu_Type Typ, int Count, temu_PropWriter Wr, temu_PropReader Rd, const char *Doc)
 
TEMU_API void temu_addPseudoProperty (temu_Class *Cls, const char *PropName, temu_Type Typ, int Count, temu_PropWriter Wr, temu_PropReader Rd, temu_PropWriter Set, temu_PropReader Get, const char *Doc)
 
TEMU_API int temu_addLoggingCategory (temu_Class *Cls, unsigned CategoryId, const char *Category)
 
TEMU_API const char * temu_getLoggingCategory (temu_Class *Cls, unsigned CategoryId)
 
TEMU_API int temu_isPseudoProperty (void *Obj, const char *PropName)
 
TEMU_API int temu_isNormalProperty (void *Obj, const char *PropName)
 
TEMU_API void temu_requireInterface (temu_Class *Cls, const char *PropName, const char *IfaceType)
 
TEMU_API int temu_addPort (temu_Class *C, const char *IfaceRefName, const char *IfaceName, const char *Doc)
 
TEMU_API void temu_addInterface (temu_Class *Cls, const char *IfaceName, const char *IfaceType, void *Iface, int DeprecatedParam, const char *Doc)
 
TEMU_API void * temu_getInterface (void *Obj, const char *IfaceName, int Idx)
 
TEMU_API temu_IfaceRef temu_getInterfaceRef (void *Obj, const char *IfaceName, int Idx)
 
TEMU_API void temu_addInterfaceArray (temu_Class *Cls, const char *IfaceName, const char *IfaceType, void *Iface, size_t Count, size_t Size, const char *Doc)
 
TEMU_API int temu_setVTable (temu_Class *Cls, void *VTable)
 
TEMU_API void * temu_getVTableForClass (temu_Class *Cls)
 
TEMU_API void * temu_getVTable (const void *Obj)
 
TEMU_API void temu_setTimeSource (void *Obj, void *TS)
 
TEMU_API int temu_isExternal (const void *Obj) TEMU_DEPRECATED
 
TEMU_API int temu_isQualifiedAs (const void *Obj, unsigned Qualifier)
 
TEMU_API int temu_isCpu (const void *Obj)
 
TEMU_API int temu_isMachine (const void *Obj)
 
TEMU_API int temu_isMemory (const void *Obj)
 
TEMU_API int temu_isComponent (const void *Obj)
 
TEMU_API void temu_qualifyAsCpu (void *Cls)
 
TEMU_API void temu_qualifyAsMachine (void *Cls)
 
TEMU_API void temu_qualifyAsMemory (void *Cls)
 
TEMU_API void temu_qualifyAs (void *Cls, unsigned Qualifier)
 
TEMU_API void temu_objsysClear (void)
 
TEMU_API void temu_objsysClearObjects (void)
 
TEMU_API void * temu_addObject (const char *ClsName, const char *ObjName, void *Obj) TEMU_DEPRECATED
 
TEMU_API void * temu_createObject (const char *ClsName, const char *ObjName, const temu_CreateArg *Args)
 
TEMU_API void temu_disposeObject (void *Obj)
 
TEMU_API temu_Classtemu_classForName (const char *ClsName)
 
TEMU_API const char * temu_nameForClass (temu_Class *Cls)
 
TEMU_API temu_Classtemu_classForObject (const void *Obj)
 
TEMU_API temu_Classtemu_classForObjectName (const char *Obj) TEMU_DEPRECATED
 
TEMU_API int temu_propInfoForClass (temu_Class *Cls, unsigned PIIndex, unsigned PICount, temu_PropInfo *PI)
 
TEMU_API void * temu_objectForName (const char *Name)
 
TEMU_API const char * temu_nameForObject (const void *Obj)
 
TEMU_API const char * temu_nameForInterface (const void *Obj, const void *Iface)
 
TEMU_API const char * temu_typenameForInterface (const void *Obj, const void *Iface)
 
TEMU_API int temu_loadPlugin (const char *PluginName)
 
TEMU_API void temu_pluginPathAppend (const char *Path)
 
TEMU_API void temu_pluginPathRemove (const char *Path)
 
TEMU_API void temu_pluginPathPrint (void)
 
TEMU_API const char * temu_typeToName (temu_Type Typ)
 
TEMU_API void ** temu_getProcessors (void)
 
TEMU_API size_t temu_getProcessorCount (void)
 
TEMU_API void ** temu_getComponents (void)
 
TEMU_API size_t temu_getComponentCount (void)
 
TEMU_API int temu_connect (void *A, const char *PropName, void *B, const char *IfaceName)
 
TEMU_API int temu_serialiseJSON (const char *FileName)
 
TEMU_API int temu_deserialiseJSON (const char *FileName)
 
TEMU_API void temu_serialiseProp (void *Ctxt, const char *Name, temu_Type Typ, int Count, void *Data)
 
TEMU_API void temu_deserialiseProp (void *Ctxt, void *Obj, const char *Name)
 
TEMU_API int temu_checkpointGetLength (void *Ctxt, const char *Name)
 
TEMU_API temu_Propval temu_checkpointGetValue (void *Ctxt, const char *Name, int Idx)
 
TEMU_API int temu_checkSanity (int Report)
 
TEMU_API int temu_generateObjectGraph (const char *Path, int Display)
 
TEMU_API int temu_isValidObjectName (const char *Name)
 
TEMU_API int temu_isValidClassName (const char *Name)
 
TEMU_API int temu_isValidInterfaceName (const char *Name)
 
TEMU_API int temu_isValidPropertyName (const char *Name)
 
TEMU_API void temu_foreachObject (void(*Func)(void *, void *), void *Arg)
 
TEMU_API void temu_foreachClass (void(*Func)(temu_Class *, void *), void *Arg)
 
TEMU_API void temu_foreachProcessor (void(*Func)(temu_Object *, void *), void *Arg)
 
TEMU_API void temu_foreachProperty (temu_Class *C, void(*Func)(temu_Class *, const char *, void *), void *Arg)
 
TEMU_API void temu_foreachInterface (temu_Class *C, void(*Func)(temu_Class *, const char *, void *), void *Arg)
 

Macro Definition Documentation

#define PROP_ASSERT (   p,
 
)

Definition at line 499 of file Objsys.h.

#define PROP_VAL_INITIALIZER (   typ,
  suffix,
  typetag,
  valtag 
)
Value:
static inline temu_Propval temu_makeProp##suffix(typ val) \
{ \
pv.Typ = typetag; \
pv.valtag = val; \
return pv; \
} \
static inline typ temu_propValue##suffix(temu_Propval pv) \
{ \
PROP_ASSERT(pv.Typ, typetag); \
typ val = pv.valtag; \
return val; \
}
temu_Type Typ
Definition: Objsys.h:299
#define PROP_ASSERT(p, t)
Definition: Objsys.h:499
struct temu_Propval temu_Propval

Definition at line 506 of file Objsys.h.

#define TEMU_BUFF_DEFINED

Definition at line 45 of file Objsys.h.

#define TEMU_COMPONENT_DEFINED

Definition at line 54 of file Objsys.h.

#define TEMU_DYN_ARRAY_TYPE (   T,
 
)

Definition at line 172 of file Objsys.h.

#define TEMU_IFACE_REFERENCE_TYPE (   N)

Definition at line 129 of file Objsys.h.

#define TEMU_NO_WRAP

Definition at line 41 of file Objsys.h.

#define TEMU_NULL_ARG
Value:
{ \
NULL, { teTY_Invalid } \
}

Definition at line 1133 of file Objsys.h.

#define temu_Object_   void

Definition at line 73 of file Objsys.h.

#define TEMU_OBJECT_IFACE_TYPE   "ObjectIface"

Definition at line 1950 of file Objsys.h.

#define TEMU_PLUGIN_INIT   void temu_pluginInit(void)

Definition at line 25 of file Objsys.h.

#define TEMU_QUAL_CLOCK   6

Definition at line 1470 of file Objsys.h.

#define TEMU_QUAL_COMPONENT   5

Definition at line 1469 of file Objsys.h.

#define TEMU_QUAL_CPU   1

Definition at line 1465 of file Objsys.h.

#define TEMU_QUAL_EXTERNAL   3

Definition at line 1467 of file Objsys.h.

#define TEMU_QUAL_MACHINE   2

Definition at line 1466 of file Objsys.h.

#define TEMU_QUAL_MEMORY   4

Definition at line 1468 of file Objsys.h.

#define TEMU_QUAL_NONE   0

Definition at line 1464 of file Objsys.h.

#define TEMU_QUAL_USER   65536

Definition at line 1474 of file Objsys.h.

Typedef Documentation

typedef void temu_Class

Definition at line 58 of file Objsys.h.

Definition at line 55 of file Objsys.h.

typedef void temu_Dict

Definition at line 276 of file Objsys.h.

typedef struct temu_IfaceRef temu_IfaceRef
typedef void temu_ListNode

Definition at line 283 of file Objsys.h.

typedef void temu_MetaIface

Definition at line 59 of file Objsys.h.

typedef void*(* temu_ObjectCreateFunc)(const char *Name, int Argc, const temu_CreateArg *Argv)

Definition at line 1138 of file Objsys.h.

typedef void(* temu_ObjectDisposeFunc)(void *)

Definition at line 1140 of file Objsys.h.

typedef temu_Propval(* temu_PropReader)(void *Obj, int Idx)

A prop reader function is provided when properties are registered, it is responsible for reading the property when temu_readValue is called. The function can be used to introduce side-effects on reads unlike the getValue which will never have side-effects and only returns the raw value.

Definition at line 555 of file Objsys.h.

typedef struct temu_Propref temu_Propref

Typed property reference.

The property reference contains a type tag and a raw pointer to the property.

typedef struct temu_Propval temu_Propval

Generic property value.

As properties can be of any normal type, the propval struct provides a sum type/tagged union which contain both the type tag and the property value.

typedef void(* temu_PropWriter)(void *Obj, temu_Propval Pv, int Idx)

A prop writer function is provided when properties are registered, it is responsible for writing the property when temu_writeValue is called. The function can be used to introduce side-effects on writes unlike the setValue which will never have side-effects and only sets the raw value.

Definition at line 547 of file Objsys.h.

typedef enum temu_Type temu_Type

Enumeration Type Documentation

enum temu_Type
Enumerator
teTY_Invalid 
teTY_Intptr 
teTY_Uintptr 
teTY_Float 
teTY_Double 
teTY_U8 
teTY_U16 
teTY_U32 
teTY_U64 
teTY_I8 
teTY_I16 
teTY_I32 
teTY_I64 
teTY_Obj 
teTY_InternalPtr 
teTY_IfaceRef 
teTY_IfaceRefArray 
teTY_String 
teTY_Buffer 
teTY_Dict 
teTY_Vector 
teTY_List 

Definition at line 221 of file Objsys.h.

Function Documentation

TEMU_API void temu_addInterface ( temu_Class Cls,
const char *  IfaceName,
const char *  IfaceType,
void *  Iface,
int  DeprecatedParam,
const char *  Doc 
)

Register interface with the named class.

Parameters
Cls_nameName of class to add interface to
IfacenameInterface name
IfaceTypeInterface type
IfacePointer to the interface structure.
TEMU_API void temu_addInterfaceArray ( temu_Class Cls,
const char *  IfaceName,
const char *  IfaceType,
void *  Iface,
size_t  Count,
size_t  Size,
const char *  Doc 
)

Add an array of interfaces to a class

Interface arrays are especially useful when e.g. multiple "network ports" are available, although they can be added manually with distinct names (e.g. uartaiface, uartbiface, etc), the interface array registration allows for the addition of several interfaces at once. Individual interfaces are then referred to with normal index syntax, e.g. obj:uartiface[0].

Parameters
ClsClass pointer
IfaceNamename of interface
IfaceTypename of interface type
IfacePointer to array of interfaces
CountNumber of interfaces in array
SizeSize of one interface (e.g. sizeof(uartiface[0]))
DocDocumentation comment for interface
TEMU_API int temu_addLoggingCategory ( temu_Class Cls,
unsigned  CategoryId,
const char *  Category 
)

temu_addLogginCategory adds a logging category to the class

Parameters
Clsthe class
CategoryIdThe category id. Valid range is [8,16)
CategoryThe category name
Returns
0 for success, 1 indicates failure.
TEMU_API void* temu_addObject ( const char *  ClsName,
const char *  ObjName,
void *  Obj 
)

Add object with external class.

Note that external classes and objects have been deprecated and the function will be removed in TEMU3.

Parameters
ClsNameName of class used for instantiation
ObjNameName of object in object system
ObjThe object to add.
Returns
Obj on success, otherwise NULL.
TEMU_API int temu_addPort ( temu_Class C,
const char *  IfaceRefName,
const char *  IfaceName,
const char *  Doc 
)

Make interface reference property and an interface inverses

A port is a bidirectional interface. Thus, if an interface reference is connected to another objects interface, the remote object will be told to issue a reverse connection. This is convenient as it simplifies device connection during system configuration and construction. That is, instead of calling the connect two times with the inverse connections explicitly, only one call is needed.

Parameters
CThe class object
IfaceRefNamethe name of the interface reference property
IfaceNameName of interface that is the inverse of the interface ref property.
DocDocumentation string
Returns
0 on success, non-zero otherwise.
TEMU_API void temu_addProperty ( temu_Class Cls,
const char *  PropName,
int  Offset,
temu_Type  Typ,
int  Count,
temu_PropWriter  Wr,
temu_PropReader  Rd,
const char *  Doc 
)

Add a property to a class.

Parameters
ClsThe class object
PropNameName of the property to add.
OffsetOffset in bytes from the start of the class to the value the property refers to.
TypType of the property.
CountSet to > 1 to indicate that the property is an array, the value is the length of the array.
WrProperty write function. This function can have side-effects.
RdProperty read function. This function can have side-effects.
DocDocumentation string
TEMU_API void temu_addPseudoProperty ( temu_Class Cls,
const char *  PropName,
temu_Type  Typ,
int  Count,
temu_PropWriter  Wr,
temu_PropReader  Rd,
temu_PropWriter  Set,
temu_PropReader  Get,
const char *  Doc 
)

Add property without storage

A pseudo property does not have backing storage (and therefore no offset). They exist to provide access to computed properties.

Pseudo properties also work fine with C++ types with non-standard layout.

Pseudo properties are checkpointed if the set and get functions are implemented. The set and get should implement read and write without semantic effect. That is, if the property is a register, then the read and write should have the effect of an actual register access (including event rescheduling etc), while for a get/set, only the value of the register is modified, event restoration is done differently.

Parameters
Clsclass to add pseudo property to
PropNamename of pseudo property
TypType of property
Countnumber of elements, 1 for a scalar.
WrProperty write function (semantic effect)
RdProperty read function (semantic effect)
SetProperty set function (non-semantic)
GetProperty get function (non-semantic)
DocDocumentation string
TEMU_API double temu_asDouble ( temu_Propval  Pv)

temu_asDouble Converts the given property to double

Parameters
PvThe property to be converted
Returns
Returns the property as an unsigned integer
TEMU_API int64_t temu_asInteger ( temu_Propval  Pv)

temu_asInteger Converts the given propery to integer

Parameters
PvThe property to be converted
Returns
Returns the property as integer
TEMU_API uint64_t temu_asUnsigned ( temu_Propval  Pv)

temu_asUnsigned Converts the given property to unsigned integer

Parameters
PvThe property to be converted
Returns
Returns the property as an unsigned integer
TEMU_API int temu_checkpointGetLength ( void *  Ctxt,
const char *  Name 
)

Get number of entries for the serialised property

Parameters
CtxtContext passed to deserialise function
NameName of property / key in the serialised file
Returns
Length of the property in elements. Negative on error.
TEMU_API temu_Propval temu_checkpointGetValue ( void *  Ctxt,
const char *  Name,
int  Idx 
)

Get value for named checkpoint value

Parameters
CtxtContext is passed to deserialise interface function
NameName of the saved value
IdxIndex of the saved value (if array)
Returns
Property value with the contents saved to the checkpoint
TEMU_API int temu_checkSanity ( int  Report)

Check object system sanity.

The function traverses all objects and their properties and ensures that all (scalar) interface properties are connected. An object can override the default check by implementing the checkSanity function in the ObjectIface.

Parameters
Reportset to 1 to have the function report connectivity issues on stdout, 2 to report on stderr, and 0 to not report at all.
Returns
Returns 0 if the object system is connected. Returns non-zero if the object system is not properly connected.
TEMU_API temu_Class* temu_classForName ( const char *  ClsName)

Get the class pointer for the named class temu_classForName

Parameters
ClsNameThe name of the class
Returns
Pointer to the class if found, otherwise NULL
TEMU_API temu_Class* temu_classForObject ( const void *  Obj)

Get the class for the given object.

Parameters
ObjPointer to the object
Returns
Pointer to the class type object
TEMU_API temu_Class* temu_classForObjectName ( const char *  Obj)

Get class for named object

Parameters
ObjPointer to the object
Returns
Pointer to the class type object
TEMU_API int temu_connect ( void *  A,
const char *  PropName,
void *  B,
const char *  IfaceName 
)

Connect an interface property in object A to the interface in object B. If A.PropName is an interface array, B,B:IfaceName will be appended to it. For dynamic arrays, it is pushed to the end, for static arrays, it is placed in the first null slot (unless, the indexing syntax is used in the property name).

Parameters
AThe object to connect.
PropNameThe name of the property in object A
BThe object to connect to.
IfaceNameThe name of the interface in object B
Returns
0 on success, otherwise non-zero
TEMU_API void* temu_createObject ( const char *  ClsName,
const char *  ObjName,
const temu_CreateArg Args 
)

Create object with class and name.

Parameters
ClsNameName of class used for instantiation
ObjNameName of object in object system
ArgsNamed argument pairs to pass into constructor. The list of args should be terminated by a TEMU_NULL_ARG. In case no arguments are passed, pass in NULL.
Returns
Allocated object. Result is NULL in case of: class does not exist, object already allocated with the given name, out of memory.
TEMU_API int temu_deserialiseJSON ( const char *  FileName)

De-serialise the simulation state.

The function clears the whole internal object system, reads the JSON file FileName and creates all the objects.

If a class implements the ObjectIface, the (optional) deserialise procedure will be called.

Parameters
FileNameThe filename that contains the JSON data
Returns
0 on success, otherwise non-zero
TEMU_API void temu_deserialiseProp ( void *  Ctxt,
void *  Obj,
const char *  Name 
)

temu_deserialiseProp Deserialize a serialized property

Parameters
CtxtAn opaque context, this is the same context as is passed to the deserialise interface function.
ObjObject being deserialised
NameThe name of the property
TEMU_API temu_Dict* temu_dictCreate ( void  )

temu_dictCreate Creates a dictionary object

Returns
A pointer to the dictionary object
TEMU_API void temu_dictDispose ( temu_Dict Dict)

temu_dictDispose Delete a dictionary object

Parameters
DictPointer to the dictionary object to be deleted
TEMU_API const char* temu_dictGetNextKey ( temu_Dict Dict,
const char *  Key 
)

temu_dictGetNextKey Given a specific key of a dictionary, the next key is provided by this function

Parameters
DictThe dictionary that contains the keys
KeyThe key, whose next value in the dict to be provided
Returns
The key that comes after Key, or nullptr on failure
TEMU_API temu_Propval temu_dictGetValue ( temu_Dict Dict,
const char *  Name 
)

temu_dictGetValue retrieve a dictionary value by name

Parameters
DictPointer to the dictionary object
NameThe name associated with the value to be retrieved
Returns
The value
TEMU_API int temu_dictInsertValue ( temu_Dict Dict,
const char *  Name,
temu_Propval  Val 
)

temu_dictInsertValue Inserts a name/value pair to a dictionary

Parameters
DictPointer to the dictionary object
NameThe name to be inserted
ValThe value to be inserted
Returns
0 on success. Other values indicate failures (e.g. the key is already used)
TEMU_API int temu_dictRemoveValue ( temu_Dict Dict,
const char *  Name 
)

temu_dictRemoveValue Erase a name/value pair from a dictionary by name

Parameters
DictPointer to the dictionary object
NameThe name of the pair to be removed
Returns
0 on success. Other values indicate errors (e.g. key was unavailable in the dictionary)
TEMU_API void temu_disposeObject ( void *  Obj)

Dispose object. The function will call the Objects dispose function.

Parameters
ObjThe object to delete.
TEMU_API void temu_foreachClass ( void(*)(temu_Class *, void *)  Func,
void *  Arg 
)

Call function on every class in the object system The function is called with the metaclass pointer and the argument. NOTE: This function is experimental.

Parameters
FuncFunction to call
ArgArgument passed as the last parameter to Func
TEMU_API void temu_foreachInterface ( temu_Class C,
void(*)(temu_Class *, const char *, void *)  Func,
void *  Arg 
)

Call function on every interface in a class. The function is called with the class pointer, interface name and the argument. NOTE: This function is experimental.

Parameters
CClass to iterate properties
FuncFunction to call
ArgArgument passed as the last parameter to Func
TEMU_API void temu_foreachObject ( void(*)(void *, void *)  Func,
void *  Arg 
)

Call function on every object in the object system The function is called with the object pointer and the argument. NOTE: This function is experimental.

Parameters
FuncFunction to call
ArgArgument passed as the last parameter to Func
TEMU_API void temu_foreachProcessor ( void(*)(temu_Object *, void *)  Func,
void *  Arg 
)

Call function on every processor in the object system The function is called with the CPU pointer and the argument. NOTE: This function is experimental.

Parameters
FuncFunction to call
ArgArgument passed as the last parameter to Func
TEMU_API void temu_foreachProperty ( temu_Class C,
void(*)(temu_Class *, const char *, void *)  Func,
void *  Arg 
)

Call function on every property in a class. The function is called with the class pointer, property name and the argument. NOTE: This function is experimental.

Parameters
CClass to iterate properties
FuncFunction to call
ArgArgument passed as the last parameter to Func
TEMU_API int temu_generateObjectGraph ( const char *  Path,
int  Display 
)

Print the current object graph as a dot file

Pass NULL (or nullptr) to generate to stdout. And set Display to non-zero to automatically display the generated dot-file.

Parameters
PathDestination file to write the graph to. NULL indicates stdout.
DisplayIf non-zero, the function will attempt to display the graph by running it through dot and .
Returns
0 if the generation was successful. Non-zero in case of failure.
TEMU_API size_t temu_getComponentCount ( void  )

temu_getComponentCount Get the number of components in the current simulation

Returns
The number of components in the current simulation
TEMU_API void** temu_getComponents ( void  )

temu_getComponents Get the number of components in the current simulation

Returns
An array of the pointers to the components in the current simulation, the length of the array can be obtained from temu_getComponentCount()
TEMU_API void* temu_getInterface ( void *  Obj,
const char *  IfaceName,
int  Idx 
)
TEMU_API temu_IfaceRef temu_getInterfaceRef ( void *  Obj,
const char *  IfaceName,
int  Idx 
)

temu_getInterfaceRef Retrieve a reference to an interface identified by its name

Parameters
ObjPointer to the object containing the interface
IfaceNameName of the interface
IdxTODO
Returns
The interface reference as a temu_IfaceRef object
TEMU_API const char* temu_getLoggingCategory ( temu_Class Cls,
unsigned  CategoryId 
)

temu_getLogginCategory adds a logging category to the class

Parameters
Clsthe class
CategoryIdThe category id. Valid range is [8,16)
Returns
Pointer to the category string, NULL for failure.
TEMU_API temu_Propval temu_getNamedObjectProp ( const char *  Obj,
const char *  PropName,
int  Idx 
)

temu_getNamedObjectProp Get a property from an object identified by name

Parameters
ObjObject name
PropNameProperty name
IdxIndex of the property. Set to 0 if the property is not an array
Returns
returns the property value
TEMU_API size_t temu_getProcessorCount ( void  )

temu_getProcessorCount Get the number of processors in the current simulation

Returns
The number of processors in the current simulation
TEMU_API void** temu_getProcessors ( void  )

temu_getProcessors Get the list of processors in the current simulation

Returns
An array of processor pointers, the length can be obtained from temu_getProcessorCount()
TEMU_API int temu_getPropDynLength ( const void *  Obj,
const char *  PropName 
)

temu_getPropDynLength TODO

Parameters
ObjPointer to the object of the property
PropNameName of the property
Returns
TODO
TEMU_API int temu_getPropLength ( const void *  Obj,
const char *  PropName 
)

temu_getPropLength Returns property length/size if a property is an array

Parameters
ObjPointer to the object of the property
PropNameName of the property
Returns
The length of the property
TEMU_API temu_PropName temu_getPropName ( const void *  Obj,
const char *  PropName 
)

Get a reference to a named property.

Parameters
ObjAn object of a class with the relevant property registered.
PropNameThe name of the property to be queried.
Returns
Prop name object, note that the returned name string is not the same as the passed string. The returned string has a lifetime bound to the class, hence it can be returned without any problems.
TEMU_API temu_Propref temu_getPropref ( const void *  Obj,
const char *  PropName 
)

Get a reference to the named property. The propref is a typetag and a pointer to the raw value, as such it does not work with delegated properties in components, nor with pseudo properties.

Parameters
ObjAn object of a class with the relevant property registered.
PropNameThe name of the property to be queried.
Returns
Object of the property reference
TEMU_API temu_Type temu_getPropType ( const void *  Obj,
const char *  PropName 
)

temu_getPropType Get the type of a property

Parameters
ObjPointer to the object of the property
PropNameName of the property
Returns
Property type
TEMU_API temu_Propval temu_getValue ( void *  Obj,
const char *  PropName,
int  Idx 
)

temu_getValue Get the value of a property from an object

Parameters
ObjThe object that contains the property
PropNameProperty name
IdxIndex of the property. Set to 0 if the property is not an array
Returns
The value of the property
TEMU_API int16_t temu_getValueI16 ( void *  Obj,
const char *  PropName,
int  Idx 
)

temu_getValueI16 Get the value of a property from an object if it is an int16

Parameters
ObjThe object that contains the property
PropNameProperty name
IdxIndex of the property. Set to 0 if the property is not an array
Returns
The value of the property
TEMU_API int32_t temu_getValueI32 ( void *  Obj,
const char *  PropName,
int  Idx 
)

temu_getValueI32 Get the value of a property from an object if it is an int32

Parameters
ObjThe object that contains the property
PropNameProperty name
IdxIndex of the property. Set to 0 if the property is not an array
Returns
The value of the property
TEMU_API int64_t temu_getValueI64 ( void *  Obj,
const char *  PropName,
int  Idx 
)

temu_getValueI64 Get the value of a property from an object if it is an int64

Parameters
ObjThe object that contains the property
PropNameProperty name
IdxIndex of the property. Set to 0 if the property is not an array
Returns
The value of the property
TEMU_API int8_t temu_getValueI8 ( void *  Obj,
const char *  PropName,
int  Idx 
)

temu_getValueI8 Get the value of a property from an object if it is an int8

Parameters
ObjThe object that contains the property
PropNameProperty name
IdxIndex of the property. Set to 0 if the property is not an array
Returns
The value of the property
TEMU_API uint16_t temu_getValueU16 ( void *  Obj,
const char *  PropName,
int  Idx 
)

temu_getValueU16 Get the value of a property from an object if it is an uint16

Parameters
ObjThe object that contains the property
PropNameProperty name
IdxIndex of the property. Set to 0 if the property is not an array
Returns
The value of the property
TEMU_API uint32_t temu_getValueU32 ( void *  Obj,
const char *  PropName,
int  Idx 
)

temu_getValueU32 Get the value of a property from an object if it is an uint32

Parameters
ObjThe object that contains the property
PropNameProperty name
IdxIndex of the property. Set to 0 if the property is not an array
Returns
The value of the property
TEMU_API uint64_t temu_getValueU64 ( void *  Obj,
const char *  PropName,
int  Idx 
)

temu_getValueU64 Get the value of a property from an object if it is an uint64

Parameters
ObjThe object that contains the property
PropNameProperty name
IdxIndex of the property. Set to 0 if the property is not an array
Returns
The value of the property
TEMU_API uint8_t temu_getValueU8 ( void *  Obj,
const char *  PropName,
int  Idx 
)

temu_getValueU8 Get the value of a property from an object if it is an uint8

Parameters
ObjThe object that contains the property
PropNameProperty name
IdxIndex of the property. Set to 0 if the property is not an array
Returns
The value of the property
TEMU_API void* temu_getVTable ( const void *  Obj)

Get the VTable pointer for an object. This only works for internal objects that inherits from temu_Object.

Parameters
ObjThe object in question
Returns
Pointer to the vtable in question
TEMU_API void* temu_getVTableForClass ( temu_Class Cls)

temu_getVTableForClass Get the VTable pointer for a class

Parameters
ClsThe class, for which the vtable is to be retrieved
Returns
Pointer to the vtable in question
TEMU_API temu_IfaceRefArray temu_ifaceRefArrayAlloc ( unsigned  Reserve)

Allocate interface array.

Parameters
ReserveNumber of entries to reserve initially.
Returns
The allocated interface array.
TEMU_API void temu_ifaceRefArrayDispose ( temu_IfaceRefArray Arr)
TEMU_API void temu_ifaceRefArrayPush ( temu_IfaceRefArray *Arr  TEMU_NONNULL,
temu_IfaceRef  Iface 
)

Push an interface reference to the interface array.

Parameters
ArrThe interface reference array
IfaceThe interface reference (object-interface pointer pair)
TEMU_API void temu_ifaceRefArrayPush2 ( temu_IfaceRefArray *Arr  TEMU_NONNULL,
void *Obj  TEMU_NONNULL,
void *Iface  TEMU_NONNULL 
)

Push an object and raw interface pointer to an interface array.

Parameters
ArrThe interface reference array.
ObjThe object implementing the relevant interface
IfacePointer to the interface struct.
TEMU_API unsigned temu_ifaceRefArraySize ( temu_IfaceRefArray Arr)

Get the length of a dynamically allocated interface array.

Parameters
ArrThe interface array to get the size from.
Returns
The length in number of entries.
TEMU_API int temu_isComponent ( const void *  Obj)

temu_isComponent Checks if an object is a component

Parameters
ObjThe object to test
Returns
0 for false, non-zero for true
TEMU_API int temu_isCpu ( const void *  Obj)

Predicate for identifying CPU classes. In release without assert builds this runs in O(1) time. The predicate should never be used on external objects.

Parameters
ObjThe object to test
Returns
0 for false, non-zero for true
TEMU_API int temu_isDiscrete ( temu_Propval  Pv)

temu_isDiscrete checks whether the numeric property is an integer-like

Parameters
PvThe property to be checked
Returns
0 for false, non-zero for true
TEMU_API int temu_isExternal ( const void *  Obj)

Predicate for identifying external classes The function runs in log(n) time, where n is the number of objects registered in the object system. Should not be used during normal execution.

Note that external classes / objects have been deprecated and will be removed in TEMU3.

Returns
0 if internal, otherwise non-zero
TEMU_API int temu_isMachine ( const void *  Obj)

Predicate for identifying CPU classes. In release without assert builds this runs in O(1) time. The predicate should never be used on external objects.

Parameters
ObjThe object to test
Returns
0 for false, non-zero for true
TEMU_API int temu_isMemory ( const void *  Obj)

temu_isMemory Checks whether an object is a memory object

Parameters
ObjThe object to test
Returns
0 for false, non-zero for true
TEMU_API int temu_isNormalProperty ( void *  Obj,
const char *  PropName 
)

temu_isNormalProperty Checks whether a property is a normal property (not a pseudo-property)

Parameters
ObjThe object that contains the property
PropNameThe property name
Returns
0 for false, non-zero for true
TEMU_API int temu_isNumber ( temu_Propval  Pv)

temu_isNumber Checks whether a property is a number

Parameters
PvThe property to be checked
Returns
0 for false, non-zero for true
TEMU_API int temu_isPseudoProperty ( void *  Obj,
const char *  PropName 
)

temu_isPseudoProperty Checks whether a property is a pseudo-property

Parameters
ObjThe object that contains the property
PropNameThe property name
Returns
0 for false, non-zero for true
TEMU_API int temu_isQualifiedAs ( const void *  Obj,
unsigned  Qualifier 
)

temu_isQualifiedAs Check if an object is qualified as Qualifier

Parameters
ObjThe object to be checked
QualifierThe qualification to be checked
Returns
0 for false, non-zero for true
TEMU_API int temu_isReal ( temu_Propval  Pv)

temu_isReal Checks whether a property is a real number

Parameters
PvThe property to be checked
Returns
0 for false, non-zero for true
TEMU_API int temu_isSigned ( temu_Propval  Pv)
TEMU_API int temu_isString ( temu_Propval  Pv)

temu_isString Checks whether a property is a string

Parameters
PvThe property to be checked
Returns
0 for false, non-zero for true
TEMU_API int temu_isUnsigned ( temu_Propval  Pv)
TEMU_API int temu_isValidClassName ( const char *  Name)
TEMU_API int temu_isValidInterfaceName ( const char *  Name)
TEMU_API int temu_isValidObjectName ( const char *  Name)
TEMU_API int temu_isValidPropertyName ( const char *  Name)
TEMU_API void temu_listAppend ( temu_List List,
temu_Propval  Val 
)

temu_listAppend Add an element to the end of a linked-list

Parameters
ListThe list, to which the element to be added
ValThe element to be added
TEMU_API temu_List temu_listCreate ( temu_Type  Typ)

temu_listCreate Create a linked-list object

Parameters
TypThe type to be stored in the elements of the linked list
Returns
A newly created list.
TEMU_API void temu_listDispose ( temu_List List)

temu_listDispose Delete a linked-list object

Parameters
ListThe list to be deleted
TEMU_API temu_ListNode* temu_listGetHead ( temu_List List)

temu_listGetHead Get the first element of a linked-list

Parameters
ListThe list, whose first element is requested
Returns
Pointer to the first element of the linked-list
TEMU_API temu_ListNode* temu_listGetNext ( temu_ListNode Node)

temu_listGetNext Get the next element of a linked list

Parameters
NodeThe node, whose next element is requested
Returns
The next element if available, otherwise nullptr
TEMU_API temu_ListNode* temu_listGetPrev ( temu_ListNode Node)

temu_listGetPrev Get the previous element of a linked list

Parameters
NodeThe node, whose next element is requested
Returns
The previous element if available, otherwise nullptr
TEMU_API temu_ListNode* temu_listGetTail ( temu_List List)

temu_listGetTail Get the last element of a linked-list

Parameters
ListThe list, whose last element is requested
Returns
Pointer to the last element of the linked-list
TEMU_API temu_Propval temu_listNodeGetVal ( temu_ListNode Node)

temu_listNodeGetVal Get value of a linked-list node

Parameters
NodeThe node, from which the value to be extracted
Returns
The value extracted from the node
TEMU_API void temu_listPrepend ( temu_List List,
temu_Propval  Val 
)

temu_listPrepend Add an element to the beginning of a linked-list

Parameters
ListThe list, to which the element to be added
ValThe element to be added
TEMU_API temu_Propval temu_listRemoveHead ( temu_List List)

temu_listRemoveHead Removes the first element of a linked-list

Parameters
ListThe list, from which the first element to be removed
Returns
The element that was removed from the list
TEMU_API temu_Propval temu_listRemoveTail ( temu_List List)

temu_listRemoveHead Removes the last element of a linked-list

Parameters
ListThe list, from which the last element to be removed
Returns
The element that was removed from the list
TEMU_API int temu_loadPlugin ( const char *  PluginName)

Load a plugin. When a plugin is loaded the temu_pluginInit function will be called. This function should create and define any classes that the plugin provides.

The function loads plugins following the operating system's loading rules. This means in particular that first, the plugin will be found in the RPATH location of libTEMUSupport (which refers to the TEMU lib directory). Secondly, it will look in the LD_LIBRARY_PATH and other standard load directories.

In practice, it will look for lib<Plugin>.so in the T-EMU plugin paths, or libTEMU<Plugin>.so in the same paths. It will then fallback on attempting to load libTEMU<Plugin>.so from the system load paths. If the plugin name contains a slash '/' it will be treated as a path and not a plugin name.

Parameters
PluginNameA path or plugin name
Returns
0 on success, non-zero otherwise.
TEMU_API const char* temu_nameForClass ( temu_Class Cls)

temu_nameForClass Get the class name from its object

Parameters
ClsPointer to the object of the class in question
Returns
The name of the class as a C-string
TEMU_API const char* temu_nameForInterface ( const void *  Obj,
const void *  Iface 
)

Get name for interface

Parameters
ObjPointer to the object that contains the interface
IfacePointer to the interface
Returns
The name of the interface as C-string
TEMU_API const char* temu_nameForObject ( const void *  Obj)

Get the name of an object

Parameters
ObjPointer to the object
Returns
Name of the object as C-string
TEMU_API void* temu_objectForName ( const char *  Name)

Get object for name

Parameters
NameThe name of the object
Returns
Pointer to the object
TEMU_API int temu_objectHasIface ( const void *  Obj,
const char *  IfaceName 
)

temu_objectHasInterface Check if the object has a named interface

Parameters
ObjPointer to the object to query
IfaceNameInterface name to look for
Returns
0 if the interface does not exist, otherwise the interface exists
TEMU_API int temu_objectHasProp ( const void *  Obj,
const char *  PropName 
)

temu_objectHasProperty Check if the object has a named property

Parameters
ObjPointer to the object of the property
PropNameName of the property
Returns
0 if the property does not exist, otherwise the property is valid
TEMU_API void temu_objsysClear ( void  )

Erase all classes, interfaces, properties and objects registered in the object system. Not that objects of an external class will not be de-allocated. The responsibility of that lies with the programmer.

TEMU_API void temu_objsysClearObjects ( void  )

Erase all objects, but do not delete classes.

TEMU_API void temu_pluginPathAppend ( const char *  Path)

temu_pluginPathAppend Add a path to the list of paths, where T-emu searches for plugins

Parameters
PathThe path to append
TEMU_API void temu_pluginPathPrint ( void  )

temu_pluginPathPrint Print the list of paths, where T-emu searches for plugins

TEMU_API void temu_pluginPathRemove ( const char *  Path)

temu_pluginPathRemove Remove a path from the list of paths, where T-emu searches for plugins

Parameters
Pathto remove
TEMU_API int temu_propInfoForClass ( temu_Class Cls,
unsigned  PIIndex,
unsigned  PICount,
temu_PropInfo PI 
)

Get property info for class

It is possible to extract low level property info data using this function. This can be useful if integrating in another simulator or if integrating the system in e.g. a GUI in which you need to provide object introspection.

The function can be called with the PI array set to NULL to return the number of properties in the class.

You can read out all property fields using the following sequence:

temu_PropInfo PI; unsigned i = 0; int r;
while ((r = temu_propInfoForClass(C, i, 1, &PI)) == 1) {
// ...
i += r;
}
Parameters
ClsThe class to inspect
PIIndexThe property index to read from.
PICountSize of PI array in number of entries. PI Pointer to an array of prop info objects to fill in.
Returns
Number of read PI entries. In case PI is NULL, the total number of PIs for the class.
TEMU_API void temu_qualifyAs ( void *  Cls,
unsigned  Qualifier 
)

Bless the class so that the isQualified predicate returns 1. Qualifiers with the MSb cleared are reserved for T-EMU internals.

Parameters
ClsThe class to be blessed
TEMU_API void temu_qualifyAsCpu ( void *  Cls)

Bless the class so that the isCpu predicate returns 1. There are certain assumptions that CPU classes must meet. These assumptions are not stable yet, so do not use this in user code.

Parameters
ClsThe class to be blessed
TEMU_API void temu_qualifyAsMachine ( void *  Cls)

Bless the class so that the isMachine predicate returns 1. There are certain assumptions that machine classes must meet. These assumptions are not stable yet, so do not use this in user code.

Parameters
ClsThe class to be blessed
TEMU_API void temu_qualifyAsMemory ( void *  Cls)

Bless the class so that the isMemory predicate returns 1 temu_qualifyAsMemory

Parameters
ClsThe class to be blessed
TEMU_API temu_Propval temu_readNamedObjectProp ( const char *  Obj,
const char *  PropName,
int  Idx 
)

temu_readNamedObjectProp Get a property from an object identified by name with side-effects.

Parameters
ObjObject name
PropNameProperty name
IdxIndex of the property. Set to 0 if the property is not an array
Returns
returns the property value
TEMU_API temu_Propval temu_readValue ( void *  Obj,
const char *  PropName,
int  Idx 
)

Read a property value with side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
IdxIndex of property, set to 0 if it is not an array.
Returns
The property value corresponding to the name. In case of the property not being found, the Typ field of the returned property will be teTY_Invalid.
TEMU_API int16_t temu_readValueI16 ( void *  Obj,
const char *  PropName,
int  Idx 
)

Read typed properties.

The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.

Parameters
ObjObject pointer
PropNameName of property to read
IdxIndex in property array, set to 0 if the property is not an array
Returns
The read out property value.
TEMU_API int32_t temu_readValueI32 ( void *  Obj,
const char *  PropName,
int  Idx 
)

Read typed properties.

The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.

Parameters
ObjObject pointer
PropNameName of property to read
IdxIndex in property array, set to 0 if the property is not an array
Returns
The read out property value.
TEMU_API int64_t temu_readValueI64 ( void *  Obj,
const char *  PropName,
int  Idx 
)

Read typed properties.

The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.

Parameters
ObjObject pointer
PropNameName of property to read
IdxIndex in property array, set to 0 if the property is not an array
Returns
The read out property value.
TEMU_API int8_t temu_readValueI8 ( void *  Obj,
const char *  PropName,
int  Idx 
)

Read typed properties.

The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.

Parameters
ObjObject pointer
PropNameName of property to read
IdxIndex in property array, set to 0 if the property is not an array
Returns
The read out property value.
TEMU_API uint16_t temu_readValueU16 ( void *  Obj,
const char *  PropName,
int  Idx 
)

Read typed properties.

The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.

Parameters
ObjObject pointer
PropNameName of property to read
IdxIndex in property array, set to 0 if the property is not an array
Returns
The read out property value.
TEMU_API uint32_t temu_readValueU32 ( void *  Obj,
const char *  PropName,
int  Idx 
)

Read typed properties.

The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.

Parameters
ObjObject pointer
PropNameName of property to read
IdxIndex in property array, set to 0 if the property is not an array
Returns
The read out property value.
TEMU_API uint64_t temu_readValueU64 ( void *  Obj,
const char *  PropName,
int  Idx 
)

Read typed properties.

The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.

Parameters
ObjObject pointer
PropNameName of property to read
IdxIndex in property array, set to 0 if the property is not an array
Returns
The read out property value.
TEMU_API uint8_t temu_readValueU8 ( void *  Obj,
const char *  PropName,
int  Idx 
)

Read typed properties.

The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.

Parameters
ObjObject pointer
PropNameName of property to read
IdxIndex in property array, set to 0 if the property is not an array
Returns
The read out property value.
TEMU_API temu_Class* temu_registerClass ( const char *  ClsName,
temu_ObjectCreateFunc  Create,
temu_ObjectDisposeFunc  Dispose 
)

Register a class in the TEMU object system. With these classes, the TEMU object system is responsible for allocation and de-allocation.

Parameters
ClsNameThe name of the class that is to be created.
CreateA constructor, the constructor is responsible for allocation and initialisation of the object.
DisposeA destructor, this function is responsible for deleting the objects of the class.
Returns
A pointer to the class object that can be further used to register properties and interfaces.
TEMU_API temu_Class* temu_registerExternalClass ( const char *  ClsName)

Register an external class in the TEMU object system. An external class described objects that are managed outside the object system. Such classes can for example be used to bridge between two different object systems (e.g. TEMU and SMP2).

The function will be removed in TEMU3, to integrate TEMU objects and other object systems create wrapper classes that has a pointer to the external object.

Parameters
ClsNameThe name of the class that is to be created.
Returns
A pointer to the class object that can be further used to register properties and interfaces.
TEMU_API void temu_requireInterface ( temu_Class Cls,
const char *  PropName,
const char *  IfaceType 
)

Associate the interface reference property with an interface type.

Setting the type, prevents the connect command / function to assign the connection if the target interface type is not the same as the property interface reference type.

Parameters
ClsClass pointer
PropNameName of interface reference property
IfaceTypeType required to connect the property
TEMU_API int temu_serialiseJSON ( const char *  FileName)

Serialise the simulation state to the given file name.

The serialisation writes a JSON formatted file and calls the serialise procedure in the (optional) ObjectIface if it is implemented.

The serialisation interface can for example be used to write out memory buffers to separate files as such data should not be written to a JSON file.

Parameters
FileNameThe filename, to which the JSON data is to be stored
Returns
0 on success, otherwise non-zero
TEMU_API void temu_serialiseProp ( void *  Ctxt,
const char *  Name,
temu_Type  Typ,
int  Count,
void *  Data 
)

Serialise an explicit property, this can be called from the serialisiation interface. Note that the availability of pseudo properties makes this function and the serialise interface more or less obsolete.

Parameters
CtxtThe context object that has the property (same as passed to serialise function in the interface)
NameThe name of the property
TypThe type of the property
Count0 if the property is not an array, otherwise the element number in the property
DataSerialized data
TEMU_API void temu_setNamedObjectProp ( const char *  Obj,
const char *  PropName,
temu_Propval  Val,
int  Idx 
)

temu_setNamedObjectProp Set a property value, where the object is identified by its name

Parameters
ObjObject name
PropNameProperty name
Valthe value to set
IdxIndex of the property. Set to 0 if the property is not an array
TEMU_API void temu_setTimeSource ( void *  Obj,
void *  TS 
)

Set time source object for models. Typically TS is a CPU. You can only set the time source for an internal class.

Parameters
ObjObject to set time source in.
TSTime source object (CPU or clock model)
TEMU_API void temu_setValue ( void *  Obj,
const char *  PropName,
temu_Propval  Val,
int  Idx 
)

Set a raw property value without side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_setValueI16 ( void *  Obj,
const char *  PropName,
int16_t  Val,
int  Idx 
)

Set a raw property value without side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_setValueI32 ( void *  Obj,
const char *  PropName,
int32_t  Val,
int  Idx 
)

Set a raw property value without side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_setValueI64 ( void *  Obj,
const char *  PropName,
int64_t  Val,
int  Idx 
)

Set a raw property value without side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_setValueI8 ( void *  Obj,
const char *  PropName,
int8_t  Val,
int  Idx 
)

Set a raw property value without side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_setValueU16 ( void *  Obj,
const char *  PropName,
uint16_t  Val,
int  Idx 
)

Set a raw property value without side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_setValueU32 ( void *  Obj,
const char *  PropName,
uint32_t  Val,
int  Idx 
)

Set a raw property value without side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_setValueU64 ( void *  Obj,
const char *  PropName,
uint64_t  Val,
int  Idx 
)

Set a raw property value without side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_setValueU8 ( void *  Obj,
const char *  PropName,
uint8_t  Val,
int  Idx 
)

Set a raw property value without side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API int temu_setVTable ( temu_Class Cls,
void *  VTable 
)

Set the VTable pointer.

Temu classes, provides the ability to, for internal objects query for a VTable manually in O(1) time. In practice this can be any pointer, but it is typically used to register performance sensitive interfaces. E.g. the CPU and machine classes have their own VTable types that refer to a number of interfaces they implement.

Parameters
ClsThe class, for which the vtable to be set
VTablePointer to the vtable to be used
Returns
0 on success, non-zero otherwise.
TEMU_API const char* temu_typenameForInterface ( const void *  Obj,
const void *  Iface 
)

Get type name for interface

Parameters
ObjPointer to the object that contains the interface
IfacePointer to the interface
Returns
The name of the type as C-string
TEMU_API const char* temu_typeToName ( temu_Type  Typ)

Get a string representing the type tag.

Parameters
TypThe type, whose name is required
Returns
The name as a C-string
TEMU_API temu_Vector temu_vecCreate ( temu_Type  Typ)

temu_vecCreate Create a vector object

Parameters
TypThe type of the elements
Returns
the vector object created
TEMU_API void temu_vecDispose ( temu_Vector Vec)

temu_vecDispose Delete a vector object

Parameters
VecThe vector object to be deleted
TEMU_API void* temu_vecGetData ( temu_Vector Vec)

temu_vecGetData Retrieve the array of elements of a vector

Parameters
VecThe vector, whose elements are requested
Returns
Returns a pointer to the first element of the vector
TEMU_API size_t temu_vecGetSize ( temu_Vector Vec)

temu_vecGetSize Get the number of elements of a vector

Parameters
VecThe vector, whose size to be retrieved
Returns
The number of elements in Vec
TEMU_API void temu_vecPush ( temu_Vector Vec,
temu_Propval  Val 
)

temu_vecPush Add an element to a vector object

Parameters
VecThe vector, to which the element to be added
ValThe element to be added
TEMU_API void temu_writeNamedObjectProp ( const char *  Obj,
const char *  PropName,
temu_Propval  Val,
int  Idx 
)

temu_setNamedObjectProp Set a property value, where the object is identified by its name, with side-effects

Parameters
ObjObject name
PropNameProperty name
Valthe value to set
IdxIndex of the property. Set to 0 if the property is not an array
TEMU_API void temu_writeValue ( void *  Obj,
const char *  PropName,
temu_Propval  Val,
int  Idx 
)

Write a property value with side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_writeValueI16 ( void *  Obj,
const char *  PropName,
int16_t  Val,
int  Idx 
)

Write a property value with side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_writeValueI32 ( void *  Obj,
const char *  PropName,
int32_t  Val,
int  Idx 
)

Write a property value with side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_writeValueI64 ( void *  Obj,
const char *  PropName,
int64_t  Val,
int  Idx 
)

Write a property value with side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_writeValueI8 ( void *  Obj,
const char *  PropName,
int8_t  Val,
int  Idx 
)

Write a property value with side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_writeValueU16 ( void *  Obj,
const char *  PropName,
uint16_t  Val,
int  Idx 
)

Write a property value with side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_writeValueU32 ( void *  Obj,
const char *  PropName,
uint32_t  Val,
int  Idx 
)

Write a property value with side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_writeValueU64 ( void *  Obj,
const char *  PropName,
uint64_t  Val,
int  Idx 
)

Write a property value with side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.
TEMU_API void temu_writeValueU8 ( void *  Obj,
const char *  PropName,
uint8_t  Val,
int  Idx 
)

Write a property value with side-effects

Parameters
ObjObject pointer
PropNameName of property to read.
ValThe value to set. It must be of the correct type.
IdxIndex of property, set to 0 if it is not an array.