Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cTimeSchedule.h
Go to the documentation of this file.
1 //
6 
7 #ifndef _INC_cTimeSchedule_H
8 #define _INC_cTimeSchedule_H
9 #ifndef NO_PRAGMA_ONCE
10 #pragma once
11 #endif
12 
13 #include "../GrayLibBase.h"
17 #include "GrayCore/include/cAtom.h"
19 
20 namespace GrayLib
21 {
23 
24  class cTimeScheduleVal : public cRefBase
25  {
28  public:
30  {
31  }
33  {
34  }
35  virtual bool IsActiveEval(const cTimeUnits& rTimeNow) = 0;
36  };
37 
39  {
42  private:
43  cAtomRef m_aSpecialName;
44  public:
46  : m_aSpecialName(aSpecialName)
47  {
48  }
50  {
51  return m_aSpecialName.get_StrA();
52  }
53  };
55 
57  {
61 
62  public:
63  bool m_bAnd;
64  bool m_bNot;
65 
66  public:
67  cTimeScheduleElem(bool bAnd = false)
68  : m_bAnd(bAnd)
69  {
70  }
71  };
72 
74  {
77 
78  private:
79  TIMEUNIT_TYPE m_eField;
80  WORD m_wStart;
81  WORD m_wStop;
82 
83  public:
84  cTimeScheduleField(TIMEUNIT_TYPE eField = TIMEUNIT_QTY, WORD wStart = 0, WORD wStop = 0)
85  : cTimeScheduleElem(false)
86  , m_eField(eField)
87  , m_wStart(wStart)
88  , m_wStop(wStop)
89  {
90  }
91 
92  virtual bool IsActiveEval(const cTimeUnits& rTimeNow) const;
93  };
94 
96  {
100  private:
101  cTimeScheduleSpecialEvalPtr m_pSpecialEval;
102  public:
104  : cTimeScheduleElem(false)
105  , m_pSpecialEval(pSpecialEval)
106  {
107  }
108  virtual bool IsActiveEval(const cTimeUnits& rTimeNow) const;
109  };
110 
112  {
115  public:
116  bool IsActiveEval(const cTimeUnits& rTimeNow) const;
118  };
119 
121  {
124  public:
126  : cTimeScheduleElem(false)
127  {
128  }
129  virtual bool IsActiveEval(const cTimeUnits& rTimeNow) const
130  {
131  return cTimeScheduleSet::IsActiveEval(rTimeNow);
132  }
133  };
134 
136  {
143 
144  public:
146  cTimeScheduleSet m_Rules; // boolean algebra rule set for when this should run.
147  cTimeInt m_tLast; // Last time this was run.
148 
149  public:
150  cTimeSchedule();
151  cTimeSchedule(const char* pszText);
152  ~cTimeSchedule();
153 
154  HRESULT SetRules(const char* pszText);
155  HRESULT AddRuleElem(cTimeScheduleElem* pElem);
156 
158  bool IsActiveEval(const cTimeUnits& rTimeNow) const;
159  bool IsActiveEval(const cTimeInt& rTimeNow) const;
160 
161  // @todo When will this be true/false next. transition.
162  // @todo Serialize
163 
165  };
166 
167  class GRAYLIB_LINK cTimeScheduleMgr : public cSingleton<cTimeScheduleMgr>
168  {
173 
174  private:
176  // @todo cache results for these ?
177 
178  public:
180  ~cTimeScheduleMgr();
181 
182  cAtomRef FindSpecial(const char* pszName) const;
184  bool IsActiveEval(const cTimeScheduleSpecialEval* pEval, const cTimeUnits& rTimeNow) const;
185  };
186 };
187 #endif // _INC_cTimeSchedule_H
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define CHEAPOBJECT_IMPL
Definition: cHeapObject.h:32
Definition: cTimeSchedule.h:121
virtual bool IsActiveEval(const cTimeUnits &rTimeNow) const
Definition: cTimeSchedule.h:129
cTimeScheduleBlock()
Definition: cTimeSchedule.h:125
Definition: cTimeSchedule.h:57
cTimeScheduleElem(bool bAnd=false)
Definition: cTimeSchedule.h:67
bool m_bAnd
And/Or Boolean logic on cTimeScheduleSet.
Definition: cTimeSchedule.h:63
bool m_bNot
Definition: cTimeSchedule.h:64
Definition: cTimeSchedule.h:74
virtual bool IsActiveEval(const cTimeUnits &rTimeNow) const
cTimeScheduleField(TIMEUNIT_TYPE eField=TIMEUNIT_QTY, WORD wStart=0, WORD wStop=0)
Definition: cTimeSchedule.h:84
Definition: cTimeSchedule.h:168
bool IsActiveEval(const cTimeScheduleSpecialEval *pEval, const cTimeUnits &rTimeNow) const
cAtomRef FindSpecial(const char *pszName) const
HRESULT AddSpecial(cTimeScheduleSpecialEval *pEval) const
Definition: cTimeSchedule.h:112
bool IsActiveEval(const cTimeUnits &rTimeNow) const
cArrayRef< cTimeScheduleElem > m_Rules
boolean algebra rules
Definition: cTimeSchedule.h:117
Definition: cTimeSchedule.h:39
cTimeScheduleSpecialEval(cAtomRef aSpecialName)
Definition: cTimeSchedule.h:45
cStringA get_Name() const
Definition: cTimeSchedule.h:49
Definition: cTimeSchedule.h:96
virtual bool IsActiveEval(const cTimeUnits &rTimeNow) const
cTimeScheduleSpecial(cTimeScheduleSpecialEval *pSpecialEval)
Definition: cTimeSchedule.h:103
Definition: cTimeSchedule.h:25
virtual ~cTimeScheduleVal()
Definition: cTimeSchedule.h:32
virtual bool IsActiveEval(const cTimeUnits &rTimeNow)=0
cTimeScheduleVal()
Definition: cTimeSchedule.h:29
Definition: cTimeSchedule.h:136
cTimeInt m_tLast
Definition: cTimeSchedule.h:147
cTimeScheduleSet m_Rules
Rules that apply to when this will happen.
Definition: cTimeSchedule.h:146
UNITTEST_FRIEND(cTimeSchedule)
Definition: cArrayRef.h:21
Definition: cArraySortRef.h:199
Definition: cAtom.h:63
const STR_t & get_StrA() const noexcept
Definition: cAtom.h:120
Definition: cRefPtr.h:22
Definition: cSingleton.h:127
< similar to the MFC CTime and cTimeSpan, not as accurate or large ranged as COleDateTime
Definition: cTimeInt.h:101
Definition: cTimeUnits.h:146
Definition: cMesh.h:22
UNITTEST2_PREDEF(cQuadtree)
cRefPtr< cTimeScheduleSpecialEval > cTimeScheduleSpecialEvalPtr
Definition: cTimeSchedule.h:54
TIMEUNIT_TYPE
Definition: cTimeUnits.h:124
@ TIMEUNIT_QTY
END of cTimeUnits.
Definition: cTimeUnits.h:137