My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
msu_type.h
Go to the documentation of this file.
1 /*
2 START OF LICENSE STUB
3  DeDOS: Declarative Dispersion-Oriented Software
4  Copyright (C) 2017 University of Pennsylvania, Georgetown University
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 END OF LICENSE STUB
19 */
25 #ifndef MSU_TYPE_H
26 #define MSU_TYPE_H
27 #include "routing.h"
28 #include "ctrl_runtime_messages.h"
29 
30 #include <stdint.h>
31 
32 // Need forward declarations due to circular dependency
33 struct local_msu;
34 struct msu_msg;
35 struct msu_msg_hdr;
36 struct msu_type;
37 
38 typedef ssize_t (*serialization_fn)(struct msu_type *, struct msu_msg *, void **output);
39 typedef void *(*deserialization_fn)(struct local_msu *self, size_t input_size, void *input,
40  size_t *out_size);
41 
46 struct msu_type{
48  char *name;
49 
51  unsigned int id;
52 
59  int (*init_type)(struct msu_type *type);
60 
64  void (*destroy_type)(struct msu_type *type);
65 
75  int (*init)(struct local_msu *self, struct msu_init_data *initial_data);
76 
81  void (*destroy)(struct local_msu *self);
82 
89  int (*receive)(struct local_msu *self, struct msu_msg *msg);
90 
91  int (*receive_error)(struct local_msu *self, struct msu_msg *msg);
92 
101  int (*route)(struct msu_type *type, struct local_msu *sender,
102  struct msu_msg *msg, struct msu_endpoint *output);
103 
113 
119 
129 
131 };
132 
136 void destroy_msu_types();
137 
145 int init_msu_type_id(unsigned int type_id);
146 
152 struct msu_type *get_msu_type(int id);
153 
154 #endif // MSS_TYPE_H
void(* destroy)(struct local_msu *self)
Type-specific destructor that frees any internal data or state.
Definition: msu_type.h:81
void *(* deserialization_fn)(struct local_msu *self, size_t input_size, void *input, size_t *out_size)
Definition: msu_type.h:39
Header for messages passed to MSUs.
Definition: msu_message.h:85
void destroy_msu_types()
Calls the type-sepecific constructor for each instantiated MSU type.
Definition: msu_type.c:69
int(* receive)(struct local_msu *self, struct msu_msg *msg)
Handles the receiving of data sent from other MSUs.
Definition: msu_type.h:89
struct msu_type * get_msu_type(int id)
Gets the MSU type with the provided ID.
Definition: msu_type.c:80
int(* receive_error)(struct local_msu *self, struct msu_msg *msg)
Definition: msu_type.h:91
unsigned int id
Numerical identifier for the MSU.
Definition: msu_type.h:51
deserialization_fn deserialize_error
Definition: msu_type.h:130
The structure that represents an MSU located on the local machine.
Definition: local_msu.h:38
serialization_fn serialize
Defines serialization protocol for data sent to this MSU type If NULL, assumes no pointers in the msu...
Definition: msu_type.h:112
int init_msu_type_id(unsigned int type_id)
Initializes the MSU type with the given ID, calling the custom constructor if appropriate.
Definition: msu_type.c:132
Data with which an MSU is initialized, and the payload for messages of type CTRL_CREATE_MSU.
Definition: dfg.h:66
Definitions of structures for sending messages from the global controller to runtimes.
Functions for routing MSU messages between MSUs.
ssize_t(* serialization_fn)(struct msu_type *, struct msu_msg *, void **output)
Definition: msu_type.h:38
serialization_fn serialize_error
Defines serialization protocol for errors returned to this MSU type If NULL, assumes no pointers in t...
Definition: msu_type.h:118
int(* route)(struct msu_type *type, struct local_msu *sender, struct msu_msg *msg, struct msu_endpoint *output)
Choose which MSU of this type the previous MSU will route to.
Definition: msu_type.h:101
Defines a type of MSU.
Definition: msu_type.h:46
int(* init)(struct local_msu *self, struct msu_init_data *initial_data)
Type-specific construction function.
Definition: msu_type.h:75
deserialization_fn deserialize
Defines deserialization protocl for data received by this MSU type If NULL, assumes no pointers in th...
Definition: msu_type.h:128
void(* destroy_type)(struct msu_type *type)
Destructor for an MSU type, should destroy context initialized in init_type.
Definition: msu_type.h:64
A message that is to be delivered to an instance of an MSU.
Definition: msu_message.h:101
char * name
Name for the msu type.
Definition: msu_type.h:48
int(* init_type)(struct msu_type *type)
Constructor for an MSU_type itself, should initialize whatever context all MSUs of this type might ne...
Definition: msu_type.h:59
An endpoint to which an msu_msg can be delivered.
Definition: routing.h:32