My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Macros | Functions | Variables
msu_type.c File Reference

Registration and location of msu types. More...

#include "dfg.h"
#include "msu_type.h"
#include "logging.h"
#include "msu_type_list.h"

Go to the source code of this file.

Macros

#define MAX_TYPE_ID   1000
 MOVEME: MAX_TYPE_ID This is the maximum ID that can be assigned to an MSU type. More...
 
#define N_MSU_TYPES   (sizeof(DEFINED_MSU_TYPES) / sizeof(struct msu_type*))
 The number of available MSU types. More...
 

Functions

static int register_msu_type (struct msu_type *type)
 Regsiters an MSU type so that it can be later referenced by its ID. More...
 
void destroy_msu_types ()
 Calls the type-sepecific constructor for each instantiated MSU type. More...
 
struct msu_typeget_msu_type (int id)
 Gets the MSU type with the provided ID. More...
 
static bool has_required_fields (struct msu_type *type)
 Checks whether the msu type has the required fields to be used. More...
 
static int init_msu_type (struct msu_type *type)
 Initializes a specific MSU type, calling its init function and registering it for future calls. More...
 
int init_msu_type_id (unsigned int type_id)
 Initializes the MSU type with the given ID, calling the custom constructor if appropriate. More...
 

Variables

static struct msu_typeDEFINED_MSU_TYPES [] = { &SOCKET_MSU_TYPE, }
 Every MSU type that can be used. More...
 
static struct msu_typemsu_types [1000]
 Pointers to MSU Types, indexed by ID. More...
 

Detailed Description

Registration and location of msu types.

Definition in file msu_type.c.

Macro Definition Documentation

#define MAX_TYPE_ID   1000

MOVEME: MAX_TYPE_ID This is the maximum ID that can be assigned to an MSU type.

Definition at line 35 of file msu_type.c.

#define N_MSU_TYPES   (sizeof(DEFINED_MSU_TYPES) / sizeof(struct msu_type*))

The number of available MSU types.

Definition at line 46 of file msu_type.c.

Function Documentation

void destroy_msu_types ( )

Calls the type-sepecific constructor for each instantiated MSU type.

Definition at line 69 of file msu_type.c.

struct msu_type* get_msu_type ( int  id)

Gets the MSU type with the provided ID.

Parameters
idThe type ID of the MSU type to retrieve
Returns
The MSU Type with the given ID, NULL in N/A

Definition at line 80 of file msu_type.c.

static bool has_required_fields ( struct msu_type type)
static

Checks whether the msu type has the required fields to be used.

(At the moment, the only required field is receive)

Returns
true/false

Definition at line 94 of file msu_type.c.

static int init_msu_type ( struct msu_type type)
static

Initializes a specific MSU type, calling its init function and registering it for future calls.

Parameters
typeThe type of MSU to be registered
Returns
0 on success, -1 on error

Definition at line 109 of file msu_type.c.

int init_msu_type_id ( unsigned int  type_id)

Initializes the MSU type with the given ID, calling the custom constructor if appropriate.

This function is meant to be called on each MSU type that is defined in the DFG used to initialize the runtime.

Returns
0 on success, -1 on error

Definition at line 132 of file msu_type.c.

static int register_msu_type ( struct msu_type type)
static

Regsiters an MSU type so that it can be later referenced by its ID.

Parameters
typeMSU Type to be registered
Returns
0 on success, -1 on error

Definition at line 58 of file msu_type.c.

Variable Documentation

struct msu_type* DEFINED_MSU_TYPES[] = { &SOCKET_MSU_TYPE, }
static

Every MSU type that can be used.

Defined in msu_type_list.h, or overridden from previous definition

Definition at line 41 of file msu_type.c.

struct msu_type* msu_types[1000]
static

Pointers to MSU Types, indexed by ID.

Definition at line 51 of file msu_type.c.