Removed unused (and problematic during SWIG) part of time_spec_t and exposed time_spec_t in the library's ABI

This commit is contained in:
Piotr Krysik 2017-11-03 09:58:13 +01:00
parent 6e41d06bbf
commit d32ba5b471
3 changed files with 24 additions and 56 deletions

View File

@ -18,6 +18,7 @@
#ifndef INCLUDED_TYPES_TIME_SPEC_HPP
#define INCLUDED_TYPES_TIME_SPEC_HPP
#include <grgsm/api.h>
#include <boost/operators.hpp>
#include <ctime>
@ -36,16 +37,9 @@ namespace gr {
* This gives the fractional seconds enough precision to unambiguously
* specify a clock-tick/sample-count up to rates of several petahertz.
*/
class time_spec_t : boost::additive<time_spec_t>, boost::totally_ordered<time_spec_t>{
class GRGSM_API time_spec_t : boost::additive<time_spec_t>, boost::totally_ordered<time_spec_t>{
public:
/*!
* Get the system time in time_spec_t format.
* Uses the highest precision clock available.
* \return the system time as a time_spec_t
*/
static time_spec_t get_system_time(void);
/*!
* Copy constructor
*/

View File

@ -20,54 +20,6 @@
namespace gr {
namespace gsm {
/***********************************************************************
* Time spec system time
**********************************************************************/
#ifdef HAVE_CLOCK_GETTIME
#include <time.h>
time_spec_t time_spec_t::get_system_time(void){
timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);
return time_spec_t(ts.tv_sec, ts.tv_nsec, 1e9);
}
#endif /* HAVE_CLOCK_GETTIME */
#ifdef HAVE_MACH_ABSOLUTE_TIME
#include <mach/mach_time.h>
time_spec_t time_spec_t::get_system_time(void){
mach_timebase_info_data_t info; mach_timebase_info(&info);
intmax_t nanosecs = mach_absolute_time()*info.numer/info.denom;
return time_spec_t::from_ticks(nanosecs, 1e9);
}
#endif /* HAVE_MACH_ABSOLUTE_TIME */
#ifdef HAVE_QUERY_PERFORMANCE_COUNTER
#include <Windows.h>
time_spec_t time_spec_t::get_system_time(void){
LARGE_INTEGER counts, freq;
QueryPerformanceCounter(&counts);
QueryPerformanceFrequency(&freq);
return time_spec_t::from_ticks(counts.QuadPart, double(freq.QuadPart));
}
#endif /* HAVE_QUERY_PERFORMANCE_COUNTER */
#ifdef HAVE_MICROSEC_CLOCK
#include <boost/date_time/posix_time/posix_time.hpp>
namespace pt = boost::posix_time;
time_spec_t time_spec_t::get_system_time(void){
pt::ptime time_now = pt::microsec_clock::universal_time();
pt::time_duration time_dur = time_now - pt::from_time_t(0);
return time_spec_t(
time_t(time_dur.total_seconds()),
long(time_dur.fractional_seconds()),
double(pt::time_duration::ticks_per_second())
);
}
#endif /* HAVE_MICROSEC_CLOCK */
/***********************************************************************
* Time spec constructors
**********************************************************************/

View File

@ -151,5 +151,27 @@ GR_SWIG_BLOCK_MAGIC2(gsm, message_source);
GR_SWIG_BLOCK_MAGIC2(gsm, message_sink);
%include "grgsm/trx_interface/trx.h"
GR_SWIG_BLOCK_MAGIC2(grgsm, trx);
//#pragma SWIG nowarn=319
//%include "grgsm/misc_utils/time_spec.h"
//%extend gr::gsm::time_spec_t{
// gr::gsm::time_spec_t __add__(const gr::gsm::time_spec_t &what)
// {
// gr::gsm::time_spec_t temp = *self;
// temp += what;
// return temp;
// }
// gr::gsm::time_spec_t __sub__(const gr::gsm::time_spec_t &what)
// {
// gr::gsm::time_spec_t temp = *self;
// temp -= what;
// return temp;
// }
// bool __eq__(const gr::gsm::time_spec_t &what)
// {
// return (what == *self);
// }
//};
%include "grgsm/misc_utils/fn_time.h"