#include <DateFilter.h>
Public Types | |
enum | FilterDirection { DIR_NONE = 0, DIR_OUT = 1, DIR_IN = 2, DIR_INOUT = 3 } |
Filter direction, bitmask value (MSb is IN, LSb is OUT):
| |
enum | RelativeLowerDate { NONE = 0, LAST_WEEK = 1, LAST_2_WEEKS = 2, LAST_MONTH = 3, LAST_3_MONTHS = 4, LAST_6_MONTHS = 5, ALL = 6 } |
Codes to set the lowerDate, relatively to the current time. More... | |
typedef enum DateFilter::FilterDirection | FilterDirection |
Filter direction, bitmask value (MSb is IN, LSb is OUT):
| |
typedef enum DateFilter::RelativeLowerDate | RelativeLowerDate |
Codes to set the lowerDate, relatively to the current time. | |
Public Member Functions | |
void | setDirection (const FilterDirection dir) |
void | setLowerDate (const DATE lower) |
void | setUpperDate (const DATE upper) |
_declspec (dllexport) void setRelativeLowerDate(const RelativeLowerDate value) | |
Setting this property will also set 'lowerDate' accordingly. | |
FilterDirection | getDirection () |
DATE | getLowerDate () |
DATE | getUpperDate () |
_declspec (dllexport) RelativeLowerDate getRelativeLowerDate() | |
bool | isEnabled () |
Returns true if filter enabled at least in one direction. | |
bool | execute (ClientItem *cItem) |
Checks whether the item passed verifies the current filter. | |
bool | execute (_AppointmentItemPtr &app) |
Checks whether the item passed verifies the current filter. | |
void | updateNow () |
Refreshes filter's parameters, based on the current time. | |
Private Member Functions | |
DATE | subtractMonths (const DATE inputTime, const unsigned int numMonths) |
Internal use, to subrtract x months from a DATE value. | |
Private Attributes | |
FilterDirection | direction |
The filter direction, one of FilterDirection enum. | |
DATE | lowerDate |
The lower limit of startDate. In local time. | |
DATE | upperDate |
The upper limit of startDate. In local time. | |
RelativeLowerDate | relativeLowerDate |
A code, to identify the lowerDate referring to now. One of RelativeLowerDate enum. | |
bool | usingRelativeLowerDate |
Internal use: it's set to 'true' if we set the lowerDate through the relativeLowerDate. |
Client can use this class to filter out appointment items that are not included in a specific range of time: events that verifies this filter must exist in the range between 2 dates: 'lowerDate' and 'upperDate'.
These dates must be set by the Client before using the filter; if one of them (or both) is NULL, it will not be used for the check. The 'lowerDate' can also be set through a RelativeLowerDate code, to specify a value that is always relative to the current time.
Use the method updateNow() to refresh the filter's members (e.g. if using relative dates). This method should be called before every sync session. Use the method execute() to check if a ClientItem verifies the filter or not.
typedef enum DateFilter::FilterDirection DateFilter::FilterDirection |
Filter direction, bitmask value (MSb is IN, LSb is OUT):
TODO: this enum should be defined in a more generic 'ClientFilter' class.
Codes to set the lowerDate, relatively to the current time.
NONE means we filter out all items before now LAST_WEEK means we filter out all items before last week ALL means we don't filter anything
Filter direction, bitmask value (MSb is IN, LSb is OUT):
TODO: this enum should be defined in a more generic 'ClientFilter' class.
Codes to set the lowerDate, relatively to the current time.
NONE means we filter out all items before now LAST_WEEK means we filter out all items before last week ALL means we don't filter anything
bool DateFilter::execute | ( | _AppointmentItemPtr & | app | ) |
Checks whether the item passed verifies the current filter.
Like 'execute(ClientItem*)', but uses the COM pointer object directly:
References isEnabled(), lowerDate, REFERRED_MAX_DATE, throwClientException(), upperDate, and vBoolToBool().
bool DateFilter::execute | ( | ClientItem * | cItem | ) |
Checks whether the item passed verifies the current filter.
Two checks are done, both MUST be verified to return true: 1. event MUST NOT END before lowerDate 2. event MUST NOT START after upperDate
References ClientAppointment::getCOMPtr(), ClientRecurrence::getNoEndDate(), ClientRecurrence::getPatternEndDate(), ClientRecurrence::getPatternStartDate(), ClientItem::getProperty(), ClientAppointment::getRecPattern(), isEnabled(), lowerDate, REFERRED_MAX_DATE, systemTimeToDouble(), throwClientException(), and upperDate.
Referenced by WindowsSyncSource::filterClientItem().
Internal use, to subrtract x months from a DATE value.
We use SYSTEMTIME structure, it's easier (http://msdn.microsoft.com/en-us/library/aa908737.aspx)
inputTime | the input date (VariantTime) | |
numMonths | number of months to subtract (MUST NOT be > 12) |
Referenced by updateNow().
FilterDirection DateFilter::direction [private] |
The filter direction, one of FilterDirection enum.
0 means the filter is not enabled.
Referenced by isEnabled().