File indexing completed on 2024-05-12 16:42:38

0001 /*
0002     SPDX-FileCopyrightText: 2005-2018 Thomas Baumgart <tbaumgart@kde.org>
0003     SPDX-FileCopyrightText: 2017-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef MYMONEYOBJECT_H
0008 #define MYMONEYOBJECT_H
0009 
0010 // ----------------------------------------------------------------------------
0011 // QT Includes
0012 
0013 #include <qglobal.h>
0014 
0015 // ----------------------------------------------------------------------------
0016 // Project Includes
0017 
0018 #include "kmm_mymoney_export.h"
0019 #include "mymoneyunittestable.h"
0020 
0021 class QString;
0022 
0023 /**
0024   * @author Thomas Baumgart
0025   */
0026 
0027 /**
0028   * This class represents the base class of all MyMoney objects.
0029   */
0030 class MyMoneyObjectPrivate;
0031 class KMM_MYMONEY_EXPORT MyMoneyObject
0032 {
0033     Q_DECLARE_PRIVATE(MyMoneyObject)
0034 
0035     KMM_MYMONEY_UNIT_TESTABLE
0036 
0037 public:
0038     /**
0039       * This is the destructor for the MyMoneyObject object
0040       */
0041     virtual ~MyMoneyObject();
0042 
0043     /**
0044       * This method retrieves the id of the object
0045       *
0046       * @return ID of object
0047       */
0048     QString id() const;
0049 
0050     /**
0051       * This method clears the id of the object
0052       */
0053     void clearId();
0054 
0055     /**
0056       * This method must be provided by all derived objects. It returns,
0057       * a @p true if the object is referencing the one requested by the
0058       * parameter @p id. If it does not, this method returns @p false.
0059       *
0060       * @param id id of the object to be checked for references
0061       * @retval true This object references object with id @p id.
0062       * @retval false This object does not reference the object with id @p id.
0063       */
0064     virtual bool hasReferenceTo(const QString& id) const = 0;
0065 
0066     bool operator == (const MyMoneyObject& right) const;
0067 
0068 protected:
0069     MyMoneyObjectPrivate * d_ptr;
0070     explicit MyMoneyObject(MyMoneyObjectPrivate &dd);
0071     MyMoneyObject(MyMoneyObjectPrivate &dd,
0072                   const QString& id);
0073 };
0074 
0075 #endif
0076