acl/lib_acl_cpp/app/ndb/ctl_server/db.h

128 lines
2.1 KiB
C
Raw Normal View History

#pragma once
class acl::locker;
class db_tbl;
class idx_host;
class database;
// <20><><EFBFBD><EFBFBD><EFBFBD>ֶε<D6B6><CEB5><EFBFBD><EFBFBD><EFBFBD>
typedef enum
{
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>
} idx_type_t;
/**
* <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
class db_idx
{
public:
/**
* <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>
*/
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:
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>
};
class db_tbl
{
public:
/**
* <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>
*/
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:
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>
};
class database
{
public:
/**
* <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>
*/
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:
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>
acl::locker* lock_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>
};