13 using namespace Huggle;
16 QNetworkAccessManager Query::NetworkManager;
22 this->Status = StatusNull;
31 this->StartTime = QDateTime::currentDateTime();
32 this->RetryOnTimeoutFailure =
true;
40 throw new Exception(
"Memory leak: Query::CallbackResult was not deleted before destructor was called");
47 if (this->Status == StatusDone || this->Status == StatusInError)
51 if (QDateTime::currentDateTime() > this->StartTime.addSecs(this->Timeout))
53 if (!this->
Repeated && this->RetryOnTimeoutFailure)
56 this->StartTime = QDateTime::currentDateTime();
67 this->
Result->Failed =
true;
69 this->Status = StatusInError;
86 return "Revert Query";
95 return "Invalid target";
98 QString Query::QueryStatusToString()
105 switch (this->Status)
111 case StatusProcessing:
116 if (this->
Result->Failed && this->Result->ErrorMessage !=
"")
bool Repeated
When a query fail and retry this is changed to true so that it doesn't endlessly restart.
virtual void Process()
Execute query.
virtual QString QueryTargetToString()
Return a target of a query.
virtual bool Processed()
Returns true in case that query is processed.
void RegisterConsumer(const int consumer)
Registers a consumer.
static unsigned int LastID
This is a last ID used by a constructor of a query.
virtual QString QueryTypeToString()
Convert a type of this query to a string.
Callback callback
Callback.
virtual void Kill()
Terminates a query.
QueryType Type
Type of a query.
virtual ~Query()
Destructor for query.
Query()
Creates empty query.
Every exception raised by huggle is defined by this class.
Query * Dependency
Dependency for query.
QString ErrorMessage
If query is in error the reason for error is stored here.
QString CustomStatus
Custom status.
unsigned int ID
Every query has own unique ID which can be used to work with them.
void * CallbackResult
This is a pointer to object returned by your callback function.
QueryResult * Result
Result of query, see documentation of QueryResult for more.