File indexing completed on 2024-04-28 16:30:15

0001 /***************************************************************************
0002  * SPDX-FileCopyrightText: 2022 S. MANKOWSKI stephane@mankowski.fr
0003  * SPDX-FileCopyrightText: 2022 G. DE BURE support@mankowski.fr
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  ***************************************************************************/
0006 #ifndef SKGUNITVALUEOBJECT_H
0007 #define SKGUNITVALUEOBJECT_H
0008 /** @file
0009  * This file defines classes SKGUnitValueObject.
0010  *
0011  * @author Stephane MANKOWSKI / Guillaume DE BURE
0012  */
0013 
0014 #include "skgbankmodeler_export.h"
0015 #include "skgerror.h"
0016 #include "skgobjectbase.h"
0017 
0018 class SKGUnitObject;
0019 
0020 /**
0021  * This class is a value at a time for a unit
0022  */
0023 class SKGBANKMODELER_EXPORT SKGUnitValueObject final : public SKGObjectBase
0024 {
0025 public:
0026     /**
0027      * Default constructor
0028      */
0029     explicit SKGUnitValueObject();
0030 
0031     /**
0032      * Constructor
0033      * @param iDocument the document containing the object
0034      * @param iID the identifier in @p iTable of the object
0035      */
0036     explicit SKGUnitValueObject(SKGDocument* iDocument, int iID = 0);
0037 
0038     /**
0039      * Copy constructor
0040      * @param iObject the object to copy
0041      */
0042     SKGUnitValueObject(const SKGUnitValueObject& iObject);
0043 
0044     /**
0045      * Copy constructor
0046      * @param iObject the object to copy
0047      */
0048     explicit SKGUnitValueObject(const SKGObjectBase& iObject);
0049 
0050     /**
0051      * Operator affectation
0052      * @param iObject the object to copy
0053      */
0054     SKGUnitValueObject& operator= (const SKGObjectBase& iObject);
0055 
0056     /**
0057      * Operator affectation
0058      * @param iObject the object to copy
0059      */
0060     SKGUnitValueObject& operator= (const SKGUnitValueObject& iObject);
0061 
0062     /**
0063      * Destructor
0064      */
0065     virtual ~SKGUnitValueObject();
0066 
0067     /**
0068      * Set the quantity for the date of this unit
0069      * @param iValue the quantity
0070      * @return an object managing the error
0071      *   @see SKGError
0072      */
0073     SKGError setQuantity(double iValue);
0074 
0075     /**
0076      * Get the quantity for the date of this unit
0077      * @return the quantity
0078      */
0079     double getQuantity() const;
0080 
0081     /**
0082      * Set date of this value
0083      * @param iDate the date
0084      * @return an object managing the error
0085      *   @see SKGError
0086      */
0087     // cppcheck-suppress passedByValue
0088     SKGError setDate(QDate iDate);
0089 
0090     /**
0091      * Get date of this value
0092      * @return the date
0093      */
0094     QDate getDate() const;
0095 
0096     /**
0097      * Get the parent unit
0098      * @param oUnit the parent unit
0099      * @return an object managing the error
0100      *   @see SKGError
0101      */
0102     SKGError getUnit(SKGUnitObject& oUnit) const;
0103 
0104 protected:
0105     /**
0106      * Get where clause needed to identify objects.
0107      * For this class, the whereclause is based on date + unit
0108      * @return the where clause
0109      */
0110     QString getWhereclauseId() const override;
0111 };
0112 /**
0113  * Declare the class
0114  */
0115 Q_DECLARE_TYPEINFO(SKGUnitValueObject, Q_MOVABLE_TYPE);
0116 #endif