5553
|
1 The main object to access the DB is the ServerIndex class that is accessible from the ServerContext.
|
|
2
|
|
3 ServerIndex inherits from StatelessDatabaseOperations.
|
|
4
|
|
5 StatelessDatabaseOperations owns an IDatabaseWrapper member (db).
|
|
6 StatelessDatabaseOperations has 2 internal Transaction classes (ReadOnlyTransactions and ReadWriteTransactions) that implements the DB
|
|
7 operations by calling the methods from IDatabaseWrapper:ITransaction.
|
|
8
|
|
9 IDatabaseWrapper has 2 direct derived classes:
|
|
10 - BaseDatabaseWrapper which simply provides a "not implemented" implementation of new methods to its derived classes:
|
|
11 - OrthancPluginDatabase that is a legacy plugin interface
|
|
12 - OrthancPluginDatabaseV3 that is a legacy plugin interface
|
|
13 - SQLiteDatabaseWrapper that is used by the default SQLite DB in Orthanc
|
|
14 - OrthancPluginDatabaseV4 that is the latest plugin interface and uses protobuf
|
|
15
|
|
16 When you add a new method in the DB (e.g: UpdateAndGetStatistics with a new signature), you must:
|
|
17 - define it as a member of StatelessDatabaseOperations
|
|
18 - define it as a member of StatelessDatabaseOperations::ReadWriteTransactions or StatelessDatabaseOperations::ReadOnlyTransactions
|
|
19 - define it as a member of IDatabaseWrapper:ITransaction
|
|
20 - define it in OrthancDatabasePlugin.proto (new request + new response + new message)
|
|
21 - define it in OrthancPluginDatabaseV4
|
|
22 - define a NotImplemented default implementation in BaseDatabaseWrapper
|
|
23 - optionally define it in SQLiteDatabaseWrapper if it can be implemented in SQLite
|
|
24 - very likely define it as a DbCapabilities in IDatabaseWrapper::DbCapabilities (e.g: Has/SetUpdateAndGetStatistics()) such that the Orthanc
|
|
25 core knows if it can use it or not.
|
|
26
|
|
27 Then, in the orthanc-databases repo, you should:
|
|
28 - define it as a virtual member of IDatabaseBackend
|
|
29 - define it as a member of IndexBackend
|
|
30 - add a handler for the new protobuf message in DatabaseBackendAdapterV4
|