1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

use more const qualifiers

This commit is contained in:
Steffen Vogel 2018-08-06 11:08:23 +02:00
parent 3bba9c16b0
commit 86b03265b2
4 changed files with 26 additions and 26 deletions

View file

@ -79,34 +79,34 @@ void hist_reset(struct hist *h);
void hist_put(struct hist *h, double value);
/** Calcluate the variance of all counted values. */
double hist_var(struct hist *h);
double hist_var(const struct hist *h);
/** Calculate the mean average of all counted values. */
double hist_mean(struct hist *h);
double hist_mean(const struct hist *h);
/** Calculate the standard derivation of all counted values. */
double hist_stddev(struct hist *h);
double hist_stddev(const struct hist *h);
/** Print all statistical properties of distribution including a graphilcal plot of the histogram. */
void hist_print(struct hist *h, int details);
void hist_print(const struct hist *h, int details);
/** Print ASCII style plot of histogram */
void hist_plot(struct hist *h);
void hist_plot(const struct hist *h);
/** Dump histogram data in Matlab format.
*
* @return The string containing the dump. The caller is responsible to free() the buffer.
*/
char * hist_dump(struct hist *h);
char * hist_dump(const struct hist *h);
/** Prints Matlab struct containing all infos to file. */
int hist_dump_matlab(struct hist *h, FILE *f);
int hist_dump_matlab(const struct hist *h, FILE *f);
/** Write the histogram in JSON format to fiel \p f. */
int hist_dump_json(struct hist *h, FILE *f);
int hist_dump_json(const struct hist *h, FILE *f);
/** Build a libjansson / JSON object of the histogram. */
json_t * hist_json(struct hist *h);
json_t * hist_json(const struct hist *h);
#ifdef __cplusplus
}

View file

@ -99,9 +99,9 @@ struct mapping_entry {
};
};
int mapping_remap(struct list *m, struct sample *remapped, struct sample *original, struct stats *s);
int mapping_remap(const struct list *m, struct sample *remapped, const struct sample *original, const struct stats *s);
int mapping_update(struct mapping_entry *e, struct sample *remapped, struct sample *original, struct stats *s);
int mapping_update(const struct mapping_entry *e, struct sample *remapped, const struct sample *original, const struct stats *s);
int mapping_parse(struct mapping_entry *e, json_t *cfg, struct list *nodes);
@ -109,7 +109,7 @@ int mapping_parse_str(struct mapping_entry *e, const char *str, struct list *nod
int mapping_parse_list(struct list *l, json_t *cfg, struct list *nodes);
int mapping_to_str(struct mapping_entry *me, unsigned index, char **str);
int mapping_to_str(const struct mapping_entry *me, unsigned index, char **str);
#ifdef __cplusplus
}

View file

@ -119,22 +119,22 @@ void hist_reset(struct hist *h)
memset(h->data, 0, h->length * sizeof(unsigned));
}
double hist_mean(struct hist *h)
double hist_mean(const struct hist *h)
{
return (h->total > 0) ? h->_m[0] : NAN;
}
double hist_var(struct hist *h)
double hist_var(const struct hist *h)
{
return (h->total > 1) ? h->_s[0] / (h->total - 1) : NAN;
}
double hist_stddev(struct hist *h)
double hist_stddev(const struct hist *h)
{
return sqrt(hist_var(h));
}
void hist_print(struct hist *h, int details)
void hist_print(const struct hist *h, int details)
{
if (h->total > 0) {
hist_cnt_t missed = h->total - h->higher - h->lower;
@ -159,7 +159,7 @@ void hist_print(struct hist *h, int details)
stats("Counted values: %ju", h->total);
}
void hist_plot(struct hist *h)
void hist_plot(const struct hist *h)
{
hist_cnt_t max = 1;
@ -200,7 +200,7 @@ void hist_plot(struct hist *h)
table_footer(&table);
}
char * hist_dump(struct hist *h)
char * hist_dump(const struct hist *h)
{
char *buf = alloc(128);
@ -214,7 +214,7 @@ char * hist_dump(struct hist *h)
return buf;
}
json_t * hist_json(struct hist *h)
json_t * hist_json(const struct hist *h)
{
json_t *json_buckets, *json_hist;
@ -248,7 +248,7 @@ json_t * hist_json(struct hist *h)
return json_hist;
}
int hist_dump_json(struct hist *h, FILE *f)
int hist_dump_json(const struct hist *h, FILE *f)
{
json_t *j = hist_json(h);
@ -259,7 +259,7 @@ int hist_dump_json(struct hist *h, FILE *f)
return ret;
}
int hist_dump_matlab(struct hist *h, FILE *f)
int hist_dump_matlab(const struct hist *h, FILE *f)
{
fprintf(f, "struct(");
fprintf(f, "'low', %f, ", h->low);

View file

@ -240,7 +240,7 @@ out: json_decref(json_mapping);
return ret;
}
int mapping_update(struct mapping_entry *me, struct sample *remapped, struct sample *original, struct stats *s)
int mapping_update(const struct mapping_entry *me, struct sample *remapped, const struct sample *original, const struct stats *s)
{
int len = me->length;
int off = me->offset;
@ -257,7 +257,7 @@ int mapping_update(struct mapping_entry *me, struct sample *remapped, struct sam
switch (me->type) {
case MAPPING_TYPE_STATS: {
struct hist *h = &s->histograms[me->stats.id];
const struct hist *h = &s->histograms[me->stats.id];
switch (me->stats.type) {
case MAPPING_STATS_TYPE_TOTAL:
@ -288,7 +288,7 @@ int mapping_update(struct mapping_entry *me, struct sample *remapped, struct sam
}
case MAPPING_TYPE_TIMESTAMP: {
struct timespec *ts;
const struct timespec *ts;
switch (me->timestamp.type) {
case MAPPING_TIMESTAMP_TYPE_RECEIVED:
@ -347,7 +347,7 @@ int mapping_update(struct mapping_entry *me, struct sample *remapped, struct sam
return 0;
}
int mapping_remap(struct list *m, struct sample *remapped, struct sample *original, struct stats *s)
int mapping_remap(const struct list *m, struct sample *remapped, const struct sample *original, const struct stats *s)
{
int ret;
@ -366,7 +366,7 @@ int mapping_remap(struct list *m, struct sample *remapped, struct sample *origin
return 0;
}
int mapping_to_str(struct mapping_entry *me, unsigned index, char **str)
int mapping_to_str(const struct mapping_entry *me, unsigned index, char **str)
{
const char *type;