[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [ksecrets] src/runtime/ksecrets_backend: Some more qualifiers and constructors
From: Valentin Rusu <kde () rusu ! info>
Date: 2015-08-07 19:57:13
Message-ID: E1ZNnlR-0002yB-Tf () scm ! kde ! org
[Download RAW message or body]
Git commit a023d42c855bafb2f692c85665ab78063a2331fc by Valentin Rusu.
Committed on 06/08/2015 at 18:18.
Pushed by vrusu into branch 'master'.
Some more qualifiers and constructors
M +65 -27 src/runtime/ksecrets_backend/ksecrets_backend.h
http://commits.kde.org/ksecrets/a023d42c855bafb2f692c85665ab78063a2331fc
diff --git a/src/runtime/ksecrets_backend/ksecrets_backend.h b/src/runtime/ksecrets_backend/ksecrets_backend.h
index 489a842..22b2441 100644
--- a/src/runtime/ksecrets_backend/ksecrets_backend.h
+++ b/src/runtime/ksecrets_backend/ksecrets_backend.h
@@ -32,24 +32,37 @@
*
* This class would store the secrets into an underlying custom formated file.
*
- * Each API call is stateless. That is, the secrets file will always be left in a consistent
- * state between calls. So, even if your application crashes, the file won't get corrupted.
- * FIXME is that OK? Further tests should be confirm if a background sync should be introduced
- * in order to get operations faster. However, today computing power do not justify
- * Ã priori optimizations, so this first version would modify the file with each API call.
- * That guarantee client applications that edits are always synced to disk/storage.
+ * Each API call is stateless. That is, the secrets file will always be left
+ *in a consistent
+ * state between calls. So, even if your application crashes, the file won't
+ *get corrupted.
+ * FIXME is that OK? Further tests should be confirm if a background sync
+ *should be introduced
+ * in order to get operations faster. However, today computing power do
+ *not justify
+ * Ã priori optimizations, so this first version would modify the file
+ *with each API call.
+ * That guarantee client applications that edits are always synced to
+ *disk/storage.
*
- * The API calls are organized in classes, following the structure of data in the backend.
- * Applications will first work with a Collection, the search or insert Items into it.
- * The Item class holds, sure enough, the secret value but also let applications associate
- * the secret value with metadata, such as the label or other custom properties.
+ * The API calls are organized in classes, following the structure of data in
+ *the backend.
+ * Applications will first work with a Collection, the search or insert Items
+ *into it.
+ * The Item class holds, sure enough, the secret value but also let
+ *applications associate
+ * the secret value with metadata, such as the label or other custom
+ *properties.
*
* Before using a collection, the application should open it.
* Upon opening, it's possible to indicate if readonly mode is possible.
*
- * When opening without readonly flag, then the file is exclusively locked. The lock is
- * released when the class is destroyed. You should keep the file locked as shortly as
- * possible, in order to avoid deadlocks between applications that also need to read the
+ * When opening without readonly flag, then the file is exclusively locked.
+ *The lock is
+ * released when the class is destroyed. You should keep the file locked as
+ *shortly as
+ * possible, in order to avoid deadlocks between applications that also need
+ *to read the
* secrets. For more information @see open().
*
* TODO give here a code example once the API stabilizes
@@ -88,8 +101,7 @@ public:
TimeStamped(const TimeStamped&) = default;
TimeStamped& operator=(const TimeStamped&) = default;
- template <class FUNC>
- void modify(FUNC func)
+ template <class FUNC> void modify(FUNC func)
{
func();
modifiedTime = std::time(nullptr);
@@ -114,6 +126,9 @@ public:
* @see Collection
*/
class Item : public TimeStamped {
+ Item(const Item&) = default;
+ Item& operator=(const Item&) = default;
+
std::string label() const noexcept;
bool setLabel(std::string&&) noexcept;
@@ -123,6 +138,10 @@ public:
ItemValue value() const noexcept;
bool setValue(ItemValue&&) noexcept;
+ protected:
+ Item();
+ friend class KSecretsBackend;
+
private:
std::shared_ptr<ItemPrivate> d;
};
@@ -131,19 +150,29 @@ public:
/**
* Each application organizes it's secrets in collections.
*
- * Typical applications will only use one collection. A collection can store
- * an arbitrary amount of Items. Each Item has a label, custom attributes and
+ * Typical applications will only use one collection. A collection can
+ *store
+ * an arbitrary amount of Items. Each Item has a label, custom attributes
+ *and
* a secret value.
*
- * The custom attributes are application-defined. This API would store these
+ * The custom attributes are application-defined. This API would store
+ *these
* attributes as they are provided.
*
- * Search methods are provided to let application locate items by specifying
- * only a subset of these custom attributes. When searching, partial matching is
- * used, so you could only provide part of the value of an attribute and get all
- * the items having attribute value containing that partially specified value.
+ * Search methods are provided to let application locate items by
+ *specifying
+ * only a subset of these custom attributes. When searching, partial
+ *matching is
+ * used, so you could only provide part of the value of an attribute and
+ *get all
+ * the items having attribute value containing that partially specified
+ *value.
*/
class Collection : public TimeStamped {
+ Collection(const Collection&) = default;
+ Collection& operator=(const Collection&) = default;
+
std::string label() const noexcept;
bool setLabel(std::string&&) noexcept;
@@ -157,7 +186,8 @@ public:
* possible. So please check if via it's operator bool() before using
* it.
*/
- ItemPtr createItem(std::string&& label, AttributesMap&&, ItemValue&&) noexcept;
+ ItemPtr createItem(
+ std::string&& label, AttributesMap&&, ItemValue&&) noexcept;
/*
* Convenience method for creating items without supplemental
* attributes.
@@ -167,6 +197,11 @@ public:
* it.
*/
ItemPtr createItem(std::string&& label, ItemValue&&) noexcept;
+
+ protected:
+ Collection();
+ friend class KSecretsBackend;
+
private:
std::shared_ptr<CollectionPrivate> d;
};
@@ -183,7 +218,7 @@ public:
*/
KSecretsBackend();
KSecretsBackend(const KSecretsBackend&) = delete;
- virtual ~KSecretsBackend();
+ virtual ~KSecretsBackend() = default;
enum class OpenStatus {
Good,
@@ -192,16 +227,19 @@ public:
FileNotFound,
PermissionDeniedByTheSystem
};
- std::future<OpenStatus> open(std::string&&, bool readOnly = true) noexcept;
+ std::future<OpenStatus> open(
+ std::string&&, bool readOnly = true) noexcept;
std::vector<std::string> dirCollections() noexcept;
/*
- * @return CollectionPtr which can empty if the call did not succeed. Please check that with operator bool().
+ * @return CollectionPtr which can empty if the call did not succeed.
+ *Please check that with operator bool().
* If it fails, have you already called open()?
*
*/
CollectionPtr createCollection(std::string&&) noexcept;
/*
- * @return CollectionPtr which can empty if the call did not succeed, e.g. the collection was not found.
+ * @return CollectionPtr which can empty if the call did not succeed, e.g.
+ * the collection was not found.
* Please check that with operator bool()
*/
CollectionPtr readCollection(std::string&&) const noexcept;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic