d49ed108cd22810799ad3a025ab2be55eba96c13
[ardour.git] / libs / ardour / ardour / data_type.h
1 /*
2     Copyright (C) 2006 Paul Davis 
3     
4     This program is free software; you can redistribute it and/or modify it
5     under the terms of the GNU General Public License as published by the Free
6     Software Foundation; either version 2 of the License, or (at your option)
7     any later version.
8     
9     This program is distributed in the hope that it will be useful, but WITHOUT
10     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12     for more details.
13     
14     You should have received a copy of the GNU General Public License along
15     with this program; if not, write to the Free Software Foundation, Inc.,
16     675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #ifndef __ardour_data_type_h__
20 #define __ardour_data_type_h__
21
22 #include <jack/jack.h>
23
24 namespace ARDOUR {
25
26 class DataType
27 {
28 public:
29         enum Symbol {
30                 NIL = 0,
31                 AUDIO,
32                 MIDI
33         };
34
35         DataType(const Symbol& symbol)
36         : _symbol(symbol)
37         {}
38
39         /** Construct from a string (Used for loading from XML) */
40         DataType(const string& str) {
41                 if (str == "audio")
42                         _symbol = AUDIO;
43                 //else if (str == "midi")
44                 //      _symbol = MIDI;
45                 else
46                         _symbol = NIL;
47         }
48
49         bool operator==(const Symbol symbol) { return _symbol == symbol; }
50         bool operator!=(const Symbol symbol) { return _symbol != symbol; }
51
52         /** Get the Jack type this DataType corresponds to */
53         const char* to_jack_type() {
54                 switch (_symbol) {
55                         case AUDIO: return JACK_DEFAULT_AUDIO_TYPE;
56                         //case MIDI:  return JACK_DEFAULT_MIDI_TYPE;
57                         default:    return "";
58                 }
59         }
60         
61         /** Inverse of the from-string constructor */
62         const char* to_string() {
63                 switch (_symbol) {
64                         case AUDIO: return "audio";
65                         //case MIDI:  return "midi";
66                         default:    return "unknown"; // reeeally shouldn't ever happen
67                 }
68         }
69
70 private:
71         Symbol _symbol;
72 };
73
74
75
76 } // namespace ARDOUR
77
78 #endif // __ardour_data_type_h__
79