diff options
author | Josh Blum | 2013-06-21 00:33:31 -0700 |
---|---|---|
committer | Josh Blum | 2013-06-21 00:33:31 -0700 |
commit | d47f192f9edfc2332fa73e6ed6c4c1cdedefb96c (patch) | |
tree | 9a7e3be6fc923b5e274b6cb634e751aa39e29ccd /include | |
parent | d08b195de44d2e85467de1764884c14973f92115 (diff) | |
download | sandhi-d47f192f9edfc2332fa73e6ed6c4c1cdedefb96c.tar.gz sandhi-d47f192f9edfc2332fa73e6ed6c4c1cdedefb96c.tar.bz2 sandhi-d47f192f9edfc2332fa73e6ed6c4c1cdedefb96c.zip |
gras: adding pythonic interface to time tag
Diffstat (limited to 'include')
-rw-r--r-- | include/gras/CMakeLists.txt | 3 | ||||
-rw-r--r-- | include/gras/time_tag.hpp | 7 | ||||
-rw-r--r-- | include/gras/time_tag.i | 39 |
3 files changed, 48 insertions, 1 deletions
diff --git a/include/gras/CMakeLists.txt b/include/gras/CMakeLists.txt index becd6cb..176d5e5 100644 --- a/include/gras/CMakeLists.txt +++ b/include/gras/CMakeLists.txt @@ -16,8 +16,9 @@ install(FILES sbuffer.hpp sbuffer.i tags.hpp - time_tag.hpp tags.i + time_tag.hpp + time_tag.i tag_iter.hpp tag_iter.i thread_pool.hpp diff --git a/include/gras/time_tag.hpp b/include/gras/time_tag.hpp index d350fa2..9459f9f 100644 --- a/include/gras/time_tag.hpp +++ b/include/gras/time_tag.hpp @@ -11,6 +11,13 @@ namespace gras { +/*! + * TimeTag represents an absolute time or a time delta. + * A TimeTag can be converted to and from a tick count. + * Conversion support is provided for the pseudo-standard + * PMCTuple format often used inside a StreamTag value. + * And TimeTag supports overloaded arithmetic operations. + */ struct GRAS_API TimeTag : boost::less_than_comparable<TimeTag>, boost::additive<TimeTag> diff --git a/include/gras/time_tag.i b/include/gras/time_tag.i new file mode 100644 index 0000000..fb3d721 --- /dev/null +++ b/include/gras/time_tag.i @@ -0,0 +1,39 @@ +// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. + +#ifndef INCLUDED_GRAS_TIME_TAG_I +#define INCLUDED_GRAS_TIME_TAG_I + +%{ +#include <gras/time_tag.hpp> +%} + +//////////////////////////////////////////////////////////////////////// +// remove base class warning -- boost::less_than_comparable<TimeTag> +// remove base class warning -- boost::additive<TimeTag> +//////////////////////////////////////////////////////////////////////// +#pragma SWIG nowarn=401 + +%include <gras/gras.hpp> +%include <gras/chrono.hpp> +%include <gras/time_tag.hpp> +%import <PMC/PMC.i> + +//////////////////////////////////////////////////////////////////////// +// Make it pythonic +//////////////////////////////////////////////////////////////////////// +%extend gras::TimeTag +{ + bool __nonzero__(void) + { + return ($self)->to_ticks() != 0; + } + + int __cmp__(const TimeTag &other) + { + if ((*($self)) < other) return -1; + if ((*($self)) > other) return +1; + return 0; + } +} + +#endif /*INCLUDED_GRAS_TIME_TAG_I*/ |