~vbursian/research-assistant/trunk

« back to all changes in this revision

Viewing changes to RANet/DB_SQL_Net.h

  • Committer: Viktor Bursian
  • Date: 2020-07-16 22:38:41 UTC
  • mfrom: (9.25.2 DIST) (9.16.21 VB)
  • Revision ID: vik@pryanik-20200716223841-0gp0sf6m5imdjtb3
Tags: version_1.5.0
releasing version 1.5.0, closing v.1.4 development

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
////////////////////////////////////////////////////////////////////////////////
2
2
/*! @file DB_SQL_Net.h   RANet back-end, based on storage in a relational DB
3
3
                         accessed via SQL.
4
 
- Part of RANet - Research Assistant Net Library (based on ANSI C++).
5
 
- Uses  Qt v.5.0  -  http://qt-project.org/
6
 
- Copyright(C) 2013, Viktor E. Bursian, St.Petersburg, Russia.
7
 
                     VBursian@gmail.com
 
4
- Part of RANet - Research Assistant Net Library.
 
5
- Uses  Qt v.5  - http://qt.io/
 
6
- Copyright(C) 2013-2020, Viktor E. Bursian, St.Petersburg, Russia.
 
7
                          VBursian AT gmail DOT com
8
8
*///////////////////////////////////////////////////////////////////////////////
9
9
#ifndef DB_SQL_Net_H
10
10
#define DB_SQL_Net_H
36
36
    class RANet_EXPORT  sNodeUUID : public sNodeLocation
37
37
    {
38
38
      public://static
39
 
        static sNodeUUID          ForTheRoot (psNet,sDB_UUID);
 
39
        static sNodeUUID          ForTheRoot (psNet,sDB_UUID,rcsVersion);
40
40
 
41
41
      public:
42
42
        virtual                   ~sNodeUUID ()
93
93
    virtual                   ~sDB_SQL_Net ();
94
94
                              sDB_SQL_Net ();
95
95
    virtual bool              SaveAll ();
 
96
    virtual bool              Preset (sString textual_URL);
96
97
 
97
98
  public://implementation of inherited
98
99
    virtual bool              CreateNew ();
99
100
    virtual bool              PreOpenSetUp ();
 
101
    virtual bool              Open (sString textual_URL);
100
102
    virtual bool              Open ();
101
103
    virtual void              Close ();
102
104
    virtual bool              IsOpen ();
110
112
 
111
113
  public:
112
114
    void                      AddDBLink (rsDB_Link  link);
 
115
    void                      EditLink (rsDB_Link  link);
 
116
    void                      RemovePartition (psDatabase  partition);
 
117
    virtual bool              LoadDatabases (bool  recursive =true);
113
118
 
114
119
  protected:
115
120
    virtual psNode            LoadNode (pcsNodeLocation);
125
130
    virtual bool              RemoveAttribute (pcsNodeLocation   host
126
131
                                              ,pcsNodeLocation   value);
127
132
    virtual bool              GetNodeStorageTime (pcsNodeLocation,rsTime);
 
133
 
 
134
  public:
128
135
    virtual bool              LoadRoot ();
129
 
    virtual bool              LoadDatabases (psDatabase);
130
 
    virtual bool              CreateTables (rcsDB_Info);
 
136
    virtual bool              LoadDatabases (psDatabase ,bool recursive =true);
 
137
 
 
138
  public: //static SQL-specific
 
139
    static void               RunSQL (rcsDB_Info  part_info
 
140
                                     ,rcsString   sql_text );
 
141
    static void               SetParamValue (rcsDB_Link  partition
 
142
                                            ,rcsString   param_key
 
143
                                            ,rcsString   param_value);
 
144
    static bool               CreateNewPartition (rcsDB_Info
 
145
                                                 ,bool  initiate =true);
 
146
    static bool               CreateTables (rcsDB_Info
 
147
                                           ,bool  initiate
 
148
                                                  //!< add params and root
 
149
                                                  =true);
 
150
    static void               ReplicatePartition (rcsDB_Info  source
 
151
                                                 ,rcsDB_Info  destination
 
152
                                                 ,int *       progress = NULL);
 
153
    static void               ReplicatePartNodes (rcsDB_Link  source
 
154
                                                 ,rcsDB_Link  destination
 
155
                                                 ,int *       progress = NULL);
 
156
    static void               ReplicatePartAttrs (rcsDB_Link  source
 
157
                                                 ,rcsDB_Link  destination
 
158
                                                 ,int *       progress = NULL);
131
159
 
132
160
  protected://static constants
133
 
    static const QString      DBIdFieldDecl;
134
 
    static const QString      NodeIdFieldDecl;
 
161
    static csString           DBIdFieldDecl;
 
162
    static csString           NodeIdFieldDecl;
135
163
 
136
164
  public://fields
137
165
    std::map<sDB_UUID
138
166
            ,psDatabase>      Databases;
139
 
 
140
 
  private://fields
141
167
    sDB_Info                  RootDB_Info;
142
168
    sDB_UUID                  RootDB_UUID;
 
169
    sVersion                  RootDB_Version;
 
170
 
 
171
  private://fields
143
172
    sNodePtr                  TheRoot;
144
173
    QMutex                    LoadedNodesMutex;
145
174
    std::map<sNodeUUID
162
191
{
163
192
  Q_OBJECT
164
193
  public:
 
194
    static const int          StartDelay;
165
195
    static const int          OnIdlePause;
166
196
 
167
197
  public:
169
199
                              sSynchronizer (psDB_SQL_Net);
170
200
 
171
201
  public slots:
 
202
    void                      StartSaving ();
172
203
    void                      SaveSome ();
173
204
    void                      RefreshSome ();
174
205