X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=include%2Ftrace.h;h=20e3186e8cc70164c98c81f10b04c154b8eb736f;hp=d302d3c2f7e1f8afa61e73c2e63c66db55d3fdc9;hb=7ef485116d6859eb1e31753b3e3a89de44985272;hpb=2d39e823ba389fc68e5317c422b55be006094252 diff --git a/include/trace.h b/include/trace.h index d302d3c..20e3186 100644 --- a/include/trace.h +++ b/include/trace.h @@ -1,14 +1,6 @@ #ifndef TRACE_H #define TRACE_H -// Trace levels -static const char TRACE_NONE_STR[]= "none"; -static const char TRACE_TEXT_STR[]= "text"; -static const char TRACE_PHM_STR[]= "phm"; -static const char TRACE_RAYS_STR[]= "rays"; -static const char TRACE_PLOT_STR[]= "plot"; -static const char TRACE_CLIPPING_STR[]= "clipping"; - enum { TRACE_NONE, /* No tracing */ TRACE_TEXT, /* Minimal status */ @@ -18,29 +10,51 @@ enum { TRACE_CLIPPING /* Plot clipping */ }; +static const char TRACE_NONE_STR[]= "none"; +static const char TRACE_TEXT_STR[]= "text"; +static const char TRACE_PHM_STR[]= "phm"; +static const char TRACE_RAYS_STR[]= "rays"; +static const char TRACE_PLOT_STR[]= "plot"; +static const char TRACE_CLIPPING_STR[]= "clipping"; + +class TraceLevel +{ + public: + TraceLevel (const char* const traceString); + + addTrace (const char* const traceString); + + bool isTrace (const char* const traceQuery) const; + + private: + + bool addTraceElements (const char* const traceString); +}; + + inline int -opt_set_trace (const char *optarg) +opt_set_trace (const char *traceString) { - int opt; - - if (strcmp(optarg, TRACE_NONE_STR) == 0) - opt = TRACE_NONE; - else if (strcmp(optarg, TRACE_TEXT_STR) == 0) - opt = TRACE_TEXT; - else if (strcmp(optarg, TRACE_PHM_STR) == 0) - opt = TRACE_PHM; - else if (strcmp(optarg, TRACE_PLOT_STR) == 0) - opt = TRACE_PLOT; - else if (strcmp(optarg, TRACE_CLIPPING_STR) == 0) - opt = TRACE_CLIPPING; - else if (strcmp(optarg, TRACE_RAYS_STR) == 0) - opt = TRACE_RAYS; + int traceID; + + if (strcasecmp (traceString, TRACE_NONE_STR) == 0) + traceID = TRACE_NONE; + else if (strcasecmp (traceString, TRACE_TEXT_STR) == 0) + traceID = TRACE_TEXT; + else if (strcasecmp (traceString, TRACE_PHM_STR) == 0) + traceID = TRACE_PHM; + else if (strcasecmp (traceString, TRACE_PLOT_STR) == 0) + traceID = TRACE_PLOT; + else if (strcasecmp (traceString, TRACE_CLIPPING_STR) == 0) + traceID = TRACE_CLIPPING; + else if (strcasecmp (traceString, TRACE_RAYS_STR) == 0) + traceID = TRACE_RAYS; else { - sys_error(ERR_WARNING,"Invalid trace option %s\n", optarg); - opt = -1; + sys_error(ERR_WARNING,"Invalid trace option %s\n", traceString); + traceID = -1; } - return (opt); + return (traceID); }