1 /*****************************************************************************
2  * $LastChangedDate: 2009-11-22 22:39:11 -0500 (Sun, 22 Nov 2009) $
3  * @file
4  * @author  Jim E. Brooks  http://www.palomino3d.org
5  * @brief   Simulated time.
6  *//*
7  * LEGAL:   COPYRIGHT (C) 2008 JIM E. BROOKS
8  *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
9  *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
10  *****************************************************************************/
11 
12 #define GLUE_SIM_TIME_CC 1
13 #include "base/module.hh"
14 using namespace base;
15 #include "math/module.hh"
16 #include "math/funcs.hh"
17 using namespace math;
18 #include "glue/module.hh"
19 #include "glue/sim_time.hh"
20 
21 namespace glue {
22 
23 ////////////////////////////////////////////////////////////////////////////////
24 /////////////////////////////////  SimTime  ////////////////////////////////////
25 ////////////////////////////////////////////////////////////////////////////////
26 
27 SimTime* SimTime::msInstance;
28 
29 /*****************************************************************************
30  * ctor/dtor.
31  *****************************************************************************/
SimTime(void)32 SimTime::SimTime( void )
33 :   mHour(glue::defs::DEFAULT_HOUR)
34 {
35     // NOP
36 }
37 
~SimTime()38 SimTime::~SimTime()
39 {
40     // NOP
41 }
42 
43 /*****************************************************************************
44  * Change hour.
45  *****************************************************************************/
46 void
SetHour(const Hour hour)47 SimTime::SetHour( const Hour hour )
48 {
49 ASSERT_HOUR(hour);
50     mHour = hour;
51 }
52 
53 /*****************************************************************************
54  * Hour methods.
55  *****************************************************************************/
IfDayTime(void) const56 bool SimTime::IfDayTime( void                ) const { return IfDayTime( mHour ); }
IfDayTime(const Hour hour)57 bool SimTime::IfDayTime( const Hour hour     )       { return (hour > 7) and (hour < 6+12); }
IfMorningTime(void) const58 bool SimTime::IfMorningTime( void            ) const { return IfMorningTime( mHour ); }
IfMorningTime(const Hour hour)59 bool SimTime::IfMorningTime( const Hour hour )       { return (hour >= 6) and (hour <= 7); }
IfEveningTime(void) const60 bool SimTime::IfEveningTime( void            ) const { return IfEveningTime( mHour ); }
IfEveningTime(const Hour hour)61 bool SimTime::IfEveningTime( const Hour hour )       { return (hour >= 6+12) and (hour <= 7+12); }
IfNightTime(void) const62 bool SimTime::IfNightTime( void              ) const { return IfNightTime( mHour ); }
IfNightTime(const Hour hour)63 bool SimTime::IfNightTime( const Hour hour   )       { return (hour < 6) or (hour > 7+12); }  // OR (either segment of time)
64 
65 } // namespace glue
66