|
gr-baz Package
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2004,2013 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 /* 00024 * gr-baz by Balint Seeber (http://spench.net/contact) 00025 * Information, documentation & samples: http://wiki.spench.net/wiki/gr-baz 00026 */ 00027 00028 #ifndef INCLUDED_BAZ_TIME_KEEPER_H 00029 #define INCLUDED_BAZ_TIME_KEEPER_H 00030 00031 #include <gr_sync_block.h> 00032 //#include <gr_msg_queue.h> 00033 #include <gruel/thread.h> 00034 00035 class BAZ_API baz_time_keeper; 00036 00037 /* 00038 * We use boost::shared_ptr's instead of raw pointers for all access 00039 * to gr_blocks (and many other data structures). The shared_ptr gets 00040 * us transparent reference counting, which greatly simplifies storage 00041 * management issues. This is especially helpful in our hybrid 00042 * C++ / Python system. 00043 * 00044 * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm 00045 * 00046 * As a convention, the _sptr suffix indicates a boost::shared_ptr 00047 */ 00048 typedef boost::shared_ptr<baz_time_keeper> baz_time_keeper_sptr; 00049 00050 /*! 00051 * \brief Return a shared_ptr to a new instance of baz_time_keeper. 00052 * 00053 * To avoid accidental use of raw pointers, baz_time_keeper's 00054 * constructor is private. howto_make_square2_ff is the public 00055 * interface for creating new instances. 00056 */ 00057 BAZ_API baz_time_keeper_sptr baz_make_time_keeper (int item_size, int sample_rate); 00058 00059 /*! 00060 * \brief square2 a stream of floats. 00061 * \ingroup block 00062 * 00063 * This uses the preferred technique: subclassing gr_sync_block. 00064 */ 00065 class BAZ_API baz_time_keeper : public gr_sync_block 00066 { 00067 private: 00068 // The friend declaration allows baz_time_keeper to 00069 // access the private constructor. 00070 00071 friend BAZ_API baz_time_keeper_sptr baz_make_time_keeper (int item_size, int sample_rate); 00072 00073 baz_time_keeper (int item_size, int sample_rate); // private constructor 00074 00075 int d_item_size; 00076 uint64_t d_last_time_seconds, d_first_time_seconds; 00077 double d_last_time_fractional_seconds, d_first_time_fractional_seconds; 00078 uint64_t d_time_offset; 00079 int d_sample_rate; 00080 bool d_seen_time; 00081 int d_update_count; 00082 bool d_ignore_next; 00083 gruel::mutex d_mutex; 00084 00085 public: 00086 ~baz_time_keeper (); // public destructor 00087 00088 double time(bool relative = false); 00089 void ignore_next(bool ignore = true); 00090 int update_count(void); 00091 00092 int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); 00093 }; 00094 00095 #endif /* INCLUDED_BAZ_TIME_KEEPER_H */