2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma once
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
class acl::locker;
|
|
|
|
|
class db_tbl;
|
|
|
|
|
class idx_host;
|
|
|
|
|
class database;
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ֶε<D6B6><CEB5><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2019-07-28 10:31:56 +08:00
|
|
|
|
IDX_TYPE_STR = 0, // <20>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
IDX_TYPE_BOOL, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
IDX_TYPE_INT16, // 16λ<36><CEBB><EFBFBD><EFBFBD>
|
|
|
|
|
IDX_TYPE_INT32, // 32λ<32><CEBB><EFBFBD><EFBFBD>
|
|
|
|
|
IDX_TYPE_INT64 // 64λ<34><CEBB><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
} idx_type_t;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
class db_idx
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD>
|
|
|
|
|
* @param tbl {db_tbl*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param name {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param id {unsigned int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>ID<EFBFBD><EFBFBD>
|
|
|
|
|
* @param type {idx_type_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶε<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
db_idx(db_tbl* tbl, const char* name, unsigned int id, idx_type_t type);
|
|
|
|
|
~db_idx();
|
|
|
|
|
|
|
|
|
|
const char* get_name() const
|
|
|
|
|
{
|
|
|
|
|
return name_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned int get_id() const
|
|
|
|
|
{
|
|
|
|
|
return id_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
db_tbl* get_tbl() const
|
|
|
|
|
{
|
|
|
|
|
return tbl_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
idx_type_t get_type() const
|
|
|
|
|
{
|
|
|
|
|
return type_;
|
|
|
|
|
}
|
|
|
|
|
protected:
|
|
|
|
|
private:
|
2019-07-28 10:31:56 +08:00
|
|
|
|
db_tbl* tbl_; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
char* name_; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
unsigned int id_; // <20><><EFBFBD><EFBFBD>ID<49><44>
|
|
|
|
|
idx_type_t type_; // <20><><EFBFBD><EFBFBD><EFBFBD>ֶε<D6B6><CEB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class db_tbl
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD>
|
|
|
|
|
* @param db {database*} <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param name {const char*} <EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param id {unsigned int} <EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>ID<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
db_tbl(database* db, const char* name, unsigned int id);
|
|
|
|
|
~db_tbl();
|
|
|
|
|
|
|
|
|
|
const char* get_name() const
|
|
|
|
|
{
|
|
|
|
|
return name_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned int get_id() const
|
|
|
|
|
{
|
|
|
|
|
return id_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
database* get_db() const
|
|
|
|
|
{
|
|
|
|
|
return db_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void add_idx(db_idx* idx);
|
|
|
|
|
private:
|
2019-07-28 10:31:56 +08:00
|
|
|
|
database* db_; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
char* name_; // <20><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>
|
|
|
|
|
unsigned int id_; // <20><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>ID<49><44>
|
|
|
|
|
std::list<db_idx*> idxes_; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class database
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD>
|
|
|
|
|
* @param name {const char*} <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param id {unsigned int} <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>ID<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
database(const char* name, unsigned int id);
|
|
|
|
|
~database();
|
|
|
|
|
|
|
|
|
|
const char* get_name() const
|
|
|
|
|
{
|
|
|
|
|
return name_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned int get_id() const
|
|
|
|
|
{
|
|
|
|
|
return id_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void add_tbl(db_tbl*);
|
|
|
|
|
void add_idx_host(idx_host* host);
|
|
|
|
|
protected:
|
|
|
|
|
private:
|
2019-07-28 10:31:56 +08:00
|
|
|
|
char* name_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>
|
|
|
|
|
unsigned int id_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>ID<49><44>
|
|
|
|
|
std::map<std::string, db_tbl*> tables_; // <20><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
std::vector<idx_host*> idx_hosts_; // <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
acl::locker* lock_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
};
|