35 #define MAX_TYPE_ID 1000
46 #define N_MSU_TYPES (sizeof(DEFINED_MSU_TYPES) / sizeof(struct msu_type*))
60 log_error(
"MSU type %s not registered. Type ID %d too high. Max: %d",
64 msu_types[type->
id] = type;
65 log(LOG_MSU_TYPE_INIT,
"Registered MSU type %s", type->
name);
71 struct msu_type *type = DEFINED_MSU_TYPES[i];
72 if (msu_types[type->
id] != NULL) {
82 log_error(
"MSU type %d cannot be found Type ID too high. Max: %d",
96 log_error(
"MSU type %s does not register a recieve function",
111 log_error(
"Not registering MSU type %s due to missing fields",
117 log_error(
"MSU Type %s not initialized: failed custom constructor",
121 log(LOG_MSU_TYPE_INIT,
"Initialized msu type %s", type->
name);
135 struct msu_type *type = DEFINED_MSU_TYPES[i];
136 if (type->
id == type_id) {
140 log_error(
"MSU Type ID %u not found!", type_id);
#define MAX_TYPE_ID
MOVEME: MAX_TYPE_ID This is the maximum ID that can be assigned to an MSU type.
void destroy_msu_types()
Calls the type-sepecific constructor for each instantiated MSU type.
Defines a type of MSU, including callback and accessor functions.
static struct msu_type * DEFINED_MSU_TYPES[]
Every MSU type that can be used.
#define MSU_TYPE_LIST
The complete list of MSU types.
struct msu_type * get_msu_type(int id)
Gets the MSU type with the provided ID.
Logging of status messages to the terminal.
Defines the list of MSUs that can be instantiated on a runtime.
int(* receive)(struct local_msu *self, struct msu_msg *msg)
Handles the receiving of data sent from other MSUs.
unsigned int id
Numerical identifier for the MSU.
#define log_error(fmt,...)
static bool has_required_fields(struct msu_type *type)
Checks whether the msu type has the required fields to be used.
int init_msu_type_id(unsigned int type_id)
Initializes the MSU type with the given ID, calling the custom constructor if appropriate.
#define N_MSU_TYPES
The number of available MSU types.
Interfaces for the creation and modification of the data-flow-graph and and general description of th...
static int register_msu_type(struct msu_type *type)
Regsiters an MSU type so that it can be later referenced by its ID.
static int init_msu_type(struct msu_type *type)
Initializes a specific MSU type, calling its init function and registering it for future calls...
void(* destroy_type)(struct msu_type *type)
Destructor for an MSU type, should destroy context initialized in init_type.
#define log(level, fmt,...)
Log at a custom level.
char * name
Name for the msu type.
int(* init_type)(struct msu_type *type)
Constructor for an MSU_type itself, should initialize whatever context all MSUs of this type might ne...
static struct msu_type * msu_types[1000]
Pointers to MSU Types, indexed by ID.