GNU Radio 3.6.5 C++ API

gr_audio_registry.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2011 Free Software Foundation, Inc.
00003  *
00004  * This file is part of GNU Radio
00005  *
00006  * GNU Radio is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 3, or (at your option)
00009  * any later version.
00010  *
00011  * GNU Radio is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with GNU Radio; see the file COPYING.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street,
00019  * Boston, MA 02110-1301, USA.
00020  */
00021 
00022 #ifndef INCLUDED_GR_AUDIO_REGISTRY_H
00023 #define INCLUDED_GR_AUDIO_REGISTRY_H
00024 
00025 #include <gr_audio_sink.h>
00026 #include <gr_audio_source.h>
00027 #include <string>
00028 
00029 typedef audio_source::sptr(*source_factory_t)(int, const std::string &, bool);
00030 typedef audio_sink::sptr(*sink_factory_t)(int, const std::string &, bool);
00031 
00032 enum reg_prio_type{
00033     REG_PRIO_LOW = 100,
00034     REG_PRIO_MED = 200,
00035     REG_PRIO_HIGH = 300
00036 };
00037 
00038 void audio_register_source(reg_prio_type prio, const std::string &arch, source_factory_t source);
00039 void audio_register_sink(reg_prio_type prio, const std::string &arch, sink_factory_t sink);
00040 
00041 #define AUDIO_REGISTER_FIXTURE(x) static struct x{x();}x;x::x()
00042 
00043 #define AUDIO_REGISTER_SOURCE(prio, arch) \
00044     static audio_source::sptr arch##_source_fcn(int, const std::string &, bool); \
00045     AUDIO_REGISTER_FIXTURE(arch##_source_reg){ \
00046         audio_register_source(prio, #arch, &arch##_source_fcn); \
00047     } static audio_source::sptr arch##_source_fcn
00048 
00049 #define AUDIO_REGISTER_SINK(prio, arch) \
00050     static audio_sink::sptr arch##_sink_fcn(int, const std::string &, bool); \
00051     AUDIO_REGISTER_FIXTURE(arch##_sink_reg){ \
00052         audio_register_sink(prio, #arch, &arch##_sink_fcn); \
00053     } static audio_sink::sptr arch##_sink_fcn
00054 
00055 #endif /* INCLUDED_GR_AUDIO_REGISTRY_H */