File indexing completed on 2024-05-19 05:07:20

0001 /*
0002     SPDX-FileCopyrightText: 2005-2019 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 returns @p true if the object is referencing the
0057      * one requested by the parameter @p id. If it does not,
0058      * 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      * @sa referencedObjects()
0065      */
0066     bool hasReferenceTo(const QString& id) const;
0067 
0068     /**
0069      * This method returns a QSet of object ids that this object references.
0070      *
0071      * @returns QSet<QString> of referenced objects
0072      *
0073      * @sa hasReferenceTo()
0074      */
0075     QSet<QString> referencedObjects() const;
0076 
0077     bool operator == (const MyMoneyObject& right) const;
0078 
0079 protected:
0080     MyMoneyObjectPrivate * d_ptr;
0081     explicit MyMoneyObject(MyMoneyObjectPrivate &dd);
0082     MyMoneyObject(MyMoneyObjectPrivate &dd,
0083                   const QString& id);
0084 };
0085 
0086 #endif
0087