File indexing completed on 2024-04-28 16:30:31
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 SKGNAMEDOBJECT_H 0007 #define SKGNAMEDOBJECT_H 0008 /** @file 0009 * This file defines classes SKGNamedObject. 0010 * 0011 * @author Stephane MANKOWSKI / Guillaume DE BURE 0012 */ 0013 0014 #include "skgdefine.h" 0015 #include "skgerror.h" 0016 #include "skgobjectbase.h" 0017 0018 /** 0019 * This class is a named object base. 0020 * This is a generic way to manipulate objects with name. 0021 */ 0022 class SKGBASEMODELER_EXPORT SKGNamedObject : public SKGObjectBase 0023 { 0024 /** 0025 * Name of the object 0026 */ 0027 Q_PROPERTY(QString name READ getName WRITE setName USER true) // clazy:exclude=qproperty-without-notify 0028 0029 public: 0030 /** 0031 * Return the object (@p oObject) corresponding to a name (@p iName ). 0032 * If more than one objects are returned by the query, then an error is generated 0033 * If 0 object is returned by the query, then an error is generated 0034 * @param iDocument the document where to search 0035 * @param iTable the table where to search 0036 * @param iName name of the object in @p iTable 0037 * @param oObject the result 0038 * @return an object managing the error 0039 * @see SKGError 0040 */ 0041 static SKGError getObjectByName(SKGDocument* iDocument, const QString& iTable, 0042 const QString& iName, SKGObjectBase& oObject); 0043 0044 /** 0045 * Default constructor 0046 */ 0047 explicit SKGNamedObject(); 0048 0049 /** 0050 * Constructor 0051 * @param iDocument the document containing the object 0052 * @param iTable the table of the object 0053 * @param iID the identifier in @p iTable of the object 0054 */ 0055 explicit SKGNamedObject(SKGDocument* iDocument, const QString& iTable = QString(), int iID = 0); 0056 0057 /** 0058 * Copy constructor 0059 * @param iObject the object to copy 0060 */ 0061 SKGNamedObject(const SKGNamedObject& iObject); 0062 0063 /** 0064 * Copy constructor 0065 * @param iObject the object to copy 0066 */ 0067 explicit SKGNamedObject(const SKGObjectBase& iObject); 0068 0069 /** 0070 * Operator affectation 0071 * @param iObject the object to copy 0072 */ 0073 SKGNamedObject& operator= (const SKGObjectBase& iObject); 0074 0075 /** 0076 * Operator affectation 0077 * @param iObject the object to copy 0078 */ 0079 SKGNamedObject& operator= (const SKGNamedObject& iObject); 0080 0081 /** 0082 * Destructor 0083 */ 0084 virtual ~SKGNamedObject(); 0085 0086 /** 0087 * Set the name of this object 0088 * @param iName the name 0089 * @return an object managing the error 0090 * @see SKGError 0091 */ 0092 virtual SKGError setName(const QString& iName); 0093 0094 /** 0095 * Get the name of this object 0096 * @return the name 0097 */ 0098 virtual QString getName() const; 0099 0100 protected: 0101 /** 0102 * Get where clause needed to identify objects. 0103 * For this class, the whereclause is based on name 0104 * @return the where clause 0105 */ 0106 QString getWhereclauseId() const override; 0107 }; 0108 /** 0109 * Declare the class 0110 */ 0111 Q_DECLARE_TYPEINFO(SKGNamedObject, Q_MOVABLE_TYPE); 0112 #endif