BVB Source Codes

mars Show posix_time_config.hpp Source code

Return Download mars: download posix_time_config.hpp Source code - Download mars Source code - Type:.hpp
  1. #ifndef POSIX_TIME_CONFIG_HPP___
  2. #define POSIX_TIME_CONFIG_HPP___
  3.  
  4. /* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
  5.  * Use, modification and distribution is subject to the
  6.  * Boost Software License, Version 1.0. (See accompanying
  7.  * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  8.  * Author: Jeff Garland, Bart Garst
  9.  * $Date$
  10.  */
  11.  
  12. #include <cstdlib> //for MCW 7.2 std::abs(long long)
  13. #include <boost/limits.hpp>
  14. #include <boost/cstdint.hpp>
  15. #include <boost/config/no_tr1/cmath.hpp>
  16. #include <boost/date_time/time_duration.hpp>
  17. #include <boost/date_time/time_resolution_traits.hpp>
  18. #include <boost/date_time/gregorian/gregorian_types.hpp>
  19. #include <boost/date_time/wrapping_int.hpp>
  20. #include <boost/date_time/compiler_config.hpp>
  21.  
  22. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost {
  23. namespace posix_time {
  24.  
  25. //Remove the following line if you want 64 bit millisecond resolution time
  26. //#define BOOST_GDTL_POSIX_TIME_STD_CONFIG
  27.  
  28. #ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
  29.   // set up conditional test compilations
  30. #define BOOST_DATE_TIME_HAS_MILLISECONDS
  31. #define BOOST_DATE_TIME_HAS_MICROSECONDS
  32. #define BOOST_DATE_TIME_HAS_NANOSECONDS
  33.   typedef date_time::time_resolution_traits<mars_boost::date_time::time_resolution_traits_adapted64_impl, mars_boost::date_time::nano,
  34.     1000000000, 9 > time_res_traits;
  35. #else
  36.   // set up conditional test compilations
  37. #define BOOST_DATE_TIME_HAS_MILLISECONDS
  38. #define BOOST_DATE_TIME_HAS_MICROSECONDS
  39. #undef  BOOST_DATE_TIME_HAS_NANOSECONDS
  40.   typedef date_time::time_resolution_traits<
  41.     mars_boost::date_time::time_resolution_traits_adapted64_impl, mars_boost::date_time::micro,
  42.                                             1000000, 6 > time_res_traits;
  43.  
  44.  
  45. // #undef BOOST_DATE_TIME_HAS_MILLISECONDS
  46. // #undef BOOST_DATE_TIME_HAS_MICROSECONDS
  47. // #undef BOOST_DATE_TIME_HAS_NANOSECONDS
  48. //   typedef date_time::time_resolution_traits<mars_boost::int64_t, mars_boost::date_time::tenth,
  49. //                                              10, 0 > time_res_traits;
  50.  
  51. #endif
  52.  
  53.  
  54.   //! Base time duration type
  55.   /*! \ingroup time_basics
  56.    */
  57.   class time_duration :
  58.     public date_time::time_duration<time_duration, time_res_traits>
  59.   {
  60.   public:
  61.     typedef time_res_traits rep_type;
  62.     typedef time_res_traits::day_type day_type;
  63.     typedef time_res_traits::hour_type hour_type;
  64.     typedef time_res_traits::min_type min_type;
  65.     typedef time_res_traits::sec_type sec_type;
  66.     typedef time_res_traits::fractional_seconds_type fractional_seconds_type;
  67.     typedef time_res_traits::tick_type tick_type;
  68.     typedef time_res_traits::impl_type impl_type;
  69.     time_duration(hour_type hour,
  70.                   min_type min,
  71.                   sec_type sec,
  72.                   fractional_seconds_type fs=0) :
  73.       date_time::time_duration<time_duration, time_res_traits>(hour,min,sec,fs)
  74.     {}
  75.     time_duration() :
  76.       date_time::time_duration<time_duration, time_res_traits>(0,0,0)
  77.     {}
  78.     //! Construct from special_values
  79.     time_duration(mars_boost::date_time::special_values sv) :
  80.       date_time::time_duration<time_duration, time_res_traits>(sv)
  81.     {}
  82.     //Give duration access to ticks constructor -- hide from users
  83.     friend class date_time::time_duration<time_duration, time_res_traits>;
  84.   protected:
  85.     explicit time_duration(impl_type tick_count) :
  86.       date_time::time_duration<time_duration, time_res_traits>(tick_count)
  87.     {}
  88.   };
  89.  
  90. #ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
  91.  
  92.   //! Simple implementation for the time rep
  93.   struct simple_time_rep
  94.   {
  95.     typedef gregorian::date      date_type;
  96.     typedef time_duration        time_duration_type;
  97.     simple_time_rep(date_type d, time_duration_type tod) :
  98.       day(d),
  99.       time_of_day(tod)
  100.     {
  101.       // make sure we have sane values for date & time
  102.       if(!day.is_special() && !time_of_day.is_special()){
  103.         if(time_of_day >= time_duration_type(24,0,0)) {
  104.           while(time_of_day >= time_duration_type(24,0,0)) {
  105.             day += date_type::duration_type(1);
  106.             time_of_day -= time_duration_type(24,0,0);
  107.           }
  108.         }
  109.         else if(time_of_day.is_negative()) {
  110.           while(time_of_day.is_negative()) {
  111.             day -= date_type::duration_type(1);
  112.             time_of_day += time_duration_type(24,0,0);
  113.           }
  114.         }
  115.       }
  116.     }
  117.     date_type day;
  118.     time_duration_type time_of_day;
  119.     bool is_special()const
  120.     {
  121.       return(is_pos_infinity() || is_neg_infinity() || is_not_a_date_time());
  122.     }
  123.     bool is_pos_infinity()const
  124.     {
  125.       return(day.is_pos_infinity() || time_of_day.is_pos_infinity());
  126.     }
  127.     bool is_neg_infinity()const
  128.     {
  129.       return(day.is_neg_infinity() || time_of_day.is_neg_infinity());
  130.     }
  131.     bool is_not_a_date_time()const
  132.     {
  133.       return(day.is_not_a_date() || time_of_day.is_not_a_date_time());
  134.     }
  135.   };
  136.  
  137.   class posix_time_system_config
  138.   {
  139.    public:
  140.     typedef simple_time_rep time_rep_type;
  141.     typedef gregorian::date date_type;
  142.     typedef gregorian::date_duration date_duration_type;
  143.     typedef time_duration time_duration_type;
  144.     typedef time_res_traits::tick_type int_type;
  145.     typedef time_res_traits resolution_traits;
  146. #if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT)) //help bad compilers
  147. #else
  148.     BOOST_STATIC_CONSTANT(mars_boost::int64_t, tick_per_second = 1000000000);
  149. #endif
  150.   };
  151.  
  152. #else
  153.  
  154.   class millisec_posix_time_system_config
  155.   {
  156.    public:
  157.     typedef mars_boost::int64_t time_rep_type;
  158.     //typedef time_res_traits::tick_type time_rep_type;
  159.     typedef gregorian::date date_type;
  160.     typedef gregorian::date_duration date_duration_type;
  161.     typedef time_duration time_duration_type;
  162.     typedef time_res_traits::tick_type int_type;
  163.     typedef time_res_traits::impl_type impl_type;
  164.     typedef time_res_traits resolution_traits;
  165. #if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT)) //help bad compilers
  166. #else
  167.     BOOST_STATIC_CONSTANT(mars_boost::int64_t, tick_per_second = 1000000);
  168. #endif
  169.   };
  170.  
  171. #endif
  172.  
  173. } }//namespace posix_time
  174.  
  175.  
  176. #endif
  177.  
  178.  
  179.  
downloadposix_time_config.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top