128 for(i=0; i < flow_count; i++)
130 y_flow* flow = &flow_list[i];
131 total += flow->weight;
133 lr_log_message(
"y_flow: Combined total of weights is: %d", total);
149 int i, lowerbound = 0;
153 lr_log_message(
"Roll: %d", roll);
155 for(i=0; i < flow_count; i++)
157 y_flow *flow = &flow_list[i];
158 int weight = flow->weight;
161 lr_log_message(
"weight cursor: %d", cursor);
180 if(chosen_flow == NULL)
182 lr_log_message(
"Warning: Cannot execute NULL flow.");
184 else if(chosen_flow->name == NULL)
186 lr_log_message(
"Warning: Cannot execute a flow without a name!");
188 else if(chosen_flow->function == NULL)
190 lr_log_message(
"Warning: Cannot execute NULL flow function for flow %s", chosen_flow->name);
194 y_flow_func *flow_function = chosen_flow->function;
195 return flow_function();
210 lr_log_message(
"y_get_flow_by_name(%s)", flow_name);
212 for(i=0; i < flow_count; i++)
214 y_flow *flow = &flow_list[i];
217 if(
strcmp(flow_name, flow->name) == 0 )
223 lr_log_message(
"Name not found: %s", flow_name);
int y_exec_flow(y_flow *chosen_flow)
Execute a flow from a flow list.
Descriptor for one single flow in a flow list.
y_flow * y_get_flow_by_name(char *flow_name, y_flow flow_list[], int flow_count)
Fetch a specific item from a flow list, by name.
Contains core ylib support functions needed for the functioning of the library.
int strcmp(const char *string1, const char *string2)
Documented at http://www.cplusplus.com/reference/cstring/strcmp/.
int( y_flow_func)()
Type definition of a function pointer to the flow to execute.
int number
A number. Not used by ylib itself, use it however you want.
int y_calc_flow_weight_total(y_flow flow_list[], int flow_count)
Calculate the total of the weights in a given flow list.
long y_rand(void)
Generate a random (integer) number between 0 and Y_RAND_MAX (30 bit maxint).
char * name
The name of the flow.
y_flow * y_choose_flow(y_flow flow_list[], int flow_count)
Choose a flow from a list of flows.
int weight
The weight assigned to this piece of code, determining how likely it is to be executed.