fastcgi++
|
Parent class for storing query data to be passed and retrieved from statements. More...
#include <query.hpp>
Classes | |
struct | SharedData |
Sub-structure to store shared data for the query. More... |
Public Member Functions | |
QueryPar (const QueryPar &x) | |
Calling the copy constructor will not set FLAG_ORIGINAL or create new shared data. | |
~QueryPar () | |
If the original object and keepalive is not turned on, cancel() is called. | |
unsigned int | insertId () const |
Returns the insert ID returned from the query or 0 if nothing. | |
unsigned int | rows () const |
Returns the rows affected/available from the query or 0 if nothing. | |
bool | busy () const |
Returns true if copies of this query still exist (query is still working in another thread). | |
Error | error () const |
Return the error object associated with the query. | |
void | setCallback (boost::function< void()> callback=boost::function< void()>()) |
Set the callback function to be called at the end of the query. | |
bool | isCallback () |
Return true if a callback is associated with this query. | |
boost::function< void()> | getCallback () |
Get the callback function. | |
void | keepAlive (bool x) |
Set true if you want the query to not be cancelled when the original object is destroyed. | |
void | cancel () |
Call this function to cancel the query. | |
void | enableRows () |
Call this function to enable the retrieval of a row count (affected/available rows) | |
void | enableInsertId () |
Call this function to enable the retrieval of an auto-increment insert ID. | |
void | reset () |
Resets the object as though it was destroyed and reconstructed anew. |
Protected Member Functions | |
QueryPar (bool singleParameters, bool singleResults) | |
Constructed by derived classes. | |
void | setResults (void *results) |
Set's the shared data to point to the passed pointer. | |
void | setParameters (void *parameters) |
Set's the shared data to point to the passed pointer. | |
void * | relinquishResults () |
Relinquishes control over the result data. | |
void * | relinquishParameters () |
Relinquishes control over the parameter data. | |
void * | results () |
Return a void pointer to the result set. | |
const void * | results () const |
Return a const void pointer to the result set. | |
void * | parameters () |
Return a void pointer to the parameter set. | |
const void * | parameters () const |
Return a const void pointer to the parameter set. |
Private Types | |
enum | Flags { FLAG_ORIGINAL = 1, FLAG_KEEPALIVE = 1<<1 } |
Private Member Functions | |
void | callback () |
Lock and call the callback function of it exists. | |
void | clearResults () |
void | clearParameters () |
Private Attributes | |
boost::shared_ptr< SharedData > | m_sharedData |
Shared pointer to query data. | |
unsigned char | m_flags |
Flags for individual query object. |
Friends | |
class | ConnectionPar |
Parent class for storing query data to be passed and retrieved from statements.
Most of the data is stored in a shared data structure that is referenced by copies of a QueryPar object. The only non-shared data stored in the class is the m_flags object which set's two possible flags. If the query is built from the default constructor, the FLAG_ORIGINAL flag is set. This serves the purpose of keeping track of which query object actually owns the original data. With this, one can have the query cancelled in it's handler thread if the original query object goes out of scope in it's own thread. If one wishes to avoid this behaviour they can have the FLAG_KEEPALIVE flag set with the keepAlive() function.
|
private |
|
inlineprotected |
Constructed by derived classes.
[in] | singleParameters | Set to true if the parameter set is a single row |
[in] | singleResults | Set to true if the result set is a single row |
Definition at line 159 of file query.hpp.
References ASql::QueryPar::SharedData::FLAG_SINGLE_PARAMETERS, ASql::QueryPar::SharedData::FLAG_SINGLE_RESULTS, and m_sharedData.
|
inline |
|
inline |
|
inline |
Returns true if copies of this query still exist (query is still working in another thread).
Definition at line 263 of file query.hpp.
References m_sharedData.
|
inlineprivate |
Lock and call the callback function of it exists.
Definition at line 141 of file query.hpp.
References m_sharedData.
Referenced by ASql::ConnectionPar< T >::intHandler(), and setCallback().
|
inline |
Call this function to cancel the query.
This will cancel the query at the earliest opportunity. Calling a cancel will rollback any changes in the associated transaction.
Definition at line 301 of file query.hpp.
References m_sharedData.
Referenced by ~QueryPar().
|
inlineprivate |
Definition at line 149 of file query.hpp.
References m_sharedData.
|
inlineprivate |
Definition at line 148 of file query.hpp.
References m_sharedData.
Referenced by ASql::ConnectionPar< T >::intHandler().
|
inline |
Call this function to enable the retrieval of an auto-increment insert ID.
Definition at line 311 of file query.hpp.
References m_sharedData.
|
inline |
Call this function to enable the retrieval of a row count (affected/available rows)
Definition at line 304 of file query.hpp.
References m_sharedData.
|
inline |
Return the error object associated with the query.
Note this will be a default Error object if there was no error.
Definition at line 269 of file query.hpp.
References m_sharedData.
|
inline |
Get the callback function.
Definition at line 285 of file query.hpp.
References m_sharedData.
Referenced by ASql::ConnectionPar< T >::intHandler().
|
inline |
Returns the insert ID returned from the query or 0 if nothing.
Definition at line 253 of file query.hpp.
References m_sharedData.
|
inline |
Return true if a callback is associated with this query.
Definition at line 282 of file query.hpp.
References m_sharedData.
Referenced by ASql::ConnectionPar< T >::intHandler().
|
inline |
Set true if you want the query to not be cancelled when the original object is destroyed.
Note that the default is to cancel and this must be called from the original query object.
Definition at line 294 of file query.hpp.
References FLAG_KEEPALIVE, and m_flags.
Referenced by reset().
|
inlineprotected |
Return a void pointer to the parameter set.
Usually you would keep the original typed pointer around but if you lost it for some reason you can use this and cast it.
Reimplemented in ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Parameters > >::type, void >, ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, void >, ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >, and ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >.
Definition at line 228 of file query.hpp.
References m_sharedData.
Referenced by ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >::createParameters(), ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >::createParameters(), ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, void >::createParameters(), ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Parameters > >::type, void >::createParameters(), ASql::ConnectionPar< T >::intHandler(), ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >::parameters(), ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >::parameters(), ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, void >::parameters(), ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Parameters > >::type, void >::parameters(), and setParameters().
|
inlineprotected |
Return a const void pointer to the parameter set.
Usually you would keep the original typed pointer around but if you lost it for some reason you can use this and cast it.
Reimplemented in ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Parameters > >::type, void >, ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, void >, ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >, and ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >.
Definition at line 235 of file query.hpp.
References m_sharedData.
|
inlineprotected |
Relinquishes control over the parameter data.
Calling this will disassociate the query object (and it's copies) from the parameter data but won't delete it. Use this if you are done with your query object but want to keep your parameter data around. The end result in the query object (and it's copies) is to have no parameter data associated with it.
Reimplemented in ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Parameters > >::type, void >, ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, void >, ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >, and ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >.
Definition at line 207 of file query.hpp.
References m_sharedData.
Referenced by ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >::relinquishParameters(), ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >::relinquishParameters(), ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, void >::relinquishParameters(), and ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Parameters > >::type, void >::relinquishParameters().
|
inlineprotected |
Relinquishes control over the result data.
Calling this will disassociate the query object (and it's copies) from the result data but won't delete it. Use this if you are done with your query object but want to keep your result data around. The end result in the query object (and it's copies) is to have no result data associated with it.
Reimplemented in ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >, ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >, ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >, and ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >.
Definition at line 195 of file query.hpp.
References m_sharedData.
Referenced by ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >::relinquishResults(), ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >::relinquishResults(), ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >::relinquishResults(), and ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >::relinquishResults().
|
inline |
Resets the object as though it was destroyed and reconstructed anew.
Definition at line 318 of file query.hpp.
References FLAG_ORIGINAL, keepAlive(), m_flags, and m_sharedData.
|
inlineprotected |
Return a void pointer to the result set.
Usually you would keep the original typed pointer around but if you lost it for some reason you can use this and cast it.
Reimplemented in ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >, ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >, ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >, and ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >.
Definition at line 214 of file query.hpp.
References m_sharedData.
Referenced by ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >::createResults(), ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >::createResults(), ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >::createResults(), ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >::createResults(), ASql::ConnectionPar< T >::intHandler(), ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >::results(), ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >::results(), ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >::results(), ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >::results(), and setResults().
|
inlineprotected |
Return a const void pointer to the result set.
Usually you would keep the original typed pointer around but if you lost it for some reason you can use this and cast it.
Reimplemented in ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >, ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >, ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >, and ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >.
Definition at line 221 of file query.hpp.
References m_sharedData.
|
inline |
Returns the rows affected/available from the query or 0 if nothing.
Note that if using for the number of rows from a query this will represent the number of rows available before a LIMIT.
Definition at line 260 of file query.hpp.
References m_sharedData.
|
inline |
Set the callback function to be called at the end of the query.
Note that this will be called even if there is an error or the query can cancelled.
Definition at line 275 of file query.hpp.
References callback(), and m_sharedData.
Referenced by ASql::ConnectionPar< T >::intHandler().
|
inlineprotected |
Set's the shared data to point to the passed pointer.
Note that the QueryPar class assumes responsibility for destroying the parameter set unless explicitly released with relinquishParameters().
[in] | parameters | A pointer to the parameter data |
Definition at line 183 of file query.hpp.
References m_sharedData, and parameters().
Referenced by ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >::createParameters(), ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >::createParameters(), ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, void >::createParameters(), ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Parameters > >::type, void >::createParameters(), ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >::setParameters(), ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >::setParameters(), ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, void >::setParameters(), and ASql::Query< Parameters, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Parameters > >::type, void >::setParameters().
|
inlineprotected |
Set's the shared data to point to the passed pointer.
Note that the QueryPar class assumes responsibility for destroying the result set unless explicitly released with relinquishResults().
[out] | results | A pointer to the result data |
Definition at line 174 of file query.hpp.
References m_sharedData, and results().
Referenced by ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >::createResults(), ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >::createResults(), ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >::createResults(), ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >::createResults(), ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >::setResults(), ASql::Query< Parameters, Results, typename boost::enable_if< boost::is_base_of< Data::Set, Parameters > >::type, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >::setResults(), ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::Set, Results > >::type >::setResults(), and ASql::Query< void, Results, void, typename boost::enable_if< boost::is_base_of< Data::SetContainer, Results > >::type >::setResults().
|
friend |
|
private |
Flags for individual query object.
FLAG_ORIGINAL: Set only if this query object was constructed with the default constructor. Never set if constructed from the copy constructor.
FLAG_KEEPALIVE: Set if the query should not be cancelled if the original object goes out of scope before the query is complete.
Definition at line 136 of file query.hpp.
Referenced by keepAlive(), reset(), and ~QueryPar().
|
private |
Shared pointer to query data.
Definition at line 127 of file query.hpp.
Referenced by busy(), callback(), cancel(), clearParameters(), clearResults(), enableInsertId(), enableRows(), error(), getCallback(), insertId(), ASql::ConnectionPar< T >::intHandler(), isCallback(), parameters(), QueryPar(), relinquishParameters(), relinquishResults(), reset(), results(), rows(), setCallback(), setParameters(), and setResults().