Spectra
Classes | Macros | Functions
monitorCreator.h File Reference
#include <string>
#include <fstream>
#include <utility>
#include <stack>
#include <regex>
#include <cstdio>
#include "formulaAnalyser.h"
Include dependency graph for monitorCreator.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  monitorCreator
 

Macros

#define GENERATED_FILES_NAME   "monitor"
 
#define HEADER_FILE
 
#define MONITOR_C_HEADER
 
#define DECLARE_AUX_STRUCTURES
 
#define ENUM_VAR_NAMES   "enum VarNames { %s };\n\n"
 
#define MONITOR_STRUCT_DECLARATION
 
#define MONITOR_STRUCT_DEFINITION
 
#define MONITOR_VERIFY_INIT
 
#define MONITOR_VERIFY_CHECK_AND_FINALIZE
 
#define FAIL_REPORT_METHOD
 

Functions

long fileSize (const char *filename)
 

Macro Definition Documentation

◆ DECLARE_AUX_STRUCTURES

#define DECLARE_AUX_STRUCTURES
Value:
"typedef bool (*fce)();\n"\
"\n"\
"typedef struct {\n"\
" bool evaluated;\n"\
" bool value;\n"\
" fce lambda;\n"\
"} expr;\n"\
"\n"\
"bool get(expr *e){\n"\
" if (!e->evaluated) {\n"\
" e->value = e->lambda();\n"\
" }\n"\
" return e->value;\n"\
"}\n\n"\

◆ ENUM_VAR_NAMES

#define ENUM_VAR_NAMES   "enum VarNames { %s };\n\n"

◆ FAIL_REPORT_METHOD

#define FAIL_REPORT_METHOD
Value:
"\n"\
"void printFailReport() {\n"\
" fprintf(stderr,\"Verification failed after round #%%d!\\nRelevant changes:\\n\", M.hb);\n"\
"\n"\
" int i;\n"\
" /*< Print all changes in formulae values that happened in the failure heartbeat */\n"\
" for (i = %d; i > 0 ; i--) {\n" /* count of formulae - 1 -> the root is not printed*/\
" if (M.check[i]) {\n"\
" fprintf(stderr, M.formulaeContents[i], (M.now[i]?\"true\":\"false\")); \n"\
" }\n"\
" }\n"\
"}\n\n"

◆ GENERATED_FILES_NAME

#define GENERATED_FILES_NAME   "monitor"

◆ HEADER_FILE

#define HEADER_FILE
Value:
"%s\n" /* comment - when and how was this generated */\
"#ifndef MONITOR_H\n"\
"#define MONITOR_H\n\n"\
"#include <stdio.h>\n"\
"#include <string.h>\n"\
"#include <stdbool.h>\n"\
"#include \"%s\"\n\n" /* name of given header file with definitions */ \
"#ifdef __cplusplus\n"\
"extern \"C\" {\n#endif\n\n"\
" bool monitorVerify();\n\n"\
"#ifdef __cplusplus\n}\n#endif\n\n"\
"#endif"

◆ MONITOR_C_HEADER

#define MONITOR_C_HEADER
Value:
"%s\n" /* comment - when and how was this generated */\
"#include \"" GENERATED_FILES_NAME ".h\"\n\n"\
"#ifdef __cplusplus\n"\
"extern \"C\" {\n"\
"#endif\n\n"
#define GENERATED_FILES_NAME
Definition: monitorCreator.h:16

◆ MONITOR_STRUCT_DECLARATION

#define MONITOR_STRUCT_DECLARATION
Value:
"\ntypedef struct {\n"\
" expr values[%d];\n" /* count of state variables */ \
" const char* formulaeContents[%d];\n" /* count of formulae */\
" bool pre[%d], now[%d], check[%d];\n" /* 3x count of formulae */\
" int since[%d];\n" /* count of formulae */\
" int children[%d][%d];\n"/* count of formulae, max. count of children */\
" int chCnt[%d];\n" /* count of formulae */\
" int hb;\n"\
"} monitor;\n\n"

◆ MONITOR_STRUCT_DEFINITION

#define MONITOR_STRUCT_DEFINITION
Value:
"monitor M = {\n"\
" {%s\n" /* values of state variables */\
" },\n" \
" {%s\n" /* strings representing contents of formulae */\
" },\n" \
" {false},\n" /* pre */\
" {false},\n" /* now */\
" {false},\n" /* check */\
" {0},\n" /* since */\
" {%s\n"/* lists of children */\
" },\n" \
" { %s },\n"/* counts of children */\
" 0\n" /* initial heartbeat number */\
"};\n\n" \
"bool initiated = false;\n\n"

◆ MONITOR_VERIFY_CHECK_AND_FINALIZE

#define MONITOR_VERIFY_CHECK_AND_FINALIZE
Value:
"\n" \
" for (int i = 0; i < %d; i++) {\n" /* count of formulae */\
" if (M.now[i] != M.pre[i])\n" \
" M.since[i] = M.hb;\n" \
" if ((M.check[i] || i == 0) && M.since[i] == M.hb) {\n" \
" M.check[i] = true;" \
" for (int j = 0; j < M.chCnt[i]; j++) {\n" \
" M.check[M.children[i][j]] = true;\n" \
" }\n" \
" } else M.check[i] = false;\n" \
" }\n" \
"\n" \
" if (!M.now[0]) printFailReport();\n" \
" return M.now[0];\n" \
"}\n"

◆ MONITOR_VERIFY_INIT

#define MONITOR_VERIFY_INIT
Value:
"bool monitorVerify() {\n" \
" M.hb++;\n" \
" if (!initiated) {prepare();}\n" \
" else {\n" \
" for (int i = 0; i < %d; i++) {\n" /* count of formulae */\
" M.pre[i] = M.now[i]; }\n" \
" }\n" \
"\n"

Function Documentation

◆ fileSize()

long fileSize ( const char *  filename)