/builddir/build/BUILD/raul-0.4.0/raul/AtomLiblo.hpp

00001 /* This file is part of Raul.
00002  * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
00003  * 
00004  * Raul is free software; you can redistribute it and/or modify it under the
00005  * terms of the GNU General Public License as published by the Free Software
00006  * Foundation; either version 2 of the License, or (at your option) any later
00007  * version.
00008  * 
00009  * Raul is distributed in the hope that it will be useful, but WITHOUT ANY
00010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for details.
00012  * 
00013  * You should have received a copy of the GNU General Public License along
00014  * with this program; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00016  */
00017 
00018 #ifndef RAUL_ATOM_LIBLO_HPP
00019 #define RAUL_ATOM_LIBLO_HPP
00020 
00021 #include <lo/lo.h>
00022 #include <raul/Atom.hpp>
00023 
00024 namespace Raul {
00025 
00030 namespace AtomLiblo {
00031 
00033 inline void
00034 lo_message_add_atom(lo_message m, const Atom& atom)
00035 {
00036     switch (atom.type()) {
00037     case Atom::INT:
00038         lo_message_add_int32(m, atom.get_int32());
00039         break;
00040     case Atom::FLOAT:
00041         lo_message_add_float(m, atom.get_float());
00042         break;
00043     case Atom::STRING:
00044         lo_message_add_string(m, atom.get_string());
00045         break;
00046     case Atom::BLOB:
00047         // FIXME: is this okay?  what does liblo do?
00048         lo_message_add_blob(m, const_cast<void*>(atom.get_blob()));
00049         break;
00050     case Atom::NIL:
00051     default:
00052         lo_message_add_nil(m);
00053         break;
00054     }
00055 }
00056 
00057 
00059 inline Atom
00060 lo_arg_to_atom(char type, lo_arg* arg)
00061 {
00062     switch (type) {
00063     case 'i':
00064         return Atom(arg->i);
00065     case 'f':
00066         return Atom(arg->f);
00067     case 's':
00068         return Atom(&arg->s);
00069     //case 'b'
00070         // FIXME: How to get a blob from a lo_arg?
00071         //return Atom(arg->b);
00072     default:
00073         return Atom();
00074     }
00075 }
00076 
00077 
00078 } // namespace AtomLiblo
00079 } // namespace Raul
00080 
00081 #endif // RAUL_ATOM_LIBLO_HPP

Generated on Wed Apr 9 08:14:41 2008 for RAUL by  doxygen 1.5.1