Blame view

src/dbrelation.h 6 KB
fe12aa6a   Steven de Ridder   Initial commit. d...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
  /* ****************************************************************************
   * Copyright 2019 Open Systems Development BV                                 *
   *                                                                            *
   * Permission is hereby granted, free of charge, to any person obtaining a    *
   * copy of this software and associated documentation files (the "Software"), *
   * to deal in the Software without restriction, including without limitation  *
   * the rights to use, copy, modify, merge, publish, distribute, sublicense,   *
   * and/or sell copies of the Software, and to permit persons to whom the      *
   * Software is furnished to do so, subject to the following conditions:       *
   *                                                                            *
   * The above copyright notice and this permission notice shall be included in *
   * all copies or substantial portions of the Software.                        *
   *                                                                            *
   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *
   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    *
   * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    *
   * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        *
   * DEALINGS IN THE SOFTWARE.                                                  *
   * ***************************************************************************/
  
  #ifndef OSDEV_COMPONENTS_DBRELATION_H
  #define OSDEV_COMPONENTS_DBRELATION_H
  
  #include <QObject>
  #include <QString>
  
  namespace osdev  {
  namespace components {
  
  /*!
   * \brief   The DbRelation class is a container class holding the
   *          information regarding the relation between two tables.
   */
  
  class DbRelation : public QObject
  {
      Q_OBJECT
  
  public:
      DbRelation( QObject *parent = nullptr );
  
      /*!
       * \brief   Get the name of the database scheme
       * \return  The schemaname as QString. isEmpty() is true if none was set.
       */
      const QString& schemaName() const { return m_schemaName; }
  
      /*!
       * \brief   Set the name of the database scheme
       * \param   _schemaName - The name of the schema.
       */
      void setSchemaName( const QString &_schemaName ) { m_schemaName = _schemaName; }
  
      /*!
       * \brief   Get the name of the table this relation describes.
       * \return  The name of the table this relation describes.
       */
      const QString& tableName() const { return m_tableName; }
  
      /*!
       * \brief   Set the name of the table this relation describes.
       * \param   _tableName - The name of the table this relation describes.
       */
      void setTableName( const QString &_tableName ) { m_tableName = _tableName; }
  
      /*!
       * \brief   Get the name of the constraint this relation describes.
       * \return  the name of the constraint this relation describes.
       */
      const QString& constraintName() const { return m_constraintName; }
  
      /*!
       * \brief   Set the name of the constraint this relation describes.
       * \param   _constraintName - The name of the constraint this relation describes.
       */
      void setConstraintName( const QString &_constraintName ) { m_constraintName = _constraintName; }
  
      /*!
       * \brief   Get the name of the related table this relation describes.
       * \return  the name of the related table this relation describes.
       */
      const QString& foreignTable() const { return m_foreignTable; }
  
      /*!
       * \brief   Set the name of the related table this relation describes.
       * \param   _foreignTable - the name of the related table this relation describes.
       */
      void setForeignTable( const QString &_foreignTable ) { m_foreignTable = _foreignTable; }
  
      /*!
       * \brief   The name of the field on the maintable this relation describes.
       * \return  The name of the field on the maintable this relation describes.
       */
      const QString& indexColumn() const { return m_indexColumn; }
  
      /*!
       * \brief   Set the name of the field on the maintable this relation describes.
       * \param   _indexColumn - The name of the field on the maintable this relation describes.
       */
      void setIndexColumn( const QString &_indexColumn ) { m_indexColumn = _indexColumn; }
  
      /*!
       * \brief   Gets the name of the primary key field of the related table.
       * \return  The name of the primary key field of the related table.
       */
      const QString& foreignPrimKey() const { return m_foreignPrimKey; }
  
      /*!
       * \brief Sets the name of the primary key field of the related table.
       * \param _foreignPrimKey - The name of the primary key field of the related table.
       */
      void setForeignPrimKey( const QString &_foreignPrimKey ) { m_foreignPrimKey = _foreignPrimKey; }
  
      /*!
       * \brief   Return the relation structure as a QString for Debugging purposes
       * \return  The datastructure in QString representation.
       */
      QString asString() const { return QString( "SchemaName : %1 \nTableName : %2 \n ConstraintName : %3 \n ForeignTable : %4 \n IndexColumn : %5 \n Foreign Primary Key : %6")
                  .arg( m_schemaName, m_tableName, m_constraintName, m_foreignTable, m_indexColumn, m_foreignPrimKey ); }
  
  private:
      QString     m_schemaName;       ///< The name of the database scheme
      QString     m_tableName;        ///< The name of the target-table
      QString     m_constraintName;   ///< The name of the constraint as known to the database
      QString     m_foreignTable;     ///< The name of the table the target has a relation with
      QString     m_indexColumn;      ///< The name of the column of the target table that holds the relation.
      QString     m_foreignPrimKey;   ///< The name of the primary key-field of the related table.
  };
  
  }       /* End namespace components     */
  }       /* End namespace osdev          */
  
  #endif  /* OSDEV_COMPONENTS_DBRELATION_H */