OpenAB  1.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PIMItemIndex.hpp
Go to the documentation of this file.
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5  */
10 #ifndef PIMITEMINDEX_HPP_
11 #define PIMITEMINDEX_HPP_
12 
13 #include <string>
14 #include <vector>
15 #include <helpers/SmartPtr.hpp>
16 
20 namespace OpenAB {
25 {
29 };
30 
38 {
39  public:
45 
49  virtual ~PIMItemIndex();
50 
55  struct PIMItemCheck
56  {
61  {
62  eKey,
64  };
65 
71  PIMItemCheck(const std::string& name, eFieldRole role) :
72  fieldName(name),
73  fieldRole(role),
74  enabled(true)
75  {}
76 
78 
79  std::string fieldName;
81  bool enabled;
82  };
83 
90  virtual bool operator==(const PIMItemIndex& other) const = 0;
91 
98  virtual bool operator!=(const PIMItemIndex& other) const = 0;
99 
106  virtual bool operator<(const PIMItemIndex& other) const = 0;
107 
113  virtual void addKeyField(const std::string& name, const std::string& value);
114 
120  virtual void addConflictField(const std::string& name, const std::string& value);
121 
130  virtual bool compare(const PIMItemIndex& other) const = 0;
131 
137  virtual std::string toString() const = 0;
138 
144  virtual std::string toStringFull() const = 0;
145 
151 
152  protected:
153  bool compareVectors(const std::vector<std::string>& v1,
154  const std::vector<std::string>& v2) const;
155 
156  std::vector<std::string> key_fields;
157  std::vector<std::string> conflict_fields;
158  std::vector<std::string> key_fields_names;
159  std::vector<std::string> conflict_fields_names;
160 
161  mutable std::string cached_to_string;
162 
163  private:
164  OpenAB::PIMItemType type;
165 };
166 
167 } // namespace OpenAB
168 
169 #endif // PIMITEMINDEX_HPP_
Definition: PIMItemIndex.hpp:26
~PIMItemCheck()
Definition: PIMItemIndex.hpp:77
eFieldRole
Definition: PIMItemIndex.hpp:60
PIMItemCheck(const std::string &name, eFieldRole role)
Constructor.
Definition: PIMItemIndex.hpp:71
virtual bool operator!=(const PIMItemIndex &other) const =0
Compare operator. Checks if two PIMItemIndex not matches (are totally different)
virtual std::string toStringFull() const =0
Returns string version of PIMItemIndex. It contains both PIMItemCheck::eKey and PIMItemCheck::eConfli...
Definition: PIMItemIndex.hpp:28
std::string cached_to_string
Definition: PIMItemIndex.hpp:161
Definition: PIMItemIndex.hpp:63
bool compareVectors(const std::vector< std::string > &v1, const std::vector< std::string > &v2) const
Definition: PIMItemIndex.cpp:29
Definition: PIMItemIndex.hpp:62
virtual void addConflictField(const std::string &name, const std::string &value)
Adds new PIMItemCheck::eConflict field.
Definition: PIMItemIndex.cpp:58
virtual ~PIMItemIndex()
Destructor, virtual by default.
Definition: PIMItemIndex.cpp:20
std::vector< std::string > conflict_fields
Definition: PIMItemIndex.hpp:157
virtual std::string toString() const =0
Returns string version of PIMItemIndex. It contains only PIMItemCheck::eKey fields.
virtual void addKeyField(const std::string &name, const std::string &value)
Adds new PIMItemCheck::eKey field.
Definition: PIMItemIndex.cpp:47
OpenAB::PIMItemType getType() const
Returns type of item that index is representing.
Definition: PIMItemIndex.cpp:24
PIMItemType
Definition: PIMItemIndex.hpp:24
bool enabled
Definition: PIMItemIndex.hpp:81
Definition: PIMItemIndex.hpp:27
Definition of check that will be made on PIMItemIndex instances when comparing them. Each check checks single field of PIMItem, and based on its role, detects if items are totally different, or items are modified version of the same item.
Definition: PIMItemIndex.hpp:55
eFieldRole fieldRole
Definition: PIMItemIndex.hpp:80
std::string fieldName
Definition: PIMItemIndex.hpp:79
Documentation for class PIMItemIndex. PIMItemIndex is a PIMItem representation used to match and comp...
Definition: PIMItemIndex.hpp:37
std::vector< std::string > key_fields
Definition: PIMItemIndex.hpp:156
virtual bool operator==(const PIMItemIndex &other) const =0
Compare operator. Checks if two PIMItemIndex matches (may not be exactly the same) ...
PIMItemIndex(OpenAB::PIMItemType t)
Constructor.
Definition: PIMItemIndex.cpp:15
std::vector< std::string > key_fields_names
Definition: PIMItemIndex.hpp:158
std::vector< std::string > conflict_fields_names
Definition: PIMItemIndex.hpp:159
virtual bool operator<(const PIMItemIndex &other) const =0
Compare operator.
virtual bool compare(const PIMItemIndex &other) const =0
Compares two PIMItemIndex object, checks if two PIMItemIndex are exactly the same. In opposite to compare operator it checks PIMItemCheck::eConflict fields.