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