Line |
Branch |
Exec |
Source |
1 |
|
|
// SPDX-FileCopyrightText: 2023 Carl Zeiss Microscopy GmbH |
2 |
|
|
// |
3 |
|
|
// SPDX-License-Identifier: MIT |
4 |
|
|
|
5 |
|
|
#pragma once |
6 |
|
|
|
7 |
|
|
#include <string> |
8 |
|
|
#include <unordered_set> |
9 |
|
|
#include "types.h" |
10 |
|
|
#include "DocumentType.h" |
11 |
|
|
|
12 |
|
|
namespace imgdoc2 |
13 |
|
|
{ |
14 |
|
|
/// Options for creating an imgdoc2-document. |
15 |
|
|
class ICreateOptions |
16 |
|
|
{ |
17 |
|
|
public: |
18 |
|
|
/// Sets the document type. Note that a newly created instance will have the document type "kImage2d2". |
19 |
|
|
/// \param document_type Type of the document. |
20 |
|
|
virtual void SetDocumentType(imgdoc2::DocumentType document_type) = 0; |
21 |
|
|
|
22 |
|
|
/// Sets the filename. For a Sqlite-based database, this string allows for additional functionality |
23 |
|
|
/// (like an in-memory database) - cf. https://sqlite.org/inmemorydb.html, https://sqlite.org/uri.html. |
24 |
|
|
/// The string must be given in UTF-8 encoding. |
25 |
|
|
/// |
26 |
|
|
/// \param filename The filename (in UTF8-encoding). |
27 |
|
|
virtual void SetFilename(const char* filename) = 0; |
28 |
|
|
|
29 |
|
|
/// Adds a dimension. |
30 |
|
|
/// Adding the same dimension multiple times is valid, no error is reported in this case. |
31 |
|
|
/// If the argument 'dim' is not a valid dimension identifier, an "invalid_argument" exception |
32 |
|
|
/// will be thrown. |
33 |
|
|
/// \param dim The dimension to add. |
34 |
|
|
virtual void AddDimension(imgdoc2::Dimension dim) = 0; |
35 |
|
|
|
36 |
|
|
/// Sets a flag indicating whether the database should be created containing a spatial index. |
37 |
|
|
/// \param use_spatial_index True if to construct with a spatial index. |
38 |
|
|
virtual void SetUseSpatialIndex(bool use_spatial_index) = 0; |
39 |
|
|
|
40 |
|
|
/// Adds a dimension for which an index is to be created. |
41 |
|
|
/// Adding the same dimension multiple times is valid, no error is reported in this case. |
42 |
|
|
/// If the argument 'dim' is not a valid dimension identifier, an "invalid_argument" exception |
43 |
|
|
/// will be thrown. |
44 |
|
|
/// \param dim The dimension for which to create an index. |
45 |
|
|
virtual void AddIndexForDimension(imgdoc2::Dimension dim) = 0; |
46 |
|
|
|
47 |
|
|
/// Sets a flag indicating whether a BLOB table is to be constructed. Only if a BLOB table is present, the storage-type "BlobInDatabase" can be used. |
48 |
|
|
/// \param create_blob_table True to create BLOB table. |
49 |
|
|
virtual void SetCreateBlobTable(bool create_blob_table) = 0; |
50 |
|
|
|
51 |
|
|
/// Gets the document type. |
52 |
|
|
/// \returns The document type. |
53 |
|
|
[[nodiscard]] virtual imgdoc2::DocumentType GetDocumentType() const = 0; |
54 |
|
|
|
55 |
|
|
/// Whether the document should be created with a spatial index. |
56 |
|
|
/// \returns True if a spatial index is requested; false otherwise. |
57 |
|
|
[[nodiscard]] virtual bool GetUseSpatialIndex() const = 0; |
58 |
|
|
|
59 |
|
|
/// Gets the filename. The returned string is given in UTF8-encoding. |
60 |
|
|
/// \returns The filename. |
61 |
|
|
[[nodiscard]] virtual const std::string& GetFilename() const = 0; |
62 |
|
|
|
63 |
|
|
/// Gets the dimensions. |
64 |
|
|
/// \returns The dimensions. |
65 |
|
|
[[nodiscard]] virtual const std::unordered_set<imgdoc2::Dimension>& GetDimensions() const = 0; |
66 |
|
|
|
67 |
|
|
/// Gets dimensions for which an index is to be created. |
68 |
|
|
/// \returns The indexed dimensions. |
69 |
|
|
[[nodiscard]] virtual const std::unordered_set<imgdoc2::Dimension>& GetIndexedDimensions() const = 0; |
70 |
|
|
|
71 |
|
|
/// Gets a boolean indicating whether a blob table is to be created. |
72 |
|
|
/// \returns True if a blob table is to be created; false otherwise. |
73 |
|
|
[[nodiscard]] virtual bool GetCreateBlobTable() const = 0; |
74 |
|
|
|
75 |
|
516 |
virtual ~ICreateOptions() = default; |
76 |
|
|
|
77 |
|
|
/// Sets the filename. For a Sqlite-based database, this string allows for additional functionality |
78 |
|
|
/// (like an in-memory database) - cf. https://sqlite.org/inmemorydb.html, https://sqlite.org/uri.html. |
79 |
|
|
/// The string must be given in UTF-8 encoding. |
80 |
|
|
/// |
81 |
|
|
/// \param filename The filename (in UTF8-encoding). |
82 |
|
4 |
void SetFilename(const std::string& filename) |
83 |
|
|
{ |
84 |
|
4 |
this->SetFilename(filename.c_str()); |
85 |
|
4 |
} |
86 |
|
|
public: |
87 |
|
|
/// Adds the dimensions from the specified iterator. |
88 |
|
|
/// \tparam ForwardIterator Type of the forward iterator. |
89 |
|
|
/// \param start The start. |
90 |
|
|
/// \param end The end. |
91 |
|
|
template<class ForwardIterator> |
92 |
|
|
void AddDimensions(ForwardIterator start, ForwardIterator end) |
93 |
|
|
{ |
94 |
|
|
while (start != end) |
95 |
|
|
{ |
96 |
|
|
this->AddDimension(*start++); |
97 |
|
|
} |
98 |
|
|
} |
99 |
|
|
}; |
100 |
|
|
} |
101 |
|
|
|