1 |
/* $Id$ */ |
---|
2 |
|
---|
3 |
/* |
---|
4 |
* FreeBob Streaming API |
---|
5 |
* FreeBob = Firewire (pro-)audio for linux |
---|
6 |
* |
---|
7 |
* http://freebob.sf.net |
---|
8 |
* |
---|
9 |
* Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> |
---|
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 as published by |
---|
13 |
* the Free Software Foundation {} either version 2 of the License, or |
---|
14 |
* (at your option) any later version. |
---|
15 |
* |
---|
16 |
* This program is distributed in the hope that it will be useful, |
---|
17 |
* but WITHOUT ANY WARRANTY {} without even the implied warranty of |
---|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
19 |
* GNU General Public License for more details. |
---|
20 |
* |
---|
21 |
* You should have received a copy of the GNU General Public License |
---|
22 |
* along with this program {} if not, write to the Free Software |
---|
23 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
24 |
* |
---|
25 |
*/ |
---|
26 |
|
---|
27 |
#include "OscArgument.h" |
---|
28 |
|
---|
29 |
namespace OSC { |
---|
30 |
|
---|
31 |
IMPL_DEBUG_MODULE( OscArgument, OscArgument, DEBUG_LEVEL_VERBOSE ); |
---|
32 |
|
---|
33 |
OscArgument::OscArgument(int32_t i) |
---|
34 |
: m_isInt(true) |
---|
35 |
, m_intVal(i) |
---|
36 |
, m_isInt64(false) |
---|
37 |
, m_int64Val(0) |
---|
38 |
, m_isFloat(false) |
---|
39 |
, m_floatVal(0.0) |
---|
40 |
, m_isString(false) |
---|
41 |
, m_stringVal("") |
---|
42 |
{} |
---|
43 |
|
---|
44 |
OscArgument::OscArgument(int64_t i) |
---|
45 |
: m_isInt(false) |
---|
46 |
, m_intVal(0) |
---|
47 |
, m_isInt64(true) |
---|
48 |
, m_int64Val(i) |
---|
49 |
, m_isFloat(false) |
---|
50 |
, m_floatVal(0.0) |
---|
51 |
, m_isString(false) |
---|
52 |
, m_stringVal("") |
---|
53 |
{} |
---|
54 |
|
---|
55 |
OscArgument::OscArgument(float f) |
---|
56 |
: m_isInt(false) |
---|
57 |
, m_intVal(0) |
---|
58 |
, m_isInt64(false) |
---|
59 |
, m_int64Val(0) |
---|
60 |
, m_isFloat(true) |
---|
61 |
, m_floatVal(f) |
---|
62 |
, m_isString(false) |
---|
63 |
, m_stringVal("") |
---|
64 |
{} |
---|
65 |
|
---|
66 |
OscArgument::OscArgument(string s) |
---|
67 |
: m_isInt(false) |
---|
68 |
, m_intVal(0) |
---|
69 |
, m_isInt64(false) |
---|
70 |
, m_int64Val(0) |
---|
71 |
, m_isFloat(false) |
---|
72 |
, m_floatVal(0.0) |
---|
73 |
, m_isString(true) |
---|
74 |
, m_stringVal(s) |
---|
75 |
{} |
---|
76 |
|
---|
77 |
OscArgument::~OscArgument() |
---|
78 |
{} |
---|
79 |
|
---|
80 |
bool |
---|
81 |
OscArgument::operator == ( const OscArgument& rhs ) |
---|
82 |
{ |
---|
83 |
if(m_isInt && rhs.m_isInt) { |
---|
84 |
return m_intVal == rhs.m_intVal; |
---|
85 |
} else if(m_isInt64 && rhs.m_isInt64) { |
---|
86 |
return m_int64Val == rhs.m_int64Val; |
---|
87 |
} else if(m_isFloat && rhs.m_isFloat) { |
---|
88 |
return m_floatVal == rhs.m_floatVal; |
---|
89 |
} else if(m_isString && rhs.m_isString) { |
---|
90 |
return m_stringVal == rhs.m_stringVal; |
---|
91 |
} else { |
---|
92 |
return false; |
---|
93 |
} |
---|
94 |
} |
---|
95 |
|
---|
96 |
void |
---|
97 |
OscArgument::print() |
---|
98 |
{ |
---|
99 |
debugOutput(DEBUG_LEVEL_NORMAL, " Argument "); |
---|
100 |
if(m_isInt) { |
---|
101 |
debugOutputShort(DEBUG_LEVEL_NORMAL, " Int : %ld\n", m_intVal); |
---|
102 |
} else if(m_isInt64) { |
---|
103 |
debugOutputShort(DEBUG_LEVEL_NORMAL, " Int64 : %lld\n", m_int64Val); |
---|
104 |
} else if(m_isFloat) { |
---|
105 |
debugOutputShort(DEBUG_LEVEL_NORMAL, " Float : %f\n", m_floatVal); |
---|
106 |
} else if(m_isString) { |
---|
107 |
debugOutputShort(DEBUG_LEVEL_NORMAL, " String : %s\n", m_stringVal.c_str()); |
---|
108 |
} else { |
---|
109 |
debugOutputShort(DEBUG_LEVEL_NORMAL, " Empty\n"); |
---|
110 |
} |
---|
111 |
} |
---|
112 |
|
---|
113 |
} // end of namespace OSC |
---|