~vbursian/research-assistant/intervers

« back to all changes in this revision

Viewing changes to RANet/DB_SQL_Net.h

  • Committer: Viktor Bursian at blin-Ubuntu
  • Date: 2013-06-29 18:01:41 UTC
  • mto: (4.2.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: vbursian@gmail.com-20130629180141-oby3p7oezibrddqm
перед переделкой sStorable & related changes in descendants

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
#define DB_SQL_Net_H
11
11
#include "Net.h"
12
12
#include "NodePtr.h"
 
13
#include "QtSQLWrapper.hpp"
13
14
#include <QString>
 
15
#include <map>
14
16
namespace RA {
15
17
//------------------------------------------------------------------------------
16
18
 
17
 
ANNOUNCE_CLASS(sDB_SQL_NodeUID)
18
 
ANNOUNCE_CLASS(sDB_SQL_NodeLocation)
19
 
 
20
 
//---------------------------------------------------------- sDB_SQL_NodeUID ---
21
 
 
22
 
class RANet_EXPORT  sDB_SQL_NodeUID : public sNodeUID
23
 
{
24
 
  public:
25
 
    explicit                  sDB_SQL_NodeUID ();
26
 
                              sDB_SQL_NodeUID (rcsDB_SQL_NodeUID);
27
 
    rsDB_SQL_NodeUID          operator= (rcsDB_SQL_NodeUID);
28
 
  private:
29
 
    QByteArray                UID;
30
 
};
31
 
 
32
 
//----------------------------------------------------- sDB_SQL_NodeLocation ---
33
 
 
34
 
class RANet_EXPORT  sDB_SQL_NodeLocation : public sNodeLocation
35
 
{
36
 
  public:
37
 
    virtual void              Dummy () =0;
38
 
    explicit                  sDB_SQL_NodeLocation ();
39
 
                              sDB_SQL_NodeLocation (rcsDB_SQL_NodeLocation);
40
 
    rsDB_SQL_NodeLocation     operator= (rcsDB_SQL_NodeLocation);
41
 
    bool                      operator== (rcsDB_SQL_NodeLocation) const;
42
 
    virtual psNodeLocation    Replica () const;
43
 
  private:
44
 
 
45
 
 
46
 
//  public: //types
47
 
//    enum                      eIOPrefix   //used on disk
48
 
//                                {NoNode    //for NullNode
49
 
//                                ,RightHere
50
 
//                                ,Separate
51
 
//                                };
52
 
//    enum                      eType
53
 
//                                {NotAllocated //for newborn nodes, not
54
 
//                                              //attached to the net
55
 
//                                ,InStreamFile
56
 
//                                ,InTextFile
57
 
//                                ,InRegistry
58
 
//                                };
59
 
//  public:
60
 
//                              sNodeLocation (eType      AType
61
 
//                                            ,tNodeUID   ANodeUID
62
 
//                                            ,rcsString  APath);
63
 
//                              sNodeLocation (eType        AType
64
 
//                                            ,tNodeUID     ANodeUID
65
 
//                                            ,rcsString    APath
66
 
//                                            ,rcsString    APathSuffix
67
 
//                                            ,tStreamPos   AnOffset);
68
 
//  public: // fields
69
 
//    eType                     Type;
70
 
//    tNodeUID                  NodeUID; // =0 for NullNode
71
 
//                                       // =1 for nodes having one host and
72
 
//                                       //    stored with it in the same file
73
 
//                                       // >1 and unique for others
74
 
//    sString                   Path;
75
 
//    sString                   DefaultSuffix;
76
 
//    tStreamPos                Offset;
77
 
//  #ifdef RANET_DEBUG
78
 
//  public:
79
 
//    static unsigned int       Counter;
80
 
//  #endif
81
 
};
 
19
ANNOUNCE_CLASS(sDB_SQL_Net)
82
20
 
83
21
//-------------------------------------------------------------- sDB_SQL_Net ---
84
22
 
85
23
class RANet_EXPORT  sDB_SQL_Net : public sNet
86
24
{
 
25
  public://types
 
26
    //------------------------------------------- sDB_SQL_Net::sNodeUUID ---
 
27
    ANNOUNCE_CLASS(sNodeUUID)
 
28
    class RANet_EXPORT  sNodeUUID : public sNodeLocation
 
29
    {
 
30
      public:
 
31
        static QByteArray         RootId ();
 
32
      public:
 
33
        virtual psNodeLocation    Replica () const;
 
34
        bool                      operator == (rcsNodeUUID) const;
 
35
        explicit                  sNodeUUID (const QByteArray &  db_id
 
36
                                            ,const QByteArray &  node_id)
 
37
                                      :sNodeLocation()
 
38
                                      ,DBId(db_id),NodeId(node_id)
 
39
                                    {}
 
40
      public://fields
 
41
        QByteArray                DBId; //!< Universally Unique Identifier (UUID)
 
42
                                  //! in common 38-length textual form, like
 
43
                                  //! "{550e8400-e29b-41d4-a716-446655440000}".
 
44
        QByteArray                NodeId; //!< Universally Unique Identifier (UUID)
 
45
                                  //! in common 38-length textual form, like
 
46
                                  //! "{550e8400-e29b-41d4-a716-446655440000}".
 
47
 
 
48
    };
 
49
    //-------------------------------------------- sDB_SQL_Net::sDB_Info ---
 
50
    ANNOUNCE_CLASS(sDB_Info)
 
51
    class RANet_EXPORT  sDB_Info
 
52
    {
 
53
      public:
 
54
                                  sDB_Info ();
 
55
      public://fields
 
56
        QString                   DBType;
 
57
        QString                   DBName;
 
58
        QString                   Host;
 
59
        unsigned short int        Port;
 
60
        QString                   LoginName;
 
61
    };
 
62
    //------------------------------------------- sDB_SQL_Net::sNodeInfo ---
 
63
    ANNOUNCE_CLASS(sNodeInfo)
 
64
    class RANet_EXPORT  sNodeInfo
 
65
    {
 
66
        psNode                    Node;
 
67
      friend class sDB_SQL_Net;
 
68
    };
 
69
    //----------------------------------------------------------------------
 
70
 
 
71
    typedef std::map<sNodeUUID,psNodeInfo>  tNodeIndex;
 
72
 
87
73
  public:
88
74
    virtual                   ~sDB_SQL_Net ();
89
75
                              sDB_SQL_Net (const QString &  sqlite_file_name);
90
 
  
 
76
 
91
77
  public://implementation of inherited
 
78
    virtual bool              CreateNew ();
92
79
    virtual bool              Initiate ();
93
 
    virtual bool              CreateNew ();
94
 
    
 
80
    virtual rsNodePtr         Root ();
 
81
    virtual psNode            GetNode (RA::psNodeLocation);
 
82
 
95
83
  protected:
96
84
    virtual bool              CreateTables ();
97
 
    
 
85
//    void                      RegisterNode ();
 
86
 
98
87
  protected://fields
99
 
    const QString             RootDBType;
100
 
    const QString             RootDBName;
101
 
    const QString             RootHost;
102
 
    const unsigned short int  RootHostPort;
103
 
    const QString             RootHostLoginName;
 
88
    sDB_Info                  RootDBInfo;
 
89
    QByteArray                RootDBId;
 
90
    sSqlDatabase              RootDB;
 
91
    sNodePtr                  TheRoot;
 
92
    tNodeIndex                LoadedNodes;
104
93
};
105
94
 
106
95
//------------------------------------------------------------------------------