00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef RAUL_ATOM_LIBLO_HPP
00019 #define RAUL_ATOM_LIBLO_HPP
00020
00021 #include <iostream>
00022 #include <lo/lo.h>
00023 #include <raul/Atom.hpp>
00024
00025 namespace Raul {
00026
00031 namespace AtomLiblo {
00032
00034 inline void
00035 lo_message_add_atom(lo_message m, const Atom& atom)
00036 {
00037 switch (atom.type()) {
00038 case Atom::INT:
00039 lo_message_add_int32(m, atom.get_int32());
00040 break;
00041 case Atom::FLOAT:
00042 lo_message_add_float(m, atom.get_float());
00043 break;
00044 case Atom::STRING:
00045 lo_message_add_string(m, atom.get_string());
00046 break;
00047 case Atom::BOOL:
00048 if (atom.get_bool())
00049 lo_message_add_true(m);
00050 else
00051 lo_message_add_false(m);
00052 break;
00053 case Atom::BLOB:
00054 lo_message_add_blob(m, lo_blob_new(atom.data_size(), atom.get_blob()));
00055 break;
00056 case Atom::NIL:
00057 default:
00058 lo_message_add_nil(m);
00059 break;
00060 }
00061 }
00062
00063
00065 inline Atom
00066 lo_arg_to_atom(char type, lo_arg* arg)
00067 {
00068 switch (type) {
00069 case 'i':
00070 return Atom(arg->i);
00071 case 'f':
00072 return Atom(arg->f);
00073 case 's':
00074 return Atom(&arg->s);
00075 case 'T':
00076 return Atom((bool)true);
00077 case 'F':
00078 return Atom((bool)false);
00079 default:
00080 std::cerr << "WARNING: Unable to convert OSC type '"
00081 << type << "' to Atom" << std::endl;
00082 return Atom();
00083 }
00084 }
00085
00086
00087 }
00088 }
00089
00090 #endif // RAUL_ATOM_LIBLO_HPP