|
Hydra 0.20
|
#include <Engine.h>
Public Types | |
| enum | { Add_New = 10, Add_Exists, Add_NewPath, Add_UpdatedPath, Add_Error, Load_OK = 100, Load_ErrorNeedsUpdate, Load_ErrorNotFound, Load_ErrorFatal, Load_ErrorFileMissing } |
Public Member Functions | |
| Engine (void) | |
| constructor | |
| ~Engine () | |
| destructor | |
| int | addFile (const QString &fullfilename, const QString *precalchash=0) |
| bool | erasePath (const QString &fullfilename) |
| bool | eraseHash (const QString &hash) |
| int | getFileItem (const QString &fullfilename, hydra::FileItemRecord *item, hydra::FileHashRecord *hash, hydra::FilePathRecord *path) |
| int | getFileItem (const QString &fullfilename, hydra::FileItemRecord &rec) |
| int | getFileItemByHash (const QString &hashkey, hydra::FileItemRecord *item, hydra::FileHashRecord *hash) |
| int | regetFileItem (hydra::FileItemRecord &rec) |
| bool | saveFileItem (hydra::FileItemRecord &rec, const QDateTime &newmodtime) |
| hydra::DB & | filePathDB (void) |
| hydra::DB & | fileHashDB (void) |
| hydra::DB & | fileItemDB (void) |
Static Public Member Functions | |
| static Engine * | instance (void) |
| static QString | homeDir (void) |
| static QString | dbDir (void) |
| static char | codeToChar (int code) |
| static bool | statFile (const QString &fullfilename, double &modtime, qint64 &filesize) |
The main processing engine for hydra applications. It is a singleton class that should be instatiated by your main or similar function.
| int hydra::Engine::addFile | ( | const QString & | fullfilename, |
| const QString * | precalchash = 0 |
||
| ) |
Adds a file to the db. This will also repair/update any outof date records. If precalchash is provided, then it is assumed to be the hash of the given file.
| static char hydra::Engine::codeToChar | ( | int | code | ) | [static] |
This converts any of the errors codes into a ascii char that may be suitable for status output.
| static QString hydra::Engine::dbDir | ( | void | ) | [static] |
Returns the directory where the database files are stored. (This is usually ~/.hydradb)
This will also create it, if necesary.
| bool hydra::Engine::eraseHash | ( | const QString & | hash | ) |
Erase the given hash from the database. Note, that this will UNTIE the hash from its current item record, effectivly forgetting its tags, etc. Upon rediscovery, the hash will get a new item record. Returns true on success (which for now, is always)
| bool hydra::Engine::erasePath | ( | const QString & | fullfilename | ) |
Erase the given path from the database. Returns true on success (which for now, is always)
| int hydra::Engine::getFileItem | ( | const QString & | fullfilename, |
| hydra::FileItemRecord * | item, | ||
| hydra::FileHashRecord * | hash, | ||
| hydra::FilePathRecord * | path | ||
| ) |
Loads the given file from the DB Any of the pointers may be null.
| int hydra::Engine::getFileItem | ( | const QString & | fullfilename, |
| hydra::FileItemRecord & | rec | ||
| ) |
Loads the given file from the DB
This is a shorter version of the above.
| int hydra::Engine::getFileItemByHash | ( | const QString & | hashkey, |
| hydra::FileItemRecord * | item, | ||
| hydra::FileHashRecord * | hash | ||
| ) |
Loads the given file from the DB, by hash
| static QString hydra::Engine::homeDir | ( | void | ) | [static] |
Gets the path to the user's home directory, or "." if not found.
| static Engine* hydra::Engine::instance | ( | void | ) | [inline, static] |
Returns the static instance, if any
| int hydra::Engine::regetFileItem | ( | hydra::FileItemRecord & | rec | ) |
Reloads the given file item from db. The fileitem must have previously been loaded from the db (ie. its id field must be valid).
Returns the same codes as getFileItem()
| bool hydra::Engine::saveFileItem | ( | hydra::FileItemRecord & | rec, |
| const QDateTime & | newmodtime | ||
| ) |
Saves the given item to the db.
| rec | the record to save |
| newmodtime | the modification time to use. If this isValid, rec.modtime will be set to this before saving |
| static bool hydra::Engine::statFile | ( | const QString & | fullfilename, |
| double & | modtime, | ||
| qint64 & | filesize | ||
| ) | [static] |
gets the mod time and file size of the given file returns true on success