Add tiny test
[ctsim.git] / libctsim / trace.cpp
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:         trace.cpp        Class for trace
5 **   Programmer:   Kevin Rosenberg
6 **   Date Started: June 2000
7 **
8 **  This is part of the CTSim program
9 **  Copyright (C) 1983-2009 Kevin Rosenberg
10 **
11 **  This program is free software; you can redistribute it and/or modify
12 **  it under the terms of the GNU General Public License (version 2) as
13 **  published by the Free Software Foundation.
14 **
15 **  This program is distributed in the hope that it will be useful,
16 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 **  GNU General Public License for more details.
19 **
20 **  You should have received a copy of the GNU General Public License
21 **  along with this program; if not, write to the Free Software
22 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23 ******************************************************************************/
24
25 #include "ct.h"
26
27 const int Trace::TRACE_INVALID = -1;
28 const int Trace::TRACE_NONE = 0;
29 const int Trace::TRACE_CONSOLE = 1;
30 const int Trace::TRACE_PHANTOM = 2;
31 const int Trace::TRACE_PROJECTIONS = 3;
32 const int Trace::TRACE_PLOT = 4;
33 const int Trace::TRACE_CLIPPING = 5;
34
35 const int Trace::BIT_CONSOLE = 0x0001;
36 const int Trace::BIT_PHANTOM = 0x0002;
37 const int Trace::BIT_PROJECTIONS = 0x0004;
38 const int Trace::BIT_PLOT = 0x0008;
39 const int Trace::BIT_CLIPPING = 0x0010;
40
41 const char* Trace::s_aszTraceName[] =
42 {
43   "none",
44   "console",
45   "phantom",
46   "proj",
47   "plot",
48   "clipping",
49 };
50
51 const char* Trace::s_aszTraceTitle[] =
52 {
53   "None",
54   "Console",
55   "Phantom",
56   "Projections",
57   "Plot",
58   "Clipping",
59 };
60
61 const int Trace::s_iTraceCount = sizeof(s_aszTraceName) / sizeof(const char*);
62
63
64 const char*
65 Trace::convertTraceIDToName (const int idTrace)
66 {
67   const char *name = "";
68
69   if (idTrace >= 0 && idTrace < s_iTraceCount)
70       return (s_aszTraceName[idTrace]);
71
72   return (name);
73 }
74
75 const char*
76 Trace::convertTraceIDToTitle (const int idTrace)
77 {
78   const char *title = "";
79
80   if (idTrace >= 0 && idTrace < s_iTraceCount)
81       return (s_aszTraceName[idTrace]);
82
83   return (title);
84 }
85
86 int
87 Trace::convertTraceNameToID (const char* const traceName)
88 {
89   int id = Trace::TRACE_INVALID;
90
91   for (int i = 0; i < s_iTraceCount; i++)
92       if (strcasecmp (traceName, s_aszTraceName[i]) == 0) {
93           id = i;
94           break;
95       }
96
97   return (id);
98 }
99