From a17d015022ed522924d7e271a462a174f0b1d770 Mon Sep 17 00:00:00 2001 From: EndrII Date: Sat, 26 Sep 2020 16:33:49 +0300 Subject: [PATCH] added docs for dbaddress, dbaddresskey and dbcachekey classes --- Heart/DataBaseSpace/dbaddress.h | 43 ++++++++++++++++++++++++++++-- Heart/DataBaseSpace/dbaddresskey.h | 2 +- Heart/DataBaseSpace/dbcachekey.h | 38 +++++++++++++++++--------- Heart/NetworkSpace/networknode.h | 7 ----- 4 files changed, 68 insertions(+), 22 deletions(-) diff --git a/Heart/DataBaseSpace/dbaddress.h b/Heart/DataBaseSpace/dbaddress.h index d8057c63..d6bf2192 100644 --- a/Heart/DataBaseSpace/dbaddress.h +++ b/Heart/DataBaseSpace/dbaddress.h @@ -15,20 +15,32 @@ namespace QH { /** - * @brief The DbAddress class - this is address of data base object + * @brief The DbAddress class is class for work with database addresses. Database Address it is structure with 2 values. + * \code + * { + * QString _table; // this is name of table of object. + BaseId _id; // this is id of object. + * } + * \endcode */ class HEARTSHARED_EXPORT DbAddress : public StreamBase { public: DbAddress() = default; + + /** + * @brief DbAddress this constructo initialize a default database address. + * @param table This is table name in database. + * @param id This is id of object in table. + */ DbAddress(const QString& table, const BaseId& id); QDataStream &fromStream(QDataStream &stream); QDataStream &toStream(QDataStream &stream) const; /** - * @brief toString - return a string implementation fo this object + * @brief toString This method return a string implementation fo this object * @return string of object */ QString toString() const; @@ -36,12 +48,34 @@ class HEARTSHARED_EXPORT DbAddress : public StreamBase { friend bool operator== (const DbAddress& left, const DbAddress& other); friend bool operator!= (const DbAddress& left, const DbAddress& other); + /** + * @brief isValid This method check object for valid. + * @return true if object is valid. + */ bool isValid() const; + /** + * @brief table This method return table name. + * @return table name of object. + */ const QString& table() const; + + /** + * @brief setTable This method set new table name of address. + * @param table new value of table name. + */ void setTable(const QString &table); + /** + * @brief id This method return id of object in table. + * @return id of object. + */ const BaseId &id() const; + + /** + * @brief setId This method set id for this address. + * @param id tgis is new value of objects id. + */ void setId(const BaseId &id); private: @@ -50,6 +84,11 @@ class HEARTSHARED_EXPORT DbAddress : public StreamBase { BaseId _id; }; +/** + * @brief qHash This functions cals int 32 hash of address. + * @param address This is input address. + * @return unsigned int 32 hash value. + */ qint64 qHash(const DbAddress& address); } diff --git a/Heart/DataBaseSpace/dbaddresskey.h b/Heart/DataBaseSpace/dbaddresskey.h index 7e3ed2ea..cb475bac 100644 --- a/Heart/DataBaseSpace/dbaddresskey.h +++ b/Heart/DataBaseSpace/dbaddresskey.h @@ -14,7 +14,7 @@ namespace QH { /** - * @brief The DbAddressKey class - key provider for DbAddress + * @brief The DbAddressKey class is implementation for calc hash key of DbAddress objects. */ class HEARTSHARED_EXPORT DbAddressKey: public DbAddress, public AbstractKey { diff --git a/Heart/DataBaseSpace/dbcachekey.h b/Heart/DataBaseSpace/dbcachekey.h index 73d6feab..80a8fb8e 100644 --- a/Heart/DataBaseSpace/dbcachekey.h +++ b/Heart/DataBaseSpace/dbcachekey.h @@ -18,23 +18,38 @@ namespace QH { /** - * @brief The DBCacheKey class - is database main key value + * @brief The DBCacheKey class is memory storrage for registered key values. + * This class have a static array for contains all child classes of the AbstractKey class. + * + * Description: + * + * Any key it is unsigned int implementatio of any AbstractKey child objects. + * This class provide functions: + * - The Get of value of AbstractKey child classes (it hash). for more information see the AbstractKey::hash method. + * For this use the HASH_KEY(X) macros. + * - The Calc of hash value of any AbstractKey child classes (it hash). + * If the hash is has been calculated then hash returned from the cache of DBCacheKey. + * For this use the VALUE_KEY(X) macros. + * - The Generate of keys description. + * For this use the DESCRIPTION_KEY(X) macros. + * + * @note This class is implementation of the Singleton pattern. Use carefully. */ class HEARTSHARED_EXPORT DBCacheKey { public: /** - * @brief instance + * @brief instance This method return instance of this singleton object. * @return singleton of object */ static DBCacheKey* instance(); template /** - * @brief value - return vale from key - * @param key - hash of ke value - * @return value of key + * @brief value This method return the vale from key. for more convenient use the HASH_KEY(X) macros. + * @param key This is hash of key value + * @return value of key. */ const TYPE* value(uint key) const { return dynamic_cast(_data.value(key, nullptr)); @@ -42,9 +57,9 @@ class HEARTSHARED_EXPORT DBCacheKey template /** - * @brief key - return hash key and save object into objects table - * @param value - the value of a key objekt - * @return hash of input value + * @brief key This method return hash key and save object into objects table. For more convenient use the VALUE_KEY(X) macros + * @param value this is value of a key objekt + * @return hash of input value. */ uint key(const TYPE& value) { auto object = dynamic_cast(&value); @@ -61,13 +76,12 @@ class HEARTSHARED_EXPORT DBCacheKey } /** - * @brief description - return string description of id - * @param hash - * @return + * @brief description This method return string description of id (hash). For more convenient use the DESCRIPTION_KEY(X) macros. + * @param hash this is hash value of object (id) + * @return information about this hash value. */ QString description(uint hash) const; - private: QHash _data; DBCacheKey(); diff --git a/Heart/NetworkSpace/networknode.h b/Heart/NetworkSpace/networknode.h index bb12a35a..4cae0c89 100644 --- a/Heart/NetworkSpace/networknode.h +++ b/Heart/NetworkSpace/networknode.h @@ -98,13 +98,6 @@ class HEARTSHARED_EXPORT NetworkNode : public DataBaseNode bool sendData(PKG::AbstractData *resp, const HostAddress &nodeId, const Header *req = nullptr) override; - /** - * @brief initDefaultDbObjects create default cache and db writer if pointer is null - * @param cache - * @param writer - */ - void initDefaultDbObjects(SqlDBCache *cache, SqlDBWriter *writer); - /** * @brief parsePackage * @param pkg