MTimeRule.h
1 /*****************************************************************************
2  **
3  ** Header file for Muster API Time rule object lib
4  **
5  ** Name : MTimeRule.h
6  ** Author : Leonardo Bernardini
7  ** Version : Alpha 9.0 Wed May 17th 2017
8  **
9  ** Copyright 2000-2017, Virtual Vertex
10  ** All Rights Reserved.
11  **
12  ** This file contains UNPUBLISHED PROPRIETARY SOURCE CODE.
13  ** The contents of this file may not be disclosed to third parties, copied
14  ** or duplicated in any form, in whole or in part, without the prior written
15  ** permission of the author.
16  **
17  *****************************************************************************/
18 #ifndef MTIMERULE_H
19 #define MTIMERULE_H
20 
21 #ifdef WIN32
22 // Windows definitions
23 #ifdef MCLIENTLIB_EXPORTS
24 #define MCLIENTLIB_API __declspec(dllexport)
25 #else
26 #define MCLIENTLIB_API __declspec(dllimport)
27 #endif
28 #else
29 
30 #ifndef MCLIENTLIB_EXPORTS
31 #ifdef LINUX
32 #define MCLIENTLIB_API
33 #else
34 #define MCLIENTLIB_API
35 #endif
36 #else
37 #define MCLIENTLIB_API
38 #endif
39 #endif
40 
41 // Disable STL Export warning, member is private, we don't need direct access from the DLL client
42 #if defined(_WIN32)
43 #pragma warning(disable: 4251)
44 #endif // _WIN32
45 
46 #include <string>
47 #include <vector>
48 #include <list>
49 
50 namespace MClientLib {
51 
62  class MCLIENTLIB_API MTimeRule {
63  private:
64  int type;
65  int availability;
66  long long int startingTime;
67  long long int endingTime;
68 
69 
70  public:
71 
72  enum kTimeRulesEvaluation {
73  kTimeRuleMatch,
74  kTimeRuleDontMatch,
75  kTimeRuleNotPertinent
76  };
77 
78  enum kTimeRulesType {
79  kTimeRuleDayRange,
80  kTimeRuleTimeSpan
81  };
82 
83  enum kTimeRulesAvailability {
84  kTimeRuleNotAvailable,
85  kTimeRuleAvailable
86  };
87 
88  MTimeRule();
89  void setType(int ruleType);
90  int getType();
91 
92  void setAvailability(int ruleAvailability);
93  int getAvailability();
94 
95  void getRuleTimeSpan(long long int& _startingTime, long long int& _endingTime);
96  void setRuleTimeSpan(long long int _startingTime, long long int _endingTime);
97  void setRuleDayRange(int startingDay, int startingHour, int startingMinutes,
98  int endingDay,int endingHours, int endingMinutes);
99  void getRuleDayRange(int& startingDay, int& startingHour, int& startingMinutes,
100  int& endingDay,int& endingHours, int& endingMinutes);
101 
104  static std::vector<MTimeRule> Unmarshall(const std::string& );
105  static std::string Marshall(const std::vector<MTimeRule>& list);
106 
107 
108 #ifndef SWIG
109  void encodeTree(void* _pt, std::string (*encodeFunc)(const std::string &),int encoding) const;
110  void decodeTree(void* _pt);
111  int Evaluate() const;
112  static int Evaluate(const std::vector<MTimeRule>& rules,int defaultValue = kTimeRuleNotPertinent);
113  static void encodeTreeList(void* _pt, std::string (*encodeFunc)(const std::string &),int encoding,const std::vector<MTimeRule>& list) ;
114  static std::vector<MTimeRule> decodeTreeList(void* _pt);
115 #endif
116  } ;
120 }
121 
122 #endif