Skip to content

Commit

Permalink
added docs for dbaddress, dbaddresskey and dbcachekey classes
Browse files Browse the repository at this point in the history
  • Loading branch information
EndrII committed Sep 26, 2020
1 parent 62b99b8 commit a17d015
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 22 deletions.
43 changes: 41 additions & 2 deletions Heart/DataBaseSpace/dbaddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,67 @@
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;

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:
Expand All @@ -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);

}
Expand Down
2 changes: 1 addition & 1 deletion Heart/DataBaseSpace/dbaddresskey.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
38 changes: 26 additions & 12 deletions Heart/DataBaseSpace/dbcachekey.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,48 @@
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 <class TYPE = AbstractKey>
/**
* @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<const TYPE*>(_data.value(key, nullptr));
}

template <class TYPE>
/**
* @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<const AbstractKey*>(&value);
Expand All @@ -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<uint, AbstractKey*> _data;
DBCacheKey();
Expand Down
7 changes: 0 additions & 7 deletions Heart/NetworkSpace/networknode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a17d015

Please sign in to comment.