libquentier  0.4.0
The library for rich desktop clients of Evernote service
ILocalStorageDataElement.h
1 /*
2  * Copyright 2016 Dmitry Ivanov
3  *
4  * This file is part of libquentier
5  *
6  * libquentier is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * libquentier is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libquentier. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef LIB_QUENTIER_TYPES_I_LOCAL_STORAGE_DATA_ELEMENT_H
20 #define LIB_QUENTIER_TYPES_I_LOCAL_STORAGE_DATA_ELEMENT_H
21 
22 #include <quentier/utility/Linkage.h>
23 #include <quentier/utility/Macros.h>
24 #include <quentier/utility/UidGenerator.h>
25 #include <QString>
26 #include <QUuid>
27 
28 namespace quentier {
29 
30 class QUENTIER_EXPORT ILocalStorageDataElement
31 {
32 public:
33  virtual const QString localUid() const = 0;
34  virtual void setLocalUid(const QString & guid) = 0;
35  virtual void unsetLocalUid() = 0;
36 
37  virtual ~ILocalStorageDataElement() {}
38 };
39 
40 #define DEFINE_LOCAL_UID_GETTER(type) \
41  const QString type::localUid() const { \
42  return UidGenerator::UidToString(d->m_localUid); \
43  }
44 
45 #define DEFINE_LOCAL_UID_SETTER(type) \
46  void type::setLocalUid(const QString & uid) { \
47  d->m_localUid = uid; \
48  }
49 
50 #define DEFINE_LOCAL_UID_UNSETTER(type) \
51  void type::unsetLocalUid() { \
52  d->m_localUid = QUuid(); \
53  }
54 
55 #define QN_DECLARE_LOCAL_UID \
56  virtual const QString localUid() const Q_DECL_OVERRIDE; \
57  virtual void setLocalUid(const QString & guid) Q_DECL_OVERRIDE; \
58  virtual void unsetLocalUid() Q_DECL_OVERRIDE;
59 
60 #define QN_DEFINE_LOCAL_UID(type) \
61  DEFINE_LOCAL_UID_GETTER(type) \
62  DEFINE_LOCAL_UID_SETTER(type) \
63  DEFINE_LOCAL_UID_UNSETTER(type)
64 
65 } // namespace quentier
66 
67 #endif // LIB_QUENTIER_TYPES_I_LOCAL_STORAGE_DATA_ELEMENT_H
Definition: ILocalStorageDataElement.h:30