diff options
author | Lukas Zeller <luz@plan44.ch> | 2011-06-20 17:17:45 +0200 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2011-06-20 17:20:46 +0200 |
commit | 51707dfa8870f0f0b50569955b02f9ca88266d61 (patch) | |
tree | fb20c24f8f5304c109e76c162abb33f9475a8fdd | |
parent | e62279538cea575d2e589b8ca0bda396dcbc0352 (diff) |
<comparescript>: added COMPAREMODE(), needed to determine compare mode
A compare script must know what the compare mode is. When checking for
"items equal", it must return 0 (equal) or -999 (not equal). When doing an
age comparison, it must 1 or -1.
The new COMPAREMODE() method returns a string which identifies the current
mode:
"all", // compare all fields, even irrelevant ones
"n/a", // n/a (scripted)
"conflict", // compare fields relevant for (normal sync) conflict detection
"slowsync", // compare fields relevant for slow sync match
"firstsync", // compare fields relevant for first time slow sync match (possibly relaxed comparison rules)
"age", // no test for equality, only for age (returns SYSYNC_NOT_COMPARABLE if age comparison not possible)
A script only needs to check for "age", and it equal, do the age comparison
instead of checking for equality.
-rwxr-xr-x | src/sysync/multifielditemtype.cpp | 15 | ||||
-rwxr-xr-x | src/sysync/syncitem.cpp | 12 | ||||
-rwxr-xr-x | src/sysync/syncitem.h | 3 |
3 files changed, 30 insertions, 0 deletions
diff --git a/src/sysync/multifielditemtype.cpp b/src/sysync/multifielditemtype.cpp index d4e5e05..6f1d810 100755 --- a/src/sysync/multifielditemtype.cpp +++ b/src/sysync/multifielditemtype.cpp @@ -220,6 +220,20 @@ public: } }; // func_CompareFields + + // string COMPARISONMODE() + // returns mode of comparison + static void func_ComparisonMode(TItemField *&aTermP, TScriptContext *aFuncContextP) + { + TMultiFieldItemType *mfitP = static_cast<TMultiFieldItemType *>(aFuncContextP->getCallerContext()); + if (!mfitP->fFirstItemP) aTermP->unAssign(); // no comparison + else { + aTermP->setAsString(comparisonModeNames[mfitP->fEqMode]); + } + }; // func_CompareFields + + + #endif @@ -325,6 +339,7 @@ const TBuiltInFuncDef DataTypeFuncDefs[] = { { "SETWINNINGCHANGED", TMFTypeFuncs::func_SetWinningChanged, fty_none, 1, param_IntArg }, { "SETLOOSINGCHANGED", TMFTypeFuncs::func_SetLoosingChanged, fty_none, 1, param_IntArg }, { "COMPAREFIELDS", TMFTypeFuncs::func_CompareFields, fty_integer, 0, NULL }, + { "COMPARISONMODE", TMFTypeFuncs::func_ComparisonMode, fty_string, 0, NULL }, #endif { "SYNCOP", TMFTypeFuncs::func_SyncOp, fty_string, 0, NULL }, { "REJECTITEM", TMFTypeFuncs::func_RejectItem, fty_none, 1, param_IntArg }, diff --git a/src/sysync/syncitem.cpp b/src/sysync/syncitem.cpp index 1ee1c07..5cc2fb1 100755 --- a/src/sysync/syncitem.cpp +++ b/src/sysync/syncitem.cpp @@ -37,6 +37,18 @@ const char * const sysync::compareRelevanceNames[numEQmodes] = { "n/a" }; + +const char * const sysync::comparisonModeNames[numEQmodes] = { + "all", // compare all fields, even irrelevant ones + "n/a", // n/a (scripted) + "conflict", // compare fields relevant for (normal sync) conflict detection + "slowsync", // compare fields relevant for slow sync match + "firstsync", // compare fields relevant for first time slow sync match (possibly relaxed comparison rules) + "age", // no test for equality, only for age (returns SYSYNC_NOT_COMPARABLE if age comparison not possible) +}; + + + /* * Implementation of TSyncItem */ diff --git a/src/sysync/syncitem.h b/src/sysync/syncitem.h index 83476bd..d805902 100755 --- a/src/sysync/syncitem.h +++ b/src/sysync/syncitem.h @@ -44,7 +44,10 @@ typedef enum { // RELEVANCE COMPARE MODE // be modified // Fields with eqm_none will also not be included in CRC calculations for detecting changes. +// Names for TEqualityMode when used as field relevance extern const char * const compareRelevanceNames[numEQmodes]; + // Names for TEqualityMode when used as comparison mode +extern const char * const comparisonModeNames[numEQmodes]; // merge options |