Huggle
build:^490^dce1e5c
|
Query base class for all http queries executed by huggle. More...
#include <query.hpp>
Public Member Functions | |
Query () | |
Creates empty query. | |
virtual | ~Query () |
Destructor for query. | |
virtual void | Kill () |
Terminates a query. More... | |
virtual void | Process () |
Execute query. More... | |
void | ProcessCallback () |
virtual bool | Processed () |
Returns true in case that query is processed. | |
unsigned int | QueryID () |
virtual QString | QueryStatusToString () |
virtual QString | QueryTargetToString () |
Return a target of a query. More... | |
virtual QString | QueryTypeToString () |
Convert a type of this query to a string. | |
![]() | |
unsigned long | CollectableID () |
CollectableID. More... | |
QString | DebugHgc () |
DebugHgc. More... | |
bool | IsLocked () |
bool | IsManaged () |
IsManaged Managed class is deleted by GC and must not be deleted by hand. More... | |
void | Lock () |
Lock this object so that other threads can't change consumers or modify its properties. | |
void | RegisterConsumer (const int consumer) |
Registers a consumer. More... | |
void | RegisterConsumer (const QString consumer) |
Registers a consumer. More... | |
virtual bool | SafeDelete () |
Use this if you are not sure if you can delete this object in this moment. | |
void | Unlock () |
Unlock this object for deletion by other threads. | |
void | UnregisterConsumer (const int consumer) |
This function will remove a string which prevent the object from being removed. More... | |
void | UnregisterConsumer (const QString consumer) |
This function will remove a string which prevent the object from being removed. More... | |
Public Attributes | |
Callback | callback |
Callback. More... | |
void * | CallbackResult |
This is a pointer to object returned by your callback function. | |
QString | CustomStatus |
Custom status. More... | |
Query * | Dependency |
Dependency for query. More... | |
bool | HiddenQuery |
QueryResult * | Result |
Result of query, see documentation of QueryResult for more. | |
bool | RetryOnTimeoutFailure |
QDateTime | StartTime |
enum _Status | Status |
Current status of a query. | |
int | Timeout |
QueryType | Type |
Type of a query. More... | |
Static Public Attributes | |
static QNetworkAccessManager | NetworkManager |
Private Attributes | |
unsigned int | ID |
Every query has own unique ID which can be used to work with them. | |
bool | Repeated |
When a query fail and retry this is changed to true so that it doesn't endlessly restart. | |
Static Private Attributes | |
static unsigned int | LastID = 0 |
This is a last ID used by a constructor of a query. | |
Query base class for all http queries executed by huggle.
Every request to website is processed as a query, this is a base object that all other queries are derived from. The query system is using own GC see a QueryGC That means every query is either unmanaged or managed. In case it is managed, the GC will care about it being removed from operating memory and you must not call a delete on it, otherwise program will crash.
|
inlinevirtual |
Terminates a query.
In case it's not running nothing happens, in case query is currently running it should be immediately stopped and error result should be generated This is only a virtual interface implemented in Query which does nothing by default it is necessary for every query to implement this for it to work properly
Reimplemented in Huggle::ApiQuery, Huggle::WebserverQuery, and Huggle::RevertQuery.
Definition at line 121 of file query.hpp.
Referenced by Processed().
|
inlinevirtual |
Execute query.
This is a main() of every query, your implementation goes here
Reimplemented in Huggle::ApiQuery, Huggle::RevertQuery, Huggle::WebserverQuery, Huggle::EditQuery, and Huggle::WLQuery.
Definition at line 113 of file query.hpp.
Referenced by Processed().
void Query::ProcessCallback | ( | ) |
If you inherit query you should allways call this from a signal that you receive when the query finish
Definition at line 126 of file query.cpp.
References callback, CallbackResult, and Huggle::Collectable::RegisterConsumer().
unsigned int Query::QueryID | ( | ) |
Every query has own unique ID which can be used to work with them this function returns that
Definition at line 135 of file query.cpp.
References ID.
Referenced by Huggle::ProcessList::InsertQuery(), Huggle::ProcessList::RemoveQuery(), and Huggle::ProcessList::UpdateQuery().
|
virtual |
Return a target of a query.
Target is either explicitly defined abstract identifier that is used for statistical purposes, or it is provided by query itself, based on a type of that query typical example would be a page that is affected by ApiQuery
Reimplemented in Huggle::ApiQuery, and Huggle::RevertQuery.
Definition at line 93 of file query.cpp.
Referenced by Huggle::ProcessList::InsertQuery(), and Huggle::ProcessList::UpdateQuery().
Callback Huggle::Query::callback |
Callback.
If this is not a NULL this function will be called by query once it's finished, a consumer called "delegate" will be created and you will have to either replace it or remove in your function otherwise you create a leak in huggle
Definition at line 87 of file query.hpp.
Referenced by ProcessCallback(), and Query().
QString Huggle::Query::CustomStatus |
Custom status.
This can be used to override the current string representation of status with some custom string, the system will still process the primary status but user will see this custom string in a process list
Definition at line 76 of file query.hpp.
Referenced by Huggle::ApiQuery::FinishRollback(), Huggle::RevertQuery::Process(), Huggle::RevertQuery::ProcessRevert(), Query(), and Huggle::RevertQuery::Rollback().
Query* Huggle::Query::Dependency |
Dependency for query.
If you put anything in here, it either must be NULL or query that is processed. The query will not be flagged as processed until the dependency is processed as well, for most types of queries they will not even start before that
Definition at line 103 of file query.hpp.
Referenced by Query().
bool Huggle::Query::HiddenQuery |
Query doesn't have internal data displayed in debug log, this is usefull when you are working with passwords in parameters
Definition at line 96 of file query.hpp.
Referenced by Huggle::ApiQuery::Process(), and Query().
QueryType Huggle::Query::Type |
Type of a query.
This is very useful when you are casting a query to different type
Definition at line 80 of file query.hpp.
Referenced by Huggle::ApiQuery::ApiQuery(), Query(), and QueryTypeToString().