OpenAB  1.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PIMItem.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 PIMITEM_HPP_
11 #define PIMITEM_HPP_
12 
13 #include <PIMItem/PIMItemIndex.hpp>
14 
18 namespace OpenAB {
22 class PIMItem
23 {
24  public:
25 
31  {
32  type = t;
33  };
34 
38  virtual ~PIMItem(){};
39 
49  virtual bool parse(const std::string& raw) = 0;
50 
55  virtual SmartPtr<PIMItemIndex> getIndex() = 0;
56 
62  virtual std::string getRawData() const = 0;
63 
64  typedef std::string ID;
65 
71  virtual ID getId() const
72  {
73  return id;
74  }
75 
82  virtual void setId(const ID& id,
83  bool replace = false)
84  {
85  (void) replace;
86  this->id = id;
87  }
88 
89  typedef std::string Revision;
90 
96  virtual Revision getRevision() const
97  {
98  return revision;
99  }
100 
105  virtual void setRevision(const Revision& rev)
106  {
107  revision = rev;
108  }
109 
110  typedef std::vector<OpenAB::PIMItem::ID> IDs;
111  typedef std::vector<OpenAB::PIMItem::Revision> Revisions;
112 
113 
119  {
120  return type;
121  }
122 
123  protected:
127 };
128 
129 } // namespace OpenAB
130 
131 #endif // PIMITEM_HPP_
std::string Revision
Definition: PIMItem.hpp:89
virtual bool parse(const std::string &raw)=0
Parses item from string. Format of string to be parsed from depends on type of item.
virtual Revision getRevision() const
Returns Source/Storage specific revision of item. Can be empty, as not all Sources/Storages provides ...
Definition: PIMItem.hpp:96
virtual SmartPtr< PIMItemIndex > getIndex()=0
Returns index for given item.
virtual ~PIMItem()
Destructor, virtual by default.
Definition: PIMItem.hpp:38
PIMItemType getType() const
Returns type of item.
Definition: PIMItem.hpp:118
virtual ID getId() const
Returns Source/Storage specific id of item. Can be empty, as not all Sources/Storages provides id of ...
Definition: PIMItem.hpp:71
std::vector< OpenAB::PIMItem::Revision > Revisions
Definition: PIMItem.hpp:111
Smart pointer implementation for safely passing around dynamically created data. Smart pointers are r...
Definition: SmartPtr.hpp:32
PIMItem(PIMItemType t)
Constructor.
Definition: PIMItem.hpp:30
std::vector< OpenAB::PIMItem::ID > IDs
Definition: PIMItem.hpp:110
PIMItemType type
Definition: PIMItem.hpp:124
ID id
Definition: PIMItem.hpp:125
virtual std::string getRawData() const =0
Returns raw data of item. Format of raw data depends on type of item.
virtual void setRevision(const Revision &rev)
Sets revision of item.
Definition: PIMItem.hpp:105
PIMItemType
Definition: PIMItemIndex.hpp:24
virtual void setId(const ID &id, bool replace=false)
Sets id of item.
Definition: PIMItem.hpp:82
std::string ID
Definition: PIMItem.hpp:64
Revision revision
Definition: PIMItem.hpp:126
Class representing PIM item.
Definition: PIMItem.hpp:22