coan 4.2.4
state_utils.h File Reference
#include "bool.h"
#include <stdlib.h>
#include <assert.h>
#include <string.h>
Include dependency graph for state_utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define IMPLEMENT_STATIC(component, init_type)
#define IMPLEMENT_DYNAMIC(component, init_type)
#define IMPLEMENT(component, init_type)   IMPLEMENT_STATIC(component,init_type)
#define USE_STATIC_INITIALISER(component)
#define DEFINE_USER_INIT(component)
#define DEFINE_USER_FINIS(component)
#define INCLUDE_PUBLIC(component)   PUBLIC_STATE_T(component) PUBLIC_STATE(component)
#define STATE_DEF(component)   typedef struct component##_state_s
#define STATE_T(component)   component##_state_t
#define NO_PRIVATE_STATE(component)   typedef PUBLIC_STATE_T(component) STATE_T(component)
#define GET_STATE(component, field)   GET_STATIC_STATE(component,field)
#define SET_STATE(component, field)   SET_STATIC_STATE(component,field)
#define PUBLIC_STATE_DEF(component)   typedef struct component##_public_state_s
#define PUBLIC_STATE_T(component)   component##_public_state_t
#define NO_PUBLIC_STATE(component)   typedef STATE_T(component) PUBLIC_STATE_T(component)
#define IMPORT(component)
Macros for component client code.
#define INITIALISE(component)   INITOR(component)()
#define FINALISE(component)   INITOR(component)()
#define REINITIALISE(component)   (void)(FINALISE(component),INITIALISE(component))
#define GET_PUBLIC(component, field)   (assert(true),(PUBLIC_HANDLE(component)->field))
#define SET_PUBLIC(component, field)   (PUBLIC_HANDLE(component)->field)

Enumerations

enum  component_storage_type { STATE_STATIC, STATE_DYNAMIC }
enum  component_initialisation_type { ZERO_INITABLE, STATIC_INITABLE, USER_INITABLE }
#define STATE_ALLOCATOR   (malloc)
#define STATE(component)   component##_state
#define PUBLIC_STATE(component)   component##_public_state
#define HANDLE(component)   component##_h
#define PUBLIC_HANDLE(component)   component##_public_h
#define USER_INIT(component)   component##_init
#define USER_FINIS(component)   component##_finis
#define USER_INIT_HANDLE(component)   component##_init_h
#define USER_FINIS_HANDLE(component)   component##_finis_h
#define INITOR(component)   component##_initor
#define FINITOR(component)   component##_finitor
#define STATIC_INITIALISER(component)   component##_static_initialiser
#define STATIC_INITIALISER_HANDLE(component)   component##_static_initialiser_h
#define STORAGE_TYPE_TAG(component)   component##_storage_type
#define INITIALISATION_TYPE_TAG(component)   component##_initialisation_type
#define DECL_USER_INIT(component)   void USER_INIT(component)(STATE_T(component) *)
#define DECL_USER_FINIS(component)   void USER_FINIS(component)(STATE_T(component) *)
#define DECL_USER_INIT_HANDLE(component)   void (*USER_INIT_HANDLE(component))(STATE_T(component) *)
#define DECL_USER_FINIS_HANDLE(component)   void (*USER_FINIS_HANDLE(component))(STATE_T(component) *)
#define DECL_INITOR(component)   void INITOR(component)(void)
#define DECL_FINITOR(component)   void FINITOR(component)(void)
#define DECL_STATIC_INITIALISER(component)   static const STATE_T(component) STATIC_INITIALISER(component)
#define DECL_STATIC_INITIALISER_HANDLE(component)   static const STATE_T(component) * const STATIC_INITIALISER_HANDLE(component)
#define SELECT_STATIC(component)   enum component##_storage_type { STORAGE_TYPE_TAG(component) = STATE_STATIC }
#define SELECT_DYNAMIC(component)   enum component##_storage_type { STORAGE_TYPE_TAG(component) = STATE_DYNAMIC }
#define SELECT_INITIALISATION_TYPE(component, init_type)   enum component##_init_type { INITIALISATION_TYPE_TAG(component) = init_type }
#define SELECT_ZERO_INITABLE(component)   SELECT_INITIALISATION_TYPE(component,ZERO_INITABLE)
#define SELECT_STATIC_INITABLE(component)   SELECT_INITIALISATION_TYPE(component,STATIC_INITABLE)
#define SELECT_USER_INITABLE(component)   SELECT_INITIALISATION_TYPE(component,USER_INITABLE)
#define IS_STATIC(component)   (STORAGE_TYPE_TAG(component) == (int)STATE_STATIC)
#define IS_ZERO_INITABLE(component)   (INITIALISATION_TYPE_TAG(component) == (int)ZERO_INITABLE)
#define HAS_STATIC_INITIALISER(component)   (INITIALISATION_TYPE_TAG(component) == STATIC_INITABLE)
#define HAS_USER_INIT(component)   (INITIALISATION_TYPE_TAG(component) == (int)USER_INITABLE)
#define DECL_DYNAMIC_STATE(component)
#define DECL_STATIC_STATE(component)
#define IMPORT_INITOR(component)   extern DECL_INITOR(component)
#define IMPORT_FINITOR(component)   extern DECL_FINITOR(component)
#define IMPORT_STATE(component)   extern PUBLIC_STATE_T(component) * PUBLIC_HANDLE(component)
#define GET_STATE_BY_HANDLE(component, field)   (assert(true),HANDLE(component)->field)
#define SET_STATE_BY_HANDLE(component, field)   (HANDLE(component)->field)
#define GET_STATIC_STATE(component, field)   (assert(true),STATE(component).field)
#define SET_STATIC_STATE(component, field)   (STATE(component).field)
#define DEFINE_INITOR(component)
#define DEFINE_FINITOR(component)
void component_initor (bool is_static, bool is_zero_initable, void **state, void **public_state, void const *initialiser, size_t size, void(*user_init)())
void component_finitor (bool is_static, void **state, void **public_state, void(*user_finis)())

Detailed Description

The file provides the State Utils interface

Definition in file state_utils.h.


Define Documentation

#define FINALISE (   component)    INITOR(component)()

Finalise the component's state - appropriately whether static or dynamic, user-finalised or not.

Parameters:
componentName of the component

Definition at line 887 of file state_utils.h.

#define GET_PUBLIC (   component,
  field 
)    (assert(true),(PUBLIC_HANDLE(component)->field))
#define INITIALISE (   component)    INITOR(component)()

Initialise the component's state - appropriately whether static or dynamic, zero-initialisable, static-initialisable, user-initialisable.

Parameters:
componentName of the component

Definition at line 881 of file state_utils.h.

Referenced by ready().

#define REINITIALISE (   component)    (void)(FINALISE(component),INITIALISE(component))

Finalise and then initialise the component's state appropriately

Parameters:
componentName of the component

Definition at line 892 of file state_utils.h.

#define SET_PUBLIC (   component,
  field 
)    (PUBLIC_HANDLE(component)->field)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines