extensions/clientprefs/query.h
author David Anderson <dvander@alliedmods.net>
Sun Jul 06 04:49:55 2008 +0000 (2008-07-06)
branchrefac-jit
changeset 2168 c24a6fa957db
permissions -rw-r--r--
jit refactoring branch
dvander@2168
     1
/**
dvander@2168
     2
 * vim: set ts=4 :
dvander@2168
     3
 * =============================================================================
dvander@2168
     4
 * SourceMod Client Preferences Extension
dvander@2168
     5
 * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
dvander@2168
     6
 * =============================================================================
dvander@2168
     7
 *
dvander@2168
     8
 * This program is free software; you can redistribute it and/or modify it under
dvander@2168
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
dvander@2168
    10
 * Free Software Foundation.
dvander@2168
    11
 * 
dvander@2168
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
dvander@2168
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
dvander@2168
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
dvander@2168
    15
 * details.
dvander@2168
    16
 *
dvander@2168
    17
 * You should have received a copy of the GNU General Public License along with
dvander@2168
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
dvander@2168
    19
 *
dvander@2168
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
dvander@2168
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
dvander@2168
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
dvander@2168
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
dvander@2168
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
dvander@2168
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
dvander@2168
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
dvander@2168
    27
 * or <http://www.sourcemod.net/license.php>.
dvander@2168
    28
 *
dvander@2168
    29
 * Version: $Id$
dvander@2168
    30
 */
dvander@2168
    31
dvander@2168
    32
#ifndef _INCLUDE_SOURCEMOD_CLIENTPREFS_QUERY_H_
dvander@2168
    33
#define _INCLUDE_SOURCEMOD_CLIENTPREFS_QUERY_H_
dvander@2168
    34
dvander@2168
    35
#include "extension.h"
dvander@2168
    36
#include "cookie.h"
dvander@2168
    37
#include "sh_string.h"
dvander@2168
    38
dvander@2168
    39
enum querytype
dvander@2168
    40
{
dvander@2168
    41
	Query_InsertCookie = 0,
dvander@2168
    42
	Query_SelectData,
dvander@2168
    43
	Query_InsertData,
dvander@2168
    44
	Query_SelectId,
dvander@2168
    45
	Query_CreateTable,
dvander@2168
    46
};
dvander@2168
    47
dvander@2168
    48
class TQueryOp : public IDBThreadOperation
dvander@2168
    49
{
dvander@2168
    50
public:
dvander@2168
    51
	TQueryOp(IDatabase *db, const char *query, enum querytype type, int client);
dvander@2168
    52
	TQueryOp(IDatabase *db, const char *query, enum querytype type, Cookie *cookie);
dvander@2168
    53
	~TQueryOp() {}
dvander@2168
    54
dvander@2168
    55
	IDBDriver *GetDriver();
dvander@2168
    56
	IdentityToken_t *GetOwner();
dvander@2168
    57
dvander@2168
    58
	void Destroy();
dvander@2168
    59
dvander@2168
    60
	void RunThreadPart();
dvander@2168
    61
	/* Thread has been cancelled due to driver unloading. Nothing else to do? */
dvander@2168
    62
	void CancelThinkPart()
dvander@2168
    63
	{
dvander@2168
    64
	}
dvander@2168
    65
	void RunThinkPart();
dvander@2168
    66
dvander@2168
    67
private:
dvander@2168
    68
	IDatabase *m_pDatabase;
dvander@2168
    69
	IQuery *m_pQuery;
dvander@2168
    70
	SourceHook::String m_Query;
dvander@2168
    71
	char error[255];
dvander@2168
    72
	enum querytype m_type;
dvander@2168
    73
	int m_client;
dvander@2168
    74
	int m_insertId;
dvander@2168
    75
	Cookie *pCookie;
dvander@2168
    76
};
dvander@2168
    77
dvander@2168
    78
dvander@2168
    79
#endif // _INCLUDE_SOURCEMOD_CLIENTPREFS_QUERY_H_