GNU Radio 3.4.0 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2010 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef INCLUDED_GR_TAG_INFO_H 00024 #define INCLUDED_GR_TAG_INFO_H 00025 00026 #include <gruel/pmt.h> 00027 00028 namespace gr_tags { 00029 00030 enum { 00031 TAG_NITEM_REF = 0, 00032 TAG_SRCID_REF, 00033 TAG_KEY_REF, 00034 TAG_VALUE_REF 00035 }; 00036 00037 /* 00038 extern const pmt::pmt_t key_time; 00039 extern const pmt::pmt_t key_sample_rate; 00040 extern const pmt::pmt_t key_frequency; 00041 extern const pmt::pmt_t key_rssi; 00042 extern const pmt::pmt_t key_gain; 00043 */ 00044 00045 /*! 00046 * \brief Returns the item \p tag occurred at (as a uint64_t) 00047 */ 00048 static inline uint64_t 00049 get_nitems(const pmt::pmt_t &tag) { 00050 return pmt::pmt_to_uint64(pmt::pmt_tuple_ref(tag, TAG_NITEM_REF)); 00051 } 00052 00053 /*! 00054 * \brief Returns the source ID of \p tag (as a PMT) 00055 */ 00056 static inline pmt::pmt_t 00057 get_srcid(const pmt::pmt_t &tag) { 00058 return pmt::pmt_tuple_ref(tag, TAG_SRCID_REF); 00059 } 00060 00061 /*! 00062 * \brief Returns the key of \p tag (as a PMT symbol) 00063 */ 00064 static inline pmt::pmt_t 00065 get_key(const pmt::pmt_t &tag) { 00066 return pmt::pmt_tuple_ref(tag, TAG_KEY_REF); 00067 } 00068 00069 /*! 00070 * \brief Returns the value of \p tag (as a PMT) 00071 */ 00072 static inline pmt::pmt_t 00073 get_value(const pmt::pmt_t &tag) { 00074 return pmt::pmt_tuple_ref(tag, TAG_VALUE_REF); 00075 } 00076 00077 /*! 00078 * \brief Comparison function to test which tag, \p x or \p y, came first in time 00079 */ 00080 static inline bool 00081 nitems_compare(pmt::pmt_t x, pmt::pmt_t y) { 00082 return get_nitems(x) < get_nitems(y); 00083 } 00084 00085 }; /* namespace tags */ 00086 00087 #endif /* GR_TAG_INFO */