19#ifndef HEADER_ONLINE_REQUEST_HPP
20#define HEADER_ONLINE_REQUEST_HPP
22#include "utils/cpp2011.hpp"
23#include "utils/no_copy.hpp"
24#include "utils/synchronised.hpp"
60 class Request :
public std::enable_shared_from_this<Request>,
127 Request(
int priority,
int type);
128 virtual ~Request() {}
204 return s == S_EXECUTED || s == S_DONE;
222 const std::shared_ptr<Request>& b)
const
224 return a->getPriority() < b->getPriority();
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
This class is used by the priority queue to sort requests by priority.
Definition: request.hpp:217
bool operator()(const std::shared_ptr< Request > &a, const std::shared_ptr< Request > &b) const
Compares two requests, returns if the first request has a lower priority than the second one.
Definition: request.hpp:221
Stores a request for the HTTP Manager.
Definition: request.hpp:62
bool isAbortable() const
Returns if this request can be aborted.
Definition: request.hpp:155
void setAbortable(bool b)
Sets if this request is abortable or not.
Definition: request.hpp:159
const int m_type
Type of the request.
Definition: request.hpp:65
int getType() const
Returns the type of the request.
Definition: request.hpp:139
virtual void callback()
Executed when a request has finished.
Definition: request.hpp:135
const int m_priority
The priority of this request.
Definition: request.hpp:69
virtual void operation()
The actual operation to be executed.
Definition: request.hpp:111
void execute()
Executes the request.
Definition: request.cpp:58
void setDone()
Should only be called by the manager.
Definition: request.hpp:179
bool isDone() const
Returns if this request is done.
Definition: request.hpp:187
Synchronised< State > m_state
Set to though if the reply of the request is in and callbacks are executed.
Definition: request.hpp:106
virtual void afterOperation()
Virtual function to be called after an operation.
Definition: request.hpp:119
virtual bool isAllowedToAdd() const
Virtual method to check if a request has initialized all needed members to a valid value.
Definition: request.hpp:210
bool isPreparing() const
Returns if this request is being prepared.
Definition: request.hpp:191
State
The different state of the requst:
Definition: request.hpp:87
void setBusy()
Sets the request state to busy.
Definition: request.hpp:163
virtual void prepareOperation()
Virtual function to be called before an operation.
Definition: request.hpp:115
Synchronised< bool > m_is_abortable
If this request can be aborted (at the end of STK).
Definition: request.hpp:102
void setExecuted()
Sets the request to be completed.
Definition: request.hpp:171
bool hasBeenExecuted() const
Checks if the request has completed or done (i.e.
Definition: request.hpp:201
bool isBusy() const
Returns if this request is busy.
Definition: request.hpp:195
Synchronised< bool > m_cancel
Cancel this request if it is active.
Definition: request.hpp:97
void queue()
Inserts this request into the RequestManager's queue for executing.
Definition: request.cpp:49
void executeNow()
Executes the request now, i.e.
Definition: request.cpp:81
bool isCancelled() const
Returns if this request is to be canceled.
Definition: request.hpp:151
int getPriority() const
Returns the priority of this request.
Definition: request.hpp:143
void cancel()
Signals that this request should be canceled.
Definition: request.hpp:147
A variable that is automatically synchronised using pthreads mutex.
Definition: synchronised.hpp:28
void setAtomic(const TYPE &v)
Sets the value of this variable using a mutex.
Definition: synchronised.hpp:59
TYPE getAtomic() const
Returns a copy of this variable.
Definition: synchronised.hpp:68