[Issue #2 ] 南瑞郭海龙交接最终版2.0

1.由于郭海龙修改了提供的库,导致增加了大量南瑞的头文件,
  所以新建include目录用于存放所有的南瑞提供的同文件。

2. 修复sys_nicmonitor进程重启后,调用接口告警问题。

3. 增加USER_NUSP宏,用于nusp用户。

4. 由于新增了许多头文件且需交接给郭海龙,所以独立了一版2.0版本以用于区分。

	修改:     code/README
	新文件:   code/dep/42/dotconf#1.0.13-1.pkg.tar.gz
	新文件:   code/dep/42/run.sh
	新文件:   code/dep/90/libdotconf-dev_1.3-0.2_amd64.deb
	新文件:   code/dep/90/libdotconf-dev_1.3-0.2_arm64.deb
	新文件:   code/dep/90/libdotconf0_1.3-0.2_amd64.deb
	新文件:   code/dep/90/libdotconf0_1.3-0.2_arm64.deb
	新文件:   code/dep/90/run.sh
	新文件:   code/dep/libproc_common.so
	新文件:   code/dep/old/libman.so
	新文件:   code/dep/proc_common.cpp
	新文件:   code/sys_nicmonitor-code.tar.gz
	修改:     code/sys_nicmonitor/Makefile
	修改:     code/sys_nicmonitor/README
	新文件:   code/sys_nicmonitor/include/common_types.h
	新文件:   code/sys_nicmonitor/include/d5000_err.h
	新文件:   code/sys_nicmonitor/include/db_api/DeleteRecorder.h
	新文件:   code/sys_nicmonitor/include/db_api/codb_net.h
	新文件:   code/sys_nicmonitor/include/db_api/mc_rtdb_m.h
	新文件:   code/sys_nicmonitor/include/db_api/mc_rtdb_mng.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_apinet.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_apinet_rtdb_key.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_apiop.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_apiop.h.old
	新文件:   code/sys_nicmonitor/include/db_api/odb_app2id.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_autolock.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_baseindex.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_ckeymanager.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_common.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_define.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_double_overflow_hashindex.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_field.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_hashindex.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_hashpk.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_intel_ptr.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_lock.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_net.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_net_m.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_netfactory.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_nooverflow_pk.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_orbmgr.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_profile.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_prv_struct.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_public.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_rtdbbase.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_rtdbfactory.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_rtdbop.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_rtdbtable.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_struct.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_system.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_table.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_tablebase.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_tablemgr.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_tablenet.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_tableop.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_where.h
	新文件:   code/sys_nicmonitor/include/db_api/pub_buf.h
	新文件:   code/sys_nicmonitor/include/db_api/rtdb_graph_name_list.h
	新文件:   code/sys_nicmonitor/include/db_api/server2proto.h
	新文件:   code/sys_nicmonitor/include/db_api/tab2idx.h
	新文件:   code/sys_nicmonitor/include/db_api/vl_get_data.h
	新文件:   code/sys_nicmonitor/include/db_api/vl_struct.h
	新文件:   code/sys_nicmonitor/include/db_api/vl_struct_m.cpp
	新文件:   code/sys_nicmonitor/include/db_api/vl_struct_m.h
	新文件:   code/sys_nicmonitor/include/db_com/CAppNo.h
	新文件:   code/sys_nicmonitor/include/db_com/CCharArray.h
	新文件:   code/sys_nicmonitor/include/db_com/CDataStream.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbCommitClient.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbMonitorClient.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbMonitorLocal.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbMonitorShm.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbRepSet.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbSem.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbSemUse.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbShm.h
	新文件:   code/sys_nicmonitor/include/db_com/CDyCfgLocal.h
	新文件:   code/sys_nicmonitor/include/db_com/CDyCommitClient.h
	新文件:   code/sys_nicmonitor/include/db_com/CDyMonitorClient.h
	新文件:   code/sys_nicmonitor/include/db_com/CDyMonitorLocal.h
	新文件:   code/sys_nicmonitor/include/db_com/CDyMonitorShm.h
	新文件:   code/sys_nicmonitor/include/db_com/CDySem.h
	新文件:   code/sys_nicmonitor/include/db_com/CDySemUse.h
	新文件:   code/sys_nicmonitor/include/db_com/CDyShm.h
	新文件:   code/sys_nicmonitor/include/db_com/CDyTagShmInfo.h
	新文件:   code/sys_nicmonitor/include/db_com/CErrorLog.h
	新文件:   code/sys_nicmonitor/include/db_com/CFindFile.h
	新文件:   code/sys_nicmonitor/include/db_com/CPrecTime.h
	新文件:   code/sys_nicmonitor/include/db_com/CRecordSet.h
	新文件:   code/sys_nicmonitor/include/db_com/CRedisAccess.h
	新文件:   code/sys_nicmonitor/include/db_com/CRepSet.h
	新文件:   code/sys_nicmonitor/include/db_com/CSaveReCommitSql.h
	新文件:   code/sys_nicmonitor/include/db_com/CSqlResultAlign.h
	新文件:   code/sys_nicmonitor/include/db_com/CSqlResultAlignClient.h
	新文件:   code/sys_nicmonitor/include/db_com/CSqlResultAlignClient2.h
	新文件:   code/sys_nicmonitor/include/db_com/DBAccess.h
	新文件:   code/sys_nicmonitor/include/db_com/DBCipher.h
	新文件:   code/sys_nicmonitor/include/db_com/DBConnectPool.h
	新文件:   code/sys_nicmonitor/include/db_com/DbFileNetIf.h
	新文件:   code/sys_nicmonitor/include/db_com/Hbase.h
	新文件:   code/sys_nicmonitor/include/db_com/Hbase_constants.h
	新文件:   code/sys_nicmonitor/include/db_com/Hbase_types.h
	新文件:   code/sys_nicmonitor/include/db_com/MyMutex.h
	新文件:   code/sys_nicmonitor/include/db_com/cross_region_sync_client.h
	新文件:   code/sys_nicmonitor/include/db_com/database_rep_m.h
	新文件:   code/sys_nicmonitor/include/db_com/db_commit_define.h
	新文件:   code/sys_nicmonitor/include/db_com/db_commit_m.h
	新文件:   code/sys_nicmonitor/include/db_com/db_error_define.h
	新文件:   code/sys_nicmonitor/include/db_com/db_extern.h
	新文件:   code/sys_nicmonitor/include/db_com/db_global.h
	新文件:   code/sys_nicmonitor/include/db_com/db_micro_define.h
	新文件:   code/sys_nicmonitor/include/db_com/db_monitor_define.h
	新文件:   code/sys_nicmonitor/include/db_com/db_monitor_define.h.old
	新文件:   code/sys_nicmonitor/include/db_com/db_monitor_extern.h
	新文件:   code/sys_nicmonitor/include/db_com/db_monitor_global.h
	新文件:   code/sys_nicmonitor/include/db_com/db_monitor_m.h
	新文件:   code/sys_nicmonitor/include/db_com/db_monitor_m.h.old
	新文件:   code/sys_nicmonitor/include/db_com/db_rep_lib_define.h
	新文件:   code/sys_nicmonitor/include/db_com/db_stat_m.h
	新文件:   code/sys_nicmonitor/include/db_com/db_stat_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/ds_log.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_commit_m.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_monitor_define.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_monitor_m.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_public_m.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_sample_define_m.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_sample_define_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_stat_m.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_stat_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/hiredis.h
	新文件:   code/sys_nicmonitor/include/db_com/interpreter_define.h
	新文件:   code/sys_nicmonitor/include/db_com/interpreter_struct.h
	新文件:   code/sys_nicmonitor/include/db_com/lexical_anls.h
	新文件:   code/sys_nicmonitor/include/db_com/public_m.h
	新文件:   code/sys_nicmonitor/include/db_com/query_sample_m.h
	新文件:   code/sys_nicmonitor/include/db_com/query_sample_pi.h
	新文件:   code/sys_nicmonitor/include/db_com/query_sample_pi_m.h
	新文件:   code/sys_nicmonitor/include/db_com/query_sample_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/query_sample_service_pi_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/query_stat_m.h
	新文件:   code/sys_nicmonitor/include/db_com/query_stat_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/rdb_commit_client.h
	新文件:   code/sys_nicmonitor/include/db_com/rdb_commit_m.h
	新文件:   code/sys_nicmonitor/include/db_com/rdb_define.pb.h
	新文件:   code/sys_nicmonitor/include/db_com/read.h
	新文件:   code/sys_nicmonitor/include/db_com/rtdbkey_defs.h
	新文件:   code/sys_nicmonitor/include/db_com/sample_data_client_base.h
	新文件:   code/sys_nicmonitor/include/db_com/sample_data_m.h
	新文件:   code/sys_nicmonitor/include/db_com/sample_define_m.h
	新文件:   code/sys_nicmonitor/include/db_com/sample_define_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/sample_modify_m.h
	新文件:   code/sys_nicmonitor/include/db_com/sample_modify_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/sds.h
	新文件:   code/sys_nicmonitor/include/db_com/server_define.h
	新文件:   code/sys_nicmonitor/include/db_com/sheetdataclient.h
	新文件:   code/sys_nicmonitor/include/db_com/sheetdataclient.h0604
	新文件:   code/sys_nicmonitor/include/db_com/sql_sp_client_base.h
	新文件:   code/sys_nicmonitor/include/db_com/sql_sp_define.h
	新文件:   code/sys_nicmonitor/include/db_com/sql_sp_m.h
	新文件:   code/sys_nicmonitor/include/db_com/sql_sp_send_client_base.h
	新文件:   code/sys_nicmonitor/include/db_com/sql_syntax_anls.h
	新文件:   code/sys_nicmonitor/include/db_com/sql_to_cime.h
	新文件:   code/sys_nicmonitor/include/db_com/sqlite_access.h
	新文件:   code/sys_nicmonitor/include/db_com/sqlite_server_client.h
	新文件:   code/sys_nicmonitor/include/db_com/sqlite_srv_m.h
	新文件:   code/sys_nicmonitor/include/db_com/store_access_client.h
	新文件:   code/sys_nicmonitor/include/db_com/trigger_sample_m.h
	新文件:   code/sys_nicmonitor/include/db_com/trigger_sample_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/wholepubtools.h
	新文件:   code/sys_nicmonitor/include/db_com/wholesampledata.h
	新文件:   code/sys_nicmonitor/include/db_com/wholesqlsp.h
	新文件:   code/sys_nicmonitor/include/log_api.h
	新文件:   code/sys_nicmonitor/include/log_define.h
	新文件:   code/sys_nicmonitor/include/logclient.h
	新文件:   code/sys_nicmonitor/include/port_def.h
	新文件:   code/sys_nicmonitor/include/proc_common.h
	新文件:   code/sys_nicmonitor/include/scn_common.h
	新文件:   code/sys_nicmonitor/include/sysadm/proc_define.h
	新文件:   code/sys_nicmonitor/include/sysadm/scn_define.h
	新文件:   code/sys_nicmonitor/include/system.h
	修改:     code/sys_nicmonitor/mnic.c
	修改:     code/sys_nicmonitor/nicinfo_shm.c
	修改:     code/sys_nicmonitor/test.c
	修改:     code/sys_nicmonitor/version.h
	新文件:   code/test/test_nic
	新文件:   code/test/test_nic.cpp
	新文件:   packages/sys_nicmonitor-2.0-linx90-aarch64-bin-d5000.tar.gz
	新文件:   packages/sys_nicmonitor-2.0-linx90-aarch64-bin-nusp.tar.gz
	新文件:   packages/sys_nicmonitor-2.0-linx90-x86_64-bin-d5000.tar.gz
	新文件:   packages/sys_nicmonitor-2.0-linx90-x86_64-bin-nusp.tar.gz
	重命名:   sys_nicmonitor-arm-bin.tar.gz -> packages/sys_nicmonitor-arm-bin.tar.gz
	重命名:   sys_nicmonitor-arm.tar.gz -> packages/sys_nicmonitor-arm.tar.gz
	新文件:   packages/sys_nicmonitor-mips64-bin.tar.gz
	新文件:   packages/sys_nicmonitor-mips64.tar.gz

Signed-off-by: Wei, Jing <jwei@linx-info.com>
This commit is contained in:
Wei, Jing
2020-10-22 19:15:38 +08:00
parent 78444a27f8
commit 5c462e7adb
193 changed files with 38570 additions and 243 deletions

View File

@@ -0,0 +1,102 @@
// insert into the odb_table.cpp
#include "common_types.h"
#ifndef _WINDOWS64
#ifndef _HPUX
#include <pthread.h>
#else
#include <sys/pthread.h>
#endif
#include <sys/sem.h>
#include <sys/ipc.h>
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#else
#include <WinSock2.h>
#include <windows.h>
#include <direct.h>
#include <io.h>
#include <process.h>
#include <time.h>
#include <sys/timeb.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include "ThreadKit/ThreadKit.h"
#ifdef _WINDOWS64
#ifdef ODB_API_LIB_EXPORTS
#define ODB_API_LIB_API __declspec(dllexport)
#else
#define ODB_API_LIB_API __declspec(dllimport)
#endif
#else
#define ODB_API_LIB_API
#endif
#define LOGLOCK 0x10999
#define FILEMAXSIZE 30000000
#define BIGSIZE 90000000
#define FRESH (int)'6'
#define NOTFRESH (int)'A'
class ODB_API_LIB_API DeleteRecorder
{
private:
FILE* _m_file_handle;
int _m_file_size;
int _m_status;
char processName[256];
char fileName[256];
cmnUint64 processID;
int lockID;
time_t fileTag;
static DeleteRecorder * _m_instance;
#ifndef _WINDOWS64
static pthread_mutex_t _m_lock;
#else
// static CRITICAL_SECTION _m_lock;
static THREADKIT::Mutex _m_lock;
#endif
DeleteRecorder(const DeleteRecorder &);
void operator = (const DeleteRecorder &);
int initLock();
int lockLog();
int unlockLog();
int initLog();
int checkAndRenameLog();
int getNameFromPid();
public:
static DeleteRecorder * getInstance();
DeleteRecorder();
~DeleteRecorder();
int openLog();
int writeLog(int app, int tab, cmnInt64 logContent);
// int renameLog();
int isValid();
};
void WriteLog(int,int,cmnInt64);

View File

@@ -0,0 +1,175 @@
#ifndef __CODB_NET_H__
#define __CODB_NET_H__
#include "db_api/odb_net_m.h"
#include "db_api/odb_define.h"
#ifndef _WINDOWS64
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#endif
#include "servicemanage.h"
#ifdef _WINDOWS64
#ifdef ODB_API_LIB_EXPORTS
#define ODB_API_LIB_API __declspec(dllexport)
#else
#define ODB_API_LIB_API __declspec(dllimport)
#endif
#else
#define ODB_API_LIB_API
#endif
namespace RTDB_SERVER
{
template<class T>
bool serializeProto(const T & message, char * &pret, int & retlen)
{
std::string output;
if (!message.SerializeToString(&output)) {
return false;
}
retlen = output.size();
pret = new char[retlen];
memcpy(pret, output.c_str(), retlen);
return true;
}
template<class T>
bool parseProto(T & ret_message, const char * buf, int len)
{
if (!ret_message.ParseFromArray(buf, len)) {
return false;
}
return true;
}
class ODB_API_LIB_API CODB_NET
{
public:
CODB_NET();
~CODB_NET();
public:
int TableCreate(RTDB_PROTO::REQ_STDB_CREATE& req_create);//1
int TableDelete(RTDB_PROTO::REQ_STDB_DELETE& req_delete);//2
int TableGet(RTDB_PROTO::REQ_READ& read_req, RTDB_PROTO::RSP_READ& read_rsp);//3
int TableGet(RTDB_PROTO::REQ_READ_OLD& read_req, RTDB_PROTO::RSP_READ& read_rsp);//3 for remote
int TableGet(RTDB_PROTO::REQ_READ& read_req, RTDB_PROTO::RSP_READ& read_rsp, DB_BYTE_T& remote_byte);//3
int TableGet(RTDB_PROTO::REQ_READ_OLD& read_req, RTDB_PROTO::RSP_READ& read_rsp, DB_BYTE_T& remote_byte);//3 for remote
int TableGetASync(RTDB_PROTO::REQ_READ& read_req);
int TableGet_OPT(RTDB_PROTO::REQ_READ& read_req, char** buf_ptr, int& data_size);//40
int TableGet_OPT(RTDB_PROTO::REQ_READ_OLD& read_req, char** buf_ptr, int& data_size);//40 for remote
int TableGet_OPT(RTDB_PROTO::REQ_READ& read_req, char** buf_ptr, int& data_size, DB_BYTE_T& remote_byte);//40
int TableGet_OPT(RTDB_PROTO::REQ_READ_OLD& read_req, char** buf_ptr, int& data_size, DB_BYTE_T& remote_byte);//40 for remote
int TableGet_OPTASync(RTDB_PROTO::REQ_READ& read_req);//40
int TableGetByName(RTDB_PROTO::REQ_READ& read_req, RTDB_PROTO::RSP_READ& read_rsp);//4
int TableGetByName(RTDB_PROTO::REQ_READ_OLD& read_req, RTDB_PROTO::RSP_READ& read_rsp);//4 for remote
int TableGetByNameASync(RTDB_PROTO::REQ_READ& read_req);//4
int TableGetByName_OPT(RTDB_PROTO::REQ_READ& read_req, char** buf_ptr, int& data_size, DB_BYTE_T& remote_byte);//41
int TableGetByName_OPT(RTDB_PROTO::REQ_READ_OLD& read_req, char** buf_ptr, int& data_size, DB_BYTE_T& remote_byte);//41
int TableGetByName_OPTASync(RTDB_PROTO::REQ_READ& read_req);//41
int TableGetByFieldValue(RTDB_PROTO::REQ_CON& read_req, RTDB_PROTO::RSP_CON& read_rsp);//5
int TableGetByFieldValueASync(RTDB_PROTO::REQ_CON& read_req);//5
int TableWrite(RTDB_PROTO::REQ_KEY_WRITE& write_req);//6
int TableWriteASync(RTDB_PROTO::REQ_KEY_WRITE& write_req);//6
int TableModify(RTDB_PROTO::REQ_MODIFY& modify_req);//7
int TableModifyASync(RTDB_PROTO::REQ_MODIFY& modify_req);//7
int TableUpdate(RTDB_PROTO::REQ_UPDATE& update_req);//8
int TableUpdateASync(RTDB_PROTO::REQ_UPDATE& update_req);//8
int DeleteRecord(RTDB_PROTO::REQ_KEY_ERASE& delete_req);//9
int DeleteRecordASync(RTDB_PROTO::REQ_KEY_ERASE& delete_req);//9
int TableClear(RTDB_PROTO::REQ_TABLE_CLEAR& clear_req);//10
int TableClearASync(RTDB_PROTO::REQ_TABLE_CLEAR& clear_req);//10
int GetTablePara(RTDB_PROTO::REQ_PARAMETER& para_req, RTDB_PROTO::RSP_PARAMETER& para_rsp);//11
int GetTableParaASync(RTDB_PROTO::REQ_PARAMETER& para_req);//11
#ifdef _APP_SYS_SUBSTATION
int GetTableParaAll(RTDB_PROTO::REQ_PARAMETER& para_req, RTDB_PROTO::RSP_PARAMETER& para_rsp);//35
int TableGetAll(RTDB_PROTO::REQ_READ& read_req, RTDB_PROTO::RSP_READ& read_rsp);//36
int GetTableParaVir(RTDB_PROTO::REQ_VIR_FIELD& para_req, RTDB_PROTO::RSP_VIR_FIELD& para_rsp);//37
#endif
int GetTableParameter(RTDB_PROTO::REQ_PARAMETER& para_req, RTDB_PROTO::RSP_READ& para_rsp);//12
int GetAppTableParameter(RTDB_PROTO::REQ_APP_PARAMETER& para_req, RTDB_PROTO::RSP_APP_PARAMETER& para_rsp);//13
int GetFieldPara(RTDB_PROTO::REQ_FIELD_BASE_INFO& para_req , RTDB_PROTO::RSP_FIELD_BASE_INFO& para_rsp);//14
int GetKeyInfo(RTDB_PROTO::RSP_KEYINFO& key_rsp);//15
int GetKeyInfoSlice(RTDB_PROTO::RSP_KEYINFO_SLICE& key_rsp);//15
int TableGetBySql(RTDB_PROTO::REQ_SQL& select_req, RTDB_PROTO::RSP_READ& select_rsp);//16
int TableGetBySqlASync(RTDB_PROTO::REQ_SQL& select_req);//16
int MenuRead(RTDB_PROTO::REQ_MENU& menu_req, RTDB_PROTO::RSP_MENU& menu_rsp);//17
int TableReleMenuRead(RTDB_PROTO::REQ_RELE_MENU& rele_req, RTDB_PROTO::RSP_RELE_MENU& rele_rsp);//18
int GetNameStringByKeyID(RTDB_PROTO::REQ_NAME_STRING& name_req, RTDB_PROTO::RSP_NAME_STRING& name_rsp);//19
int GetNameStringByKeyIDASync(RTDB_PROTO::REQ_NAME_STRING& name_req);//19
int GetRefMenuString(RTDB_PROTO::REQ_REF_MENU& ref_req, RTDB_PROTO::RSP_REF_MENU& ref_rsp);//20
int GetRefMenuStringAsync(RTDB_PROTO::REQ_REF_MENU& ref_req);//20
int GetNameStringByMultiKeyID(RTDB_PROTO::REQ_MULTI_NAME_STRING& name_req, RTDB_PROTO::RSP_MULTI_NAME_STRING& name_rsp);//21
int GetNameStringByMultiKeyIDASync(RTDB_PROTO::REQ_MULTI_NAME_STRING& name_req);//21
int GraphGetData(RTDB_PROTO::GRAPH_REAL_ODB_REQ& real_req, RTDB_PROTO::GRAPH_REAL_RSP& real_rsp);//22
int GraphGetData(RTDB_PROTO::GRAPH_REAL_ODB_REQ_OLD& real_req, RTDB_PROTO::GRAPH_REAL_RSP& real_rsp);//22
int GraphGetDataASync(RTDB_PROTO::GRAPH_REAL_ODB_REQ& real_req);
int GraphGetAppInfo(RTDB_PROTO::GRAPH_ORDER_KEY_REQ& app_req, RTDB_PROTO::GRAPH_ORDER_KEY_RSP& app_rsp);//23
int GraphGetAppInfoASync(RTDB_PROTO::GRAPH_ORDER_KEY_REQ& app_req);//23
int ExchangeNameNo(RTDB_PROTO::REQ_ENTITY& object_req, RTDB_PROTO::RSP_ENTITY& object_rsp);//24
int GetFacNameByKeyNo(RTDB_PROTO::REQ_FAC& fac_req, RTDB_PROTO::RSP_FAC& fac_rsp);//25
int GetFacNameByFacID(RTDB_PROTO::REQ_FAC& fac_req, RTDB_PROTO::RSP_FAC& fac_rsp);//26
int GetFacNameByFacNo(RTDB_PROTO::REQ_FAC& fac_req, RTDB_PROTO::RSP_FAC& fac_rsp);//27
int GetFacIDByFacName(RTDB_PROTO::REQ_FAC& fac_req, RTDB_PROTO::RSP_FAC& fac_rsp);//28
int GetFacNoByFacName(RTDB_PROTO::REQ_FAC& fac_req, RTDB_PROTO::RSP_FAC& fac_rsp);//29
int GetFacIDByFacNo(RTDB_PROTO::REQ_FAC& fac_req, RTDB_PROTO::RSP_FAC& fac_rsp);//30
int GetFacNoByFacID(RTDB_PROTO::REQ_FAC& fac_req, RTDB_PROTO::RSP_FAC& fac_rsp);//31
int GetValueAndStatus(RTDB_PROTO::REQ_VAL_STA& req_key_id, RTDB_PROTO::RSP_INT_VAL_STA* rsp_int_val, RTDB_PROTO::RSP_FLOAT_VAL_STA* rsp_float_val, RTDB_PROTO::RSP_CHAR_VAL_STA* rsp_char_val, RTDB_PROTO::RSP_LONG_VAL_STA* rsp_long_val, RTDB_PROTO::RSP_UNION_VAL_STA* rsp_union_val);//32
int GetValueAndStatus(RTDB_PROTO::REQ_VAL_STA_OLD& req_key_id, RTDB_PROTO::RSP_INT_VAL_STA* rsp_int_val, RTDB_PROTO::RSP_FLOAT_VAL_STA* rsp_float_val, RTDB_PROTO::RSP_CHAR_VAL_STA* rsp_char_val, RTDB_PROTO::RSP_LONG_VAL_STA* rsp_long_val, RTDB_PROTO::RSP_UNION_VAL_STA* rsp_union_val);//32
int GetValueAndStatusASync(RTDB_PROTO::REQ_VAL_STA& req_key_id);//32
int GetValueAndStatus_YCOPT (RTDB_PROTO::REQ_VAL_STA& req_key_id,
std::vector<float> & vec_val, std::vector<int> & vec_status);//42
int GetValueAndStatus_YXOPT (RTDB_PROTO::REQ_VAL_STA& req_key_id,
std::vector<unsigned char> & vec_val, std::vector<int> & vec_status);//43
int PingRtdbServer(int req_data , int& rsp_data);//33
int GraphDataSend(RTDB_PROTO::GRAPH_REAL_ODB_REQ &real_req,Handle &hdl) ;//22
int GraphDataRecv(RTDB_PROTO::GRAPH_REAL_RSP &real_rsp,Handle &hdl,int &ret);
int DeleteRecords(RTDB_PROTO::DEL_REQ& delete_req);//34
int DeleteRecordsASync(RTDB_PROTO::DEL_REQ& delete_req);//34
int ReadAsyncRsp(char** rsp_buffer, int* rsp_len, int& ret_code, DB_BYTE_T& remote_byte);
int ReadAsyncRsp(char** rsp_buffer, int* rsp_len, int& ret_code);
int ReadAsyncRsp(int& ret_code);
int ReadAsyncRsp(RTDB_PROTO::RSP_INT_VAL_STA* rsp_int_val, RTDB_PROTO::RSP_FLOAT_VAL_STA* rsp_float_val, RTDB_PROTO::RSP_CHAR_VAL_STA* rsp_char_val, RTDB_PROTO::RSP_LONG_VAL_STA* rsp_long_val, RTDB_PROTO::RSP_UNION_VAL_STA* rsp_union_val);//32
int ReadAsyncRespGraphGetData(RTDB_PROTO::GRAPH_REAL_RSP& real_rsp, int& ret_code);
void FreeAsyncHandle();
#ifdef _APP_SYS_SUBSTATION
////add for xdb wuqx ----- 2012-07-11
int XdbAccess(RTDB_PROTO::REQ_XDB& req, RTDB_PROTO::RSP_XDB& rsp);
#endif
public:
int SetServiceInfo(ServiceInfo& service_info);
int SetDomainInfo(const DomainInfo* p_domain_info);
void SetHandle(const Handle handle);
void ClearHandle(const Handle handle);
static CODB_NET* _narrow(ServiceInfo& serv_info, DomainInfo* p_domain_info = NULL);
private:
ServiceInfo m_Serviceinfo;
DomainInfo* m_pDomaininfo;
char m_IpAddress[64];
int m_Port;
public:
Handle m_Handle;
Handle m_Handle_Async;
};
}
#endif

View File

@@ -0,0 +1,61 @@
//**************************************
// Generated by mcpp translator
// Version 1.3
//**************************************
#ifndef __MC_RTDB_M_H__
#define __MC_RTDB_M_H__
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
typedef MLang::VECTOR<char> MC_SEQ_CHAR;
typedef MLang::VECTOR<int> MC_SEQ_INT;
struct MC_SYNC_RT_DATA
{
int ctx_no;
int byte_tag;
MLang::STRING scn_name;
int scn_inst;
MLang::STRING subscn_name;
int subscn_inst;
int table_no;
int op_type;
int all_field_num;
int one_record_size;
int record_num;
int stage;
int stageall;
MLang::STRING stage_message;
MLang::STRING description;
int map_no;
int run_status;
int zipped;
int unzipped_length;
int zipped_length;
int reserve_para_1;
int reserve_para_2;
int reserve_para_3;
MC_SEQ_INT op_field;
MC_SEQ_CHAR key_buf;
MC_SEQ_CHAR op_buf;
MC_SYNC_RT_DATA();
MC_SYNC_RT_DATA(const MC_SYNC_RT_DATA&);
MC_SYNC_RT_DATA&operator=(const MC_SYNC_RT_DATA&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<MC_SYNC_RT_DATA> MC_SEQ_SYNC_RT_DATA;
struct MC_SYNC_RT_DATA_VEC
{
MC_SEQ_SYNC_RT_DATA sync_rt_data_vec;
MC_SYNC_RT_DATA_VEC();
MC_SYNC_RT_DATA_VEC(const MC_SYNC_RT_DATA_VEC&);
MC_SYNC_RT_DATA_VEC&operator=(const MC_SYNC_RT_DATA_VEC&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,125 @@
#ifndef _MC_RTDB_MNG_H_
#define _MC_RTDB_MNG_H_
#ifdef _WINDOWS64
#ifdef MC_RTDB_MNG_EXPORTS
#define MC_RTDB_MNG_API __declspec(dllexport)
#else
#define MC_RTDB_MNG_API __declspec(dllimport)
#endif
#else
#define MC_RTDB_MNG_API
#endif
#include <string>
#include <vector>
#include "pub_buf.h"
#include "db_api/mc_rtdb_m.h"
struct McScnInfo
{
std::string scn_name;
int scn_inst;
std::string subscn_name;
int subscn_inst;
};
struct TableColumnKey
{
//int app_no;
std::string scn_name;
int scn_inst;
std::string subscn_name;
int subscn_inst;
int table_no;
std::string column_name;
std::vector<struct RTDB_KEY_STRU> keys;
};
struct StageStruct
{
int stage;
char stage_message[512];
char description[1024];
int map_no;
int run_status;
};
class MC_RTDB_MNG_API McRtdbMng
{
public:
McRtdbMng();
~McRtdbMng();
//实时同步数据更新信息
//int SyncSnapShot(const int app_no, std::vector<struct TableColumnKey>& tck, const struct StageStruct stage_stru);
int SyncSnapShot(const struct McScnInfo& scninfo, std::vector<struct TableColumnKey>& tck, const struct StageStruct stage_stru);
//保存应用数据更新信息,数据文件存放在~/conf/mc_scn下{app_name}.dat
//int SaveSnapShot(const std::string app_name, int stage, const std::string description);
int SaveSnapShot(const struct McScnInfo& scninfo, int stage, const std::string& description);
//从数据文件恢复应用数据更新信息
//int RecoverSnapShot(const std::string app_name, int stage);
int RecoverSnapShot(const struct McScnInfo& scninfo, int stage);
//设置计算阶段状态信息
int SetStage(const struct McScnInfo& scninfo, const struct StageStruct stage_stru);
//读取计算阶段状态信息 (domain = NULL时读取本机否则读取指定机器)
//int ReadStage(int app_no, std::string& stage_message, std::string& description, int& map_no, int& run_status, char* domain = NULL);
int ReadStage(const struct McScnInfo& scninfo, std::string& stage_message, std::string& description, int& map_no, int& run_status, char* domain = NULL);
//读取计算的总阶段数作为返回值
//int ReadTotalStage(int app_no);
int ReadTotalStage(const struct McScnInfo& scninfo);
//设置计算的总阶段数
//int SetTotalStage(int app_no, int stageall);
int SetTotalStage(const struct McScnInfo& scninfo, int stageall);
//修改本机的RunStatus
//int SetRunStatus (int app_no, int run_status); //run_status值为0或1
int SetRunStatus(const struct McScnInfo& scninfo, int run_status); //run_status值为0或1
//仅在主机状态下使用修改本机的RunStatus并将其他中心的RunStatus值设为0
//int SetRunStatusSync(int app_no, int run_status);
int SetRunStatusSync(const struct McScnInfo& scninfo, int run_status);
int WriteSnapShotToStandBy (const char* recive_buf, const int buf_len);
private:
int read_tck_config(const struct McScnInfo& scninfo, std::vector<struct TableColumnKey>& tck);
int read_destination(const std::vector<struct MC_CLUSTER>& vec_cluster);
int read_data(const std::vector<struct TableColumnKey>& tck, CBuffer& buf, \
int stage = 0, char* stage_message = NULL, char* description = NULL, \
int map_no = 0, int run_status = 0, int stageall = 0);
//int SetStage(const struct McScnInfo& scninfo, const struct StageStruct stage_stru);
int SetTotalStageToStandBy(const struct McScnInfo& scninfo, int stageall);
int SetStageToStandBy(const struct McScnInfo& scninfo, const struct StageStruct stage_stru);
int get_local_name(char* local_name);
int SetStageSync(const struct McScnInfo& scninfo, int stage);
int SetMessageSync(const struct McScnInfo& scninfo, const std::string description);
//TEST
int ReadTotalStage_Conf(int app_no);
//TEST
int SetTotalStage_Conf(int app_no, int stageall);
};
#endif

View File

@@ -0,0 +1,269 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_apinet.h
DESCRIPTION: for class CTableNet of net access
FUNCTION LIST:
COMMENT: for net access
History:
Date Version Modifier Activities
2004-06-25 1.1 add context_no parameter
2003-01-09 1.0 modify
================================================================================
2003-01-09 1.0 created
*******************************************************************************/
#ifndef __ODB_APINET_h__
#define __ODB_APINET_h__
#ifndef __ODB_COMMON_H__
#include "db_api/odb_common.h"
#endif
#ifndef __ODB_TABLEBASE_H__
#include "db_api/odb_tablebase.h"
#endif
#ifndef __ODB_NETFACTORY_h__
#include "db_api/odb_netfactory.h"
#endif
#include "task_service.h"
#include "db_api/odb_net_m.h"
#include "db_api/codb_net.h"
#ifdef _WINDOWS64
#ifdef ODB_API_LIB_EXPORTS
#define ODB_API_LIB_API __declspec(dllexport)
#else
#define ODB_API_LIB_API __declspec(dllimport)
#endif
#else
#define ODB_API_LIB_API
#endif
using namespace std;
//using namespace RTDB_SERVER;
using namespace ODB;
namespace NET_ODB
{
//lmj add for GraphGetDataEx
typedef struct
{
cmnInt64 graph_id;
cmnInt64 cal_type;
cmnInt64 req_status; //-1,0<><30>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>,1(<28><><EFBFBD><EFBFBD>)
Handle hdl;
} TGraphReq;
typedef struct
{
std::string scn_name;
std::string subscn_name;
int type;
} TApiNetPriv;
class ODB_API_LIB_API CApiNet: public CTableBase
{
public:
CApiNet();
CApiNet(const int app_no, const short context_no = 0 );
CApiNet(const int app_no, const int table_no, const short context_no=0);
//CApiNet(const char *hostname);
~CApiNet();
public:
int SetAppNo(const int app_no, const short context_no = 0);
int SetScenario(const std::string& scenario_name,
int scenario_inst_no,
const std::string& sub_scenario_name,
int sub_scenario_inst_no);
int SetScenario(const int scenario_no,
const int scenario_inst_no,
const int sub_scenario_no,
const int sub_scenario_inst_no);
int SetAppNo(const std::string& scenario_name,
int scenario_inst_no,
const std::string& sub_scenario_name,
int sub_scenario_inst_no);
int Open(const std::string& scenario_name,
int scenario_inst_no,
const std::string& sub_scenario_name,
int sub_scenario_inst_no, int table_no);
int SetHostMode(const char* host_name);
int Open(const int table_no );
int Open(const int app_no, const int table_no, const short context_no=0);
//int Open(const char* hostname);
public:
int MenuRead(const char* menu_name, std::vector<struct MENU_INFO>& vec_menu, const int menu_status=MENU_ON);
int TableReleMenuRead(const int table_no, std::vector<struct MENU_RELEVANT>& vec_menu);
//int GetNameStringByKeyID(const KEY_ID_STRU& keyid_stru, string& ref_string);
//int GetNameStringByKeyIDSplit(const KEY_ID_STRU& keyid_stru, string& ref_string);
//int GetNameStringByKeyID(const std::vector<KEY_ID_STRU>& vec_keyid, std::vector<string>& vec_ref_string);
//int GetNameStringByKeyIDSplit(const std::vector<KEY_ID_STRU>& vec_keyid, std::vector<string>& vec_ref_string);
int GetRefMenuString(const int table_no, std::vector<struct MENU_STRING>& vec_menu);
int GetRefMenuStringSplit(const int table_no, std::vector<struct MENU_STRING>& vec_menu);
//jinjing 2017-01-17
int GetRefMenuStringMultiKeys(const int table_no, std::vector<RTDB_KEY_STRU>& vec_rtdbkeyid,
std::vector<struct MENU_STRING>& vec_menu);
//int GetNameStringByID(const cmnInt64 reference_id, string& ref_string);
//int GetNameStringByIDSplit(const long reference_id, string& ref_string);
//int GetNameStringByID(const std::vector<cmnInt64>& vec_refid, std::vector<std::string>& vec_ref_string);
//int GetNameStringByIDSplit(const std::vector<long>& vec_refid, std::vector<std::string>& vec_ref_string);
int GetNameStringBykey(const char* key_ptr, string& ref_string);
int GetNameStringBykeySplit(const char* key_ptr, string& ref_string);
int GetNameStringByAppKeyID( const std::vector<struct APP_KEY_STRU>& vec_appkeyid, std::vector<string>& vec_name_string);
int GetNameStringByAppID( const std::vector<APP_ID_STRU>& vec_appid, std::vector<string>& vec_name_string);
int GetNameStringByRtdbKeyID(const RTDB_KEY_STRU& rtdb_keyid_stru, string& ref_string);
int GetNameStringByRtdbKeyIDSplit(const RTDB_KEY_STRU& rtdb_keyid_stru, string& ref_string);
int GetNameStringByRtdbKeyID(const std::vector<RTDB_KEY_STRU>& vec_rtdbkeyid, std::vector<string>& vec_ref_string);
int GetNameStringByRtdbKeyIDSplit(const std::vector<RTDB_KEY_STRU>& vec_rtdbkeyid, std::vector<string>& vec_ref_string);
int GraphGetAppInfo(const struct ODB::GRAPH_ORDER_KEY_REQ& graph_req, struct ODB::GRAPH_ORDER_KEY_RSP& graph_rsp);
int GraphGetAppInfoSplit(const struct ODB::GRAPH_ORDER_KEY_REQ& graph_req, struct ODB::GRAPH_ORDER_KEY_RSP& graph_rsp);
int GraphGetData(const struct RTDB_SERVER::GRAPH_REAL_REQ& real_req , RTDB_SERVER::GRAPH_REAL_RSP& real_rsp);
int GraphGetDataSplit(const struct RTDB_PROTO::GRAPH_REAL_REQ& real_req , RTDB_SERVER::GRAPH_REAL_RSP& real_rsp);
int GraphGetDataSplitSimple(const struct RTDB_PROTO::GRAPH_REAL_REQ& real_req , RTDB_SERVER::GRAPH_REAL_RSP& real_rsp);
private:
int GraphGetData(const RTDB_PROTO::GRAPH_REAL_REQ& real_req, RTDB_SERVER::GRAPH_REAL_RSP& real_rsp);
void GraphRealReqConv(const RTDB_SERVER::GRAPH_REAL_REQ &real_req, RTDB_PROTO::GRAPH_REAL_REQ &real_req_inner);
void GraphRealRspConv(const RTDB_PROTO::GRAPH_REAL_RSP &real_rsp_inner, RTDB_SERVER::GRAPH_REAL_RSP &real_rsp);
//int GraphGetDataEx(const struct RTDB_SERVER::GRAPH_REAL_REQ& real_req , RTDB_SERVER::GRAPH_REAL_RSP_out real_rsp, bool is_req=true);
//int GraphDataRecv(const struct RTDB_SERVER::GRAPH_REAL_REQ& real_req , RTDB_SERVER::GRAPH_REAL_RSP_out real_rsp );
//int SqlGet(const char* str_sql, char** buf_ptr, int& buf_size);
public:
int GetFacNameByKeyNo(const int table_no, const char* key_ptr, string& ref_string);
int GetFacNameByFacID(char* fac_name, const RTDB_KEY_STRU fac_id);
int GetFacNameByFacNo(char* fac_name, const int fac_no);
int GetFacIDByFacName(RTDB_KEY_STRU& fac_id, const char* fac_name);
int GetFacNoByFacName(int& fac_no, const char* fac_name);
int GetFacIDByFacNo(RTDB_KEY_STRU& fac_id, const int fac_no);
int GetFacNoByFacID( int& fac_no, const RTDB_KEY_STRU fac_id);
int ColMeasType( const std::vector<RTDB_KEY_STRU> vec_keyid , std::vector<int>& vec_col_prop );
public:
int GetAppNameByNo(char* app_name, const int app_no) { return 0;}
int GetAppNoByName(int& app_no, const char* app_name) { return 0;}
int GetTableNameByNo(char* table_name, const int table_no, const bool is_eng=true) { return 0;}
int GetTableNoByName(int& table_no, const char* table_name, const bool is_eng=true) { return 0;}
int GetFieldNameByNo(char* field_name, const int field_no, const bool is_eng=true) { return 0;}
int GetFieldNoByName(int& field_no, const char* field_name, const bool is_eng=true) { return 0;}
public:
/*int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym
int GetValueAndStatusSplit(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym
int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc
int GetValueAndStatusSplit(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc
int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatusSplit(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
int GetValueAndStatusSplit(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct UNION_VALUE_STATUS> & KeyIdValVec );//union type
*/
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU > &staStruVec , std::vector< struct INT_VALUE_STATUS> & KeyIdValVec);//ym
int GetValueAndStatusSplit(const std::vector<struct KEY_ID_STA_STRU > &staStruVec , std::vector< struct INT_VALUE_STATUS> & KeyIdValVec);//ym
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU > &staStruVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec);//yc
int GetValueAndStatusSplit(const std::vector<struct KEY_ID_STA_STRU > &staStruVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec);//yc
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatusSplit(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
int GetValueAndStatusSplit(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct UNION_VALUE_STATUS> & KeyIdValVec );//union type
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym
int GetValueAndStatusSplit(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc
int GetValueAndStatusSplit(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatusSplit(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
int GetValueAndStatusSplit(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
int GetRefMenuString (int table_no, std::vector<struct MENU_STRING>& vec_menu, short area_no);
int GetRefMenuStringWithAreaSplit(int table_no, std::vector<struct MENU_STRING>& vec_menu, short area_no);
int GetRefMenuString(const vector<int> vec_table, std::vector<struct MENU_STRING>& vec_menu);
public:
int PingRtdbServer(int req_data , int & rep_data);
int GraphDataSend(const struct RTDB_PROTO::GRAPH_REAL_REQ& real_req );
int GraphDataRecv(RTDB_PROTO::GRAPH_REAL_RSP& real_rsp );
public:
int SetDomainName(const char* domain_name);
int SetSecLabel(tSecLabel& sec_label);
void ClearDomainName();
int SetSliceNo(cmnUint32 slice_no);
private:
int Start();
int Refresh();
int Refresh(int app_no);
int GetSliceByKey(const char* key, cmnUint32& slice_no);
int GetAllSlice(vector<int>& slice_no);
int GetKeyInfo();
int GetKeyInfoSlice();
inline int slice_app_to_no(int slice_app_no){return slice_app_no % 1000;}
inline int slice_no_to_app(int slice_no){return slice_no+AP_SCADA_AREA;}
private:
CApiNet(const CApiNet&);
CApiNet& operator=(const CApiNet&);
private:
RTDB_SERVER::CODB_NET* m_OdbNet;
CNetFactory* m_Factory;
//Handle m_Handle; //for service_bus
std::vector<int> m_VecKey;
std::vector<int> m_IsSliced;
//
short m_ContextNo;
int m_AppNo;
int m_TableNo;
DB_BYTE_T m_ByteTag;
string m_ScenarioName ;
int m_ScenarioInstance ;
string m_SubScenarioName ;
int m_SubScenarioInstance ;
char m_DomainName[40];
tSecLabel m_SecLabel;
bool m_IsRemote;
int m_SliceNo;
TaskService* task_service;
bool m_IsSysAdmHost;
char m_HostName[MAX_NAME_STRING_LEN];
TGraphReq *m_pGraphReq; //lmj add for GraphGetDataEx
TApiNetPriv *m_pPrvStru; //lmj add for reserver
};
}
#endif

View File

@@ -0,0 +1,236 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_apinet.h
DESCRIPTION: for class CTableNet of net access
FUNCTION LIST:
COMMENT: for net access
History:
Date Version Modifier Activities
2004-06-25 1.1 add context_no parameter
2003-01-09 1.0 modify
================================================================================
2003-01-09 1.0 created
*******************************************************************************/
#ifndef __ODB_APINET_h__
#define __ODB_APINET_h__
#ifndef __ODB_COMMON_H__
#include "db_api/odb_common.h"
#endif
#ifndef __ODB_TABLEBASE_H__
#include "db_api/odb_tablebase.h"
#endif
#ifndef __ODB_NETFACTORY_h__
#include "db_api/odb_netfactory.h"
#endif
#include "task_service.h"
#include "db_api/odb_net_m.h"
#include "db_api/codb_net.h"
#ifdef _WINDOWS64
#ifdef ODB_API_LIB_EXPORTS
#define ODB_API_LIB_API __declspec(dllexport)
#else
#define ODB_API_LIB_API __declspec(dllimport)
#endif
#else
#define ODB_API_LIB_API
#endif
using namespace std;
//using namespace RTDB_SERVER;
using namespace ODB;
namespace NET_ODB
{
//lmj add for GraphGetDataEx
typedef struct
{
cmnInt64 graph_id;
cmnInt64 cal_type;
cmnInt64 req_status; //-1,0£¨È¡Êý£©,1(ÇëÇó)
Handle hdl;
} TGraphReq;
typedef struct
{
int type;
} TApiNetPriv;
class ODB_API_LIB_API CApiNet: public CTableBase
{
public:
CApiNet();
CApiNet(const int app_no, const short context_no = 0 );
CApiNet(const int app_no, const int table_no, const short context_no=0);
//CApiNet(const char *hostname);
~CApiNet();
public:
int SetAppNo(const int app_no, const short context_no = 0);
int SetHostMode(const char* host_name);
int Open(const int table_no );
int Open(const int app_no, const int table_no, const short context_no=0);
//int Open(const char* hostname);
public:
int MenuRead(const char* menu_name, std::vector<struct MENU_INFO>& vec_menu, const int menu_status=MENU_ON);
int TableReleMenuRead(const int table_no, std::vector<struct MENU_RELEVANT>& vec_menu);
int GetNameStringByKeyID(const KEY_ID_STRU& keyid_stru, string& ref_string);
int GetNameStringByKeyIDSplit(const KEY_ID_STRU& keyid_stru, string& ref_string);
int GetNameStringByKeyID(const std::vector<KEY_ID_STRU>& vec_keyid, std::vector<string>& vec_ref_string);
int GetNameStringByKeyIDSplit(const std::vector<KEY_ID_STRU>& vec_keyid, std::vector<string>& vec_ref_string);
int GetRefMenuString(const int table_no, std::vector<struct MENU_STRING>& vec_menu);
int GetRefMenuStringSplit(const int table_no, std::vector<struct MENU_STRING>& vec_menu);
//jinjing 2017-01-17
int GetRefMenuStringMultiKeys(const int table_no, std::vector<KEY_ID_STRU>& vec_keyid,
std::vector<struct MENU_STRING>& vec_menu);
int GetNameStringByID(const cmnInt64 reference_id, string& ref_string);
int GetNameStringByIDSplit(const long reference_id, string& ref_string);
int GetNameStringByID(const std::vector<cmnInt64>& vec_refid, std::vector<std::string>& vec_ref_string);
int GetNameStringByIDSplit(const std::vector<long>& vec_refid, std::vector<std::string>& vec_ref_string);
int GetNameStringBykey(const char* key_ptr, string& ref_string);
int GetNameStringBykeySplit(const char* key_ptr, string& ref_string);
int GetNameStringByAppKeyID( const std::vector<struct APP_KEY_STRU>& vec_appkeyid, std::vector<string>& vec_name_string);
int GetNameStringByAppID( const std::vector<APP_ID_STRU>& vec_appid, std::vector<string>& vec_name_string);
int GetNameStringByRtdbKeyID(const RTDB_KEY_STRU& rtdb_keyid_stru, string& ref_string);
int GetNameStringByRtdbKeyID(const std::vector<RTDB_KEY_STRU>& vec_rtdbkeyid, std::vector<string>& vec_ref_string);
int GraphGetAppInfo(const struct ODB::GRAPH_ORDER_KEY_REQ& graph_req, struct ODB::GRAPH_ORDER_KEY_RSP& graph_rsp);
int GraphGetAppInfoSplit(const struct ODB::GRAPH_ORDER_KEY_REQ& graph_req, struct ODB::GRAPH_ORDER_KEY_RSP& graph_rsp);
int GraphGetData(const struct RTDB_SERVER::GRAPH_REAL_REQ& real_req, RTDB_SERVER::GRAPH_REAL_RSP& real_rsp);
int GraphGetDataSplit(const struct RTDB_SERVER::GRAPH_REAL_REQ& real_req , RTDB_SERVER::GRAPH_REAL_RSP& real_rsp);
int GraphGetDataSplitSimple(const struct RTDB_SERVER::GRAPH_REAL_REQ& real_req , RTDB_SERVER::GRAPH_REAL_RSP& real_rsp);
//int GraphGetDataEx(const struct RTDB_SERVER::GRAPH_REAL_REQ& real_req , RTDB_SERVER::GRAPH_REAL_RSP_out real_rsp, bool is_req=true);
//int GraphDataRecv(const struct RTDB_SERVER::GRAPH_REAL_REQ& real_req , RTDB_SERVER::GRAPH_REAL_RSP_out real_rsp );
//int SqlGet(const char* str_sql, char** buf_ptr, int& buf_size);
public:
int GetFacNameByKeyNo(const int table_no, const char* key_ptr, string& ref_string);
int GetFacNameByFacID(char* fac_name, const cmnInt64 fac_id);
int GetFacNameByFacNo(char* fac_name, const int fac_no);
int GetFacIDByFacName(cmnInt64& fac_id, const char* fac_name);
int GetFacNoByFacName(int& fac_no, const char* fac_name);
int GetFacIDByFacNo(cmnInt64& fac_id, const int fac_no);
int GetFacNoByFacID( int& fac_no, const cmnInt64 fac_id);
int ColMeasType( const std::vector<KEY_ID_STRU> vec_keyid , std::vector<int>& vec_col_prop );
public:
int GetAppNameByNo(char* app_name, const int app_no) { return 0;}
int GetAppNoByName(int& app_no, const char* app_name) { return 0;}
int GetTableNameByNo(char* table_name, const int table_no, const bool is_eng=true) { return 0;}
int GetTableNoByName(int& table_no, const char* table_name, const bool is_eng=true) { return 0;}
int GetFieldNameByNo(char* field_name, const int field_no, const bool is_eng=true) { return 0;}
int GetFieldNoByName(int& field_no, const char* field_name, const bool is_eng=true) { return 0;}
public:
int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym
int GetValueAndStatusSplit(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym
int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc
int GetValueAndStatusSplit(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc
int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatusSplit(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
int GetValueAndStatusSplit(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct UNION_VALUE_STATUS> & KeyIdValVec );//union type
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU > &staStruVec , std::vector< struct INT_VALUE_STATUS> & KeyIdValVec);//ym
int GetValueAndStatusSplit(const std::vector<struct KEY_ID_STA_STRU > &staStruVec , std::vector< struct INT_VALUE_STATUS> & KeyIdValVec);//ym
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU > &staStruVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec);//yc
int GetValueAndStatusSplit(const std::vector<struct KEY_ID_STA_STRU > &staStruVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec);//yc
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatusSplit(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
int GetValueAndStatusSplit(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct UNION_VALUE_STATUS> & KeyIdValVec );//union type
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
int GetRefMenuString (int table_no, std::vector<struct MENU_STRING>& vec_menu, short area_no);
int GetRefMenuStringWithAreaSplit(int table_no, std::vector<struct MENU_STRING>& vec_menu, short area_no);
public:
int PingRtdbServer(int req_data , int & rep_data);
int GraphDataSend(const struct RTDB_SERVER::GRAPH_REAL_REQ& real_req );
int GraphDataRecv(RTDB_SERVER::GRAPH_REAL_RSP& real_rsp );
public:
int SetDomainName(const char* domain_name);
int SetSecLabel(tSecLabel& sec_label);
void ClearDomainName();
private:
int Start();
int Refresh();
int Refresh(int app_no);
int GetSliceByKey(const char* key, cmnUint32& slice_no);
int GetAllSlice(vector<int>& slice_no);
int GetKeyInfo();
int GetKeyInfoSlice();
inline int slice_app_to_no(int slice_app_no){return slice_app_no % 1000;}
inline int slice_no_to_app(int slice_no){return slice_no+AP_SCADA_AREA;}
private:
CApiNet(const CApiNet&);
CApiNet& operator=(const CApiNet&);
private:
RTDB_SERVER::CODB_NET* m_OdbNet;
CNetFactory* m_Factory;
//Handle m_Handle; //for service_bus
std::vector<int> m_VecKey;
std::vector<int> m_IsSliced;
//
short m_ContextNo;
int m_AppNo;
int m_TableNo;
DB_BYTE_T m_ByteTag;
char m_DomainName[40];
tSecLabel m_SecLabel;
bool m_IsRemote;
int m_SliceNo;
TaskService* task_service;
bool m_IsSysAdmHost;
char m_HostName[MAX_NAME_STRING_LEN];
TGraphReq *m_pGraphReq; //lmj add for GraphGetDataEx
TApiNetPriv *m_pPrvStru; //lmj add for reserver
};
}
#endif

View File

@@ -0,0 +1,233 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_api.h
DESCRIPTION: general function declaration
FUNCTION LIST:
COMMENT: public application
History:
Date Version Modifier Activities
2004-06-25 1.1 add context_no parameter
2003-05-28 1.0 modify
================================================================================
2003-05-28 1.0 created
*******************************************************************************/
#ifndef __ODB_APIOP_H__
#define __ODB_APIOP_H__
#ifndef __ODB_TABLEOP_H__
#include "db_api/odb_tableop.h"
#endif
#ifdef _WINDOWS64
#ifdef ODB_API_LIB_EXPORTS
#define ODB_API_LIB_API __declspec(dllexport)
#else
#define ODB_API_LIB_API __declspec(dllimport)
#endif
#else
#define ODB_API_LIB_API
#endif
using namespace std;
namespace ODB
{
typedef vector<int> IntVec;
typedef struct
{
int slice_no;
int type;
CTableOp *m_pColOp;
CTableOp *m_pMenuOp;
string m_ScenarioName ;
int m_ScenarioInstance ;
string m_SubScenarioName ;
int m_SubScenarioInstance ;
} TApiOpPriv;
class ODB_API_LIB_API CApiOp: public CTableBase
{
public:
CApiOp();
CApiOp ( const int app_no , const short context_no = 0);
CApiOp ( const int app_no, const int table_no , const short context_no = 0);
~CApiOp();
int Open (const int app_no, const int table_no, const short context_no = 0);
int Open (const int table_no);
int SetAppNo (const int app_no, const short context_no = 0);
int SetScenario(const std::string& scenario_name,
const int scenario_inst_name,
const std::string& sub_scenario_name,
const int sub_scenario_inst_name);
int SetScenario(const int scenario_no,
const int scenario_inst_no,
const int sub_scenario_no,
const int sub_scenario_inst_no);
int SetAppNo(const std::string& scenario_name,
const int scenario_inst_name,
const std::string& sub_scenario_name,
const int sub_scenario_inst_name);
int SetSliceNo(int slice_no);
public:
int MenuRead(const char* menu_name, std::vector<struct MENU_INFO>& vec_menu, const int menu_status=MENU_ON);
int MenuRead(const char* menu_name, char** buf_ptr, int& buf_size, const int menu_status=MENU_ON);//obsolete
//
int TableReleMenuRead (const int table_no, const int field_no );
int TableReleMenuRead(const int table_no, const int field_no, std::vector<struct MENU_RELEVANT>& vec_menu);
int TableReleMenuRead(const int table_no, std::vector<struct MENU_RELEVANT>& vec_menu);
int TableReleMenuRead(const int table_no, const int field_no, char** buf_ptr, int& buf_size);//obsolete
int TableReleMenuRead(const int table_no, char** buf_ptr, int& buf_size);//obsolete
//
int GetRefMenuString(const int table_no, std::vector<struct MENU_STRING>& vec_menu);
int GetRefMenuString(const vector<int> vec_table, std::vector<struct MENU_STRING>& vec_menu);
int GetRefMenuString(const int table_no, char*& menu_buf_ptr, int& menu_buf_size);//obsolete
//
int GetNameStringByID(const cmnInt64 reference_id, std::string& ref_string);
int GetNameStringByID(const cmnInt64 reference_id, char*& referenced_namebuf, int& namebuf_size);
//
int GetNameStringByID(const std::vector<cmnInt64>& vec_refid, std::vector<std::string>& vec_ref_string);
/*
int GetNameStringByKeyID(const KEY_ID_STRU& keyid_stru, std::string& ref_string);
int GetNameStringByKeyID(const std::vector<KEY_ID_STRU>& vec_keyid, std::vector<string>& vec_ref_string);
int GetNameStringByKeyID( const KEY_ID_STRU& keyid_stru, char*& referenced_namebuf, int& namebuf_size);
*/
//
int GetNameStringBykey (const char* key_ptr, std::string& ref_string);
int GetNameStringBykey(const char* key_ptr, char*& referenced_namebuf, int& namebuf_size );
//
int GetNameStringByAppKeyID( const std::vector<struct APP_KEY_STRU>& vec_appkeyid, std::vector<string>& vec_name_string);
int GetNameStringByAppID( const std::vector<APP_ID_STRU>& vec_appid, std::vector<string>& vec_name_string);
int GetNameStringByRtdbKeyID( const std::vector<struct RTDB_KEY_STRU>& vec_rtdbkeyid, std::vector<string>& vec_name_string);
int GetNameStringByRtdbKeyID( const RTDB_KEY_STRU& rtdbkeyid_stru, char*& referenced_namebuf, int& namebuf_size);
int GetNameStringByRtdbKeyID(const RTDB_KEY_STRU rtdbkeyid_stru, std::string& ref_string);
//
int GetRefFlag (const int table_no, const short field_no); //obsolete
int GetRefFlag (const short field_no);
public:
int GetFacNameByKeyNo(const int table_no, const char* key_ptr, std::string& ref_string);
int GetFacNameByFacID(char* fac_name, const RTDB_KEY_STRU fac_id);
int GetFacNameByFacNo (char* fac_name, const int fac_no);
int GetFacIDByFacName(RTDB_KEY_STRU& fac_id, const char* fac_name);
int GetFacNoByFacName (int& fac_no, const char* fac_name);
int GetFacIDByFacNo(RTDB_KEY_STRU& fac_id, const int fac_no);
int GetFacNoByFacID(int& fac_no, const RTDB_KEY_STRU fac_id);
public:
//int ColMeasType ( const KEY_ID_STRU keyid , int& col_prop );
int ColMeasType ( const int table_no, const int col_id , int& col_prop );
//int ColMeasType( const std::vector<KEY_ID_STRU> vec_keyid , std::vector<int>& vec_col_prop );
public:
//
int GraphGetAppInfo(const struct GRAPH_ORDER_KEY_REQ& graph_req, struct GRAPH_ORDER_KEY_RSP& graph_rsp);
int GraphGetValue();
public:
int GetAppNameByNo(char* app_name, const int app_no) { return 0;}
int GetAppNoByName(int& app_no, const char* app_name) { return 0;}
int GetTableNameByNo(char* table_name, const int table_no, const bool is_eng=true) { return 0;}
int GetTableNoByName(int& table_no, const char* table_name, const bool is_eng=true) { return 0;}
int GetFieldNameByNo(char* field_name, const int field_no, const bool is_eng=true) { return 0;}
int GetFieldNoByName(int& field_no, const char* field_name, const bool is_eng=true) { return 0;}
public:
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct UNION_VALUE_STATUS> & KeyIdValVec );//union type
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec, bool order); //ym
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec, bool order); //yc
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec, bool order); //yx
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec, bool order); //long
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct UNION_VALUE_STATUS> & KeyIdValVec, bool order);//union type
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU > &staStruVec , std::vector< struct INT_VALUE_STATUS> & KeyIdValVec);//ym
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU > &staStruVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec);//yc
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct UNION_VALUE_STATUS> & KeyIdValVec );//union type
//int GetFieldNoFromKeyId(const std::vector<KEY_ID_STRU> &struVec , std::vector<int> &FieldNoVec);
int ColMeasType( const RTDB_KEY_STRU rtdbkeyid , int& col_prop );
int ColMeasType( const std::vector<RTDB_KEY_STRU> vec_rtdbkeyid , std::vector<int>& vec_col_prop );
int GetFieldNoFromRtdbKeyId(const std::vector<RTDB_KEY_STRU> &struVec , std::vector<int> &FieldNoVec);
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
private:
int GetFieldValueByNo(char** field_value_ptr, int& field_length, const char* record_ptr, const int field_no);
int GetFieldValueByName(char** field_value_ptr, int& field_length, const char* record_ptr, const char* field_name);
int GetRecordInfo(char** buf_ptr, short& field_num, int& record_num, int& record_size);
int GetRecordInfoByKey(char** buf_ptr, short& field_num, int& record_num, int& record_size, const char* key_ptr);
int GetMenuStringByValue(const char* menu_name, const int menu_val, const int menu_type, char*& menu_string, int& string_len);
int get_string(char* total_namestring, const char* read_record_ptr, const struct STDB_FIELD_TAB* mov_field_ptr);
int GetNameString(std::string& total_namestring, const char* read_record_ptr, const struct STDB_FIELD_TAB* mov_field_ptr);
int Start();
int SetContext (const short context_no);
//int GetPosFromKeyIdStru(const std::vector<KEY_ID_STRU> &struVec , vector<int> &errPosVec , vector<IntVec> &posVec);
private:
CApiOp (const CApiOp&);
CApiOp& operator= (const CApiOp&);
private:
enum
{
TABLE_COLUMN_INFO = 100002,
TABLE_MENU_INFO = 100005,
TABLE_RELEVANT_MENU = 6,
TABLE_FAC_INFO = 405,
};
short m_ContextNo;
int m_AppNo;
int m_TableNo;
CTableOp* m_TableOp;
//CTableOp* m_ColOp;
TApiOpPriv *m_pPrvStru;
};
}
#endif

View File

@@ -0,0 +1,227 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_api.h
DESCRIPTION: general function declaration
FUNCTION LIST:
COMMENT: public application
History:
Date Version Modifier Activities
2004-06-25 1.1 add context_no parameter
2003-05-28 1.0 modify
================================================================================
2003-05-28 1.0 created
*******************************************************************************/
#ifndef __ODB_APIOP_H__
#define __ODB_APIOP_H__
#ifndef __ODB_TABLEOP_H__
#include "db_api/odb_tableop.h"
#endif
#ifdef _WINDOWS64
#ifdef ODB_API_LIB_EXPORTS
#define ODB_API_LIB_API __declspec(dllexport)
#else
#define ODB_API_LIB_API __declspec(dllimport)
#endif
#else
#define ODB_API_LIB_API
#endif
using namespace std;
namespace ODB
{
typedef vector<int> IntVec;
typedef struct
{
int slice_no;
int type;
CTableOp *m_pColOp;
CTableOp *m_pMenuOp;
} TApiOpPriv;
class ODB_API_LIB_API CApiOp: public CTableBase
{
public:
CApiOp();
CApiOp ( const int app_no , const short context_no = 0);
CApiOp ( const int app_no, const int table_no , const short context_no = 0);
~CApiOp();
int Open (const int app_no, const int table_no, const short context_no = 0);
int Open (const int table_no);
int SetAppNo (const int app_no, const short context_no = 0);
int SetScenario(const std::string& scenario_name,
const int scenario_inst_name,
const std::string& sub_scenario_name,
const int sub_scenario_inst_name);
int SetScenario(const int scenario_no,
const int scenario_inst_no,
const int sub_scenario_no,
const int sub_scenario_inst_no);
int SetAppNo(const std::string& scenario_name,
const int scenario_inst_name,
const std::string& sub_scenario_name,
const int sub_scenario_inst_name);
int SetSliceNo(int slice_no);
public:
int MenuRead(const char* menu_name, std::vector<struct MENU_INFO>& vec_menu, const int menu_status=MENU_ON);
int MenuRead(const char* menu_name, char** buf_ptr, int& buf_size, const int menu_status=MENU_ON);//obsolete
//
int TableReleMenuRead (const int table_no, const int field_no );
int TableReleMenuRead(const int table_no, const int field_no, std::vector<struct MENU_RELEVANT>& vec_menu);
int TableReleMenuRead(const int table_no, std::vector<struct MENU_RELEVANT>& vec_menu);
int TableReleMenuRead(const int table_no, const int field_no, char** buf_ptr, int& buf_size);//obsolete
int TableReleMenuRead(const int table_no, char** buf_ptr, int& buf_size);//obsolete
//
int GetRefMenuString(const int table_no, std::vector<struct MENU_STRING>& vec_menu);
int GetRefMenuString(const vector<int> vec_table, std::vector<struct MENU_STRING>& vec_menu);
int GetRefMenuString(const int table_no, char*& menu_buf_ptr, int& menu_buf_size);//obsolete
//
int GetNameStringByID(const cmnInt64 reference_id, std::string& ref_string);
int GetNameStringByID(const cmnInt64 reference_id, char*& referenced_namebuf, int& namebuf_size);
//
int GetNameStringByID(const std::vector<cmnInt64>& vec_refid, std::vector<std::string>& vec_ref_string);
/*
int GetNameStringByKeyID(const KEY_ID_STRU& keyid_stru, std::string& ref_string);
int GetNameStringByKeyID(const std::vector<KEY_ID_STRU>& vec_keyid, std::vector<string>& vec_ref_string);
int GetNameStringByKeyID( const KEY_ID_STRU& keyid_stru, char*& referenced_namebuf, int& namebuf_size);
*/
//
int GetNameStringBykey (const char* key_ptr, std::string& ref_string);
int GetNameStringBykey(const char* key_ptr, char*& referenced_namebuf, int& namebuf_size );
//
int GetNameStringByAppKeyID( const std::vector<struct APP_KEY_STRU>& vec_appkeyid, std::vector<string>& vec_name_string);
int GetNameStringByAppID( const std::vector<APP_ID_STRU>& vec_appid, std::vector<string>& vec_name_string);
int GetNameStringByRtdbKeyID( const std::vector<struct RTDB_KEY_STRU>& vec_rtdbkeyid, std::vector<string>& vec_name_string);
int GetNameStringByRtdbKeyID( const RTDB_KEY_STRU& rtdbkeyid_stru, char*& referenced_namebuf, int& namebuf_size);
int GetNameStringByRtdbKeyID(const RTDB_KEY_STRU rtdbkeyid_stru, std::string& ref_string);
//
int GetRefFlag (const int table_no, const short field_no); //obsolete
int GetRefFlag (const short field_no);
public:
int GetFacNameByKeyNo(const int table_no, const char* key_ptr, std::string& ref_string);
int GetFacNameByFacID(char* fac_name, const RTDB_KEY_STRU fac_id);
int GetFacNameByFacNo (char* fac_name, const int fac_no);
int GetFacIDByFacName(RTDB_KEY_STRU& fac_id, const char* fac_name);
int GetFacNoByFacName (int& fac_no, const char* fac_name);
int GetFacIDByFacNo(RTDB_KEY_STRU& fac_id, const int fac_no);
int GetFacNoByFacID(int& fac_no, const RTDB_KEY_STRU fac_id);
public:
//int ColMeasType ( const KEY_ID_STRU keyid , int& col_prop );
int ColMeasType ( const int table_no, const int col_id , int& col_prop );
//int ColMeasType( const std::vector<KEY_ID_STRU> vec_keyid , std::vector<int>& vec_col_prop );
public:
//
int GraphGetAppInfo(const struct GRAPH_ORDER_KEY_REQ& graph_req, struct GRAPH_ORDER_KEY_RSP& graph_rsp);
int GraphGetValue();
public:
int GetAppNameByNo(char* app_name, const int app_no) { return 0;}
int GetAppNoByName(int& app_no, const char* app_name) { return 0;}
int GetTableNameByNo(char* table_name, const int table_no, const bool is_eng=true) { return 0;}
int GetTableNoByName(int& table_no, const char* table_name, const bool is_eng=true) { return 0;}
int GetFieldNameByNo(char* field_name, const int field_no, const bool is_eng=true) { return 0;}
int GetFieldNoByName(int& field_no, const char* field_name, const bool is_eng=true) { return 0;}
public:
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct UNION_VALUE_STATUS> & KeyIdValVec );//union type
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec, bool order); //ym
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec, bool order); //yc
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec, bool order); //yx
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec, bool order); //long
//int GetValueAndStatus(const std::vector<KEY_ID_STRU> &struVec , std::vector< struct UNION_VALUE_STATUS> & KeyIdValVec, bool order);//union type
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU > &staStruVec , std::vector< struct INT_VALUE_STATUS> & KeyIdValVec);//ym
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU > &staStruVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec);//yc
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
int GetValueAndStatus(const std::vector<struct KEY_ID_STA_STRU> &staStruVec , std::vector< struct UNION_VALUE_STATUS> & KeyIdValVec );//union type
//int GetFieldNoFromKeyId(const std::vector<KEY_ID_STRU> &struVec , std::vector<int> &FieldNoVec);
int ColMeasType( const RTDB_KEY_STRU rtdbkeyid , int& col_prop );
int ColMeasType( const std::vector<RTDB_KEY_STRU> vec_rtdbkeyid , std::vector<int>& vec_col_prop );
int GetFieldNoFromRtdbKeyId(const std::vector<RTDB_KEY_STRU> &struVec , std::vector<int> &FieldNoVec);
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long
private:
int GetFieldValueByNo(char** field_value_ptr, int& field_length, const char* record_ptr, const int field_no);
int GetFieldValueByName(char** field_value_ptr, int& field_length, const char* record_ptr, const char* field_name);
int GetRecordInfo(char** buf_ptr, short& field_num, int& record_num, int& record_size);
int GetRecordInfoByKey(char** buf_ptr, short& field_num, int& record_num, int& record_size, const char* key_ptr);
int GetMenuStringByValue(const char* menu_name, const int menu_val, const int menu_type, char*& menu_string, int& string_len);
int get_string(char* total_namestring, const char* read_record_ptr, const struct STDB_FIELD_TAB* mov_field_ptr);
int GetNameString(std::string& total_namestring, const char* read_record_ptr, const struct STDB_FIELD_TAB* mov_field_ptr);
int Start();
int SetContext (const short context_no);
//int GetPosFromKeyIdStru(const std::vector<KEY_ID_STRU> &struVec , vector<int> &errPosVec , vector<IntVec> &posVec);
private:
CApiOp (const CApiOp&);
CApiOp& operator= (const CApiOp&);
private:
enum
{
TABLE_COLUMN_INFO = 100002,
TABLE_MENU_INFO = 100005,
TABLE_RELEVANT_MENU = 6,
TABLE_FAC_INFO = 405,
};
short m_ContextNo;
int m_AppNo;
int m_TableNo;
CTableOp* m_TableOp;
//CTableOp* m_ColOp;
TApiOpPriv *m_pPrvStru;
};
}
#endif

View File

@@ -0,0 +1,80 @@
#ifndef _APPNAME2ID_
#define _APPNAME2ID_
#include "common_types.h"
#ifndef _WINDOWS64
#ifndef _HPUX
#include <pthread.h>
#else
#include <sys/pthread.h>
#endif
#include <unistd.h>
#else
#include <winsock2.h>
#include <windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#ifdef _WINDOWS64
#ifdef ODB_API_LIB_EXPORTS
#define ODB_API_LIB_API __declspec(dllexport)
#else
#define ODB_API_LIB_API __declspec(dllimport)
#endif
#else
#define ODB_API_LIB_API
#endif
#define MAXSIZE 8092
struct ID2NameNode
{
int app_id;
char app_name[32];
struct ID2NameNode * next_pointer;
};
class ODB_API_LIB_API CAppNameIDTrans
{
public :
CAppNameIDTrans();
CAppNameIDTrans(const CAppNameIDTrans&);
~CAppNameIDTrans();
//void operator= (const CAppNameIDTrans&);
private:
#ifndef _WINDOWS64
static pthread_mutex_t s_guard;
#else
static CRITICAL_SECTION s_guard;
#endif
static CAppNameIDTrans * s_instance ;
ID2NameNode * m_hashTable;
ID2NameNode * second;
char* m_InitPtr;
cmnInt64 * freePos;
cmnInt64 freePointer;
public:
static CAppNameIDTrans * getInstance();
char * getAppNameByID(const int app_id);
int createHashTable();
int putData2Table();
};
#endif

View File

@@ -0,0 +1,138 @@
#ifndef _PVLOCK
#define _PVLOCK
#include "db_api/odb_common.h"
#include "db_api/odb_define.h"
#include "ThreadKit/ThreadKit.h"
#ifndef _WINDOWS64
#ifndef _HPUX
#include <pthread.h>
#else
#include <sys/pthread.h>
#endif
#else
#include <process.h>
#endif
#include "db_api/odb_lock.h"
#ifdef _WINDOWS64
typedef int key_t;
#endif
class PVLock
{
private:
PVLock(const PVLock&);
PVLock& operator=(const PVLock&);
int m_semid;
int m_semno;
public:
PVLock(key_t key , int no);
~PVLock();
};
class PMutexLock
{
private:
PMutexLock(const PMutexLock&);
PMutexLock& operator=(const PMutexLock&);
#ifndef _WINDOWS64
pthread_mutex_t * m_mutex;
public:
PMutexLock(pthread_mutex_t * out_mutex):m_mutex(out_mutex)
{
if( 0 != pthread_mutex_lock(m_mutex ))
{
printf("Error in pthread mutex lock ...,errno === %d \n" , errno);
}
}
~PMutexLock()
{
if(0 != pthread_mutex_unlock(m_mutex))
{
printf("Error in pthread mutex unlock ... errno === %d \n" , errno);
}
}
#else
/*
CRITICAL_SECTION* m_mutex;
public:
PMutexLock(CRITICAL_SECTION* out_mutex):m_mutex(out_mutex)
{
EnterCriticalSection(m_mutex);
}
~PMutexLock()
{
LeaveCriticalSection(m_mutex);
}
*/
THREADKIT::Mutex* m_mutex;
public:
PMutexLock(THREADKIT::Mutex* out_mutex):m_mutex(out_mutex)
{
m_mutex->lock();
}
~PMutexLock()
{
m_mutex->unlock();
};
#endif
};
class CRWLock
{
private:
struct ODB::LOCK_STRU *m_LockPtr;
DB_LOCK_T m_RWType;
int* m_SemId;
CRWLock();
CRWLock(const CRWLock& theLock);
CRWLock& operator=(const CRWLock& theLock);
public:
//jinjing 20120429
CRWLock(struct ODB::LOCK_STRU *lock_ptr,const DB_LOCK_T lock_type, int& table_semid);
~CRWLock();
int ChangeLockType(const DB_LOCK_T lock_type);
// CRWLock(struct ODB::LOCK_STRU *lock_ptr,const DB_LOCK_T lock_type, int& table_semid)
// {
// //jinjing 20120428
//// ODB::COdbLock::Lock(*lock_ptr, lock_type, table_semid);
//// m_LockPtr = lock_ptr;
//// m_RWType = lock_type;
//// m_SemId = table_semid;
// m_SemId = table_semid;
// TRACE("m_SemId1 = %d\n lock_type = %d", m_SemId, lock_type);
// TRACE("!!!!!Addr_AutoLock.m_SemId = %d\n", &m_SemId);
// ODB::COdbLock::Lock(*lock_ptr, lock_type, m_SemId);
// TRACE("!!!!!Addr_AutoLock.m_SemId2 = %d\n", &m_SemId);
// TRACE("m_SemId2 = %d\n", m_SemId);
// m_LockPtr = lock_ptr;
// m_RWType = lock_type;
// table_semid = m_SemId;
// TRACE("table_semid = %d\n", table_semid);
// }
// ~CRWLock()
// {
// ODB::COdbLock::UnLock(*m_LockPtr, m_RWType, m_SemId);
// }
//
// int ChangeLockType(const DB_LOCK_T lock_type)
// {
// if(lock_type != m_RWType)
// {
// ODB::COdbLock::UnLock(*m_LockPtr,m_RWType, m_SemId);
// ODB::COdbLock::Lock(*m_LockPtr,lock_type, m_SemId);
// m_RWType = lock_type;
// }
// return 0;
// }
};
#endif

View File

@@ -0,0 +1,54 @@
/*******************************************************************************
ModuleName: Real Time Database management system
FileName: rtdb_api.cpp
DESCRIPTION: rtdb api interfaces implementation
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
2009-01-10 1.1 add net interfaces
================================================================================
2008-10-30 1.0 created
*******************************************************************************/
//#include <vector>
#include "db_api/odb_prv_struct.h"
#ifndef _CBASEINDEX
#define _CBASEINDEX
#ifdef _WINDOWS64
#ifdef ODB_API_LIB_EXPORTS
#define ODB_API_LIB_API __declspec(dllexport)
#else
#define ODB_API_LIB_API __declspec(dllimport)
#endif
#else
#define ODB_API_LIB_API
#endif
namespace ODB
{
class ODB_API_LIB_API CBaseIndex
{
public:
virtual int need_rebuilt(char *existed_table_ptr,struct STDB_TAB *stdb_tab_ptr,struct STDB_FIELD_TAB *stdb_field_tab_ptr,INDEX_DEFINE &index_define,int &shm_id) =0;
virtual int CreateIndex(struct STDB_TAB *stdb_tab_ptr,struct STDB_FIELD_TAB *stdb_field_tab_ptr,INDEX_DEFINE &index_define,int &shm_id,int &shm_size) =0;
virtual int Open(char *index_file_name,int table_id,int index_id)=0; //table_id、index_id用来和INDEX_STDB_TAB::table_id、INDEX_STDB_TAB::field_id匹配校验
virtual int Open(int index_shmid,int table_id,int index_id) = 0; //table_id、index_id用来和INDEX_STDB_TAB::table_id、INDEX_STDB_TAB::field_id匹配校验
virtual int SetIndexPtr(char *index_ptr)= 0; //把缓存的指针赋值给索引类这样就不用使用前面的Open函数。
virtual int GetKeyByIndex(char *index_ptr,std::vector<char *> &index_array)=0;//考虑多个关键字可能索引的值相同的情况。
virtual int GetKeyPointerByIndex(char *index_ptr, int& pointer)=0;//只对主键索引有效根据index得到记录的物理位置
virtual int IndexInsert(char *index_ptr,char *key_ptr)=0;
virtual int BulkIndexInsert(char *bulk_index_key_ptr)=0;//下装的时候,对于顺序索引肯定是有用的。相当于在索引外部排好序,然后一把把所有的索引全部插入进去。
virtual int Indexdelete(char *index_ptr,char *key_ptr)=0;
virtual int IndexClear()=0;
virtual int GetIdxMthd()=0;
virtual int FreeResource()=0;//譬如unmap或者shmdt掉指针。
virtual int DebugDisp(int type)=0;//方便调试用不同的type显示不同或者详细程度不同的信息。
virtual int GetIndexRecNum() = 0;//返回索引记录总的个数包括索引区、溢出区、主溢出区有效记录个数的总和。但是无溢出HASH索引只是返回0。
virtual DB_STATUS_T GetIndexStatus()=0;//返回索引的状态
virtual void SetIndexStatus(DB_STATUS_T idx_status)=0;//设置索引头上的索引状态
virtual ~CBaseIndex(){};
};
}
#endif

View File

@@ -0,0 +1,64 @@
#ifndef _CKEYMAN
#define _CKEYMAN
#include "db_api/odb_define.h"
#include "db_api/odb_prv_struct.h"
#ifndef _WINDOWS64
#include "sys/time.h"
#else
#include <time.h>
#endif
#include "db_api/odb_autolock.h"
#define MAGICLEN 16
#define MAX_FIX_INDEX_NUM 100
struct FIX_INDEX_DEF
{
short ctx_no;
int app_no;
int table_no;
int idx_seq_no;
};
struct KEY_MANAGE_TAB
{
char magic[MAGICLEN];
int valid ;// = INVALID;
int shmKey;
int semKey;
time_t createTime;
int fix_index_num;
struct FIX_INDEX_DEF fix_index_def_array[MAX_FIX_INDEX_NUM];
};
class CKeyManager
{
private:
static struct KEY_MANAGE_TAB* m_ShmManTabPtr;
static CKeyManager * m_KeyManPtr;
static int m_SemId;
CKeyManager();
CKeyManager(const CKeyManager&);
CKeyManager& operator =(const CKeyManager&);
int Init();
public:
int GetShmKey();
int GetSemKey();
time_t GetCreateTime();
int GetFixIdxDef(struct FIX_INDEX_DEF **fix_idx_array_ptr);
int InsertFixIdxDef(struct FIX_INDEX_DEF &fix_idx_def);
int DeleteFixIdxDef(struct FIX_INDEX_DEF &fix_idx_def);
static CKeyManager * GetInstance();
};
#endif

View File

@@ -0,0 +1,202 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_common.h
DESCRIPTION: common data struct define
FUNCTION LIST:
COMMENT: public application
History:
Date Version Modifier Activities
2002-09-01 1.0 modify
================================================================================
2002-09-01 1.0 created
*******************************************************************************/
#ifndef __ODB_COMMON_H__
#define __ODB_COMMON_H__
#include "common_types.h"
#include "db_api/odb_public.h"
//#include "odb_struct.h"
#include "db_api/odb_prv_struct.h"
#include "db_api/odb_app2id.h"
#ifdef _WINDOWS64
#ifdef ODB_API_LIB_EXPORTS
#define ODB_API_LIB_API __declspec(dllexport)
#else
#define ODB_API_LIB_API __declspec(dllimport)
#endif
#else
#define ODB_API_LIB_API
#endif
#ifdef _WINDOWS64
typedef int key_t;
#endif
using namespace std;
namespace ODB
{
//系统表管理类
class ODB_API_LIB_API CCommon
{
public:
CCommon(){};
~CCommon(){};
//map file // 2002-10-01
static char* MapFile(const char* file_name, const int stab_total_size, const bool read_only = false);
static char* MapFile(const char* file_name, MAP_FILE_KEY map_id, const int stab_total_size, const bool read_only = false);
#ifdef _WINDOWS64
static char* MapFile(const char* file_name, const int stab_total_size, const char* uniq_flag, bool read_only = false);
static char* MapFile(const char* file_name, MAP_FILE_KEY map_id, const int stab_total_size, const char* uniq_flag, bool read_only = false);
#endif
static int UmapFile(char* addr_t, const int size);
static int UmapFile(char* addr_t, MAP_FILE_KEY map_id, const int size);
//sort // 2002-11-20
//static void QkSort(std::vector<RCD_TYPE>& r, int base, int top);
static void QkSort(std::vector<RCD_TYPE>& r, const int base, const int top);
static void StlSort(std::vector<RCD_TYPE>& r);
//char
static char* itoa(const int value);
static int str_lwr(char* str_dst, const char* str_src);
static int str_upr(char* str_dst, const char* str_src);
static bool strip_blank1(char* ptr);
static int strip_blank2(char* str_src);
static bool StripBlank(char* str_src);
//static void str_up(char* str);
//static void str_lower(char* str);
//inline static char* dwcase(char* str);
//sem 2002-12-28
#ifndef _WINDOWS64
static int InitSem(const key_t key, const int nsems=1);
static int p(const int sem_id, const int sem_num=0);
static int v(const int sem_id, const int sem_num=0);
static int GetValue(const int sem_id, const int sem_num=0);
#else
static int p(const char* sem_name, const int sem_num);
static int v(const char* sem_name, const int sem_num = 1, const int release_num=1);
#endif
//shm
static char* GetShmPtr(const key_t key, const int size);
static int GetShmID(const key_t key, const int size);
static char* GetShmPtrByID(const int shm_id);
static int GetShmSizeByID(const int shm_id);
//time
static void TimevalSub(struct timeval* end, struct timeval* start);
static bool IsApplication(const char* app_name);
static bool IsApplication(const int app_no);
static void* Malloc(const int buf_size);
static void Free(void* pointer);
static int GetOdbId(const char* odb_id_sysfile);
static int TransTime(time_t cur_time, char* time_str);
public:
static int ExchangeData(char* buf_ptr, const int buf_size, const std::vector<MEMBER_DEFINITION>& vec_offset, const DB_BYTE_T& remote_byte);
static int ExchangeByteOrder(char* buf_ptr, const int len);
static DB_BYTE_T GetByteTag();
static int GetSize(std::vector<MEMBER_DEFINITION>& vec_member);
public:
static int PrintCtrlTab(const struct DB_CTRL_TAB* ctrl_tab_ptr);
static int PrintStdbTab(const struct STDB_TAB* stdb_tab_ptr);
static int PrintStabField(const struct STDB_FIELD_TAB* stdb_field_tab_ptr);
static int PrintField(const int data_type, const char* field_data_ptr);
private:
//static void QkPass(std::vector<RCD_TYPE>& r, int start, int tend, int& i);
static void QkPass(std::vector<RCD_TYPE>& r, const int start, const int tend, int& i);
static int CheckSize(std::vector<MEMBER_DEFINITION>& m_vecMember);
static int MakeOffset(std::vector<MEMBER_DEFINITION>& m_vecMember);
static int AssignOffset(int& index_pos, const int assign_val);
public:
static void keyid_to_long(struct KEY_STRU *key_stru_ptr,cmnUint64* key_id_ptr);
static void long_to_keyid(cmnUint64 key_id,struct KEY_STRU *key_stru_ptr);
static void long_to_tableNo(cmnUint64 key_id,short *table_no_ptr);
static void long_to_field_id(cmnUint64 key_id,short *field_id_ptr);
static void long_to_key(cmnUint64 key_id,int *key_ptr);
static void key_id_to_long(int key,short field_id,short table_id,cmnUint64*key_id_ptr);
static void long_to_key_id(cmnUint64 key_id,int *key_ptr,short *field_id_ptr,short *table_id_ptr);
static int long_to_area_no(const cmnInt64 key_id);
static void long_to_key_in_area(const cmnInt64 key_id, int& key_inarea);
static void area_key_id_to_long(int area_no, int key, short field_id, short table_id, cmnInt64& key_id);
static void long_to_long_without_area(const cmnInt64 id_with_area, cmnInt64& id_without_area);
/*
static unsigned int rtdb_keyid_to_area_id(struct RTDB_KEY_STRU rtdb_key_id);
static unsigned int rtdb_keyid_to_table_id(struct RTDB_KEY_STRU rtdb_key_id);
static unsigned int rtdb_keyid_to_serial_no(struct RTDB_KEY_STRU rtdb_key_id);
static unsigned int rtdb_keyid_to_column_id(struct RTDB_KEY_STRU rtdb_key_id);
static void set_rtdb_keyid_area_id(struct RTDB_KEY_STRU& rtdb_key_id, unsigned int area_id);
static void set_rtdb_keyid_table_id(struct RTDB_KEY_STRU& rtdb_key_id, unsigned int table_id);
static void set_rtdb_keyid_serial_no(struct RTDB_KEY_STRU& rtdb_key_id, unsigned int serial_no);
static void set_rtdb_keyid_column_id(struct RTDB_KEY_STRU& rtdb_key_id, unsigned int column_id);
static void rtdb_keyid_to_long(unsigned int area_id, unsigned int table_id, unsigned int serial_no, unsigned int column_id, struct RTDB_KEY_STRU& rtdb_key_id);
static void rtdb_keyid_to_sgid(string& sgid, const struct RTDB_KEY_STRU& rtdb_key_id);
*/
static int find_max_prime(int value);
static int hash33(char * code , int len , int max);
static int hash37(char * code , int len , int max);
static int hash_string(char * code , int len , int max);
static int hash_int(char * code , int len , int max);
static int hash_long(char * code , int len , int max);
static int ShmDetach(char *& shm_ptr , int size);
static int ShmRemove(int shm_id,int type);
static int Equal(char *,char *,int length);
static int MemCpy(char *dst,char *src,int length);
static void FormatAppKeyStru(char* app_key_stru_ptr);
static int FieldCompare(char *src_ptr,char *dst_ptr,int type,int length); //return val : 0 means equal , others means not equal
//static int NeedFixIndex(int ctx_no,int app_no,int table_no,int index_seq_no);//这儿的index_seq_no是索引在表头里面的顺序号0、1、2....,而不是索引定义表中定义的索引ID。
//int RCDCmp(const void *ee1,const void *ee2);
// //nothing
// static void do_nothing1(int nn);
// static void do_nothing2(int nn);
static int compare_keyword(const char* keyword1_ptr, const char* keyword2_ptr, const ODB::KEYWORD_STRU& key);
#ifndef _WINDOWS64
static int addItem(struct CMmapList& m_list, char* file_ptr, unsigned int map_size, const char* file_name, MAP_FILE_KEY map_id);
static char* getMapPtr(struct CMmapList& m_list, const char* file_name, MAP_FILE_KEY map_id);
static int shrinkList(struct CMmapList& m_list);
static int reduceCounter(struct CMmapList& m_list, char* file_ptr, const int size, MAP_FILE_KEY map_id);
static int recoveryList(struct CMmapList& m_list);
static void PrintList(struct CMmapList& m_list);
static CAppNameIDTrans* getAppNameIdTransPtr();
////////////////////// using map for file mapping cache ///////////////////////////
static int addMapItem(MMapInfoList& m_list, char* file_ptr, unsigned int map_size, const char* file_name, MAP_FILE_KEY map_id);
static char* getMapPtr(MMapInfoList& m_list, const char* file_name, MAP_FILE_KEY map_id);
static int shrinkMapList(MMapInfoList& m_list);
static int reduceMapCounter(MMapInfoList& m_list, char* file_ptr, const int size, MAP_FILE_KEY map_id);
static void PrintMapList(MMapInfoList& m_list);
#endif
static void setMapFlag(int m_flag);
static void setMapID(MAP_FILE_KEY& map_id, int ctx_no, int app_no, short tab_no, int area_no);
static int parseAppNameFromFileName(char* app_name, const char* app_file_name);
};
}
#endif

View File

@@ -0,0 +1,563 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_define.h
DESCRIPTION: macro define and error no
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
2002-09-01 1.0 modify
================================================================================
2002-09-01 1.0 created
*******************************************************************************/
#include "system.h"
#include "d5000_err.h"
#include "common_types.h"
#include "logclient.h"
#ifdef _WINDOWS64
#pragma warning(disable: 4996)
#pragma warning(disable: 4267)
#endif
#ifndef __ODB_DEFINE_H__
#define __ODB_DEFINE_H__
#ifndef _SHARE_MEMORY
#define DEF_SHMMEM 0
#else
#define DEF_SHMMEM 1
#endif
//const struct LogInfo ODBLOG = {2, "***", "***", "***", "odb_lib"};
//const long COLUMN_NO_FACTOR = 100000000; //wqx 2018-08-01
//const long SERILA_NO_FACTOR = 100000000; //wqx 2018-08-01
//const long AREA_NO_FACTOR = 1000000; //wqx 2018-09-10
//const long COLUMN_NO_FACTOR = AREA_NO_FACTOR * SERILA_NO_FACTOR;//wqx 2018-09-10
const long COLUMN_NO_FACTOR = 10000;//2018-10-08
const int MAX_DB_NUMBER = 999999;//16000;
const int MAX_AREA_NUM = 256;
// 2002-10-17
const int MAX_APP_TABLE = 256; //for each application
const int MAX_CONTEXT_NUM = 64;
const int MAX_APP_NUM = 256;
const int MAX_TABLE_FIELD = 512; //512
const short MAX_CONTEXT_NO = 16384;
/*----------------------------------------------------------------------------*/
const int MAX_SUBKEY_NUMBER = 10;
const unsigned int MAX_KEY_LEN = 40;
const unsigned int MAX_FILE_PATH_LEN = 40;
const unsigned int MAX_NAME_STRING_LEN = 40;
const unsigned int MAX_DATAFIELD_LEN = 16;
const unsigned int MAX_PASSWD_LEN = 8;
const unsigned int MAX_SUB_SCENARIO_INST_PER_ALLOC = 99;
const unsigned int MAX_SUB_SCENARIO_PER_ALLOC = 99;
const unsigned int MAX_SCENARIO_INST_ALLOC = 99;
const unsigned int ENG_NAME_LEN = 32;
const unsigned int CHN_NAME_LEN = 64;
const unsigned int ORIGIN_MENU_NAME_LEN = 40;
const unsigned int MENU_NAME_LEN = 64;
const unsigned int MENU_DISPLAY_LEN = 40;
const unsigned int DEFAULT_VALUE_LEN = 20;
const unsigned int ARRAY_NAME_LEN = 32;
const unsigned int DESCRIPTION_LEN = 100;
/*----------------------------------------------------------------------------*/
const unsigned int RECORD_HEAD_LEN = 4;
const unsigned int MV_SIZE = 1024;
const unsigned int INT_ADDRESS_ASSIGN = 4;
const unsigned int MAX_PHY_RECORD_LEN = 15000;
const int RTDB_APP_MOD = AF_AP_MOD; //change from 100 at 2004-07-14
const int ORB_TRY_TIMES = 3 ; //initial 20
/*----------------------------------------------------------------------------*/
const int RTDB_SYSTEM_SEM_KEY = 0x20000;
const int RTDB_APP_SEM_KEY = 0x20010;
//const int RTDB_TABLE_SEM_KEY = 0x3200;
const int RTDB_TABLE_SEM_KEY = 0x201;
/***************for CKeyManager SHMKEY and SEMKEY Begin******************************/
const int RTDB_TABLE_SHM_KEY = 0x8000;
const int RTDB_TABLE_SHAREMEMORY_SHM_KEY = 0x90000;
const int RTDB_KEY_MANAGE_SHM_KEY = 0x7999;
const int RTDB_KEY_MANAGE_SEM_KEY = 0x20001;
/***************for CKeyManager SHMKEY and SEMKEY End *******************************/
const int MAX_SEM_NUM = 25;
const int RTDB_SEM_NUM = 12;
/*----------------------------------------------------------------------------*/
const short ENTITY_APP = 1;
const short ENTITY_TABLE = 2;
const short ENTITY_FIELD = 3;
const unsigned char MODE_CHN = 0;
const unsigned char MODE_ENG = 1;
const unsigned char MODE_NAME_BY_NO = 0;
const unsigned char MODE_NO_BY_NAME = 1;
/*----------------------------------------------------------------------------*/
const char PATH_VIRGULE = '/';
//#else
//
//const char PATH_VIRGULE = '\';
//
//#endif
/*----------------------------------------------------------------------------*/
const int MODE_API = 1;
// CONDITION_TYPE: condition_type
/*----------------------------------------------------------------------------*/
const short SIMPLE_CON = 0;
const short MULTI_CON = 1;
const short HIS_SIMPLE_CON = 2;
const short HIS_MULTI_CON = 3;
const short XY_CURVE_CON = 4;
const short TABLE_CON = 5;
const short STATISTIC_CON = 6;
/* ---------------------------------------------------------------------------*/
/* Db data type */
typedef unsigned char DATA_TYPES_T; //可以考虑为enum
/* -----------------------------------------------------------
DB_OBJECT_T: 2002-10-22
---------------------------------------------------------- */
enum DB_OBJECT_T
{
OBJECT_NONE = 0,
OBJECT_SYSTEM = 1,
OBJECT_APP = 2,
OBJECT_TABLE = 3
};
/* -----------------------------------------------------------
DB_LOCK_T: 2002-10-22
---------------------------------------------------------- */
enum DB_LOCK_T
{
DB_LOCK_NONE = 0,
DB_LOCK_READ = 1,
DB_LOCK_WRITE = 2,
DB_LOCK_INTEND = 3
};
/* -----------------------------------------------------------
DB_BYTE_T: 2002-10-22
---------------------------------------------------------- */
enum DB_BYTE_T
{
BYTE_LITTLE_ENDIAN = 0,
BYTE_BIG_ENDIAN,
BYTE_OTHER
};
/* -----------------------------------------------------------
DB_CONTEXT_T: 2002-10-18
---------------------------------------------------------- */
enum DB_CONTEXT_T
{
CONTEXT_REAL_TIME = 0,
CONTEXT_RESEARCH,
CONTEXT_INSTRUCT,
CONTEXT_HISTORY = 3,
CONTEXT_NONE = 4
};
/* -----------------------------------------------------------
DB_STATUS_T: 2002-10-16
---------------------------------------------------------- */
enum DB_STATUS_T
{
TABLE_INIT = 0, //系统初始化,表未创建
TABLE_NORMAL = 1, //已经创建
TABLE_DELETED = 2, //创建后删除
TABLE_ERROR =3 ,//表或者索引出现错误,需要修复。
TABLE_DOWNLOADING = 4 //表正在下装下装结束后状态置成TABLE_NORMAL
};
/* -----------------------------------------------------------
DB_CLASS_T: db_class
---------------------------------------------------------- */
enum DB_CLASS_T
{
STDB = 0,
VIEW = 1
};
/* -----------------------------------------------------------
DB_TYPES_T: db_type
---------------------------------------------------------- */
enum DB_TYPES_T
{
DATA = 0,
INDEX = 1
};
/* -----------------------------------------------------------
DB_MEDIA_T: db_media
---------------------------------------------------------- */
enum DB_MEDIA_T
{
MEMORY = 0,
DISK = 1
};
/* -----------------------------------------------------------
INDEX_TYPE_T: index_type
---------------------------------------------------------- */
enum INDEX_TYPE_T
{
KEYWORD = 0,
RECORD_POINTER = 1
};
const int RTDB_NOT_USED = 0;
const int RTDB_USED = 1;
/* ---------------------------------------------------------
DATA_TYPES_T: db data type
--------------------------------------------------------- */
const int C_STRING_TYPE = 1;
const int C_UCHAR_TYPE = 2;
const int C_SHORT_TYPE = 3;
const int C_INT_TYPE = 4;
const int C_DATETIME_TYPE = 5;
const int C_FLOAT_TYPE = 6;
const int C_DOUBLE_TYPE = 7;
const int C_KEYID_TYPE = 8;
const int C_BINARY_TYPE = 9;
const int C_TEXT_TYPE = 10;
const int C_IMAGE_TYPE = 11;
const int C_APPKEY_TYPE = 12;
const int C_APPID_TYPE = 13;
const int C_UINT_TYPE = 14;
const int C_LONG_TYPE = 15;
const int C_RTDBKEY_TYPE = 16;
const int C_MEASRTDBKEY_TYPE = 17;
const int C_APPRTDBKEY_TYPE = 18;
const int C_SCNRTDBKEY_TYPE = 19;
/* ---------------------------------------------------------
DATA_TYPES_DISPLAY: db data type
--------------------------------------------------------- */
enum DATA_DISPLAY_T
{
D_CHAR_TYPE = 1,
D_UCHAR_TYPE = 2,
D_SHORT_TYPE = 3,
D_INT_TYPE = 4,
D_LONG_TYPE = 5,
D_FLOAT_TYPE = 6,
D_DOUBLE_TYPE = 7,
D_SINGLEMENU_TYPE = 8,
D_MUTIMENU_TYPE = 9,
D_STRING_TYPE = 10,
D_DATE_TYPE = 11,
D_TIME_TYPE = 12,
D_DATETIME_TYPE = 13,
D_MULTISTRING_TYPE = 14,
D_KEYID_TYPE = 15,
D_BINARY_TYPE = 16,
D_PASSWORD_TYPE = 17,
D_TEXT_TYPE = 18,
D_IMAGE_TYPE = 19,
D_FORMULASTRING_TYPE = 20,
D_FIELD_NAME_STRING_TYPE = 21
};
const int MENU_ALL = 2;
const int MENU_OFF = 1;
const int MENU_ON = 0;
/* -------------------------------------------------------------
ACCESS_METHODS_T: db storage methods
------------------------------------------------------------- */
enum ACCESS_METHODS_T
{
ACCESS_SEQUENT = 0,
ACCESS_DIRECT = 1,
ACCESS_HASH = 2,
ACCESS_DIRECT_HASH = 3,
ACCESS_HASH_INDEX = 4,
ACCESS_DIRECTINDEX_HASH = 5,
ACCESS_FLOW = 6,
ACCESS_NAMEID_HASH = 7,
ACCESS_DIRECTINDEX_FLOW = 8,
ACCESS_FIELD_SEQUENT_HASH = 9
};
/* -------------------------------------------------------------
PHY_ACCESS_METHODS_T: db physical storage methods
------------------------------------------------------------- */
enum PHY_ACCESS_METHODS_T
{
PHY_SEQUENT_ACCESS = 0,
PHY_LINK_ACCESS = 1,
PHY_BLOCKLINK_ACCESS = 2
};
/* -------------------------------------------------------------
sequent order
------------------------------------------------------------- */
#define ASC 0
//#define DEC 1
#define ODB_DEC 1
/* ------------------------------------------------------------
db open mode
------------------------------------------------------------ */
#define READ_OPEN 0
#define WRITE_OPEN 1
#define RDWR_OPEN 2
/* ------------------------------------------------------------
db record head status
------------------------------------------------------------ */
#define RECORD_EMPTY 0
#define RECORD_EXIST 1
#define RECORD_ERASED 3
/* ------------------------------------------------------------
db lock type
------------------------------------------------------------ */
#define RECORD_LOCK 0x01
#define FIELD_LOCK 0x02
/* ------------------------------------------------------------
db lock status
------------------------------------------------------------ */
#define UNLOCK 0
#define LOCK 1
/*------------------------------------------------------------------------------
keyword type
------------------------------------------------------------------------------*/
const int INT_KEY = 1;
const int STRING_KEY = 2;
const int INT_STRING_KEY = 3;
const int KEYID_KEY = 4;
const int APPKEY_KEY = 5;
const int APPID_KEY = 6;
const int LONG_KEY = 7;
const int RTDBKEY_KEY = 8;
const int MEASRTDBKEY_KEY = 9;
/* -------------------------------------------------------------
------------------------------------------------------------- */
#define ALL_FIELD -1
#define ALL_RECORD -1
/*------------------------------------------------------------------------------
real time dbms error retcode 2002-10-14
------------------------------------------------------------------------------*/
const int DB_OK = 0; /* success */
const int DB_ERROR = ERR_RTDB_ERROR; /* error */
const int DBE_PARA = ERR_RTDB_PARA; /* bad para_parameter */
const int DBE_CHAOS = ERR_RTDB_CHAOS; /* inner error */
const int DBE_BLOCK = -7;
//access
const int DBE_ACCESSMETH = ERR_RTDB_ACCESSMETH; /* access_meth is error */
const int DBE_EXIST = ERR_RTDB_EXIST; /* Db name is exist, cannot creat */
const int DBE_NODB = ERR_RTDB_NODB; /* Db name not founded */
const int DBE_INVDBNO = ERR_RTDB_INVDBNO; /* Db no is wrong */
const int DBE_INVFNAME = ERR_RTDB_INVFNAME; /* Field name not founded */
const int DBE_HASOPENED = ERR_RTDB_HASOPENED; /* The db has been opened */
const int DBE_FILE_NOPEN = ERR_RTDB_FILE_NOPEN; /* The file cannot open */
const int DBE_READ_FILE = ERR_RTDB_READ_FILE; /* The file cannot read */
const int DBE_APP_NO_DB = ERR_RTDB_APP_NO_DB; /* This table isn't in current application */
const int DBE_DB_NONE = ERR_RTDB_DB_NONE; /* The table is deleted or hasn't been created*/
//lock
const int DBE_LOCK = ERR_RTDB_LOCK; /* The db is locked */
const int DBE_UNLOCK = ERR_RTDB_UNLOCK; /* The db isnot locked */
const int DBE_INVUNLOCK = ERR_RTDB_INVUNLOCK; /* locker is not me */
const int DBE_NOINDEX = ERR_RTDB_NOINDEX; /* havenot index */
const int DBE_DIFFSIZE = ERR_RTDB_DIFFSIZE; /* size is different */
const int DBE_NOTCHKEY = ERR_RTDB_NOTCHKEY; /* ?? */
const int DBE_NOCACHE = ERR_RTDB_NOCACHE; /* no cache block */
const int DBE_NOTE_NEND = ERR_RTDB_NOTE_NEND; /* NOTE must be last field */
const int DBE_CTRLFULL = ERR_RTDB_CTRLFULL; /* The db ctrl table is full */
const int DBE_DBFULL = ERR_RTDB_DBFULL; /* The db is full */
const int DBE_EODB = ERR_RTDB_EODB; /* End of Database */
const int DBE_INVSIZE = ERR_RTDB_INVSIZE; /* The size is invalid */
const int DBE_DBBEGIN = ERR_RTDB_DBBEGIN; /* Have reach the begin of db */
const int DBE_DBEND = ERR_RTDB_DBEND; /* Have reach the end of db */
const int DBE_INVCCOMM = ERR_RTDB_INVCCOMM; /* Invalid comparition command */
const int DBE_TMOPEN = ERR_RTDB_TMOPEN; /* Too many open */
////key
const int DBE_KEYNOTFIND = ERR_RTDB_KEYNOTFIND; /* keyword not founded */
const int DBE_MULTIKEY = ERR_RTDB_MULTIKEY; /* Multi-keywords */
const int DBE_INVKEY = ERR_RTDB_INVKEY; /* The keyword is invalid */
const int DBE_MKEYFIELD = ERR_RTDB_MKEYFIELD; /* The keyword field can be only one */
const int DBE_KEYFLEN = ERR_RTDB_KEYFLEN; /* The keyword length must be 4 times*/
const int DBE_DBTYPE = ERR_RTDB_DBTYPE; /* Invalid db type */
const int DBE_KEYTYPE = ERR_RTDB_KEYTYPE; /* Invalid keyword type */
const int DBE_PASSWD = ERR_RTDB_PASSWD; /* Invalid passwd */
////table
const int DBE_TABLE_NO = ERR_RTDB_TABLE_NO; /* no match table or no*/
const int DBE_TABLE_STA = ERR_RTDB_TABLE_STA; /* table status is abnormal */
////record
const int DBE_EXISTREC = ERR_RTDB_EXISTREC; /* Record existed, cannot write */
const int DBE_NEXISTREC = ERR_RTDB_NEXISTREC; /* Record not existed, cannot modify */
const int DBE_SUPMAX = ERR_RTDB_SUPMAX; /* record value too bigger */
const int DBE_BELMIN = ERR_RTDB_BELMIN; /* record value too smaller */
const int DBE_RECSIZE = ERR_RTDB_RECSIZE; /* record size wrong */
const int DBE_NOTERASE = ERR_RTDB_NOTERASE; /* record not erased */
const int DBE_RECERASE = ERR_RTDB_RECERASE; /* The record is erased */
const int DBE_POINTER = ERR_RTDB_POINTER; /* record_pointer error */
const int DBE_CONT_ERR = ERR_RTDB_CONT_ERR; /* condition express error */
const int DBE_NEED_CHK = ERR_RTDB_NEED_CHK; /* something wrong, need to check record state*/
////field
const int DBE_DATATYPE = ERR_RTDB_DATATYPE; /* field data type is wrong */
const int DBE_DIFFTYPE = ERR_RTDB_DIFFTYPE; /* type is different */
const int DBE_KEYFIELD = ERR_RTDB_KEYFIELD; /* The field is keyword */
const int DBE_BIGFIELDNO = ERR_RTDB_BIGFIELDNO; /* The field no is too big */
const int DBE_DLT_WRITE = ERR_RTDB_DLT_WRITE; /* The direct link hash cannot write */
const int DBE_INVFIELDNO = ERR_RTDB_INVFIELDNO; /* field_no is wrong */
const int DBE_NOTFIND = ERR_RTDB_NOTFIND; /* Not find the value */
const int DBE_FIELD_NO = ERR_RTDB_FIELD_NO; /* no match field name or no */
const int DBE_FIELD_SIZE = ERR_RTDB_FIELD_SIZE; /* field length wrong */
const int DBE_NONE_FIELD = ERR_RTDB_NONE_FIELD; /* this table has no field */
//operation
const int DBE_INVCOMM = ERR_RTDB_INVCOMM; /* Invalid db operater command */
const int DBE_NPERMIT = ERR_RTDB_NPERMIT; /* The OP is not permit */
const int DBE_CONTEXT = ERR_RTDB_CONTEXT; /* no context or application */
const int DBE_APP_UNLOAD = ERR_RTDB_APP_UNLOAD; /* application isn't loaded */
const int DBE_SQL_COMMAND = ERR_RTDB_SQL_COMMAND; /*select error*/
const int DBE_SQL_FORM = ERR_RTDB_SQL_FORM; /*form error*/
const int DBE_SQL_WHERE = ERR_RTDB_SQL_WHERE; /*where condition error*/
const int DBE_SQL_ORDER = ERR_RTDB_SQL_ORDER; /*order by error*/
//memory
const int DBE_MEMORY = ERR_RTDB_MEMORY; /* Cannot malloc or calloc memory */
const int DBE_BUFFFULL = ERR_RTDB_BUFFFULL; /* Buffer is full */
const int DBE_MEM_NOALLOC = ERR_RTDB_MEM_NOALLOC; /* The memory cannot allocation */
const int DBE_MAP = ERR_RTDB_MAP; /* map file error */
//const int DBE_PTABFULL = -10; /* process tab is full */
//sql
const int DBE_SQL = ERR_RTDB_SQL; /* sql syntax error */
//
const int DBE_DBNAMENOTF = ERR_RTDB_DBNAMENOTF; /* db_name not founded */
const int DBE_FACNAMENOTF = ERR_RTDB_FACNAMENOTF; /* fac_name not founded */
const int DBE_VALNAMENOTF = ERR_RTDB_VALNAMENOTF; /* val_name not founded */
const int DBE_FIELDNAMENOTF = ERR_RTDB_FIELDNAMENOTF; /* field_name not founded */
//
const int DBE_VIEWFIELD = ERR_RTDB_VIEWFIELD; /* view get fieldnum over error */
const int DBE_SYBASE = ERR_RTDB_SYBASE; /* modify sybase error */
const int DBE_INDEXERR = ERR_RTDB_INDEXERR; /* index number error */
const int DBE_MODIFYSIZE = ERR_RTDB_MODIFYSIZE; /* modify bufsize error */
const int API_INVCOMM = ERR_RTDB_API_INVCOMM; /* Invalid db operater command */
const int API_NOAPP = ERR_RTDB_API_NOAPP; /* App name not founded */
const int API_NODB = ERR_RTDB_API_NODB; /* Db name not founded */
const int API_INVDBNO = ERR_RTDB_API_INVDBNO; /* Db no is wrong */
const int API_NODEOFF = ERR_RTDB_API_NODEOFF; /* node is offline */
const int API_ERRINIT = ERR_RTDB_API_ERRINIT; /* odbms init error */
const int API_NEWERR = ERR_RTDB_API_NEWERR; /* new space error */
const int API_DATAERR = ERR_RTDB_API_DATAERR; /* data tye error */
const int DBE_NOSPACE = ERR_RTDB_NOSPACE; /* no space left in disk */
/* -----------------------------------------------------------
for sql query: 2002-10-31
---------------------------------------------------------- */
enum CONDITION_OPERATOR_T
{
SQL_COND_LSC = 10, /* < */
SQL_COND_LEC = 11, /* <= */
SQL_COND_EQC = 12, /* == */
SQL_COND_GEC = 13, /* >= */
SQL_COND_GTC = 14, /* > */
SQL_COND_NEQ = 15 /* != */
};
enum LOGICAL_OPERATOR_T
{
SQL_LOG_AND = 16, /* && */
SQL_LOG_OR = 17, /* || */
SQL_LOG_NOT = 18, /* ~ */
SQL_LOG_NONE= 20
};
enum SQL_METHOD_T
{
METHOD_SELECT = 1,
METHOD_UPDATE = 2,
METHOD_DELETE = 3,
METHOD_CREATE = 4
};
#define DEF_SHMMEM 0
//SLICED_DB
const int TBL_SLICED = 1;
const int TBL_UNSLICED = 0;
//for DSCADA & SCADA
//app_area_no
#define DRTDB_APP_AREA AP_DSCADA_AREA
//app_area_no
//#define DRTDB_APP_NO AP_DMS_SCADA
#define DRTDB_APP_NO AP_SCADA
//dscada 1, scada 0
#define DRTDB_DMS 1
/******************************************************************************
* debug display option *
******************************************************************************/
#define DBG_INDEX_STDB_TAB 1
#define DBG_INDEX_STDB_FIELD_TAB 2
#define DBG_STDB_INDEX_HASH 3
#define DBG_FREE_POINTER 4
#define DBG_INDEX_STG 5
#define DBG_INDEX_OVERFLOW 6
#define DBG_ALL 7
#endif

View File

@@ -0,0 +1,84 @@
/*******************************************************************************
ModuleName: Real Time Database management system
FileName: rtdb_api.cpp
DESCRIPTION: rtdb api interfaces implementation
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
2009-01-10 1.1 add net interfaces
================================================================================
2008-10-30 1.0 created
*******************************************************************************/
#include "db_api/odb_baseindex.h"
#ifndef _CDOUBLEOVERFLOWHASHINDEX
#define _CDOUBLEOVERFLOWHASHINDEX
namespace ODB
{
class CDoubleOverFlowHashIndex:public CBaseIndex
{
public:
virtual int need_rebuilt(char *existed_table_ptr,struct STDB_TAB *stdb_tab_ptr,struct STDB_FIELD_TAB *stdb_field_tab_ptr,INDEX_DEFINE &index_define,int &shm_id);
virtual int CreateIndex(struct STDB_TAB *stdb_tab_ptr,struct STDB_FIELD_TAB *stdb_field_tab_ptr,INDEX_DEFINE &index_define,int &shm_id,int &shm_size);
virtual int Open(char *index_file_name,int table_id,int index_id); //table_id、index_id用来和INDEX_STDB_TAB::table_id、INDEX_STDB_TAB::field_id匹配校验
virtual int Open(int index_shmid,int table_id,int index_id); //table_id、index_id用来和INDEX_STDB_TAB::table_id、INDEX_STDB_TAB::field_id匹配校验
virtual int SetIndexPtr(char *index_ptr); //把缓存的指针赋值给索引类这样就不用使用前面的Open函数。
virtual int GetKeyByIndex(char *index_ptr,std::vector<char *> &index_array);
virtual int GetKeyPointerByIndex(char *index_ptr, int& pointer);//只对主键索引有效根据index得到记录的物理位置
virtual int IndexInsert(char *index_ptr,char *key_ptr);
virtual int BulkIndexInsert(char *bulk_index_key_ptr);//下装的时候
virtual int Indexdelete(char *index_ptr,char *key_ptr);
virtual int IndexClear();
virtual int GetIdxMthd();
virtual int FreeResource();//譬如unmap或者shmdt掉指针。
virtual int DebugDisp(int type);//方便调试用不同的type显示不同或者详细程度不同的信息。
virtual int GetIndexRecNum();//返回索引记录总的个数包括索引区、溢出区、主溢出区有效记录个数的总和。但是无溢出HASH索引只是返回0。
virtual DB_STATUS_T GetIndexStatus()//返回索引的状态
{
return m_IndexStdbPtr->index_status;
}
virtual void SetIndexStatus(DB_STATUS_T idx_status)//设置索引头上的索引状态
{
m_IndexStdbPtr->index_status = idx_status;
}
~CDoubleOverFlowHashIndex();//考虑在析构函数里面调用FreeResource()
private:
int malloc_chunk(int &new_record_pointer);
int pri_malloc_chunk(int &new_record_pointer);
int free_chunk(struct INDEX_STORAGE_HASH_DOVERFLOW_REC_HEAD* root_index_stg_head_ptr, int unused_record_pointer);
int free_chunk(struct INDEX_STORAGE_HASH_DOVERFLOW_REC_HEAD* root_index_stg_head_ptr, struct PRIMARY_OVERFLOW_STORAGE_HASH_REC_HEAD* pri_ofl_stg_head_ptr, int unused_record_pointer);
int pri_free_chunk(struct INDEX_STORAGE_HASH_DOVERFLOW_REC_HEAD* root_index_stg_head_ptr, int unused_record_pointer);
int index_equal(char *outer_index_ptr,char *inner_index_ptr);
private:
int disp_index_stdb_tab();
int disp_index_stdb_field_tab();
int disp_stdb_index_hash_doverflow();
int disp_free_pointer();
int disp_index_stg();
int disp_index_overflow();
int disp_index_pri_overflow();
int disp_all();
int disp_index_contents(char *index_ptr);
int disp_key_contents(char *key_ptr);
//int test_insert();
private:
struct INDEX_STDB_TAB *m_IndexStdbPtr;
struct INDEX_STDB_FIELD_TAB *m_IndexStdbFieldPtr;
struct STDB_INDEX_HASH_DOVERFLOW *m_StdbIndexHashPtr;
int *m_FreePointer;//溢出区malloc_chunk和free_chunk使用。
int *m_PriFreePointer;// 给主溢出区pri_malloc_chunk和pri_free_chunk使用。
char *m_IndexStgHashPtr;
char *m_PriOverflowStgHashPtr;
char *m_OverflowStgHashPtr;
int (*hash_func_ptr)(char *index,int length,int hash_prime);
};
}
#endif

View File

@@ -0,0 +1,85 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_field.h
DESCRIPTION: class table struct define
FUNCTION LIST:
COMMENT: field struct define
History:
Date Version Modifier Activities
2002-10-10 1.0 modify
================================================================================
2002-10-10 1.0 created
*******************************************************************************/
#ifndef __ODB_FIELD_H__
#define __ODB_FIELD_H__
#include "db_api/odb_public.h"
//#include "odb_struct.h"
#include "db_api/odb_prv_struct.h"
#include "db_api/odb_common.h"
using namespace std;
namespace ODB
{
//字段访问类
class COdbField
{
public:
COdbField();
COdbField(const char* db_area_ptr); //表头位置
COdbField(const char* db_area_ptr, int r_field_no); //表头位置 + 商用字段号
COdbField(const char* db_area_ptr, char* field_name);
~COdbField();
int SetFieldTabPtr(const char* db_area_ptr);//设置本字段控制区信息
int SetRecordPtr(char* record_ptr); //设置表的当前记录位置
//移动到指定字段位置
int MoveTo(const int r_field_no); //根据field_no定位到当前app,table的STDB_FIELD_TAB
int MoveTo(const char* field_name);
int MoveToByChn(const char* field_name);
//查询
char* GetFieldName(); //return a pointer
int GetFieldName(char* field_name); //get_fieldname_by_fieldno()//copy to a array
int GetFieldChnName(char* field_name);
int SetFieldName(const char* field_name); //set chinese field name
int GetFieldNo(bool is_real = false); //get_fieldno_by_fieldname()
int GetFieldPara(int& data_type, int& offset, int& field_length, int& is_keyword); //get_field_para_byno()
int GetFieldLength(int& field_length);
int GetLimitValue(char* field_value_ptr, const int buf_size); //limited data length
int GetFieldValue(char** field_value_ptr);
int GetFieldValue(char** field_value_ptr, int& field_length);
int GetFieldValue(char** field_value_ptr, int& field_length, const int r_field_no);
int SetFieldValue(const char* modify_field_ptr, const int modify_field_length);
private:
COdbField(const COdbField& odb_field);
COdbField& operator=(const COdbField& odb_field);
private:
// struct STDB_TAB* stdb_tab_ptr; //表首指针
// struct STDB_FIELD_TAB* stdb_field_tab_ptr; //字段首控制区信息,从OdbTable得到
// struct STDB_FIELD_TAB* cur_field_tab_ptr; //当前字段控制区信息
// char* cur_record_ptr; //当前记录数据
struct STDB_TAB* m_StdbTabPtr; //表首指针
struct STDB_FIELD_TAB* m_StdbFieldTabPtr; //字段首控制区信息,从OdbTable得到
struct STDB_FIELD_TAB* m_CurFieldTabPtr; //当前字段控制区信息
char* m_CurRecordPtr; //当前记录数据
#ifdef _APP_SYS_SUBSTATION
struct STDB_VIR_FIELD_TAB* m_StdbVirFieldTabPtr; //虚拟字段首控制区信息,从OdbTable得到
struct STDB_VIR_FIELD_TAB* m_CurVirFieldTabPtr; //当前虚拟字段首控制区信息
bool m_CurIsVirtual; //当前域号对应的是虚拟域号,要取虚拟域值
#endif
};
}
#endif

View File

@@ -0,0 +1,72 @@
/*******************************************************************************
ModuleName: Real Time Database management system
FileName: rtdb_api.cpp
DESCRIPTION: rtdb api interfaces implementation
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
2009-01-10 1.1 add net interfaces
================================================================================
2008-10-30 1.0 created
*******************************************************************************/
#include "db_api/odb_baseindex.h"
#include "db_api/odb_ckeymanager.h"
#ifndef _CHASHINDEX
#define _CHASHINDEX
namespace ODB
{
class CHashIndex:public CBaseIndex
{
public:
virtual int need_rebuilt(char *existed_table_ptr,struct STDB_TAB *stdb_tab_ptr,struct STDB_FIELD_TAB *stdb_field_tab_ptr,INDEX_DEFINE &index_define,int &shm_id);
virtual int CreateIndex(struct STDB_TAB *stdb_tab_ptr,struct STDB_FIELD_TAB *stdb_field_tab_ptr,INDEX_DEFINE &index_define,int &shm_id,int &shm_size);
virtual int Open(char *index_file_name,int table_id,int index_id); //table_id、index_id用来和INDEX_STDB_TAB::table_id、INDEX_STDB_TAB::field_id匹配校验
virtual int Open(int index_shmid,int table_id,int index_id); //table_id、index_id用来和INDEX_STDB_TAB::table_id、INDEX_STDB_TAB::field_id匹配校验
virtual int SetIndexPtr(char *index_ptr); //把缓存的指针赋值给索引类这样就不用使用前面的Open函数。
virtual int GetKeyByIndex(char *index_ptr,std::vector<char *> &index_array);
virtual int GetKeyPointerByIndex(char *index_ptr, int& pointer);//只对主键索引有效根据index得到记录的物理位置
virtual int IndexInsert(char *index_ptr,char *key_ptr);
virtual int BulkIndexInsert(char *bulk_index_key_ptr);//下装的时候
virtual int Indexdelete(char *index_ptr, char* key);
virtual int IndexClear();
virtual int GetIdxMthd();
virtual int FreeResource();//譬如unmap或者shmdt掉指针。
virtual int DebugDisp(int type);//方便调试用不同的type显示不同或者详细程度不同的信息。
virtual int GetIndexRecNum();//返回索引记录总的个数包括索引区、溢出区、主溢出区有效记录个数的总和。但是无溢出HASH索引只是返回0。
virtual DB_STATUS_T GetIndexStatus()//返回索引的状态
{
return m_IndexStdbPtr->index_status;
}
virtual void SetIndexStatus(DB_STATUS_T idx_status)//设置索引头上的索引状态
{
m_IndexStdbPtr->index_status = idx_status;
}
~CHashIndex();//考虑在析构函数里面调用FreeResource()
char * next2Ptr(int next);
int freeChunk(int pointer);
char* mallocChunk(int & pos);
int keycmp(char * key1 , char * key2);//{return 0;}
int index_equal(char * outer , char * innter);
int DebugDisp(int type , char * ptr);
private:
struct INDEX_STDB_TAB *m_IndexStdbPtr;
struct INDEX_STDB_FIELD_TAB *m_IndexStdbFieldPtr;
struct STDB_INDEX_HASH *m_StdbIndexHashPtr;
int *m_FreePointer;//溢出区malloc_chunk和free_chunk使用。
char *m_IndexStgHashPtr;
char *m_OverflowStgHashPtr;
int (*hash_func_ptr)(char *index,int length,int hash_prime);
int idxLenFlag ;
};
}
#endif

View File

@@ -0,0 +1,73 @@
/*******************************************************************************
ModuleName: Real Time Database management system
FileName: rtdb_api.cpp
DESCRIPTION: rtdb api interfaces implementation
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
2009-01-10 1.1 add net interfaces
================================================================================
2008-10-30 1.0 created
*******************************************************************************/
#include "db_api/odb_baseindex.h"
#ifndef _CHASHPK
#define _CHASHPK
namespace ODB
{
class CHashPK:public CBaseIndex
{
public:
virtual int need_rebuilt(char *existed_table_ptr,struct STDB_TAB *stdb_tab_ptr,struct STDB_FIELD_TAB *stdb_field_tab_ptr,INDEX_DEFINE &index_define,int &shm_id);
virtual int CreateIndex(struct STDB_TAB *stdb_tab_ptr,struct STDB_FIELD_TAB *stdb_field_tab_ptr,INDEX_DEFINE &index_define,int &shm_id,int &shm_size);
virtual int Open(char *index_file_name,int table_id,int index_id); //table_id、index_id用来和INDEX_STDB_TAB::table_id、INDEX_STDB_TAB::field_id匹配校验
virtual int Open(int index_shmid,int table_id,int index_id); //table_id、index_id用来和INDEX_STDB_TAB::table_id、INDEX_STDB_TAB::field_id匹配校验
virtual int SetIndexPtr(char *index_ptr); //把缓存的指针赋值给索引类这样就不用使用前面的Open函数。
virtual int GetKeyByIndex(char *index_ptr,std::vector<char *> &index_array);
virtual int GetKeyPointerByIndex(char *index_ptr, int& pointer);//只对主键索引有效根据index得到记录的物理位置
virtual int IndexInsert(char *index_ptr,char *key_ptr);
virtual int BulkIndexInsert(char *bulk_index_key_ptr);//下装的时候
virtual int Indexdelete(char *index_ptr,char *key_ptr);
virtual int IndexClear();
virtual int GetIdxMthd();
virtual int FreeResource();//譬如unmap或者shmdt掉指针。
virtual int DebugDisp(int type);//方便调试用不同的type显示不同或者详细程度不同的信息。
virtual int GetIndexRecNum();//返回索引记录总的个数包括索引区、溢出区、主溢出区有效记录个数的总和。但是无溢出HASH索引只是返回0。
virtual DB_STATUS_T GetIndexStatus()//返回索引的状态
{
return m_IndexStdbPtr->index_status;
}
virtual void SetIndexStatus(DB_STATUS_T idx_status)//设置索引头上的索引状态
{
m_IndexStdbPtr->index_status = idx_status;
}
//virtual int ModifyIndex(char *pk_ptr, int pos);
~CHashPK();//考虑在析构函数里面调用FreeResource()
private:
struct INDEX_STDB_TAB *m_IndexStdbPtr;
struct INDEX_STDB_FIELD_TAB *m_IndexStdbFieldPtr;
struct STDB_INDEX_HASH *m_StdbIndexHashPtr;
int *m_FreePointer;//溢出区malloc_chunk和free_chunk使用。
char *m_IndexStgHashPtr;
char *m_OverflowStgHashPtr;
int (*hash_func_ptr)(char *index,int length,int hash_prime);
int index_equal(char *outer_index_ptr,char *inner_index_ptr);
int malloc_chunk(int &new_record_pointer);
int free_chunk(struct INDEX_STORAGE_HASH_REC_HEAD *root_index_stg_head_ptr,int unused_record_pointer);
int assign_index(char *dest_index_ptr,char *sour_index_ptr);
int disp_index_stdb_tab();
int disp_index_stdb_field_tab();
int disp_stdb_index_hash();
int disp_free_pointer();
int disp_index_stg();
int disp_index_overflow();
int disp_all();
int disp_index_contents(char *index_ptr);
int disp_key_contents(char *key_ptr);
};
}
#endif

View File

@@ -0,0 +1,66 @@
#ifndef _ODB_INTEL_PTR
#define _ODB_INTEL_PTR
#include <vector>
template <class T> class CIntelPtr
{
private:
T *m_Ptr;
CIntelPtr(const CIntelPtr &);
CIntelPtr& operator=(const CIntelPtr &);
public:
CIntelPtr(){m_Ptr = NULL;}
void SetPtr(T* t_ptr)
{
if(m_Ptr !=NULL)
{
delete m_Ptr;
}
m_Ptr = t_ptr;
}
~CIntelPtr()
{
delete m_Ptr;
}
};
template <class T> class CIntelPtrArray
{
private:
std::vector<T *>m_PtrArray;
CIntelPtrArray(const CIntelPtrArray &);
CIntelPtrArray& operator =(const CIntelPtrArray&);
public:
CIntelPtrArray(){}
void push_back(T* t_ptr)
{
m_PtrArray.push_back(t_ptr);
return;
}
~CIntelPtrArray()
{
int i;
int vec_size = m_PtrArray.size();
for(i=0;i<vec_size;i++)
{
delete m_PtrArray[i];
}
}
T* operator[](int pos)
{
if(pos>=0 && pos<(int)(m_PtrArray.size()))
return m_PtrArray[pos];
else
return NULL;
}
int GetSize()
{
return m_PtrArray.size();
}
};
#endif

View File

@@ -0,0 +1,67 @@
/*******************************************************************************
ModuleName: ODB
FileName: odb_lock.h
DESCRIPTION:
History:
Date Version Modifier Activities
2002-10-22 1.0 modify
================================================================================
2002-10-22 1.0 created
*******************************************************************************/
#ifndef __ODB_LOCK_H__
#define __ODB_LOCK_H__
//#include "odb_struct.h"
#include "db_api/odb_prv_struct.h"
#include "db_api/odb_public.h"
namespace ODB
{
class COdbLock
{
public:
COdbLock(){};
~COdbLock(){};
static int InitLock(struct LOCK_STRU& lock);
static int ClnLock(struct LOCK_STRU& lock);
static bool CtlLock(const struct LOCK_STRU& lock, const DB_LOCK_T& lock_type);
static bool CtlUnLock(const struct LOCK_STRU& lock, const DB_LOCK_T& lock_type);
//static bool DtLock(const struct LOCK_STRU& lock, const DB_LOCK_T& lock_type);
//static bool DtUnLock(const struct LOCK_STRU& lock, const DB_LOCK_T& lock_type);
//static bool NpLock(struct LOCK_STRU& lock, const DB_LOCK_T& lock_type);
//static bool NpUnLock(struct LOCK_STRU& lock, const DB_LOCK_T& lock_type);
static bool Lock(struct LOCK_STRU& lock, const DB_LOCK_T& lock_type);
static bool UnLock(struct LOCK_STRU& lock, const DB_LOCK_T& lock_type);
static bool Lock(struct LOCK_STRU& lock, const DB_LOCK_T& lock_type, int& table_semid); //for OPTLOCK
static bool UnLock(struct LOCK_STRU& lock, const DB_LOCK_T& lock_type, int& table_semid); //for OPTLOCK
private:
static bool CtlLock(const struct LOCK_STRU& lock);
static bool CtlUnLock(const struct LOCK_STRU& lock);
static bool CtlLock(const struct LOCK_STRU& lock, int& table_semid); //for OPTLOCK
static bool CtlUnLock(const struct LOCK_STRU& lock, int& table_semid); //for OPTLOCK
//static bool DtLock(const struct LOCK_STRU& lock);
//static bool DtUnLock(const struct LOCK_STRU& lock);
static bool TryLock(struct LOCK_STRU& lock, const DB_LOCK_T& lock_type);
static bool TryLock(struct LOCK_STRU& lock, const DB_LOCK_T& lock_type, int& table_semid); //for OPTLOCK
#ifdef _WINDOWS64
static bool WinLock(const char* sem_name, const int sem_num=1);
static bool WinUnLock(const char* sem_name);
#endif
};
}
#endif

View File

@@ -0,0 +1,993 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_tablenet.h
DESCRIPTION: RTDBMS NET ACCESS INTERFACE
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
================================================================================
2009-06-09 1.0 wj created
*******************************************************************************/
const short C_DATATYPE_STRING = 1;
const short C_DATATYPE_UCHAR = 2;
const short C_DATATYPE_SHORT = 3;
const short C_DATATYPE_INT = 4;
const short C_DATATYPE_DATETIME = 5;
const short C_DATATYPE_FLOAT = 6;
const short C_DATATYPE_DOUBLE = 7;
const short C_DATATYPE_KEYID = 8;
const short C_DATATYPE_BINARY = 9;
const short C_DATATYPE_TEXT = 10;
const short C_DATATYPE_IMAGE = 11;
const short C_DATATYPE_APPKEYID = 12;
const short C_DATATYPE_APPID = 13;
const short C_DATATYPE_UINT = 14;
const short C_DATATYPE_LONG = 15;
const short C_RTDBKEY_TYPE = 16;
typedef vector<varchar> SEQ_STRING;
typedef binary SEQ_CHAR;
typedef vector<float> SEQ_FLOAT;
typedef vector<int> SEQ_LONG;
typedef vector<long> SEQ_LONGLONG;
/*------------------------------------------------------------------------------
1. RTDBMS NET ACCESS for create and delete a table
but only used by down load until now 2003-02-28
------------------------------------------------------------------------------*/
/* ---------------------------------------------------------------------
create a table
----------------------------------------------------------------------*/
typedef cmnInt64 KEYID_STRUCT;
typedef cmnUint64 unsigned long;
struct RTDB_KEY_STRU
{
cmnUint64 key_id1; //indicate table_id && column_id
cmnUint64 key_id2; //indicate area_id && serial_no/
};
struct APPKEY_STRUCT
{
int app_id;
KEYID_STRUCT key_id;
};
typedef APPKEY_STRUCT APPID_STRUCT;
struct KEYID_STATUS_STRUCT
{
KEYID_STRUCT key_id;
short status;
};
typedef vector<KEYID_STRUCT> SEQ_KEY_ID;
typedef vector<APPKEY_STRUCT> SEQ_APPKEY_ID;
typedef vector<APPID_STRUCT> SEQ_APP_ID;
typedef vector<KEYID_STATUS_STRUCT> SEQ_KEY_ID_STA;
struct union_data_type
{
int type;
union
{
varchar c_char; //C_DATATYPE_STRING
unsigned char c_uchar; //C_DATATYPE_UCHAR
short c_short; //C_DATATYPE_SHORT
int c_int; //C_DATATYPE_INT
cmnInt64 c_time; //C_DATATYPE_DATETIME
float c_float; //C_DATATYPE_FLOAT
double c_double; //C_DATATYPE_DOUBLE
KEYID_STRUCT c_keyid; //C_DATATYPE_KEYID
SEQ_CHAR c_binary; //C_DATATYPE_BINARY
SEQ_CHAR c_text; //C_DATATYPE_TEXT
SEQ_CHAR c_image; //C_DATATYPE_IMAGE
APPKEY_STRUCT c_appkeyid; //C_DATATYPE_APPKEYID
APPID_STRUCT c_appid; //C_DATATYPE_APPID
unsigned int c_uint; //C_DATATYPE_UINT
cmnInt64 c_long; //C_DATATYPE_LONG
struct RTDB_KEY_STRU c_rtdb_key; //C_C_RTDBKEY_TYPE
}val;
};
typedef vector<union_data_type> SEQ_COMMON_DATA;
struct TABLE_STRU
{
int table_no; //表号 RDBMS
short app_no;
short column_num;
varchar table_name_eng;
varchar table_name_chn;
short record_length;
int record_num;
int max_record_num;
unsigned char is_auto_generate;
unsigned char is_record_app;
};
struct COLUMN_STRU
{
short field_no; //域号 RDBMS
varchar field_name_eng;
varchar field_name_chn;
short data_length;
unsigned char data_type;
unsigned char allow_null;
unsigned char is_display;
unsigned char display_type;
short display_length;
unsigned char display_precision;
varchar menu_name;
unsigned char reference_flag;
unsigned char is_key;
unsigned char is_index;
unsigned char sort_order_no;
unsigned char reference_display;
unsigned char is_input;
unsigned char is_fix;
varchar init_value;
varchar min_value;
varchar max_value;
int reference_table;
short reference_column;
int column_special;
};
typedef vector<COLUMN_STRU> SEQ_COLUMN_INFO;
//from download idl //OutStruct
struct REQ_STDB_CREATE
{
//short app_no; //应用号
//int table_no; //表号 RDBMS
//int record_num; //记录 个数
//int field_num; //域个数
TABLE_STRU table_info; //表信息
SEQ_COLUMN_INFO column_info; //域信息
SEQ_COMMON_DATA data_value; //值
};
/* ---------------------------------------------------------------------
delete a table
----------------------------------------------------------------------*/
struct REQ_STDB_DELETE
{
short app_no;
int table_no;
varchar passwd;
};
/*------------------------------------------------------------------------------
2. RTDBMS NET ACCESS for get table and field parameter
------------------------------------------------------------------------------*/
/* ---------------------------------------------------------------------
table parameter
----------------------------------------------------------------------*/
struct TABLE_PARAMETER
{
varchar table_name_eng;
varchar table_name_chn;
int table_no; //RDBMS
int key_len;
int subkey_num;
short field_sum;
int record_number;
int record_size;
unsigned char is_auto_generated;
// int table_type; //for graph, etc
// unsigned char is_system_table; //Added 2003-09-01
// unsigned char is_record_app;
// unsigned char is_record_lock;
// unsigned char is_record_resp;
//
// int reserved_1;
// int reserved_2;
// int reserved_3;
// int reserved_4;
// int reserved_5;
};
/* ---------------------------------------------------------------------
field parameter, more 3 elements than struct COLUMN_STRU
----------------------------------------------------------------------*/
struct FIELD_PARAMETER
{
short field_no;
short r_field_no; //
short field_id; //////
short column_id; //////
varchar field_name_eng;
varchar field_name_chn;
short field_length;
unsigned char data_type;
unsigned char allow_null;
//unsigned char is_display; ////
unsigned char display_type;
//short display_length; ////
//unsigned char display_precision; ////
varchar menu_name;
unsigned char reference_flag;
unsigned char is_keyword;
unsigned char is_index;
int offset; //
int check_tag; //
unsigned char sort_order_no;
unsigned char reference_mode; //////
unsigned char reference_display;
//unsigned char is_input; ////
//unsigned char is_fix; ////
unsigned char is_app_syn; //////
unsigned char auto_meas_type; //////
varchar default_asciival;
varchar min_asciival;
varchar max_asciival;
int ref_tableno;
short ref_fieldno;
#ifdef _APP_SYS_SUBSTATION
short is_bit_field;
#endif
//unsigned char column_special;
int column_special;
int search_attribute; //Added 2003-09-01
int statics_attribute;
int reserved_1;
int reserved_2;
int reserved_3;
int reserved_4;
int reserved_5;
};
struct R_FIELD_BASE_INFO
{
int offset;
int field_length;
short field_no;
unsigned char data_type;
unsigned char is_keyword;
};
typedef vector<R_FIELD_BASE_INFO> SEQ_FIELD_BASE_INFO;
/*------------------------------------------------------------------------------
3. RTDBMS NET DATA ACCESS structure for get, write, delete, modify, update
------------------------------------------------------------------------------*/
/* ---------------------------------------------------------------------
one or many records; one or many fields;
the common structure used by others followed
----------------------------------------------------------------------*/
struct FIELD_STRU
{
short field_no;
short field_type; //data type for get; byte len for write
short field_length; // 2003-07-31 //reserved for later
};
typedef vector<FIELD_STRU> SEQ_FIELD_STRU;
struct REQ_BASE
{
short context_no; //long
int app_no; //short
int table_no;
char byte_tag; //DB_BYTE_T byte_tag;
SEQ_FIELD_STRU seq_field;
};
/* ---------------------------------------------------------------------
get one or many fields of one or many records;
maybe by key_word; if no keyword, default is current record
----------------------------------------------------------------------*/
struct REQ_READ
{
REQ_BASE base_info;
SEQ_CHAR seq_keyword; //usually only one key word
int keybuf_size; //0--no key_word, else key word data size
varchar str_fname_list;
//short get_mode; // 0 -- by field no
// 1 -- by field name
// 2 -- by key word
};
struct RSP_READ
{
int record_num; //记录 个数
int record_size;
short field_num; //域个数
SEQ_FIELD_STRU seq_field; //field信息
SEQ_CHAR seq_data; //return data value
int data_size; //return data size; 总长度
};
/* ---------------------------------------------------------------------
write one record, include key_word
----------------------------------------------------------------------*/
struct REQ_KEY_WRITE
{
REQ_BASE base_info;
SEQ_CHAR record_value; //record data value
int buf_size; //record data size
};
/* ---------------------------------------------------------------------
modify one or many fields of one or many records,
maybe by key_word; if no keyword, default is current record
----------------------------------------------------------------------*/
struct REQ_MODIFY
{
REQ_BASE base_info;
short is_field_name; //是否按域名修改 是 1 否 0
varchar field_name_str; //需要修改的域名
SEQ_CHAR seq_keyword; //key word data value
int keybuf_size; //key word data size
SEQ_CHAR field_value; //field data buffer
int buf_size; //field data size
};
/* ---------------------------------------------------------------------
update f one or many records by key_word
----------------------------------------------------------------------*/
struct REQ_UPDATE
{
REQ_BASE base_info;
SEQ_CHAR field_value; //data buffer
int buf_size; //data size
};
/* ---------------------------------------------------------------------
delete a record by key_word
----------------------------------------------------------------------*/
struct REQ_KEY_ERASE
{
REQ_BASE base_info;
SEQ_CHAR seq_keyword; //str_keyword;//2003-02-26
int keybuf_size; //redundant
};
/* ---------------------------------------------------------------------
delete many records by key
----------------------------------------------------------------------*/
struct DEL_REQ
{
REQ_BASE base_info;
int del_direction;
int del_num;
SEQ_CHAR seq_keyword;
int keybuf_size;
};
/* ---------------------------------------------------------------------
clear one table
----------------------------------------------------------------------*/
struct REQ_TABLE_CLEAR
{
REQ_BASE base_info;
};
struct REQ_FIELD_BASE_INFO
{
REQ_BASE base_info;
SEQ_LONG seq_field_no;
};
struct RSP_FIELD_BASE_INFO
{
SEQ_FIELD_BASE_INFO lseq_field_base_info;
};
/* ---------------------------------------------------------------------
get table and fields parameter (one)
----------------------------------------------------------------------*/
struct REQ_PARAMETER
{
REQ_BASE base_info;
//short para_type; //1--table parameter, 10--fields parameter
varchar str_field_list; //field's attribute that wanted to be query
};
typedef vector<FIELD_PARAMETER> SEQ_FIELD_PARAMETER;
struct RSP_PARAMETER
{
TABLE_PARAMETER table_para;
SEQ_FIELD_PARAMETER seq_field_para;
};
/* ---------------------------------------------------------------------
get table and fields parameter (two)
----------------------------------------------------------------------*/
struct REQ_APP_PARAMETER
{
int app_no;
varchar app_name; //all_name
};
//this is rsp
typedef vector<TABLE_PARAMETER> SEQ_TABLE_PARAMETER;
struct RSP_APP_PARAMETER
{
int app_no;
varchar app_name; //all_name
SEQ_TABLE_PARAMETER seq_table_para;
};
/*------------------------------------------------------------------------------
4. RTDBMS key word length of all table
2003-03-10
------------------------------------------------------------------------------*/
struct TABLE_KEYINFO
{
//int table_no; //RDBMS table no
short keyword_len; //total key word length
};
typedef vector<TABLE_KEYINFO> SEQ_TABLE_KEYINFO;
struct RSP_KEYINFO
{
SEQ_TABLE_KEYINFO seq_keyinfo;
};
/*------------------------------------------------------------------------------
5. SQL INTERFACE
2003-03-26
------------------------------------------------------------------------------*/
struct REQ_SQL
{
REQ_BASE base_info;
varchar str_select;
//SEQ_CHAR seq_select;
};
/*------------------------------------------------------------------------------
6. some function for gui
2003-06-05
------------------------------------------------------------------------------*/
/* ---------------------------------------------------------------------
menu read
----------------------------------------------------------------------*/
struct REQ_MENU
{
REQ_BASE base_info;
//SEQ_CHAR seq_menu_name;
varchar str_menu_name;
unsigned char menu_status;
};
struct MENU_INFO_STRU
{
varchar menu_name; /* 菜单名*/
unsigned char menu_no; /* 序号*/
int actual_value; /* 实际值*/
varchar display_value; /* 显示值*/
unsigned char menu_status; /* 菜单状态 */
varchar menu_macro_name;
};
typedef vector<MENU_INFO_STRU> SEQ_MENU_INFO;
struct RSP_MENU
{
int menu_num;
//int record_size;
SEQ_MENU_INFO seq_menu;
};
/* ---------------------------------------------------------------------
relevant menu read
----------------------------------------------------------------------*/
struct REQ_RELE_MENU
{
REQ_BASE base_info;
};
struct MENU_RELEVANT_STRU
{
int table_id; /* 表ID号 */
short column_id; /* 域ID号 */
int column_value; /* 域值 */
short r_column_id; /* 对应域ID号 */
varchar r_menu_name; /* 对应菜单名 */
int default_value; /* 默认值 */
};
typedef vector<MENU_RELEVANT_STRU> SEQ_MENU_RELEVANT;
struct RSP_RELE_MENU
{
int menu_num;
//int record_size;
SEQ_MENU_RELEVANT seq_menu;
};
/* ---------------------------------------------------------------------
get name varchar by key id
----------------------------------------------------------------------*/
struct REQ_NAME_STRING
{
short req_type;
REQ_BASE base_info;
KEYID_STRUCT keyid_stru; //by key id -- 1
cmnInt64 reference_id; //by id -- 2
SEQ_CHAR seq_keyword; //usually only one key word
int keybuf_size; //0--no key_word, else key word data size
};
struct RSP_NAME_STRING
{
int name_len;
varchar ref_string;
};
/* ---------------------------------------------------------------------
get name varchar by many key ids
----------------------------------------------------------------------*/
struct REQ_MULTI_NAME_STRING
{
short req_type;
REQ_BASE base_info;
SEQ_KEY_ID seq_keyid_stru; // -- 1
SEQ_APPKEY_ID seq_appkeyid_stru; // -- 2
SEQ_APP_ID seq_appid_stru; // -- 3
SEQ_LONGLONG seq_id; // -- 4
};
typedef vector<RSP_NAME_STRING> SEQ_RSP_NAME_STRING;
struct RSP_MULTI_NAME_STRING
{
SEQ_RSP_NAME_STRING seq_name_string;
};
/* ---------------------------------------------------------------------
reference menu read
----------------------------------------------------------------------*/
struct REQ_REF_MENU
{
REQ_BASE base_info;
};
struct REF_MENU_STRING
{
cmnInt64 order_no;
varchar menu_name;
};
typedef vector<REF_MENU_STRING> SEQ_REF_MENU;
struct RSP_REF_MENU
{
SEQ_REF_MENU seq_menu;
};
/*------------------------------------------------------------------------------
7. some function for graph
2003-06-16
------------------------------------------------------------------------------*/
/* ---------------------------------------------------------------------
get real time data from rtdbms server
----------------------------------------------------------------------*/
struct GRAPH_SIMPLE_REQ
{
int order_no;
cmnInt64 keyword_id;
short table_no;
short field_no;
};
struct GRAPH_XY_REQ
{
int order_no;
cmnInt64 keyword_id;
short table_no;
short field_no;
unsigned char mode; //
short data_num;
};
//
struct GRAPH_FIELD_STRU
{
int order_no;
short field_no;
varchar field_alias; //lmj add for graph list query by sql where
short rele1_table_no;
short rele1_field_no;
short rele2_table_no; //lmj add for graph list query by 2 index
short rele2_field_no; //lmj add for graph list query by 2 index
};
typedef vector<GRAPH_FIELD_STRU> SEQ_GRAPH_FIELD;
struct GRAPH_LIST_REQ
{
short table_no;
varchar condition;
SEQ_STRING where_field_seq; //lmj add for graph list query by sql where
SEQ_GRAPH_FIELD seq_field;
};
typedef vector<GRAPH_SIMPLE_REQ> SEQ_SIMPLE_REQ;
typedef vector<GRAPH_XY_REQ> SEQ_XY_REQ;
typedef vector<GRAPH_LIST_REQ> SEQ_LIST_REQ;
struct GRAPH_REAL_REQ
{
cmnInt64 graph_id; //lmj add for GraphGetDataEx
int cal_type; //lmj add for before calculate
SEQ_SIMPLE_REQ simple_req;
SEQ_XY_REQ xy_req;
SEQ_LIST_REQ list_req;
};
struct GRAPH_REAL_ODB_REQ
{
REQ_BASE base_info;
cmnInt64 graph_id; //lmj add for GraphGetDataEx
int cal_type; //lmj add for before calculate
SEQ_SIMPLE_REQ simple_req;
SEQ_XY_REQ xy_req;
SEQ_LIST_REQ list_req;
};
/*--------------------------------------------------------------------*/
struct GRAPH_SIMPLE_RSP
{
int order_no;
union_data_type data_value;
};
struct GRAPH_XY_RSP
{
int order_no;
SEQ_FLOAT seq_data_value;
};
struct ORDER_VALUE
{
int order_no;
SEQ_COMMON_DATA seq_data_value;
};
typedef vector<ORDER_VALUE> SEQ_ORDER_VALUE;
struct GRAPH_LIST_RSP
{
SEQ_ORDER_VALUE seq_list;
};
//
//
typedef vector<GRAPH_SIMPLE_RSP> SEQ_SIMPLE_RSP;
typedef vector<GRAPH_XY_RSP> SEQ_XY_RSP;
typedef vector<GRAPH_LIST_RSP> SEQ_LIST_RSP;
struct GRAPH_REAL_RSP
{
cmnInt64 graph_id; //lmj add for GraphGetDataEx
int cal_type; //lmj add for before calculate
SEQ_SIMPLE_RSP simple_rsp;
SEQ_XY_RSP xy_rsp;
SEQ_LIST_RSP list_rsp;
};
/* ---------------------------------------------------------------------
get app info from rtdbms server
----------------------------------------------------------------------*/
struct ORDER_KEY_REQ
{
int order_no;
cmnInt64 key_id;
};
typedef vector<ORDER_KEY_REQ> SEQ_ORDER_KEY_REQ;
struct GRAPH_ORDER_KEY_REQ
{
REQ_BASE base_info;
int app_no;
cmnInt64 graph_id;
SEQ_ORDER_KEY_REQ seq_order_key;
};
struct ORDER_KEY_RSP
{
int order_no;
unsigned char is_in_app;
};
typedef vector<ORDER_KEY_RSP> SEQ_ORDER_KEY_RSP;
struct GRAPH_ORDER_KEY_RSP
{
cmnInt64 graph_id;
SEQ_ORDER_KEY_RSP seq_app;
};
/*------------------------------------------------------------------------------
8. some function for exchange name & no (app/table/field, include chn/eng)
2003-12-16
------------------------------------------------------------------------------*/
struct REQ_ENTITY
{
REQ_BASE base_info;
varchar object_name;
short object_id; //app/table/field
unsigned char object_mode; // name ---> no // no --->name
unsigned char object_eng;
};
struct RSP_ENTITY
{
int object_no;
varchar object_name;
};
/*------------------------------------------------------------------------------
9. some function for factory name & no & id
2004-01-06
------------------------------------------------------------------------------*/
struct REQ_FAC
{
REQ_BASE base_info;
int table_no;
SEQ_CHAR seq_keyword; //usually only one key word
int keybuf_size; //0--no key_word, else key word data size
cmnInt64 fac_no; // hcr: fac_no & fac_id both use this member, so reserve as cmnInt64 but not short
varchar fac_name;
};
struct RSP_FAC
{
cmnInt64 fac_no;
varchar fac_name;
};
struct REQ_VAL_STA
{
short req_type; // 1 yc , 2 yx , 3 ym , 4 union type 5 yc , 6 yx , 7 ym , 8 union type
REQ_BASE base_info;
SEQ_KEY_ID keyid_stru_seq;
SEQ_KEY_ID_STA keyid_sta_stru_seq;
};
struct TIntValueStatus
{
int value;
int status;
};
struct TFloatValueStatus
{
float value;
int status;
};
struct TCharValueStatus
{
unsigned char value;
int status;
};
struct TLongValueStatus
{
cmnInt64 value;
int status;
};
struct TUnionValueStatus
{
union_data_type value;
int status;
};
typedef vector< TIntValueStatus > SEQ_INT_VAL_STA;
typedef vector< TFloatValueStatus > SEQ_FLOAT_VAL_STA;
typedef vector< TCharValueStatus > SEQ_CHAR_VAL_STA;
typedef vector< TLongValueStatus > SEQ_LONG_VAL_STA;
typedef vector< TUnionValueStatus > SEQ_UNION_VAL_STA;
struct RSP_INT_VAL_STA
{
SEQ_INT_VAL_STA rsp_val_sta;
};
struct RSP_FLOAT_VAL_STA
{
SEQ_FLOAT_VAL_STA rsp_val_sta;
};
struct RSP_CHAR_VAL_STA
{
SEQ_CHAR_VAL_STA rsp_val_sta;
};
struct RSP_LONG_VAL_STA
{
SEQ_LONG_VAL_STA rsp_val_sta;
};
struct RSP_UNION_VAL_STA
{
SEQ_UNION_VAL_STA rsp_val_sta;
};
//wj added for ConGet -- 2008.08.11
struct REQ_CON
{
REQ_BASE base_info;//base_info.seq_field.length() == 1
//FIELD_STRU get_field_info;//non or only one get_field
SEQ_FIELD_STRU get_field_info;//non or more than one get_field
SEQ_CHAR con_field_value;
};
struct RSP_CON
{
int fit_num;
int one_fit_size;//if non get_field, one_fit_size == one_record_size
SEQ_CHAR seq_data;
int data_size;
};
#ifdef _APP_SYS_SUBSTATION
//wuqx added for xdb layer access -- 2012-07-10
struct REQ_XDB
{
short op_no;
cmnInt64 table_no;
cmnInt64 id;
};
struct RSP_XDB
{
cmnInt64 oid;
cmnInt64 cnt;
};
//jinjing 20120815 for virtual field
struct VIR_FIELD_STRU
{
short v_field_no; //rtdbms 内部虚拟域号
short vr_field_no; //虚拟域号
short r_field_no; //bit field no 对应实际域号
short bit_no; // 1 - 32 位号
varchar vir_field_name_eng;
varchar vir_field_name_chn;
};
struct REQ_VIR_FIELD
{
REQ_BASE base_info;
};
typedef vector<VIR_FIELD_STRU> SEQ_VIRFIELD_STRU;
struct RSP_VIR_FIELD
{
//TABLE_PARAMETER table_para;
SEQ_VIRFIELD_STRU seq_virfield_para;
};
#endif
/*------------------------------------------------------------------------------
10. rtdb_server function number
2008-11-28
------------------------------------------------------------------------------*/
const int FUNC_TABLECREATE_NO = 1;
const int FUNC_TABLEDELETE_NO = 2;
const int FUNC_TABLEGET_NO = 3;
const int FUNC_TABLEGETBYNAME_NO = 4;
const int FUNC_TABLEGETBYFIELDVALUE_NO = 5;
const int FUNC_TABLEWRITE_NO = 6;
const int FUNC_TABLEMODIFY_NO = 7;
const int FUNC_TABLEUPDATE_NO = 8;
const int FUNC_DELETERECORD_NO = 9;
const int FUNC_TABLECLEAR_NO = 10;
const int FUNC_GETTABLEPARA_NO = 11;
const int FUNC_GETTABLEPARAMETER_NO = 12;
const int FUNC_GETAPPTABLEPARAMETER_NO = 13;
const int FUNC_GETFIELDPARA_NO = 14;
const int FUNC_GETKEYINFO_NO = 15;
const int FUNC_TABLEGETBYSQL_NO = 16;
const int FUNC_MENUREAD_NO = 17;
const int FUNC_TABLERELEMENUREAD_NO = 18;
const int FUNC_GETNAMESTRINGBYKEYID_NO = 19;
const int FUNC_GETREFMENUSTRING_NO = 20;
const int FUNC_GETNAMESTRINGBYMULTIKEYID_NO = 21;
const int FUNC_GRAPHGETDATA_NO = 22;
const int FUNC_GRAPHGETAPPINFO_NO = 23;
const int FUNC_EXCHANGENAMENO_NO = 24;
const int FUNC_GETFACNAMEBYKEYNO_NO = 25;
const int FUNC_GETFACNAMEBYFACID_NO = 26;
const int FUNC_GETFACNAMEBYFACNO_NO = 27;
const int FUNC_GETFACIDBYFACNAME_NO = 28;
const int FUNC_GETFACNOBYFACNAME_NO = 29;
const int FUNC_GETFACIDBYFACNO_NO = 30;
const int FUNC_GETFACNOBYFACID_NO = 31;
const int FUNC_GETVALUEANDSTATUS_NO = 32;
const int FUNC_PINGRTDBSERVER_NO = 33;
const int FUNC_DELETERECORDS_NO = 34;
const int FUNC_TABLEGET_OPT_NO = 40;
const int FUNC_TABLEGETBYNAME_OPT_NO = 41;
const int FUNC_GETVALUEANDSTATUS_YCOPT_NO = 42;
const int FUNC_GETVALUEANDSTATUS_YXOPT_NO = 43;
const int FUNC_GETTABLEPARA_PARA3_NO = 44;
#ifdef _APP_SYS_SUBSTATION
const int FUNC_GETTABLEPARAALL_NO = 35;
const int FUNC_TABLEGETALL_NO = 36;
const int FUNC_XDBACCESS_NO = 37;
const int FUNC_GETTABLEPARAVIR_NO = 38;
//for xdb should not been used in other situation
const int GETPARENT_NO = 1;
const int CHDFIRST_NO = 2;
const int CHDNEXT_NO = 3;
const int CHDCNT_NO = 4;
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,193 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_netfactory.h
DESCRIPTION: for class CTableNet of net access
FUNCTION LIST:
COMMENT: for net access
History:
Date Version Modifier Activities
2003-12-12 1.0 modify
================================================================================
2003-01-09 1.0 created
*******************************************************************************/
#ifndef __ODB_NETFACTORY_h__
#define __ODB_NETFACTORY_h__
#ifndef __ODB_DEFINE_H__
#include "db_api/odb_define.h"
#endif
//#ifndef __ODB_ORBMGR_H__
//#include "odb_orbmgr.h"
//#endif
#include <map>
#include <string>
#include "system.h"
#include "task_service.h"
#include "sysadm/scn_service.h"
#include "db_api/odb_net_m.h"
#include "db_api/codb_net.h"
#ifndef _WINDOWS64
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#endif
//#include "serviceglobal.h"
#include "servicemanage.h"
#define NET_FAC_LOCAL_DOMAIN "local_domain"
#ifdef _WINDOWS64
#ifdef ODB_API_LIB_EXPORTS
#define ODB_API_LIB_API __declspec(dllexport)
#else
#define ODB_API_LIB_API __declspec(dllimport)
#endif
#else
#define ODB_API_LIB_API
#endif
using namespace std;
//using namespace RTDB_SERVER;
//using namespace ODB;
//============================================================================//
struct SERVICE_MESSAGE
{
char service_name[80];
char service_object[40];
char service_port[40];
int run_port;
};
struct NET_INFO
{
RTDB_SERVER::CODB_NET* net_ptr;
NET_INFO& operator= (const NET_INFO& other)
{
if( this == &other )
{
return *this;
}
net_ptr = other.net_ptr ;
return *this;
}
};
//============================================================================//
namespace NET_ODB
{
class ODB_API_LIB_API CNetFactory
{
public:
CNetFactory();
CNetFactory(const int app_no, const short context_no = 0); //obsolete
CNetFactory(const struct SCENARIO_PARA& scn_para);
//CNetFactory(const char* host_name);
~CNetFactory();
public:
RTDB_SERVER::CODB_NET* GetInstance();
//RTDB_SERVER::CODB_NET* GetInstance(const int app_no, const short context_no = 0, const bool is_managed=true);//obsolete
//RTDB_SERVER::CODB_NET* GetInstance(const char* host_name , const int app_no, const short context_no = 0);//obsolete
//RTDB_SERVER::CODB_NET* GetInstance(const char* domain_name, const tSecLabel& sec_label, const int app_no, const short context_no = 0, const bool is_managed=true);//obsolete
RTDB_SERVER::CODB_NET* GetInstance(const char* domain_name, const tSecLabel& sec_label, const struct SCENARIO_PARA& scn_para);
RTDB_SERVER::CODB_NET* GetInstance(const char* host_name , const struct SCENARIO_PARA& scn_para);
RTDB_SERVER::CODB_NET* GetInstance(const struct SCENARIO_PARA& scn_para);
public:
int DefaultService();
int SetServiceInfo();
int SetServiceName(const char* server_name);
int SetServiceObject(const char* server_object);
int SetServiceName(const int server_port);
void SetDomainInfo();
void SetScnPara(const struct SCENARIO_PARA& scn_para);
int SetManagedMode(const bool is_managed);
void LocalRemoteChanged();
public:
//void GetServiceHandle(Handle& handle);
private:
int start();
int InitNet();
int AddToMap();
int ReadHostFromfile(char* host_name);
int GetHostByAppNo(char* host_name, const int app_no, const short context_no );//obsolete
int GetSubScnHost(char* host_name, const struct SCENARIO_PARA& scn_para);
int CheckHost(const int app_no, const short context_no); ////obsolete
int CheckHost(const struct SCENARIO_PARA& scn_para);
int CheckHost(const char* host_name);
int IsCreated(const int app_no, const short context_no); ///obsolete
int IsCreated(const struct SCENARIO_PARA& scn_para);
int IsCreated(const std::string& host_name);
void PrnMap();
private:
CNetFactory(const CNetFactory& table_net);
CNetFactory& operator=(const CNetFactory& table_net);
private:
//std::map<int, std::string> m_MAppHost;
std::map<std::string, std::string> m_MAppHost;
std::map<std::string, struct NET_INFO> m_MHostNet;
std::map<std::string, struct NET_INFO> m_MScnNet; //lmj add
std::map<std::string, struct NET_INFO> m_MScnHostNet; //lmj add
//CORBA::ORB_var m_Orb;
//CORBA::Object_var m_Obj;
RTDB_SERVER::CODB_NET* m_OdbNet;
struct SERVICE_MESSAGE m_ServiceMsg;
ServiceInfo m_Serviceinfo;
DomainInfo* m_pDomaininfo;
short m_ContextNo;//obsolete
int m_AppNo;//obsolete
struct SCENARIO_PARA m_scn_para;
char m_HostName[MAX_NAME_STRING_LEN];
char m_AppStr[20];
char m_AppCtxHostStr[40];
char m_IpAddress[64];
char m_DomainName[40];
tSecLabel m_SecLabel;
char m_ServiceName[40];
bool m_IsSysAdmHost;
//COrbMgr* m_OrbMgr;
//CServicesManage* m_ServicesManage; ////obsolete
TaskService* m_TaskService;
NS_SYSADMIN::CScnService* m_ServicesManage;
//Handle m_Handle; //for service_bus
};
}
#endif

View File

@@ -0,0 +1,66 @@
/*******************************************************************************
ModuleName: Real Time Database management system
FileName: rtdb_api.cpp
DESCRIPTION: rtdb api interfaces implementation
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
2009-01-10 1.1 add net interfaces
================================================================================
2008-10-30 1.0 created
*******************************************************************************/
#include "db_api/odb_baseindex.h"
#ifndef _CNOOVERFLOWPK
#define _CNOOVERFLOWPK
namespace ODB
{
class CNoOverflowPK:public CBaseIndex
{
public:
virtual int need_rebuilt(char *existed_table_ptr,struct STDB_TAB *stdb_tab_ptr,struct STDB_FIELD_TAB *stdb_field_tab_ptr,INDEX_DEFINE &index_define,int &shm_id);
virtual int CreateIndex(struct STDB_TAB *stdb_tab_ptr,struct STDB_FIELD_TAB *stdb_field_tab_ptr,INDEX_DEFINE &index_define,int &shm_id,int &shm_size);
virtual int Open(char *index_file_name,int table_id,int index_id); //table_id、index_id用来和INDEX_STDB_TAB::table_id、INDEX_STDB_TAB::field_id匹配校验
virtual int Open(int index_shmid,int table_id,int index_id); //table_id、index_id用来和INDEX_STDB_TAB::table_id、INDEX_STDB_TAB::field_id匹配校验
virtual int SetIndexPtr(char *index_ptr); //把缓存的指针赋值给索引类这样就不用使用前面的Open函数。
virtual int GetKeyByIndex(char *index_ptr,std::vector<char *> &index_array);
virtual int GetKeyPointerByIndex(char *index_ptr, int& pointer);//只对主键索引有效根据index得到记录的物理位置
virtual int IndexInsert(char *index_ptr,char *key_ptr);
virtual int BulkIndexInsert(char *bulk_index_key_ptr);//下装的时候
virtual int Indexdelete(char *index_ptr,char *key_ptr);
virtual int IndexClear();
virtual int GetIdxMthd();
virtual int FreeResource();//譬如unmap或者shmdt掉指针。
virtual int DebugDisp(int type);//方便调试用不同的type显示不同或者详细程度不同的信息。
virtual int GetIndexRecNum();//返回索引记录总的个数包括索引区、溢出区、主溢出区有效记录个数的总和。但是无溢出HASH索引只是返回0。
virtual DB_STATUS_T GetIndexStatus()//返回索引的状态
{
return m_IndexStdbPtr->index_status;
}
virtual void SetIndexStatus(DB_STATUS_T idx_status)//设置索引头上的索引状态
{
m_IndexStdbPtr->index_status = idx_status;
}
//virtual int ModifyIndex(char *pk_ptr, int pos);
CNoOverflowPK();
~CNoOverflowPK();//考虑在析构函数里面调用FreeResource()
public:
int GetMaxIndexPointer();
int SetTableEnv(struct STDB_TAB *stdb_tab_ptr,char *table_data_area_ptr);
private:
struct INDEX_STDB_TAB* m_IndexStdbPtr;
struct STDB_TAB *m_StdbTabPtr; //added for optimization of IndexDelete
char *m_TableDataAreaPtr; //added for optimization of IndexDelete
//struct INDEX_STDB_FIELD_TAB *m_IndexStdbFieldPtr;
int* m_PkIndexStgDirectPtr;
int (*hash_func_ptr)(char *index,int length,int hash_prime);//这种索引算法只有一种,不一定使用
};
}
#endif

View File

@@ -0,0 +1,50 @@
//***********************************************************************************
//
// 本公共类作为CORBA客户端调用的封装类
// version: no.3
// time: 2003.03.16
//
//
// Created by Wangx / Huanghf // 2003-01-01
//***********************************************************************************
#include <OB/CORBA.h>
#include <OB/Properties.h>
#include <stdlib.h>
#ifdef HAVE_STD_IOSTREAM
using namespace std;
#endif
#ifndef __ODB_ORBMGR_H__
#define __ODB_ORBMGR_H__
namespace ODB
{
class COrbMgr
{
public:
COrbMgr();
~COrbMgr();
bool InitOrb();
bool InitOrb(const char* n_orbname);
bool DelInitOrb();
bool DelOrb();
bool SetOrbPara(const char* n_str_para_name, const char* n_str_para_value);
CORBA::Object_var GetRemoteObj(CORBA::ORB_var n_orb, const char* n_reffilename);
CORBA::Object_var GetRemoteObj(CORBA::ORB_var n_orb, const char* n_server, const char* n_port, const char* n_objectname);
CORBA::ORB_var GetOrb();
bool GetOrb(CORBA::ORB_var & in_orb);
//bool SetOrb(CORBA::ORB_var n_orb);
private:
OB::Properties_var m_Props;
CORBA::ORB_var m_Orb;
};
}
#endif

View File

@@ -0,0 +1,66 @@
#ifndef __ODB_PROFILE_H__
#define __ODB_PROFILE_H__
#include <string>
#include <map>
#include <set>
using namespace std;
namespace NProfile
{
#define MAX_LINE_LENGTH 1000
class CProfile
{
public:
typedef map<string, string> KeyMapType;
typedef map<string, KeyMapType> SectionMapType;
typedef set<string> StringSetType;
private:
SectionMapType m_mapSection;
string m_strFileName;
bool GetSection(string &strSource);
bool GetKeyAndValue(const string &strSource, string &strKey, string &strValue);
bool Trim(string &strSource);
public:
CProfile();
~CProfile();
CProfile(const char *pProfileName);
CProfile(const string &strProfileName);
void SetFileName(const char *pProfileName);
void SetFileName(const string &strProfileName);
int ReadFile(void);
bool IsSectionExists(const string &strSection);
bool IsKeyExists(const string &strSection, const string &strKey);
string GetString(const string &strSection, const string &strKey,
const string &strDefalut);
int GetInt(const string &strSection, const string &strKey, int nDefault);
void GetSections(StringSetType &setSections);
void GetSectionKeys(StringSetType &setKeys, const string &strSection);
void GetSectionValues(StringSetType &setValues, const string &strSection);
int GetKeyByValue(string& strKey, const char* pValue); //
int GetKeyByValue(string& strKey, const string& strValue); //
void PrintAllValue(void);
void TestFunctions(void);
};
CProfile * CProfileInstance();
CProfile * CProfileInstance(char* _filename);
} //End of namespace NProfile
#endif // __PROFILE_FILE_H__

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,375 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: publics.h
DESCRIPTION: public define
FUNCTION LIST:
COMMENT: 操作相关结构定义 同odb_api_struct.h
History:
Date Version Modifier Activities
2002-09-01 1.0 modify
================================================================================
2002-09-01 1.0 created
*******************************************************************************/
#ifndef __ODB_PUBLIC_H__
#define __ODB_PUBLIC_H__
//公共头文件
#ifndef _WINDOWS64
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#ifndef _HPUX
#include <pthread.h>
#else
#include <sys/pthread.h>
#endif
#include <dirent.h>
#include <sys/mman.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <sys/time.h>
#include <sys/times.h>
#else
#include <winsock2.h>
#include <windows.h>
#include <direct.h>
#include <io.h>
#include <process.h>
#include <time.h>
#include <sys/timeb.h>
//#include <afxmt.h>
#endif
#include <string>
#include <vector>
#include <map>
#include <memory>
#include <algorithm>
#include <utility>
#include <iostream>
#include "ThreadKit/ThreadKit.h"
#ifndef __ODB_DEFINE_H__
#include "db_api/odb_define.h"
#endif
#include "db_api/odb_struct.h"
//namespace ODB
//{
struct TABLE_PARA
{
char table_name_eng[ENG_NAME_LEN];
char table_name_chn[CHN_NAME_LEN];
int key_len;
int subkey_num;
int record_number;
int record_size;
short field_sum;
unsigned char is_auto_generated; //key_generate_type
};
struct FIELD_PARA
{
int table_id; //表ID号 INT
short field_id; //域ID号 SHORT
short column_id; //域内部ID号 SHORT
char field_name_eng[ENG_NAME_LEN]; //域英文名 STRING(32)
char field_name_chn[CHN_NAME_LEN]; //域中文名 STRING(64)
short field_length; //数据长度 SHORT
unsigned char data_type; //数据类型 UCHAR
unsigned char is_keyword; //是否主键 UCHAR
unsigned char allow_null; //是否允许空值 UCHAR
int app_type; //应用类型 INT
unsigned char is_app_syn; //是否更新时全应用同步 UCHAR
unsigned char index_order_no; //检索器索引顺序号 UCHAR
unsigned char sort_order_no; //默认排序顺序号 UCHAR
// // // // //
unsigned char is_input; //是否允许输入 UCHAR
unsigned char is_display; //是否显示 UCHAR
short display_order_no; //显示顺序号 SHORT
unsigned char is_fix; //卷滚时是否固定 UCHAR
short display_length; //默认显示长度 SHORT
unsigned char display_precision; //小数显示精度 UCHAR
unsigned char align_type; //对齐方式 UCHAR
unsigned char display_type; //显示类型 UCHAR
char menu_name[MENU_NAME_LEN]; //菜单名 STRING(40)
unsigned char reference_flag; //数据引用类型 UCHAR
unsigned char reference_mode; //数据引用方式 UCHAR
int reference_table; //引用表名 INT
short reference_column; //引用域号 SHORT
unsigned char reference_display; //被引用时是否显示 UCHAR
char init_value[DEFAULT_VALUE_LEN]; //缺省值 STRING(20)
char min_value[DEFAULT_VALUE_LEN]; //最小值 STRING(20)
char max_value[DEFAULT_VALUE_LEN]; //最大值 STRING(20)
int column_special; //域特殊属性 INT
unsigned char auto_meas_type; //自动生成量测类型 UCHAR
short gen_array_dimension; //数组维数 SHORT
char gen_array_name[ARRAY_NAME_LEN]; //数组名称 STRING(32)
char column_description[DESCRIPTION_LEN]; //域描述信息 STRING(100)
unsigned char is_index; //
int offset; //added by RTDBMS
};
////////////////////////////////////////////////////////////////////////////////
// for down load //
// //
////////////////////////////////////////////////////////////////////////////////
/*============================================================================*/
struct STDB_CREAT_REQ
{
int app_no;
int table_no;
int table_version;
int field_sum; //short
#ifdef _APP_SYS_SUBSTATION
int bit_field_sum;
int vir_field_sum;
#endif
char table_name_eng[ENG_NAME_LEN];
char table_name_chn[CHN_NAME_LEN];
int record_num;
int record_sum;
int record_length; //short
unsigned char is_system_table;
unsigned char is_auto_generated; //key_generate_type;
unsigned char is_record_apped;
unsigned char is_record_lock;
unsigned char is_record_resp;
DB_MEDIA_T stdb_media; //no used
ACCESS_METHODS_T access_meth; //
int seq_field_no; //
char passwd[MAX_NAME_STRING_LEN]; //
int table_type; //for graph, etc
/******Added for index begin ************/
int pk_index_method;
int pk_storage_type;//主键存储方法,譬如共享内存或者文件映射内存。
int pk_mem_alloc_type;//主键内存分配方法譬如带溢出HASH的分配方法无溢出的HASH分配方法。
/******Added for index end**************/
int reserved_1;
int reserved_2;
int reserved_3;
int reserved_4;
int reserved_5;
int area_num;
int area_no[MAX_AREA_NUM];
char area_name[MAX_AREA_NUM][ENG_NAME_LEN];
int slice_flag;
};
struct FIELD_CREAT_REQ
{
int app_no; //app_type
short field_no;
short r_field_no;
short field_id;
short column_id;
short field_length;
#ifdef _APP_SYS_SUBSTATION
short is_bit_field;
#endif
char field_name_eng[ENG_NAME_LEN];
char field_name_chn[CHN_NAME_LEN];
int column_special;
int ref_tableno; //long reference_table;
short ref_fieldno; //short reference_column;
unsigned char reference_flag;
unsigned char reference_mode;
unsigned char reference_display;
unsigned char data_type;
unsigned char allow_null;
unsigned char is_keyword;
unsigned char display_type;
unsigned char is_index; //octet index_order_no;
unsigned char sort_order_no;
unsigned char is_app_syn;
unsigned char auto_meas_type;
char menu_name[MENU_NAME_LEN];
char default_asciival[DEFAULT_VALUE_LEN]; //init_value
char min_asciival[DEFAULT_VALUE_LEN]; //min_value
char max_asciival[DEFAULT_VALUE_LEN]; //max_value
int search_attribute; // 检索器的域特性 //Added 2003-09-01
int statics_attribute; // 统计的域特性
int reserved_1; // 系统保留
int reserved_2; // 系统保留
int reserved_3; // 系统保留
int reserved_4; // 系统保留
int reserved_5; // 系统保留
};
#ifdef _APP_SYS_SUBSTATION
struct VIR_FIELD_CREAT_REQ
{
short v_field_no; //rtdbms
short vr_field_no;
short r_field_no; //bit field no
short bit_no;
char vir_field_name_eng[ENG_NAME_LEN];
char vir_field_name_chn[CHN_NAME_LEN];
};
#endif
struct STDB_DELETE_REQ
{
int app_no;
int table_no;
char passwd[MAX_PASSWD_LEN];
};
//struct FIELD_TYPE
//{
// short field_no;
// short field_type; //data type for get; byte len for write
//};
struct FIELD_BASE_INFO
{
int offset;
int field_length;
short field_no;
unsigned char data_type;
unsigned char is_keyword;
};
#ifndef __i386
static char strFILE[100];
static int iLINE;
#endif
#ifndef __i386
// #define TRACE strFILE = __FILE__; iLINE = __LINE__; odb_trace
#define TRACE strcpy(strFILE, __FILE__); iLINE = __LINE__; printf("\t%s:%d-->",strFILE,iLINE); odb_trace
#else
#define TRACE(...) odb_trace(__FILE__, __LINE__, __VA_ARGS__)
#endif
#ifndef _WINDOWS64
#ifndef __i386
inline void odb_trace(const char *p,...)
{
#else
inline void odb_trace(const char *strFILE, const int iLINE, const char *p,...)
{
printf("\t%s:%d-->",strFILE,iLINE);
#endif
/*
#ifndef __i386
static char strFILE[100];
static int iLINE;
// #define TRACE strFILE = __FILE__; iLINE = __LINE__; odb_trace
#define TRACE strcpy(strFILE, __FILE__); iLINE = __LINE__; printf("\t%s:%d-->",strFILE,iLINE); odb_trace
inline void odb_trace(const char *p,...)
{
#else
#define TRACE(...) odb_trace(__FILE__, __LINE__, __VA_ARGS__)
inline void odb_trace(const char *strFILE, const int iLINE, const char *p,...)
{
printf("\t%s:%d-->",strFILE,iLINE);
#endif
*/
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
va_list va;
va_start(va,p);
pthread_mutex_lock(&lock);
vfprintf(stdout,p,va);
fflush(stdout);
pthread_mutex_unlock(&lock);
va_end(va);
}
#else
inline void odb_trace(const char *p,...)
{
/*
//printf("\t%s:%d-->",strFILE,iLINE);
static CRITICAL_SECTION cs; //定义临界区
InitializeCriticalSection(&cs);//初始化临界区
va_list va;
va_start(va,p);
EnterCriticalSection(&cs);//加锁
vfprintf(stdout,p,va);
fflush(stdout);
LeaveCriticalSection(&cs);//解锁
va_end(va);
*/
//printf("\t%s:%d-->",strFILE,iLINE);
THREADKIT::Mutex g_mutex;
va_list va;
va_start(va,p);
{
THREADKIT::Guard<THREADKIT::Mutex> guard(g_mutex);
vfprintf(stdout,p,va);
fflush(stdout);
}
va_end(va);
}
#endif
class SecClock
{
public:
SecClock(int time_out):timer(time(NULL)),time_out(time_out){}
bool TimeOut(){return time(NULL)-timer>time_out;}
private:
time_t timer;
int time_out;
};
/*============================================================================*/
extern "C"
{
void do_nothing1(int nn);
void do_nothing2(int nn);
}
//}
#endif

View File

@@ -0,0 +1,155 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_rtdbbase.h
DESCRIPTION: class system interface define
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
2003-09-10 1.0 modify
2003-12-03 1.1 modify
================================================================================
2003-09-10 1.0 created
*******************************************************************************/
#ifndef __ODB_RTDBBASE_H__
#define __ODB_RTDBBASE_H__
#ifndef __ODB_PUBLIC_H__
#include "db_api/odb_public.h"
#endif
#include "db_api/odb_prv_struct.h"
/*
#ifndef __ODB_INCLUDE_H__
#include "odb_include.h"
#endif
*/
/*
#ifndef __ODB_BASEBUFFER_H__
#include "odb_basebuffer.h"
#endif
*/
#include "pub.h"
using namespace std;
namespace ODB
{
class CRtdbBase
{
public:
CRtdbBase(){}
virtual ~CRtdbBase(){}
public:
//
//query the whole table
//
virtual int TableGet(CBuffer& buf_base) const = 0;
virtual int TableGet(const int field_no, CBuffer& buf_base) const = 0;
virtual int TableGet(const char* field_name, CBuffer& buf_base) const = 0;
virtual int TableGet(const std::vector<int>& vec_field_no, CBuffer& buf_base) const = 0;
//
//query by key word
//
virtual int TableGetByKey(const char* key_ptr, char* buf_ptr, const int buf_size) const = 0;
virtual int TableGetByKey(const char* key_ptr, const int field_no, char* field_buf_ptr, const int buf_size) const = 0;
virtual int TableGetByKey(const char* key_ptr, const char* field_name, char* field_buf_ptr, const int buf_size) const = 0;
virtual int TableGetByKey(const char* key_ptr, const std::vector<int>& vec_field_no, char* field_buf_ptr, const int buf_size) const = 0;
virtual int TableGetByKey(const char* key_ptr, const int keybuf_size, const std::vector<int>& vec_field_no, char* field_buf_ptr, const int buf_size) const = 0;
//
//modify
//
virtual int TableModify(const char* buf_ptr, const int record_num, const int record_size) const = 0;
virtual int TableModify(const int field_no, const char* field_buf_ptr, const int buf_size) const = 0;
virtual int TableModify(const char* field_name, const char* field_buf_ptr, const int buf_size) const = 0;
virtual int TableModify(const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size) const = 0;
//
//by keyword && fields
//
virtual int TableModifyByKey(const char* key_ptr, const int field_no, const char* field_buf_ptr, const int buf_size) const = 0;
virtual int TableModifyByKey(const char* key_ptr, const char* field_name, const char* field_buf_ptr, const int buf_size) const = 0;
virtual int TableModifyByKey(const char* key_ptr, const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size) const = 0;
//
//SQL interface
//
virtual int SqlGet(const char* str_sql, CBuffer& buf_base) const = 0;
public:
//
//Table PARA
//
virtual int GetTablePara(short& field_num, int& record_num, int& record_size) const = 0;
virtual int GetTablePara(struct TABLE_PARA& table_para, std::vector<struct STDB_FIELD_TAB>& vec_field_para) const = 0;
virtual int GetTablePara(const char* str_attribute, CBuffer& buf_base) const = 0;
virtual int GetFieldInfo(const std::vector<int> vec_field_no, std::vector<struct FIELD_BASE_INFO>& vec_field) const = 0;
public:
//
//Name and No
//
virtual int GetFieldNameByNo(char* field_name, const int field_no, const bool is_eng=true) = 0;
virtual int GetFieldNoByName(int& field_no, const char* field_name, const bool is_eng=true) = 0;
virtual int GetTableNameByNo(char* table_name, const int table_no, const bool is_eng=true) = 0;
virtual int GetTableNoByName(int& table_no, const char* table_name, const bool is_eng=true) = 0;
virtual int GetAppNameByNo(char* app_name, const int app_no) = 0;
virtual int GetAppNoByName(int& app_no, const char* app_name) = 0;
public:
virtual int MenuRead(const char* menu_name, std::vector<struct MENU_INFO>& vec_menu, const int menu_status=MENU_ON) = 0;
virtual int TableReleMenuRead(const int table_no, std::vector<struct MENU_RELEVANT>& vec_menu) = 0;
virtual int GetRefMenuString(const int table_no, std::vector<struct MENU_STRING>& vec_menu) = 0;
//virtual int GetNameStringByKeyID(const KEY_ID_STRU& keyid_stru, string& ref_string) = 0;
//virtual int GetNameStringByKeyID(const std::vector<KEY_ID_STRU>& vec_keyid, std::vector<string>& vec_ref_string) = 0;
virtual int GetNameStringByID(const cmnInt64 reference_id, string& ref_string) = 0;
virtual int GetNameStringBykey(const char* key_ptr, string& ref_string) = 0;
virtual int GetNameStringByAppKeyID( const std::vector<struct APP_KEY_STRU>& vec_appkeyid, std::vector<string>& vec_name_string) = 0;
virtual int GetNameStringByAppID( const std::vector<APP_ID_STRU>& vec_appid, std::vector<string>& vec_name_string) = 0;
// virtual int ColMeasType( const std::vector<KEY_ID_STRU> vec_keyid , std::vector<int>& vec_col_prop ) = 0;
// virtual int GraphGetAppInfo(const struct ODB::GRAPH_ORDER_KEY_REQ& graph_req, struct ODB::GRAPH_ORDER_KEY_RSP& graph_rsp) const = 0;
// virtual int GraphGetData(const struct CODB_NET::GRAPH_REAL_REQ& real_req, CODB_NET::GRAPH_REAL_RSP_var& real_rsp) const = 0;
public:
virtual int GetFacNameByKeyNo(const int table_no, const char* key_ptr, string& ref_string) = 0;
virtual int GetFacNameByFacID(char* fac_name, const cmnInt64 fac_id) = 0;
virtual int GetFacNameByFacNo(char* fac_name, const int fac_no) = 0;
virtual int GetFacIDByFacName(cmnInt64& fac_id, const char* fac_name) = 0;
//virtual int GetFacNoByFacName(int& fac_no, const char* fac_name) = 0; //obsolete 2004-04-03
virtual int GetFacNoByFacName(int& fac_no, const char* fac_name) = 0;
//virtual int GetFacIDByFacNo(int& fac_id, const int fac_no) = 0; //obsolete 2004-04-03
virtual int GetFacIDByFacNo(cmnInt64& fac_id, const int fac_no) = 0;
virtual int GetFacNoByFacID(int& fac_no, const cmnInt64 fac_id) = 0;
public:
virtual int GetValueAndStatus(const vector<struct KEY_ID> &struVec , vector< struct INT_VALUE_STATUS > &KeyIdValVec) = 0; //yc
virtual int GetValueAndStatus(const vector<struct KEY_ID> &struVec , vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec) = 0; //yx
virtual int GetValueAndStatus(const vector<struct KEY_ID> &struVec , vector< struct CHAR_VALUE_STATUS > & KeyIdValVec)= 0; //ym
virtual int GetValueAndStatus(const vector<struct KEY_ID> &struVec , vector< struct UNION_VALUE_STATUS> & KeyIdValVec ) = 0; //union type
};
}
#endif

View File

@@ -0,0 +1,68 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_rtdbfactory.h
DESCRIPTION: class system interface define
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
2003-09-10 1.0 modify
2003-12-05 1.1 modify
================================================================================
2003-09-10 1.0 created
*******************************************************************************/
#ifndef __ODB_RTDBFACTORY_H__
#define __ODB_RTDBFACTORY_H__
#ifndef __ODB_TABLEBASE_H__
#include "db_api/odb_tablebase.h"
#endif
#ifndef __ODB_TABLEOP_H__
#include "db_api/odb_tableop.h"
#endif
#ifndef __ODB_APIOP_H__
#include "db_api/odb_apiop.h"
#endif
#ifndef __ODB_TABLENET_h__
#include "db_api/odb_tablenet.h"
#endif
#ifndef __ODB_APINET_h__
#include "db_api/odb_apinet.h"
#endif
//#include "sam_service.h"
namespace ODB
{
class COdbFactory
{
public:
COdbFactory();
//~COdbFactory();
virtual ~COdbFactory();
virtual CTableBase* Make(const int app_no, const int table_no, const short context_no, const char* hostname, const int host_mode, const int rtdb_mode=0) ;
private:
//CServicesManage* m_ServicesManage;
CTableBase* m_Instance;
CTableOp* m_TableOp;
CApiOp* m_ApiOp;
NET_ODB::CTableNet* m_TableNet;
NET_ODB::CApiNet* m_ApiNet;
short m_ContextNo;
int m_AppNo;
int m_TableNo;
bool m_HostMode;
bool m_RtdbMode;
char m_HostName[MAX_NAME_STRING_LEN];
};
}
#endif

View File

@@ -0,0 +1,184 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_rtdbbase.h
DESCRIPTION: Unified RTDB system interface definition
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
2004-06-25 1.1 add context_no parameter
2003-08-18 1.0 modify
2003-12-03 1.0 modify //formal
================================================================================
2003-08-18 1.0 created
*******************************************************************************/
#ifndef __ODB_RTDBOP_H__
#define __ODB_RTDBOP_H__
#ifndef __ODB_RTDBBASE_H__
#include "db_api/odb_rtdbbase.h"
#endif
#ifndef __ODB_RTDBTABLE_H__
#include "db_api/odb_rtdbtable.h"
#endif
#ifdef _WINDOWS64
#ifdef ODB_API_LIB_EXPORTS
#define ODB_API_LIB_API __declspec(dllexport)
#else
#define ODB_API_LIB_API __declspec(dllimport)
#endif
#else
#define ODB_API_LIB_API
#endif
using namespace std;
namespace ODB
{
typedef NET_ODB::CTableNet CRtdbOp;
#if 0
class ODB_API_LIB_API CRtdbOp: public CTableBase
{
public:
CRtdbOp();
CRtdbOp(const int app_no, const short context_no = 0);
CRtdbOp(const int app_no, const int table_no, const short context_no = 0);
//CRtdbOp(const char *hostname);
~CRtdbOp();
public:
int Open(const int table_no);
int Open(const int app_no, const int table_no, const short context_no = 0);
//int Open(const char *hostname);
int SetAppNo(const int app_no, const short context_no = 0);
int SetHostMode(const char* host_name);
//all interface
public:
//
//query the whole table
//
int TableGet(CBuffer& buf_base) const;
int TableGet(const int field_no, CBuffer& buf_base) const;
int TableGet(const char* field_name, CBuffer& buf_base) const;
int TableGet(const std::vector<int>& vec_field_no, CBuffer& buf_base) const;
//
//query by key word
//
int TableGetByKey(const char* key_ptr, char* buf_ptr, const int buf_size) const;
int TableGetByKey(const char* key_ptr, const int field_no, char* field_buf_ptr, const int buf_size) const;
int TableGetByKey(const char* key_ptr, const char* field_name, char* field_buf_ptr, const int buf_size) const;
int TableGetByKey(const char* key_ptr, const std::vector<int>& vec_field_no, char* field_buf_ptr, const int buf_size) const;
int TableGetByKey(const char* key_ptr, const int keybuf_size, const std::vector<int>& vec_field_no, char* field_buf_ptr, const int buf_size) const;
//
//modify
//
int TableModify(const char* buf_ptr, const int record_num, const int record_size) const;
int TableModify(const int field_no, const char* field_buf_ptr, const int buf_size) const;
int TableModify(const char* field_name, const char* field_buf_ptr, const int buf_size) const;
int TableModify(const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size) const;
//
//by keyword && fields
//
int TableModifyByKey(const char* key_ptr, const int field_no, const char* field_buf_ptr, const int buf_size) const;
int TableModifyByKey(const char* key_ptr, const char* field_name, const char* field_buf_ptr, const int buf_size) const;
int TableModifyByKey(const char* key_ptr, const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size) const;
//
//SQL interface
//
virtual int SqlGet(const char* str_sql, CBuffer& buf_base) const;
public:
int GetTablePara(short& field_num, int& record_num, int& record_size) const;
int GetTablePara(struct TABLE_PARA& table_para, std::vector<struct STDB_FIELD_TAB>& vec_field_para) const;
int GetTablePara(const char* str_attribute, CBuffer& buf_base) const;
int GetFieldInfo(const std::vector<int> vec_field_no, std::vector<struct FIELD_BASE_INFO>& vec_field) const;
public:
int GetFieldNameByNo(char* field_name, const int field_no, const bool is_eng=true);
int GetFieldNoByName(int& field_no, const char* field_name, const bool is_eng=true);
int GetTableNameByNo(char* table_name, const int table_no, const bool is_eng=true);
int GetTableNoByName(int& table_no, const char* table_name, const bool is_eng=true);
int GetAppNameByNo(char* app_name, const int app_no);
int GetAppNoByName(int& app_no, const char* app_name);
public:
int MenuRead(const char* menu_name, std::vector<struct MENU_INFO>& vec_menu, const int menu_status=MENU_ON);
int TableReleMenuRead(const int table_no, std::vector<struct MENU_RELEVANT>& vec_menu);
int GetRefMenuString(const int table_no, std::vector<struct ODB::MENU_STRING>& vec_menu);
int GetNameStringByRtdbKeyID(const RTDB_KEY_STRU& keyid_stru, string& ref_string);
int GetNameStringByRtdbKeyID(const std::vector<RTDB_KEY_STRU>& vec_keyid, std::vector<string>& vec_ref_string);
int GetNameStringByID(const cmnInt64 reference_id, string& ref_string);
int GetNameStringBykey(const char* key_ptr, string& ref_string);
int GetNameStringByAppKeyID( const std::vector<struct APP_KEY_STRU>& vec_appkeyid, std::vector<string>& vec_name_string);
int GetNameStringByAppID( const std::vector<APP_ID_STRU>& vec_appid, std::vector<string>& vec_name_string);
int ColMeasType( const std::vector<RTDB_KEY_STRU> vec_keyid , std::vector<int>& vec_col_prop );
// virtual int GraphGetAppInfo(const struct ODB::GRAPH_ORDER_KEY_REQ& graph_req, struct ODB::GRAPH_ORDER_KEY_RSP& graph_rsp) const = 0;
// virtual int GraphGetData(const struct CODB_NET::GRAPH_REAL_REQ& real_req, CODB_NET::GRAPH_REAL_RSP_var& real_rsp) const = 0;
public:
int GetFacNameByKeyNo(const int table_no, const char* key_ptr, string& ref_string);
int GetFacNameByFacID(char* fac_name, const cmnInt64 fac_id);
int GetFacNameByFacNo(char* fac_name, const int fac_no);
int GetFacIDByFacName(cmnInt64& fac_id, const char* fac_name);
int GetFacNoByFacName(int& fac_no, const char* fac_name);
int GetFacIDByFacNo(cmnInt64& fac_id, const int fac_no);
int GetFacNoByFacID(int& fac_no, const cmnInt64 fac_id);
public:
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx
int GetValueAndStatus(const std::vector<RTDB_KEY_STRU> &struVec , std::vector< struct UNION_VALUE_STATUS> & KeyIdValVec );//union type
private:
void Instance();
int Refresh(const int mode_rtdb=0) const;
private:
CRtdbOp(const CRtdbOp&);
CRtdbOp& operator=(const CRtdbOp&);
private:
CRtdbTable* m_TablePtr;
short m_ContextNo;
int m_AppNo;
int m_TableNo;
bool m_HostMode;
char m_HostName[MAX_NAME_STRING_LEN];
};
#endif
}
#endif

View File

@@ -0,0 +1,160 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_rtdbtable.h
DESCRIPTION: Unified RTDB system interface definition
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
2003-08-18 1.0 modify
2003-12-05 1.0 modify //formal
================================================================================
2003-08-18 1.0 created
*******************************************************************************/
#ifndef __ODB_RTDBTABLE_H__
#define __ODB_RTDBTABLE_H__
#ifndef __ODB_RTDBBASE_H__
#include "db_api/odb_rtdbbase.h"
#endif
#ifndef __ODB_TABLEBASE_H__
#include "db_api/odb_tablebase.h"
#endif
#ifndef __ODB_FACTORY_H__
#include "db_api/odb_rtdbfactory.h"
#endif
using namespace std;
namespace ODB
{
class CRtdbTable:public CRtdbBase
{
public:
CRtdbTable();
~CRtdbTable();
public:
//
//query the whole table
//
int TableGet(CBuffer& buf_base) const;
int TableGet(const int field_no, CBuffer& buf_base) const;
int TableGet(const char* field_name, CBuffer& buf_base) const;
int TableGet(const std::vector<int>& vec_field_no, CBuffer& buf_base) const;
//
//query by key word
//
int TableGetByKey(const char* key_ptr, char* buf_ptr, const int buf_size) const;
int TableGetByKey(const char* key_ptr, const int field_no, char* field_buf_ptr, const int buf_size) const;
int TableGetByKey(const char* key_ptr, const char* field_name, char* field_buf_ptr, const int buf_size) const;
int TableGetByKey(const char* key_ptr, const std::vector<int>& vec_field_no, char* field_buf_ptr, const int buf_size) const;
int TableGetByKey(const char* key_ptr, const int keybuf_size, const std::vector<int>& vec_field_no, char* field_buf_ptr, const int buf_size) const;
//
//modify
//
int TableModify(const char* buf_ptr, const int record_num, const int record_size) const;
int TableModify(const int field_no, const char* field_buf_ptr, const int buf_size) const;
int TableModify(const char* field_name, const char* field_buf_ptr, const int buf_size) const;
int TableModify(const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size) const;
//
//by keyword && fields
//
int TableModifyByKey(const char* key_ptr, const int field_no, const char* field_buf_ptr, const int buf_size) const;
int TableModifyByKey(const char* key_ptr, const char* field_name, const char* field_buf_ptr, const int buf_size) const;
int TableModifyByKey(const char* key_ptr, const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size) const;
//
//SQL interface
//
int SqlGet(const char* str_sql, CBuffer& buf_base) const;
public:
int GetTablePara(short& field_num, int& record_num, int& record_size) const;
int GetTablePara(struct TABLE_PARA& table_para, std::vector<struct STDB_FIELD_TAB>& vec_field_para) const;
int GetTablePara(const char* str_attribute, CBuffer& buf_base) const;
int GetFieldInfo(const std::vector<int> vec_field_no, std::vector<struct FIELD_BASE_INFO>& vec_field) const;
public:
int GetFieldNameByNo(char* field_name, const int field_no, const bool is_eng=true);
int GetFieldNoByName(int& field_no, const char* field_name, const bool is_eng=true);
int GetTableNameByNo(char* table_name, const int table_no, const bool is_eng=true);
int GetTableNoByName(int& table_no, const char* table_name, const bool is_eng=true);
int GetAppNameByNo(char* app_name, const int app_no);
int GetAppNoByName(int& app_no, const char* app_name);
public:
int MenuRead(const char* menu_name, std::vector<struct MENU_INFO>& vec_menu, const int menu_status=MENU_ON);
int TableReleMenuRead(const int table_no, std::vector<struct MENU_RELEVANT>& vec_menu);
int GetRefMenuString(const int table_no, std::vector<struct ODB::MENU_STRING>& vec_menu);
int GetNameStringByRtdbKeyID(const RTDB_KEY_STRU& keyid_stru, string& ref_string);
int GetNameStringByRtdbKeyID(const std::vector<RTDB_KEY_STRU>& vec_keyid, std::vector<string>& vec_ref_string);
int GetNameStringByID(const cmnInt64 reference_id, string& ref_string);
int GetNameStringBykey(const char* key_ptr, string& ref_string);
int GetNameStringByAppKeyID( const std::vector<struct APP_KEY_STRU>& vec_appkeyid, std::vector<string>& vec_name_string);
int GetNameStringByAppID( const std::vector<APP_ID_STRU>& vec_appid, std::vector<string>& vec_name_string);
int ColMeasType( const std::vector<RTDB_KEY_STRU> vec_keyid , std::vector<int>& vec_col_prop );
// virtual int GraphGetAppInfo(const struct ODB::GRAPH_ORDER_KEY_REQ& graph_req, struct ODB::GRAPH_ORDER_KEY_RSP& graph_rsp) const = 0;
// virtual int GraphGetData(const struct CODB_NET::GRAPH_REAL_REQ& real_req, CODB_NET::GRAPH_REAL_RSP_var& real_rsp) const = 0;
public:
int GetFacNameByKeyNo(const int table_no, const char* key_ptr, string& ref_string);
int GetFacNameByFacID(char* fac_name, const cmnInt64 fac_id);
int GetFacNameByFacNo(char* fac_name, const int fac_no); //mend 2004-04-03
int GetFacIDByFacName(cmnInt64& fac_id, const char* fac_name);
int GetFacNoByFacName(int& fac_no, const char* fac_name);
int GetFacIDByFacNo(cmnInt64& fac_id, const int fac_no);
int GetFacNoByFacID(int& fac_no, const cmnInt64 fac_id);
public:
int GetValueAndStatus(const vector<struct KEY_ID> &struVec , vector< struct INT_VALUE_STATUS > &KeyIdValVec); //yc
int GetValueAndStatus(const vector<struct KEY_ID> &struVec , vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yx
int GetValueAndStatus(const vector<struct KEY_ID> &struVec , vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //ym
int GetValueAndStatus(const vector<struct KEY_ID> &struVec , vector< struct UNION_VALUE_STATUS> & KeyIdValVec ); //union type
public:
int Refresh(const int app_no, const int table_no, const short context_no, const char* hostname, const int host_mode, const int rtdb_mode=0);
int SetNetMode(const bool is_net = false);
private:
int StartRtdb();
int CleanRtdb();
private:
CRtdbTable(const CRtdbTable&);
CRtdbTable& operator=(const CRtdbTable&);
private:
CTableBase* m_TablePtr;
COdbFactory* m_Factory;
};
}
#endif

View File

@@ -0,0 +1,458 @@
#ifndef __ODB_STRUCT_H__
#define __ODB_STRUCT_H__
#ifndef _WINDOWS64
#include <sys/mman.h>
#endif
#include <map>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include "db_api/odb_define.h"
#include "common_types.h"
#include "db_com/rtdbkey_defs.h"
////////////////////////////////////////////////////////
struct SCENARIO_PARA
{
std::string scenario;
unsigned int scenario_id;//note: scenario_id is not used in comparasion, to avoid inconsistent with scenario
unsigned int scenario_inst;
std::string sub_scenario;
unsigned int sub_scenario_id;//note: sub_scenario_id is not used in comparasion, to avoid inconsistent with sub_scenario
unsigned int sub_scenario_inst;
public:
SCENARIO_PARA& operator=(const SCENARIO_PARA& _right);
bool operator==(const SCENARIO_PARA& _right) const;
bool operator<(const SCENARIO_PARA& _right) const;
bool operator<=(const SCENARIO_PARA& _right) const;
bool operator>(const SCENARIO_PARA& _right) const;
bool operator>=(const SCENARIO_PARA& _right) const;
std::string to_string() const;
};
#ifndef _BIGENDIAN
struct KEY_STRU
{
int key;
short field_id;
short table_no;
};
struct KEY_STRU_AREA
{
int key:24;
int area:8;
short field_id;
short table_no;
};
#else
struct KEY_STRU
{
short table_no;
short field_id;
int key;
};
struct KEY_STRU_AREA
{
short table_no;
short field_id;
int area:8;
int key:24;
};
#endif
struct SCENARIO_ID_INFO
{
unsigned int scenario_id;
unsigned int scenario_inst;
unsigned int sub_scenario_id;
unsigned int sub_scenario_inst;
public:
//struct SCENARIO_ID_INFO():scenario_id(0),scenario_inst(0),sub_scenario_id(0),sub_scenario_inst(0){}
//SCENARIO_PARA& operator=(const SCENARIO_ID_INFO& _right);
bool operator==(const SCENARIO_ID_INFO& _right) const;
bool operator<(const SCENARIO_ID_INFO& _right) const;
bool operator<=(const SCENARIO_ID_INFO& _right) const;
bool operator>(const SCENARIO_ID_INFO& _right) const;
bool operator>=(const SCENARIO_ID_INFO& _right) const;
bool operator!=(const SCENARIO_ID_INFO& _right) const;
std::string to_string() const;
std::string FormCommonSqlStringID() const;
};
typedef cmnInt64 KEY_ID_STRU;
typedef cmnUint32 TABLE_NO_T;
typedef cmnUint32 COLUMN_NO_T;
typedef cmnUint64 ARA_SER_NO_T;
struct RTDB_KEY_STRU
{
cmnUint64 key_id1; //indicate table_id
cmnUint64 key_id2; //indicate area_id_serial_no && column_no(4)
//Constructor
RTDB_KEY_STRU() : key_id1(0), key_id2(0) { }
RTDB_KEY_STRU(const TABLE_NO_T table_no, const ARA_SER_NO_T area_serial_no, const COLUMN_NO_T column_no = 0);
RTDB_KEY_STRU(const std::string &stringid);
//creator
//RTDB_KEY_STRU(){key_id1=0;key_id2=0;}
inline void create_key(const TABLE_NO_T table_no, const ARA_SER_NO_T area_serial_no, const COLUMN_NO_T column_no = 0);
void create_key(const std::string &stringid); //<2F><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD>̫<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD>
//operator
bool operator==(const RTDB_KEY_STRU &right) const;
bool operator!=(const RTDB_KEY_STRU &right) const;
bool operator>(const RTDB_KEY_STRU &right) const;
bool operator<(const RTDB_KEY_STRU &right) const;
bool operator<=(const RTDB_KEY_STRU &right) const;
bool operator>=(const RTDB_KEY_STRU &right) const;
RTDB_KEY_STRU& operator=(const RTDB_KEY_STRU &right);
inline bool is_null() const { return key_id1 == 0 && key_id2 == 0;}
inline void set_null() { key_id1 = 0; key_id2 = 0;}
//Get Function
inline TABLE_NO_T GetTableID() const;
inline ARA_SER_NO_T GetAreaSerialNo() const;
inline COLUMN_NO_T GetColumnNo() const;
//Set Function
void SetTableID(TABLE_NO_T table_no);
void SetAreaSerialNo(ARA_SER_NO_T area_serial_no);
void SetColumnNo(COLUMN_NO_T column_no);
std::string FormStringID() const;
std::string FormSgID() const;
std::string FormCommonSqlStringID() const;
int FormSqlStr(char* sql_value, const int length) const;
};
struct APP_KEY_STRU
{
int app_id;
RTDB_KEY_STRU key_id;
bool operator>(const APP_KEY_STRU &kr) const;
bool operator<(const APP_KEY_STRU &kr) const;
bool operator==(const APP_KEY_STRU &kr) const;
bool operator!=(const APP_KEY_STRU &kr) const;
std::string FormCommonSqlStringID() const;
int FormSqlStr(char* sql_value, const int length) const;
};
struct SCN_ID_STRU
{
struct SCENARIO_ID_INFO scn_info;
RTDB_KEY_STRU key_id;
bool operator>(const SCN_ID_STRU &kr) const;
bool operator<(const SCN_ID_STRU &kr) const;
bool operator==(const SCN_ID_STRU &kr) const;
bool operator!=(const SCN_ID_STRU &kr) const;
std::string FormCommonSqlStringID() const;
std::string FormStringID();
int FormSqlStr(char* sql_value, const int length) const;
};
struct APP_ID_STRU
{
int app_id;
RTDB_KEY_STRU key_id;
bool operator>(const APP_ID_STRU &kr) const;
bool operator<(const APP_ID_STRU &kr) const;
bool operator==(const APP_ID_STRU &kr) const;
bool operator!=(const APP_ID_STRU &kr) const;
std::string FormCommonSqlStringID() const;
int FormSqlStr(char* sql_value, const int length) const;
};
#ifdef _BIGENDIAN
struct COMM_KEY_STRU
{
short table_no;
short column_id;
int record_id;
};
#else
struct COMM_KEY_STRU
{
int record_id;
short column_id;
short table_no;
};
#endif
#ifdef _BIGENDIAN
struct COMM_KEY_AREA_STRU
{
short table_no;
short column_id;
int area_id:8;
int record_id:24;
};
#else
struct COMM_KEY_AREA_STRU
{
int record_id:24;
int area_id:8;
short column_id;
short table_no;
};
#endif
struct _RTDB_KEY_STRU //as same as RTDB_KEY_STRU, to solve the problem that RTDB_KEY_STRU need constructor
{
cmnUint64 key_id1;
cmnUint64 key_id2;
bool operator==(const _RTDB_KEY_STRU &right) const;
bool operator!=(const _RTDB_KEY_STRU &right) const;
bool operator>(const _RTDB_KEY_STRU &right) const;
bool operator<(const _RTDB_KEY_STRU &right) const;
inline cmnUint32 GetTableID() const;
inline cmnUint64 GetAreaSerialNo() const;
inline cmnUint32 GetColumnNo() const;
};
struct _SCN_ID_STRU
{
struct SCENARIO_ID_INFO scn_info;
_RTDB_KEY_STRU key_id;
bool operator>(const _SCN_ID_STRU &kr) const;
bool operator<(const _SCN_ID_STRU &kr) const;
bool operator==(const _SCN_ID_STRU &kr) const;
bool operator!=(const _SCN_ID_STRU &kr) const;
std::string FormCommonSqlStringID() const;
int FormSqlStr(char* sql_value, const int length) const;
};
struct _APP_KEY_STRU //as same as APP_KEY_STRU
{
int app_id;
_RTDB_KEY_STRU key_id;
bool operator>(const _APP_KEY_STRU &kr) const;
bool operator<(const _APP_KEY_STRU &kr) const;
bool operator==(const _APP_KEY_STRU &kr) const;
bool operator!=(const _APP_KEY_STRU &kr) const;
};
struct _APP_ID_STRU
{
int app_id;
_RTDB_KEY_STRU key_id;
bool operator>(const _APP_ID_STRU &kr) const;
bool operator<(const _APP_ID_STRU &kr) const;
bool operator==(const _APP_ID_STRU &kr) const;
bool operator!=(const _APP_ID_STRU &kr) const;
};
//
//data define for record sort of real time db
//
union SORT_DATA_TYPE
{
char to_str[CHN_NAME_LEN];
int to_int;
float to_float;
double to_double;
cmnInt64 to_long;
unsigned int to_uint;
//KEY_ID_STRU to_key;
_APP_KEY_STRU to_appkey;
_APP_ID_STRU to_appid;
unsigned char to_uchar;
_RTDB_KEY_STRU to_rtdbkey;
_RTDB_KEY_STRU to_measrtdbkey;
_SCN_ID_STRU to_scn_id;
};
//lmj add 2004.0521
struct INT_VALUE_STATUS
{
int value;
int status;
};
struct FLOAT_VALUE_STATUS
{
float value;
int status;
};
struct CHAR_VALUE_STATUS
{
// char value[CHN_NAME_LEN];
unsigned char value;
int status;
};
struct LONG_VALUE_STATUS
{
cmnInt64 value;
int status;
};
struct UNION_VALUE_STATUS
{
SORT_DATA_TYPE value;
int status;
};
struct KEY_ID_STA_STRU
{
RTDB_KEY_STRU key_id_stru;
int status_field;
};
////////////////// file mapping cache //////////////////////////
#define RDB_MAX_MAP_LEN 8000000000
#define RDB_FILE_NAME_LEN 256
typedef cmnInt64 MAP_FILE_KEY;
struct MapItem
{
char *map_file_ptr;
char file_name[RDB_FILE_NAME_LEN];
unsigned int map_size;
int counter;
MAP_FILE_KEY map_id;
MapItem *p_next;
MapItem *p_prev;
MapItem()
{
map_file_ptr = NULL;
map_size = 0;
counter = 0;
map_id = 0;
memset(file_name, 0, RDB_FILE_NAME_LEN);
p_next = NULL;
p_prev = NULL;
}
};
struct CMmapList
{
struct MapItem *m_list;
struct MapItem *m_ptail; //tail of list
long m_length;
unsigned int m_item_num;
CMmapList()
{
m_list = NULL;
m_ptail = NULL;
m_length = 0;
m_item_num = 0;
}
};
#define MAP_ID_SYSTEM 1
#if 0
struct MAP_FILE_KEY
{
#ifndef _BIGENDIAN
int area_no:8;
short table_no;
int app_no;
int ctx_no:8;
#else
int ctx_no:8;
int app_no;
short table_no;
int area_no:8;
#endif
bool operator>(const MAP_FILE_KEY& kr) const
{
// return ( (this-> > kr.app_id) ||
// ((this->app_id == kr.app_id) && (this->key_id > kr.key_id)) );
return (*(cmnInt64*)this > (const cmnInt64&)kr);
}
bool operator<(const MAP_FILE_KEY& kr) const
{
// return ( (this->ctx_no < kr.ctx_no) ||
// ((this->ctx_no == kr.ctx_no) && (this->app_no < kr.app_no)) );
return (*(cmnInt64*)this < (const cmnInt64&)kr);
}
bool operator==(const MAP_FILE_KEY& kr) const
{
// return ( (this->ctx_no == kr.ctx_no) && (this->app_no == kr.app_no)
// && (this->table_no == kr.table_no) && (this->area_no == kr.area_no));
return (*(cmnInt64*)this == (const cmnInt64&)kr);
}
bool operator!=(const MAP_FILE_KEY& kr) const
{
/*
if(this->ctx_no != kr.ctx_no)
return true;
if(this->app_no != kr.app_no)
return true;
if(this->table_no != kr.table_no)
return true;
if(this->area_no != kr.area_no)
return true;
return false;
*/
return (*(cmnInt64*)this != (const cmnInt64&)kr);
}
};
#endif
typedef struct map_file_value
{
char *map_file_ptr;
char file_name[256];
unsigned int map_size;
int counter;
}RDB_MAP_FILE_VALUE;
typedef std::map<MAP_FILE_KEY, RDB_MAP_FILE_VALUE> RDB_FILE_MAP;
typedef struct map_file_struct
{
RDB_FILE_MAP map_file_list;
cmnInt64 m_total_cache;
}MMapInfoList;
#endif

View File

@@ -0,0 +1,185 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system (For New Generation)
FileName: odb_system.h
DESCRIPTION: class system define
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
2018-11-19 1.0 wuqx created
*******************************************************************************/
#ifndef __ODB_SYSTEM_H__
#define __ODB_SYSTEM_H__
#include "db_api/odb_prv_struct.h"
#include "db_api/odb_define.h"
#include "priv_para.h"
#include <map>
#include <pthread.h>
namespace ODB
{
class COdbSystem
{
//function to get singleton
public:
static COdbSystem* GetSystemInstance();
static COdbSystem* pInstance;
static pthread_mutex_t _mutex;
//creator & destructor
public:
COdbSystem();
COdbSystem(bool load_flag);
~COdbSystem();
//inneer creator to load config data or initialize all infomation
private:
int InitSystem();
int LoadSystem();
public:
//scenario allocator
int AddScenario(
const std::string& scenario,
const unsigned int scenario_inst_no,
const std::string& sub_scenario,
const unsigned int sub_scenario_inst_no);
int AddScenario(
const unsigned int scenario_ID,
const unsigned int scenario_inst_no,
const unsigned int sub_scenario_ID,
const unsigned int sub_scenario_inst_no);
int ScenarioRemove(
const int scenario_ID,
const int scenario_inst_no,
const int sub_scenario_ID,
const int sub_scenario_inst_no);
//scenario locator
int IsScenarioCreated(
const std::string& scenario,
const unsigned int scenario_inst_no,
const std::string& sub_scenario,
const unsigned int sub_scenario_inst_no);
int IsScenarioCreated(
const unsigned int scenario_ID,
const unsigned int scenario_inst_no,
const unsigned int sub_scenario_ID,
const unsigned int sub_scenario_inst_no);
int IsSubScenarioLoaded(
const unsigned int scenario_ID,
const unsigned int scenario_inst_no,
const unsigned int sub_scenario_ID,
const unsigned int sub_scenario_inst_no);
int IsSubScenarioLoaded(
const std::string& scenario,
const unsigned int scenario_inst_no,
const std::string& sub_scenario,
const unsigned int sub_scenario_inst_no);
//sub_scenario manage
int LoadSubScenario(
const std::string& scenario,
const unsigned int scenario_inst_no,
const std::string& sub_scenario,
const unsigned int sub_scenario_inst_no);
int LoadSubScenario(
const unsigned int scenario_ID,
const unsigned int scenario_inst_no,
const unsigned int sub_scenario_ID,
const unsigned int sub_scenario_inst_no);
int CreateSubScenarioInst(
const std::string& scenario,
const unsigned int scenario_inst_no,
const std::string& sub_scenario,
const unsigned int sub_scenario_inst_no);
//infomation aquire
//exchange name & no
int GetScenarioNameByNo(std::string& scenario_name, const unsigned int scenario_id) const;
int GetScenarioNoByName(const std::string& scenario_name, unsigned int& scenario_id) const;
int GetSubScenarioNameByNo(std::string& sub_scenario_name, const unsigned int sub_scenario_id) const;
int GetSubScenarioNoByName(const std::string& sub_scenario_name, unsigned int& sub_scenario_id) const;
int GetAllOdbNoBySubScenarioName (std::vector<int>& vec_table, const std::string& scenario_name, const unsigned int scenario_inst,
const std::string& sub_scenario, const unsigned int sub_scenario_inst) const;
int GetTableNoByChnName(const char* table_name, bool is_real = false);
int GetTableNoByName(const char* table_name, bool is_real = false);
int GetTableNameByNo(char* table_name, const unsigned int r_table_no, const bool is_eng=true);
const char* GetTableNameByNo(const unsigned int r_table_no);
int IsTableExisted(const char* table_name) const;
int IsTableExisted(const unsigned int table_no) const;
//distribute subscn judge
bool IsSubScenarioDistribute(const std::string& sub_scenario_name);
bool IsSubScenarioDistribute(const unsigned int sub_scenario_id);
int DistributeSubScenario(const std::string& DistSubScenarioName, std::string& SubScenarioName);
//system reload
int ReLoadSystem();
//for debug
int Show();
int GetAllScenarioInfo(vector <struct ALL_SCN_INFO>& all_scn_info);
public:
//ptr access
DB_APP_TAB* GetAppPtr() const;
DB_CTRL_TAB* GetDbCtrlPtr() const;
DB_CTRL_TAB* GetTabDbCtrlPtr(const char* table_name) const;
DB_CTRL_TAB* GetTabDbCtrlPtr(unsigned int table_no) const;
private:
int GenerateSemKey(
const unsigned int scenario_ID,
const unsigned int scenario_inst_no,
const unsigned int sub_scenario_ID,
const unsigned int sub_scenario_inst_no);
int if_sub_scenario_sliced(const std::string& sub_scenario);
private:
bool IsSpace(char c);
void Trim(string & str);
bool AnalyseLine(const string & line, string & key, string & val);
int InitMap();
void scenario_table_clear(struct SCENARIO_INFO* ptr);
void sub_scenario_table_clear(struct SUB_SCENARIO_INFO* ptr);
private:
//inner member
//id_name map
std::map<int, string> scenario_name_id_map;
std::map<int, string> sub_scenario_name_id_map;
std::map<string, int> scenario_id_name_map;
std::map<string, int> sub_scenario_id_name_map;
//system memory ptr
struct SYSTEM_INFO* p_sys_info;
struct SCENARIO_INFO* p_scenario_table;
//sub_scenario
DB_APP_TAB* m_AppTabPtr;
DB_CTRL_TAB* m_DbCtrlTabPtr;
DB_CTRL_TAB* m_CurDbCtrlTabPtr;
unsigned int work_mode; //1 means writable 0 means no writable
int sem_id;
unsigned long memsize;
std::string m_sys_path;
std::string m_sub_scn_path;
std::string m_table_path;
};
}
#endif

View File

@@ -0,0 +1,354 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_table.h
DESCRIPTION: class table struct define
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
2002-09-01 1.0 modify
================================================================================
2002-09-01 1.0 created
*******************************************************************************/
#ifndef __ODB_TABLE_H__
#define __ODB_TABLE_H__
//#include "odb_struct.h"
#include "odb_prv_struct.h"
#include "odb_public.h"
#include "odb_common.h"
#include "odb_baseindex.h"
#include "DeleteRecorder.h"
using namespace std;
struct FIX_INDEX_DEF;
class CRWLock;
//Test Case
class CaseSearch;
class CaseTableWrite;
class CaseDeleteIndex;
#ifdef _APP_SYS_SUBSTATION
class CaseConGet;
class TestItem;
#endif
#define MAX_AREA_IDX_NUM 10
namespace ODB
{
class Tab2Idx;
enum DIRECTION
{
FORWARD = 0,
BACKWARD = 1 ,
};
class COdbTable
{
public:
COdbTable();
COdbTable(struct DB_APP_TAB* app_tab_ptr, struct DB_CTRL_TAB* ctrl_tab_ptr);
//COdbTable(struct DB_APP_TAB* app_tab_ptr, struct DB_CTRL_TAB* ctrl_tab_ptr, char* odb_file_name);
//COdbTable(struct DB_APP_TAB* app_tab_ptr, struct DB_CTRL_TAB* ctrl_tab_ptr, int odb_no);
//COdbTable(struct DB_APP_TAB* app_tab_ptr, struct DB_CTRL_TAB* ctrl_tab_ptr, char* odb_name);
COdbTable(struct DB_APP_TAB* app_tab_ptr, int odb_no);
COdbTable(struct DB_APP_TAB* app_tab_ptr, char* odb_name);
COdbTable(char* app_ptr);
~COdbTable();
//set environment after default constructor
int SetAppCtrl(struct DB_APP_TAB* app_tab_ptr, struct DB_CTRL_TAB* ctrl_tab_ptr = NULL);
//
//create & delete
//
#ifdef _APP_SYS_SUBSTATION
int CreateTable(const struct STDB_CREAT_REQ* odb_creat_ptr, const struct FIELD_CREAT_REQ* odb_field_descrb_ptr, const struct VIR_FIELD_CREAT_REQ* vir_descrb_ptr, const std::vector<MEMBER_DEFINITION>& vec_offset,INDEX_DEFINE_ARRAY &index_define_array);
#endif
int CreateTable(const struct STDB_CREAT_REQ* odb_creat_ptr, const struct FIELD_CREAT_REQ* odb_field_descrb_ptr, const std::vector<MEMBER_DEFINITION>& vec_offset,INDEX_DEFINE_ARRAY &index_define_array);
int DeleteTable(/*struct STDB_DELETE_REQ* stdb_delete_req_ptr*/);
int AddOneTable(const int r_table_no, const char* table_name_eng);
//int DeleteTable();
int CreateAreaTable(const struct STDB_CREAT_REQ* odb_creat_ptr, const struct FIELD_CREAT_REQ* odb_field_descrb_ptr, const std::vector<MEMBER_DEFINITION>& vec_offset,INDEX_DEFINE_ARRAY &index_define_array);
int DeleteAreaTable();
int ClearTable();
int ClearAreaTable();
int ClearAreaTableHoleDirect();
//write record
int WriteRecords(const char* buf_ptr, const int buf_size);
//
//operation by key word
//
int ReadRecordByKey(const char* keyword, char** record_data_ptr, int& record_data_size);
int WriteRecordByKey(const char* keyword, const char* write_record_ptr, const int write_record_size);
int DeleteRecordByKey(const char* keyword);
int UpdateRecordByKey(const char* keyword, const char* update_record_ptr, const int update_record_size);
int ModifyRecordByKey(const char* keyword, const char* modify_record_ptr, const int modify_record_size);
int DeleteAlignedRecords(const char* keyword, int direction = FORWARD);
int DeleteRecords(const char* keyword, const int key_num);
int DeleteAreaTableRecords(const char* keyword, const int key_num);
//
//query the whole table //2002-11-07
//
//int GetAllRecords(char* buf_ptr, int& buf_size);
int GetAllRecords(char* buf_ptr, const int buf_size);
int GetAreaTableAllRecords(char* buf_ptr, const int buf_size);
//
//move table among application
//
int MoveTo(const int r_table_no);
int MoveTo(const char* table_name);
//
//move record each other
//
void RecordFirst();
int RecordPre();
int RecordNext();
int RecordTo(const int no);
int RecordTo(const char* key_ptr);
void RecordLast();
//
//parameter //2002-10-16
//
struct DB_CTRL_TAB* GetCtrlTabPtr();
struct STDB_TAB* GetStdbTabPtr();
struct STDB_TAB* GetStdbTabPtr(const int area_no);
struct STDB_FIELD_TAB* GetFieldTabPtr();
char* GetDbPtr();
char* GetCurRecordPtr();
int GetKeyWordLength();
int GetRecordNum();
int GetPara(short& field_num, int& record_num, int& record_size);
int GetPara(struct TABLE_PARA& table_para);
#ifdef _APP_SYS_SUBSTATION
struct STDB_VIR_FIELD_TAB* GetVirFieldTabPtr();
//jinjing 2012-03-27
int GetParaAll(struct TABLE_PARA& table_para, std::vector<MEMBER_DEFINITION> vec_offset);
#endif
//
//physical file name
//
int GetFileName(const char* table_name_eng);
int GetWholeMapFileName(char* str_file_name);
int GetFileNameWithAreaName(const char* table_name_eng, const char* area_name);
char* GetTableName();
int GetTableName(char* table_name);
int GetTableNo(bool is_real = false);
//wj added for area tables
int SetAreaEnv(const int area_no, const bool is_manage = false);
#ifndef _APP_SYS_SUBSTATION
int CleanEnv();
#endif
DB_APP_TAB* GetAppTabPtr();
STDB_TAB* GetAreaStdbTabPtr();
time_t GetDbOpenTime(const int table_no);
char* GetTableFileName();
void SetAppTabPtr(DB_APP_TAB* app_tab_ptr);
private:
//
//Access environment //2002-10-15
//
int SetDefaultEnv();
int SetAppEnv(char* app_file_ptr);
int SetTableEnv(const struct DB_CTRL_TAB* const init_ctrl_tab_ptr);
#ifdef _APP_SYS_SUBSTATION
int CleanEnv();
#endif
//
//lock 2002-10-28
//
bool Lock(const DB_LOCK_T& lock_type);
bool UnLock(const DB_LOCK_T& lock_type);
//
//stat 2002-10-28
//
int MinusDbNumTab();
int AddDbNumTab();
int SetStaticsParaPtr(int tag, int op_time);
//
//Operation to Create // 2002-10-10
//
int fill_stdb_tab(const struct STDB_CREAT_REQ* stdb_creat_req_ptr);
//int fill_field_tab(const struct STDB_CREAT_REQ* stdb_creat_req_ptr, const struct STDB_FIELD_DESCRIBLE* stdb_field_describle_ptr);
int fill_field_tab(const struct FIELD_CREAT_REQ* stdb_field_describle_ptr, const int field_num, const std::vector<MEMBER_DEFINITION>& vec_offset);
#ifdef _APP_SYS_SUBSTATION
int fill_vir_field_tab(const struct VIR_FIELD_CREAT_REQ* vir_field_ptr, const int vir_field_num);
#endif
int get_keyword();
int fill_sequent_tab(const struct STDB_CREAT_REQ* stdb_creat_req_ptr, int& stdb_describ_area_size, int& stab_total_size);
int fill_db_ctrl_tab(const struct STDB_CREAT_REQ* stdb_creat_req_ptr,int& stdb_describ_area_size);
//
int search(const char*keyword,int &record_pointer);
int binary_search(const char* keyword, int& record_pointer,bool ext_flag=false);//ext_flag means the search area is in overflow table space in the hole direct table
struct RECORD_HEAD_STRU* get_record_head_ptr(const int record_pointer);
char* get_record_ptr(const int record_pointer);
char* get_record_ptr(const int record_pointer, int& record_size );
int compare_keyword(const char* keyword1_ptr, const char* keyword2_ptr, const int keyword_len);
//
//memory data
//
int move_record(int targ_reccord_pointer,int sour_record_pointer, const int move_num);
static int mem_move(char* targ_ptr, char* sour_ptr, const int count);
int assign_position(int* position_ptr, int assign_val);
//
//Operation to a record
//
int read_record(const int record_pointer, char** record_data_ptr, int& record_data_size); //locked by caller
int write_record(const int record_pointer, const char* write_record_ptr, const int write_record_size); //locked by caller
int delete_record(const int record_pointer); //locked
int modify_record(const int record_pointer, const char* modify_record_ptr, const int modify_record_size,CRWLock &theLock);//locked
//
//Operation to Record Head //2002-10-15
//
int set_record_head(char* record_ptr, const int exist_tag);
int get_record_head(char* record_ptr);
int need_rebuilt(char * table_file_ptr, int shm_size,int table_size);
public:
int sprint_key(char *key_ptr,char *key_string);
int sprint_field(const int data_type, const char* field_data_ptr,char *field_string);
private:
COdbTable(const COdbTable& odb_table);
COdbTable& operator=(const COdbTable& odb_table);
/***********Added for index begin ****************/
public:
INDEX_DEFINE_TAB* GetIdxDfnPtr();
FIELD_INDEX_DEFINE_TAB* GetFldIdxDfnPtr();
FIELDS_IN_INDEXS_DESC_TAB* GetFldsInIdxDescPtr();
FIELDS_USED_IN_INDEX_TAB* GetFldsUsedInIdxPtr();
CBaseIndex *GetIndexPtr(int seq_no);//返回idx_op_ptr_array的第seq_no个元素如果第seq_no个元素是NULL的话new一个元素出来。
CBaseIndex *GetPKIndexPtr();//如果pk_index_ptr不等于NULL就返回一个pk_index_ptr否则new一个新的返回。
int fill_index_tab(INDEX_DEFINE_ARRAY& seq_idx, std::vector<short>& vec_index_fieldno);
int DebugDisp(int index_seq_no,int type);
int GetAppFile(char *file_name,const struct DB_APP_TAB*app_ptr);
private:
INDEX_DEFINE_TAB *m_IdxDefPtr;
FIELDS_IN_INDEXS_DESC_TAB *m_FieldsInIdxDescPtr;
FIELD_INDEX_DEFINE_TAB *m_FieldIdxDefPtr;
FIELDS_USED_IN_INDEX_TAB *m_FieldsUsedInIndexPtr;
std::vector<CBaseIndex *> m_IdxOpPtrArray;//打开一张表的时候就先给idx_op_ptr_array分配对应的空间。只有真正使用到这个索引的时候再构造里面具体的CBaseIndex。在切换到另外一张表的时候要删除每一个CBaseIndex* 然后再重新分配idx_op_ptr_array。
//CNoOverflowPK* direct_pk_ptr;//打开表的时候就要构造好direct_pk_ptr和hash_pk_ptr切换表的时候要unmap或者detach原来里面的指针然后mmap或者attach里面的指针。
//CHashPK *hash_pk_ptr;
CBaseIndex *m_PkIdxPtr;//考虑到扩展性,还是用这样一个指针好一点。
//CBaseIndex* m_AreaIdxPtr[MAX_AREA_NUM][MAX_AREA_IDX_NUM]; //only for area tables' indexes
public:
int FormIdxErrReport(int idx_seq_no,struct FIX_INDEX_DEF &fix_idx_def );//idx_seq_no = -1 means primary key index
/***********Added for index end ****************/
/*********Added for imcompact table begin ********/
private:
int *GetHoleIdxPtr();
int HoleIdxInsert(int record_pointer);
int HoleIdxDelete(int record_pointer);
int HoleIdxDelete(int del_pointer_start, int del_pointer_end);
int m_CurHolePKPointer;//为带洞表的RecordFirst、RecordNext、RecordLast函数、RecordPre函数几个函数服务的。
char* m_ExtDataAreaPtr; //溢出表体数据区的指针
int *m_HoleIdxPtr; //带洞表主键索引指针。
int hole_direct_search (const char* in_keyword, int &record_pointer);
int hole_idx_search (const int record_pointer, int& real_pos);//根据record_pointer得到m_HoleIdxPtr下标
int CheckDownloadTime();
int ClearTableHoleDirect();
int WriteRecordByKeyHoleDirect(const char* keyword, const char* write_record_ptr, const int write_record_size);
int UpdateRecordByKeyHoleDirect(const char* keyword, const char* update_record_ptr, const int update_record_size);
int DeleteRecordByKeyHoleDirect(const char* keyword);
int DeletePK(vector<int>& vec_del_start, vector<int>& vec_del_end);
int DeleteHolePK(vector<int>& vec_del_start, vector<int>& vec_del_end);
int DeleteAlignedRecordsHoleDirect(const char* keyword, int direction = FORWARD);
/*********Added for imcompact table end ********/
#ifdef _APP_SYS_SUBSTATION
//jinjing 2012-03-29 for GetTableParaAll
int create_field_tab(char* field_para_ptr, struct STDB_FIELD_TAB* stdb_field_ptr, const int field_num, const std::vector<MEMBER_DEFINITION>& vec_offset);
//jinjing 2012-03-29 for createStdbField
int checkIsBitField(const int field_no);
#endif
public:
int& GetSemId(const int table_no); //for OPTLOCK jinjing 20120428
void SetSemId(const int table_no, const int sem_id); //for OPTLOCK jinjing 20120428
int SetSemKey(const int app_no, const int r_table_no, const short ctx_no); //for OPTLOCK
private:
struct DB_APP_TAB* m_AppTabPtr; //App info area
struct DB_SYSTEM_TAB* m_SysTabPtr;
struct DB_STATICS_TAB* m_StaticsTabPtr;
struct DB_CTRL_TAB* m_CtrlTabPtr; //Ctrl info area
struct DB_CTRL_TAB* m_CurCtrlTabPtr; //current table's Ctrl info
struct STDB_TAB* m_StdbTabPtr; //
struct STDB_TAB* m_StdbRootTabPtr; //only for area table's root
struct SEQUENT_TAB* m_SequentTabPtr; //
struct STDB_FIELD_TAB* m_StdbFieldTabPtr; //
//std::map<int, char*> m_DbFilePtr;
char* m_DbFilePtr[MAX_APP_TABLE];
char* m_AreaFilePtr[MAX_APP_TABLE][MAX_AREA_NUM]; //only for area table's root
time_t m_DbOpenTime[MAX_APP_TABLE]; //for re-open tables when download
int m_MapSize[MAX_APP_TABLE]; //for re-open tables when download
int m_SemId[MAX_APP_TABLE+1]; //for OPTLOCK
int m_CurTableNo; //for OPTLOCK
char* m_SequentAreaPtr; //current sequent area
char* m_DataAreaPtr; //current data area
int m_CurRecordPointer; //current record position
int m_CurAreaNo;
int m_LastAreaNo; //only for GetPKIdxPtr
int m_LastIdxAreaNo[MAX_AREA_IDX_NUM]; //only for GetIndexPtr
char m_FileName[120]; //current table's physical file name
char m_RootFileName[120]; //only for area table's root
#ifdef _APP_SYS_SUBSTATION
struct STDB_VIR_FIELD_TAB* m_StdbVirFieldTabPtr; //virtual field
friend class CTableOp;
//friend class ::CTestItem;
friend class ::CaseConGet;
friend class ::TestItem;
#endif
//for Recreate Index Shm
friend class Tab2Idx;
//Only for Test Case
friend class ::CaseSearch;
friend class ::CaseTableWrite;
friend class ::CaseDeleteIndex;
};
}
#endif

View File

@@ -0,0 +1,179 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_tablebase.h
DESCRIPTION: class system interface define
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
2003-09-10 1.0 modify
2003-12-03 1.1 modify
================================================================================
2003-09-10 1.0 created
*******************************************************************************/
#ifndef __ODB_TABLEBASE_H__
#define __ODB_TABLEBASE_H__
#include <pthread.h>
#ifndef __ODB_PUBLIC_H__
#include "db_api/odb_public.h"
#endif
#include "db_api/odb_prv_struct.h"
/*
#ifndef __ODB_INCLUDE_H__
#include "odb_include.h"
#endif
*/
/*
#ifndef __ODB_BASEBUFFER_H__
#include "odb_basebuffer.h"
#endif
*/
#include "pub.h"
#ifdef _WINDOWS64
#ifdef ODB_API_LIB_EXPORTS
#define ODB_API_LIB_API __declspec(dllexport)
#else
#define ODB_API_LIB_API __declspec(dllimport)
#endif
#else
#define ODB_API_LIB_API
#endif
using namespace std;
namespace ODB
{
class ODB_API_LIB_API CTableBase
{
public:
CTableBase(){}
virtual ~CTableBase(){}
//
//query the whole table
//
virtual int TableGet(CBuffer& buf_base) { return 0; }
virtual int TableGet(const int field_no, CBuffer& buf_base) { return 0; }
virtual int TableGet(const char* field_name, CBuffer& buf_base) { return 0; }
virtual int TableGet(const std::vector<int>& vec_field_no, CBuffer& buf_base) { return 0; }
//
//query by key word
//
virtual int TableGetByKey(const char* key_ptr, char* buf_ptr, const int buf_size) { return 0; }
virtual int TableGetByKey(const char* key_ptr, const int field_no, char* field_buf_ptr, const int buf_size) { return 0; }
virtual int TableGetByKey(const char* key_ptr, const char* field_name, char* field_buf_ptr, const int buf_size) { return 0; }
virtual int TableGetByKey(const char* key_ptr, const std::vector<int>& vec_field_no, char* field_buf_ptr, const int buf_size) { return 0; }
virtual int TableGetByKey(const char* key_ptr, const int keybuf_size, const std::vector<int>& vec_field_no, char* field_buf_ptr, const int buf_size) { return 0; }
//
//modify
//
virtual int TableModify(const char* buf_ptr, const int record_num, const int record_size) { return 0; }
virtual int TableModify(const int field_no, const char* field_buf_ptr, const int buf_size) { return 0; }
virtual int TableModify(const char* field_name, const char* field_buf_ptr, const int buf_size) { return 0; }
virtual int TableModify(const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size) { return 0; }
//
//by keyword && fields
//
virtual int TableModifyByKey(const char* key_ptr, const int field_no, const char* field_buf_ptr, const int buf_size) { return 0; }
virtual int TableModifyByKey(const char* key_ptr, const char* field_name, const char* field_buf_ptr, const int buf_size) { return 0; }
virtual int TableModifyByKey(const char* key_ptr, const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size) { return 0; }
//
//SQL interface
//
virtual int SqlGet(const char* str_sql, CBuffer& buf_base) { return 0; }
virtual int SqlGet(const char* str_sql, char** buf_ptr, int& buf_size) { return 0; }
public:
//
//table PARA
//
virtual int GetTablePara(short& field_num, int& record_num, int& record_size) { return 0; }
virtual int GetTablePara(struct TABLE_PARA& table_para, std::vector<struct STDB_FIELD_TAB>& vec_field_para) { return 0; }
virtual int GetTablePara(const char* str_attribute, char** field_para_ptr, int& buf_size) { return 0; }
virtual int GetFieldInfo(const std::vector<int> vec_field_no, std::vector<struct FIELD_BASE_INFO>& vec_field) { return 0;}
public:
//Name and No
virtual int GetAppNameByNo(char* app_name, const int app_no) = 0;
virtual int GetAppNoByName(int& app_no, const char* app_name) = 0;
virtual int GetTableNameByNo(char* table_name, const int table_no, const bool is_eng=true) = 0;
virtual int GetTableNoByName(int& table_no, const char* table_name, const bool is_eng=true) = 0;
virtual int GetFieldNameByNo(char* field_name, const int field_no, const bool is_eng=true) = 0;
virtual int GetFieldNoByName(int& field_no, const char* field_name, const bool is_eng=true) = 0;
public:
virtual int MenuRead(const char* menu_name, std::vector<struct MENU_INFO>& vec_menu, const int menu_status=MENU_ON){ return 0; }
virtual int TableReleMenuRead(const int table_no, std::vector<struct MENU_RELEVANT>& vec_menu){ return 0; }
virtual int GetRefMenuString(const int table_no, std::vector<struct MENU_STRING>& vec_menu){ return 0; }
virtual int GetNameStringByRtdbKeyID(const RTDB_KEY_STRU& keyid_stru, string& ref_string){ return 0; }
virtual int GetNameStringByRtdbKeyID(const std::vector<RTDB_KEY_STRU>& vec_keyid, std::vector<string>& vec_ref_string){ return 0; }
virtual int GetNameStringByID(const cmnInt64 reference_id, string& ref_string){ return 0; }
virtual int GetNameStringBykey(const char* key_ptr, string& ref_string){ return 0; }
virtual int GetNameStringByAppKeyID( const std::vector<struct APP_KEY_STRU>& vec_appkeyid, std::vector<string>& vec_name_string){ return 0; }
virtual int GetNameStringByAppID( const std::vector<APP_ID_STRU>& vec_appid, std::vector<string>& vec_name_string){ return 0; }
virtual int ColMeasType( const std::vector<RTDB_KEY_STRU> vec_keyid , std::vector<int>& vec_col_prop ) { return 0; }
// virtual int GraphGetAppInfo(const struct ODB::GRAPH_ORDER_KEY_REQ& graph_req, struct ODB::GRAPH_ORDER_KEY_RSP& graph_rsp) const;
// virtual int GraphGetData(const struct CODB_NET::GRAPH_REAL_REQ& real_req, CODB_NET::GRAPH_REAL_RSP_var& real_rsp) const;
public:
virtual int GetFacNameByKeyNo(const int table_no, const char* key_ptr, string& ref_string) { return 0; }
virtual int GetFacNameByFacID(char* fac_name, const cmnInt64 fac_id) { return 0; }
virtual int GetFacNameByFacNo(char* fac_name, const int fac_no) { return 0; }
virtual int GetFacIDByFacName(cmnInt64& fac_id, const char* fac_name) { return 0; }
virtual int GetFacNoByFacName(int& fac_no, const char* fac_name) { return 0; }
virtual int GetFacIDByFacNo(cmnInt64& fac_id, const int fac_no) { return 0; }
virtual int GetFacNoByFacID(int& fac_no, const cmnInt64 fac_id) { return 0; }
//wj added on 20081205
public:
virtual int TableWrite(const char* buf_ptr, const int record_num, const int record_size) { return 0; }
virtual int TableWrite(const char* buf_ptr, const int buf_size) { return 0; }
virtual int DeleteRecord(const char* key_ptr) { return 0; }
virtual int TableClear() { return 0; }
virtual int GetFieldPara(struct FIELD_BASE_INFO& field_info){ return 0; }
public:
virtual int StartSession(){ return 0; }
virtual int CloseSession(){ return 0; }
};
namespace SESSION_CONST{
const int SESSION_LOCK = 1;
const int SESSION_FREE = 0;
}
struct ODB_SESSION{
unsigned int session_id;
unsigned int thread_id;
unsigned int session_lock_flag;
pthread_mutex_t session_mutex;
};
}
#endif

View File

@@ -0,0 +1,53 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_tablemgr.h
DESCRIPTION: for application ctrl
FUNCTION LIST:
COMMENT: for net access
History:
Date Version Modifier Activities
2003-08-19 1.0 modify
================================================================================
2003-08-18 1.0 created
*******************************************************************************/
#ifndef __ODB_TABLEMGR_h__
#define __ODB_TABLEMGR_h__
#ifndef __ODB_TABLEOP_H__
#include "db_api/odb_tableop.h"
#endif
#ifdef _WINDOWS64
#ifdef ODB_API_LIB_EXPORTS
#define ODB_API_LIB_API __declspec(dllexport)
#else
#define ODB_API_LIB_API __declspec(dllimport)
#endif
#else
#define ODB_API_LIB_API
#endif
namespace ODB
{
class ODB_API_LIB_API CTableMgr: public CTableOp
{
public:
CTableMgr();
~CTableMgr();
public:
int LoadContxt();
int LoadContxt (const short context_no);
int MoveTo (const short context_no);
char* GetSysContxtTabPtr();
struct DB_CONTEXT_TAB* GetCurContextTabPtr();
int ShiftTo (const int app_no);
struct DB_APP_TAB* GetCurAppTabPtr();
};
}
#endif

View File

@@ -0,0 +1,327 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_tablenet.h
DESCRIPTION: for class CTableNet of net access
FUNCTION LIST:
COMMENT: for net access
History:
Date Version Modifier Activities
2004-06-25 1.1 add context_no parameter
2003-01-09 1.0 modify
2003-12-20 1.0 modify
================================================================================
2003-01-09 1.0 created
*******************************************************************************/
#ifndef __ODB_TABLENET_h__
#define __ODB_TABLENET_h__
#ifndef __ODB_COMMON_H__
#include "odb_common.h"
#endif
#ifndef __PROFILE_FILE_H__
#include "db_api/odb_profile.h"
#endif
#ifndef __ODB_TABLEBASE_H__
#include "db_api/odb_tablebase.h"
#endif
#ifndef __ODB_NETFACTORY_h__
#include "db_api/odb_netfactory.h"
#endif
#ifndef __ODB_TABLE_H__
#include "db_api/odb_table.h"
#endif
#include "task_service.h"
#include "odb_net_m.h"
#include "codb_net.h"
#include <stdio.h>
#ifdef _WINDOWS64
#ifdef ODB_API_LIB_EXPORTS
#define ODB_API_LIB_API __declspec(dllexport)
#else
#define ODB_API_LIB_API __declspec(dllimport)
#endif
#else
#define ODB_API_LIB_API
#endif
using namespace std;
//using namespace RTDB_SERVER;
using namespace ODB;
//============================================================================//
namespace NET_ODB
{
typedef struct
{
std::string scn_name;
std::string subscn_name;
int type;
} TTableNetPriv;
class ODB_API_LIB_API CTableNet: public CTableBase
{
public:
CTableNet();
CTableNet(const int app_no, const short context_no = 0);
CTableNet(const int app_no, const int table_no, const short context_no=0);
CTableNet(const std::string& scenario_name, const int scenario_inst_no, const std::string& sub_scenario_name, const int sub_scenario_inst_no, const int table_no);
CTableNet(const int scenario_no, const int scenario_inst_no, const int sub_scenario_no, const int sub_scenario_inst_no, const int table_no);
~CTableNet();
int Open(const int app_no, const int table_no, const short context_no=0);
int Open(const int table_no);
cmnInt32 Open (const std::string& scenario_name,
const int scenario_inst_no,
const std::string& sub_scenario_name,
const int sub_scenario_inst_no,
int table_no);
cmnInt32 Open (const int scenario_no,
const int scenario_inst_no,
const int sub_scenario_no,
const int sub_scenario_inst_no,
const int table_no);
int SetAppNo(const int app_no, const short context_no = 0);
int SetHostMode(const char* host_name);
//int SetManagedMode(const bool is_managed);
int SetScenario (const std::string& scenario_name,
const int scenario_inst_no,
const std::string& sub_scenario_name,
const int sub_scenario_inst_no);
int SetScenario (const int scenario_no,
const int scenario_inst_no,
const int sub_scenario_no,
const int sub_scenario_inst_no);
public:
int TableGet(CBuffer& buf_base);
int TableGet(CBuffer& buf_base, short area_no);
int TableGetWithAreaSplit(const int field_no, CBuffer& buf_base, short area_no);
int TableGetWithOrder(CBuffer& buf_base);
int TableGetSplit(const int field_no, CBuffer& buf_base);
#ifdef _APP_SYS_SUBSTATION
int TableGetAll(CBuffer& buf_base); //Get all columns included virtual columns
#endif
int TableGet(const int field_no, CBuffer& buf_base);
int TableGet(CBuffer& buf_base, const int upper, const int lower);//add select * from XXXX limit (lower, upper);
int TableGetSplit(const char* field_name, CBuffer& buf_base);
int TableGetSplit(CBuffer& buf_base, const int upper, const int lower);
int TableGet(const char* field_name, CBuffer& buf_base);
int TableGet(const char* field_name, CBuffer& buf_base, const int upper, const int lower, std::vector<MEMBER_DEFINITION>& vec_mem);
int TableGetSplit (const std::vector<int>& vec_field_no, CBuffer& buf_base);
int TableGetSplit(const char* field_name, CBuffer& buf_base, const int upper, const int lower, const std::vector<MEMBER_DEFINITION>& vec_mem);
int TableGet(const std::vector<int>& vec_field_no, CBuffer& buf_base);
int FormKEYCondition(const char* column_name_eng, const RTDB_KEY_STRU& key_value, const char* op, std::string& cond_str);
int SqlGetSplit(const char* str_sql, CBuffer& buf_base);
int SqlGetSplit(const char* keyid_sql, const std::vector<int>& vec_field_no, const int upper, const int lower, CBuffer& buf_base, const std::vector<MEMBER_DEFINITION>& vec_mem);
int SqlGet(const char* str_sql, CBuffer& buf_base);
int SqlGet(const char* str_sql, CBuffer& buf_base, std::vector<MEMBER_DEFINITION>& vec_mem);
int SqlGet(const char* str_sql, CBuffer& buf_base, short area_no);
int SqlGetWithAreaSplit(const char* str_sql, CBuffer& buf_base, short area_no);
int SqlGetSplitWithOrder(const char* str_sql, CBuffer& buf_base);
//////
int TableGet(char** buf_ptr, int& buf_size);
int TableGetSplit (const int field_no, char** field_buf_ptr, int& buf_size); //all record
int TableGet(const int field_no, char** field_buf_ptr, int& buf_size); //one field of all record
int TableGetSplit (const std::vector<int>& vec_field_no, char** field_buf_ptr, int& buf_size);
int TableGet(const std::vector<int>& vec_field_no, char** field_buf_ptr, int& buf_size); //get many fields of all record
int TableGetSplit (const char* field_name, char** field_buf_ptr, int& buf_size);
int TableGet(const char* field_name, char** field_buf_ptr, int& buf_size); //Added at 2003-11-22
int TableGetByKeySplit (const char* key_ptr, const int field_no, char* field_buf_ptr, const int buf_size);
int TableGetByKey(const char* key_ptr, char* buf_ptr, const int buf_size); //one record by key word
int TableGetByKey(const char* key_ptr, const int field_no, char* field_buf_ptr, const int buf_size); //one field of a record
int TableGetByKeySplit (const char* key_ptr, const std::vector<int>& vec_field_no, char* field_buf_ptr, const int buf_size);
int TableGetByKey(const char* key_ptr, const std::vector<int>& vec_field_no, char* field_buf_ptr, const int buf_size); //get many fields of a record
int TableGetByKeySplit (const char* key_ptr, const char* field_name, char* field_buf_ptr, const int buf_size);
int TableGetByKey(const char* key_ptr, const char* field_name, char* field_buf_ptr, const int buf_size); //Added at 2003-11-22
int TableGetByKeySplit (const char* key_ptr, const int keybuf_size, const std::vector<int>& vec_field_no, char* field_buf_ptr, const int buf_size);
int TableGetByKey(const char* key_ptr, const int keybuf_size, const std::vector<int>& vec_field_no, char* field_buf_ptr, const int buf_size);
int TableWriteSplit (const char* buf_ptr, const int buf_size);
int TableWrite(const char* buf_ptr, const int buf_size); //write one or more record
int TableWriteSync(const char* buf_ptr, const int buf_size); //write one or more record
int DeleteRecordSplit (const char* key_ptr);
int DeleteRecord(const char* key_ptr);
int DeleteRecordSync(const char* key_ptr);
int DeleteRecordsSplit (const char* key_ptr, int key_num); //delete a record by key word
int DeleteRecords(const char* key_ptr, int key_num);
//key_ptr锟角讹拷锟斤拷锟斤拷锟斤拷锟缴碉拷一锟斤拷锟斤拷锟介key_num锟斤拷示删锟斤拷锟侥革拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟缴撅拷锟斤拷锟绞憋拷锟揭伙拷锟斤拷锟揭?锟接猴拷锟斤拷前删锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷要锟叫断关硷拷锟斤拷锟角凤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟侥讹拷锟斤拷丶锟斤拷锟揭伙拷锟缴撅拷锟斤拷锟斤拷锟斤拷锟斤拷锟揭?锟街成硷拷锟斤拷锟斤拷锟斤拷删锟斤拷锟斤拷
int DeleteAlignedRecordsSplit (const char* key_ptr, int direction);
int DeleteAlignedRecords(const char* key_ptr, int direction = FORWARD);
//direction锟斤拷示锟斤拷锟斤拷FORWARD锟斤拷示删锟斤拷锟斤拷锟斤拷key_ptr锟截硷拷锟街猴拷锟斤拷前锟斤拷锟斤拷锟斤拷屑锟铰硷拷锟狡╋拷锟斤拷锟斤拷key_ptr锟斤拷应锟斤拷9锟斤拷锟斤拷录锟斤拷锟斤拷么锟斤拷删锟斤拷锟斤拷0锟斤拷9锟侥硷拷录锟斤拷锟斤拷BACKWARD锟斤拷示删锟斤拷key_ptr锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷屑锟铰硷拷锟?
//int TableModify(const char* buf_ptr, const int buf_size); //unused 2002-11-14 //modify one or many record
int TableModify(const char* buf_ptr, const int record_num, const int record_size);
int TableModify(const int field_no, const char* field_buf_ptr, const int buf_size); //modify one field of all record by field no
int TableModifyByKeySplit (const char* key_ptr, const int field_no, const char* field_buf_ptr, const int buf_size);
int TableModifyByKey(const char* key_ptr, const int field_no, const char* field_buf_ptr, const int buf_size); //modify one field by key word and field no, only one record
int TableModifyByKeySplit (const char* key_ptr, const int keybuf_size, const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size);
int TableModifyByKey(const char* key_ptr, const int keybuf_size, const int field_no, const char* field_buf_ptr, const int buf_size); //modify one field or all fields of many records by key word
int TableModifyByKey(const char* key_ptr, const int keybuf_size, const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size); //modify many fields or all fields of many records by key word
//
//
int TableModify(const char* field_name, const char* field_buf_ptr, const int buf_size) ;
int TableModify(const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size);
int TableModifyByKeySplit (const char* key_ptr, const char* field_name, const char* field_buf_ptr, const int buf_size);
int TableModifyByKey(const char* key_ptr, const char* field_name, const char* field_buf_ptr, const int buf_size);
int TableModifyByKeySplit (const char* key_ptr, const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size);
int TableModifyByKey(const char* key_ptr, const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size);
int TableModifyByKeySplit (const char* key_ptr, const int keybuf_size, const char* field_name, const char* field_buf_ptr, const int buf_size);
int TableModifyByKey(const char* key_ptr, const int keybuf_size, const char* field_name, const char* field_buf_ptr, const int buf_size);
int TableModifyByKeySync(const char* key_ptr, const int keybuf_size, const char* field_name, const char* field_buf_ptr, const int buf_size);
int TableModifyByKeySync(const char* key_ptr, const int keybuf_size, const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size); //modiify many fields or all fields of many records by key word
int TableUpdateSplit (const char* buf_ptr, const int buf_size);
int TableUpdate(const char* buf_ptr, const int buf_size); //update one or more record
int TableClearSplit();
int TableClear();
//
//SQL interface
//
//int SqlUpdate(const char* str_sql);
int SqlGetSplit (const char* str_sql, char** buf_ptr, int& buf_size);
int SqlGet(const char* str_sql, char** buf_ptr, int& buf_size);
public:
int GetFieldInfo(std::vector<struct ::FIELD_BASE_INFO>& vec_filed);
int GetFieldInfo(const std::vector<int> vec_field_no, std::vector<struct ::FIELD_BASE_INFO>& vec_field);
int GetTableParaSplit(short& field_num, int& record_num, int& record_size);
int GetTablePara(short& field_num, int& record_num, int& record_size);
int GetTablePara(struct TABLE_PARA& table_para);
int GetTablePara(struct STDB_FIELD_TAB* field_descrbptr, const int buf_size);
int GetTablePara(struct TABLE_PARA& table_para, struct STDB_FIELD_TAB* field_descrbptr, const int buf_size);
int GetTablePara(struct TABLE_PARA& table_para, struct STDB_FIELD_TAB** field_descrbptr, int& buf_size);
int GetTablePara(struct TABLE_PARA& table_para, std::vector<struct STDB_FIELD_TAB>& vec_field_para);
int GetTablePara(const char* str_attribute, char** field_para_ptr, int& buf_size);
#ifdef _APP_SYS_SUBSTATION
int GetTableParaAll(struct TABLE_PARA& table_para, std::vector<struct STDB_FIELD_TAB>& vec_field_para);
//jinjing 20120815
int GetTableParaVir(std::vector<struct STDB_VIR_FIELD_TAB>& vec_virfield_para);
#endif
//lmj add 2004.1126
int GetTablePara(struct TABLE_PARA& table_para, CBuffer& buf_base);
int GetTablePara(struct STDB_FIELD_TAB** field_descrbptr, int& buf_size);
int GetFieldPara(struct FIELD_BASE_INFO& field_info);
int GetFieldPara(vector<struct FIELD_BASE_INFO>& field_info_vec);
int GetFieldNameByNo(char* field_name, const int field_no, const bool is_eng=true);
int GetFieldNoByName(int& field_no, const char* field_name, const bool is_eng=true);
int GetTableNameByNo(char* table_name, const int table_no, const bool is_eng=true);
int GetTableNoByName(int& table_no, const char* table_name, const bool is_eng=true);
int GetAppNameByNo(char* app_name, const int app_no);
int GetAppNoByName(int& app_no, const char* app_name);
int GetTableNoByName(const char* table_name, const bool is_eng=true);
int GetTableNoByName(std::vector<int>& vec_table_no , const std::vector<string>& vec_table_name, const bool is_eng=true);
int GetTableNameByNo(std::string& table_name, const int table_no, const bool is_eng=true);
int GetAllOdbNoByAppName(int& app_no, std::vector<NAME_ID>& vec_table, const char* app_name, const bool is_eng=true);
int GetAllOdbNoByAppNo(char* app_name, std::vector<NAME_ID>& vec_table, const int app_no, const bool is_eng=true);
int GetAllOdbNoBySubScenarioName (int& sub_scenario_id, std::vector<NAME_ID>& vec_table,
const std::string& sub_scenario, const unsigned int sub_scenario_inst,
const std::string& scenario, const unsigned int scenario_inst, const bool is_eng=true);
int GetAllOdbNoBySubScenarioNo (std::string& sub_scenario, std::vector<NAME_ID>& vec_table,
const int sub_scenario_id, const unsigned int sub_scenario_inst,
const int scenario_id, const unsigned int scenario_inst, const bool is_eng=true);
int ConGetSplit(const int con_field_no, const char* con_field_value, const int con_value_size, CBuffer& buf_base);
int ConGet(const int con_field_no, const char* con_field_value, const int con_value_size, CBuffer& buf_base);
int ConGetSplit(const int get_field_no, const int con_field_no, const char* con_field_value, const int con_value_size, CBuffer& buf_base);
int ConGet(const int get_field_no, const int con_field_no, const char* con_field_value, const int con_value_size, CBuffer& buf_base);
int ConGetSplit(const vector<int>& con_field_no_array, const vector<int>& get_field_no_array, char* con_field_value, const int con_value_size, CBuffer& buf_base);
int ConGet(const vector<int>& con_field_no_array, const vector<int>& get_field_no_array, char* con_field_value, const int con_value_size, CBuffer& buf_base);
public:
int PingRtdbServer(int req_data , int & rep_data);
int GetKeySize(const int table_no); //wj added for d5000 C-API
public:
int SetDomainName(const char* domain_name);
int SetSecLabel(tSecLabel& sec_label);
void ClearDomainName();
int SetSliceNo(cmnUint32 slice_no);
private:
int TableModify(const char* buf_ptr, const int buf_size);
private:
// public:
int Start();
int Refresh();
int Refresh(int app_no);
int GetSliceByKey(const char* key, cmnUint32& slice_no);
int GetAllSlice(vector<int>& slice_no);
int ParseRsp(char** buf_ptr, int& buf_size, const RTDB_PROTO::RSP_READ& read_rsp);
int ParseRsp(char* buf_ptr, const int buf_size, const RTDB_PROTO::RSP_READ& read_rsp);
int GetKeyInfo();
int GetKeyInfoSlice();
inline int slice_app_to_no(int slice_app_no){return slice_app_no % 1000;}
inline int slice_no_to_app(int slice_no){return slice_no+AP_SCADA_AREA;}
bool IsApplication(const int app_no);
private:
CTableNet(const CTableNet&);
CTableNet& operator=(const CTableNet&);
private:
RTDB_SERVER::CODB_NET* m_OdbNet;
CNetFactory* m_Factory;
//Handle m_Handle; //for service_bus
NProfile::CProfile *m_IniFile;
//
short m_ContextNo;
int m_AppNo;
int m_TableNo;
// std::string m_scenario_name;
int m_scenario_no;
// std::string m_sub_scenario_name;
int m_sub_scenario_no;
int m_scenario_inst_no;
int m_sub_scenario_inst_no;
DB_BYTE_T m_ByteTag;
bool m_IsSysAdmHost;
char m_HostName[MAX_NAME_STRING_LEN];
char m_DomainName[40];
tSecLabel m_SecLabel;
bool m_IsRemote;
int m_SliceNo;
TaskService* task_service;
std::vector<int> m_VecKey;
std::vector<int> m_IsSliced;
std::vector<struct FIELD_BASE_INFO> m_VecField;
TTableNetPriv *m_pPrvStru;
};
}
#endif

View File

@@ -0,0 +1,658 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_tableop.h
DESCRIPTION: class system struct define
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
1004-06-28 1.1 add context_no parameter
2002-11-06 1.0 modify
================================================================================
2002-10-30 1.0 created
*******************************************************************************/
#ifndef __ODB_TABLEOP_H__
#define __ODB_TABLEOP_H__
#ifndef __ODB_SYSTEM_H__
#include "db_api/odb_system.h"
#endif
#ifndef __ODB_TABLE_H__
#include "db_api/odb_table.h"
#endif
#ifndef __ODB_FIELD_H__
#include "db_api/odb_field.h"
#endif
#ifndef __ODB_WHERE_H__
#include "db_api/odb_where.h"
#endif
#ifndef __ODB_TABLEBASE_H__
#include "db_api/odb_tablebase.h"
#endif
#include "db_api/odb_baseindex.h"
#include "slice_api/logic_table.h"
using namespace std;
//using namespace ODB_SLICE;
#ifdef _APP_SYS_SUBSTATION
class CaseSearch;
class CaseConGet;
class CaseTableModifyByKey;
class CaseTableWrite;
class CaseDeleteRecord;
class CaseTableUpdate;
class CaseDeleteIndex;
class CaseHashPKDebug;
class idx_mon;
class CaseShowIndexStatus;
class CDyDownload;
class TestItem;
#endif
namespace ODB
{
typedef struct
{
int type;
} TTableOpPriv;
// enum DIRECTION
// {
// FORWARD = 0,
// BACKWARD = 1 ,
// };
class CTableOp: public CTableBase
{
public:
//
//constructor & destructor // 2002-11-06
//
CTableOp(); //then Open()
CTableOp (const int app_no, const int table_no, const short context_no = 0);
CTableOp (const int app_no, const char* table_name, const short context_no = 0);
CTableOp (const std::string& scenario_name, const int scenario_inst_no, const std::string& sub_scenario_name, const int sub_scenario_inst_no, const int table_no);
CTableOp (const int scenario_no, const int scenario_inst_no, const int sub_scenario_no, const int sub_scenario_inst_no, const int table_no);
CTableOp (const char* app_name, const int table_no, const short context_no = 0);
CTableOp (const char* app_name, const char* table_name,
const short context_no = 0);
CTableOp (const string& app_name, const string& table_name,
const short context_no = 0);
CTableOp (const int app_no, const short context_no = 0);
//CTableOp(const char* context_name); //abandon context_name // 2004-06-25
~CTableOp();
int SetAppNo (const int app_no, const short context_no = 0);
//int Open(const std::pair<const int, const int>&, const short context_no = 0);
int Open (std::pair<int, int>, short context_no = 0); //this is no longer used
cmnInt32 Open (const int app_no, const int table_no,
const short context_no = 0);
cmnInt32 Open (const char* app_name, const int table_no,
const short context_no = 0); //
cmnInt32 Open (const int app_no, const char* table_name,
const short context_no = 0); // 2004-06-25
cmnInt32 Open (const char* app_name, const char* table_name,
const short context_no = 0); //
cmnInt32 Open (const cmnUint32 app_no, const char* table_name,
const cmnInt32 slice_no, const cmnUint16 context_no);
cmnInt32 Open (const cmnUint32 app_no, const cmnUint32 table_no,
const cmnInt32 slice_no, const cmnUint16 context_no);
cmnInt32 Open (const std::string& scenario_name,
const int scenario_inst_no,
const std::string& sub_scenario_name,
const int sub_scenario_inst_no,
const int table_no);
cmnInt32 Open (const int scenario_no,
const int scenario_inst_no,
const int sub_scenario_no,
const int sub_scenario_inst_no,
const int table_no);
cmnInt32 SetScenario(const std::string& scenario_name,
const int scenario_inst_no,
const std::string& sub_scenario_name,
const int sub_scenario_inst_no);
cmnInt32 SetScenario(const int scenario_no,const int scenario_inst_no,const int sub_scenario_no,const int sub_scenario_inst_no);
int SetSliceNo (cmnInt32 _slice_no);
//create & delete
#ifdef _APP_SYS_SUBSTATION
cmnInt32 TableCreate (const struct STDB_CREAT_REQ* stdb_creat_req_ptr,
const struct FIELD_CREAT_REQ* multi_fields_ptr,
const struct VIR_FIELD_CREAT_REQ* vir_fields_ptr,
const std::vector<MEMBER_DEFINITION>& vec_offset,
INDEX_DEFINE_ARRAY &index_define_array); //锟斤拷锟斤拷锟斤拷删锟斤拷锟斤拷锟斤拷,锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷
#endif
cmnInt32 TableCreate (const struct STDB_CREAT_REQ* stdb_creat_req_ptr,
const struct FIELD_CREAT_REQ* multi_fields_ptr,
const std::vector<MEMBER_DEFINITION>& vec_offset,
INDEX_DEFINE_ARRAY &index_define_array);
cmnInt32 TableWrite (const char* buf_ptr, const cmnUint32 record_num,
const cmnUint32 record_size);
cmnInt32 TableWrite (const char* buf_ptr,
const cmnUint32 buf_size); //write one or many records
cmnInt32 TableWriteWithoutIndex (const char* buf_ptr, const cmnUint32 record_num,
const cmnUint32 record_size);
cmnInt32 TableWriteWithoutIndex (const char* buf_ptr,
const cmnUint32 buf_size);//int TableDelete(const int app_no, const int table_no, const char* passwd_ptr); //delete by table no
cmnInt32 TableWriteNoSlice (const char* buf_ptr, const cmnUint32 record_num,
const cmnUint32 record_size);
cmnInt32 TableWriteNoSlice (const char* buf_ptr,
const cmnUint32 buf_size);//int TableDelete(const int app_no, const int table_no, const char* passwd_ptr); //delete by table no
//int TableDelete(const int app_no, const char* table_name, const char* passwd_ptr); //delete by table name
int TableClear(); //clear a table
int TableClear(int slice_no);
//
//query the whole table
//
cmnInt32 TableGet (CBuffer& buf_base);
cmnInt32 TableGetWithArea (CBuffer& buf_base, unsigned char area_no);
cmnInt32 TableGet (const int field_no, CBuffer& buf_base);
int TableGet (const char* field_name, CBuffer& buf_base);
int TableGet (const std::vector<int>& vec_field_no, CBuffer& buf_base);
//
cmnInt32 TableGet (char* buf_ptr, const int buf_size); //get all record of a table
cmnInt32 TableGet (char** buf_ptr, cmnUint32& buf_size);
cmnInt32 TableGet (char** buf_ptr, int& buf_size);
cmnInt32 TableGet (const int field_no, char** field_buf_ptr,
cmnUint32& buf_size) ; //get one field of all record by field no
cmnInt32 TableGet (const int field_no, char** field_buf_ptr,
int& buf_size) ;
int TableGet (const char* field_name, char** field_buf_ptr,
cmnUint32& buf_size);
int TableGet (const char* field_name, char** field_buf_ptr,
int& buf_size);
//get one or many fields of all record by field name //2002-11-20
int TableGet (const std::vector<int>& vec_field_no, char** field_buf_ptr,
cmnUint32& buf_size);//get one or many fields of all record
int TableGet (const std::vector<int>& vec_field_no, char** field_buf_ptr,
int& buf_size);
//
//query by key word
//
cmnInt32 TableGetByKey (const char* key_ptr, char* buf_ptr,
const int buf_size); // get one record by key word
cmnInt32 TableGetByKey (const char* key_ptr, const int field_no,
char* field_buf_ptr, const int buf_size); //get one field of one record by field no & key word
cmnInt32 TableGetByKey (const char* key_ptr, const int field_no,
char* field_buf_ptr, const int buf_size, int& data_type, int& data_len);
int TableGetByKey (const char* key_ptr, const std::vector<int>& vec_field_no,
char* field_buf_ptr, const int
buf_size); //get one or many fields by field no & key word
int TableGetByKey (const char* key_ptr, const char* field_name,
char* field_buf_ptr, const int buf_size); //get one or many fields by field name & key word
int TableGetByKey (const char* key_ptr, const int keybuf_size,
const std::vector<int>& vec_field_no, char* field_buf_ptr,
const int buf_size); //many key words
public:
int TableGet (const std::vector<int>& vec_field_no, char** field_buf_ptr,
cmnUint32& buf_size, std::vector<MEMBER_DEFINITION>& vec_offset);
int TableGet (const std::vector<int>& vec_field_no, char** field_buf_ptr,
int& buf_size, std::vector<MEMBER_DEFINITION>& vec_offset);
int TableGetByKey (const char* key_ptr, const std::vector<int>& vec_field_no,
char* field_buf_ptr, const int buf_size,
std::vector<MEMBER_DEFINITION>& vec_offset);
int TableGetByKey (const char* key_ptr, const int keybuf_size,
const std::vector<int>& vec_field_no, char* field_buf_ptr, const int buf_size,
std::vector<MEMBER_DEFINITION>& vec_offset);
//lmj add 2004.1125
int TableGetByKeyAligned (const char* key_ptr,
const std::vector<int>& vec_field_no, char* field_buf_ptr, const int buf_size,
std::vector<MEMBER_DEFINITION>& vec_offset);
int TableGetByKeyAligned (const char* key_ptr, const int keybuf_size,
const std::vector<int>& vec_field_no, char* field_buf_ptr, const int buf_size,
std::vector<MEMBER_DEFINITION>& vec_offset);
cmnInt32 TableGetBySlice (
const cmnUint32 slice_no,
const cmnUint32 phy_pos,
char* buffer,
const cmnUint32 buf_size
);
cmnInt32 TableGetByRange (cmnUint32 start, cmnUint32 end, char** buffer,
cmnUint32& buf_size);
cmnInt32 GetSliceByKey (const char* key_ptr, cmnUint32 &slice_no,
cmnUint32 &phy_pos);
//
//the whole record //modify // 2002-11-12
//
public:
int TableModify (const char* buf_ptr, const int record_num,
const int record_size); //modify one or many record
int TableModify (const char* buf_ptr, const int buf_size);
//
//many fields of all record
//
int TableModify (const int field_no, const char* field_buf_ptr,
const int buf_size); //modify one field of all record by field no
int TableModify (const char* field_name, const char* field_buf_ptr,
const int buf_size); //modify one or many fields of all record by field name
int TableModify (const std::vector<int>& vec_field_no,
const char* field_buf_ptr,
const int buf_size); //modify many fields of all record by field no
//
//by keyword && fields
//
cmnInt32 TableModifyByKey (const char* key_ptr, const int field_no,
const char* field_buf_ptr,
const int buf_size); //modify one field by key word and field no
int TableModifyByKey (const char* key_ptr, const char* field_name, const char* field_buf_ptr, const int buf_size); //modify many fields by key word and field name
int TableModifyByKey (const char* key_ptr, const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size); //modify many fields by field no
int TableModifyByKeyMulFlds (const char* key_ptr, const int field_num, ...);
//lmj add 2004.1125
int TableModifyByKeyAligned (const char* key_ptr,
const std::vector<int>& vec_field_no, const char* field_buf_ptr,
const int buf_size, std::vector<MEMBER_DEFINITION>&
vec_offset); //modify many fields by field no
//
//by keywords && fields
//
int TableModifyByKey (const char* key_ptr, const int keybuf_size, const int field_no, const char* field_buf_ptr, const int buf_size); //modify one field or all fields of many records by key word
int TableModifyByKey (const char* key_ptr, const int keybuf_size, const char* field_name, const char* field_buf_ptr, const int buf_size); //modify many fields or all fields of many records by key word
int TableModifyByKey (const char* key_ptr, const int keybuf_size, const std::vector<int>& vec_field_no, const char* field_buf_ptr, const int buf_size); //the same as above
//lmj add 2004.1125
int TableModifyByKeyAligned (const char* key_ptr, const int keybuf_size,
const std::vector<int>& vec_field_no, const char* field_buf_ptr,
const int buf_size, std::vector<MEMBER_DEFINITION>&
vec_offset); //the same as above
//
//update & delete // 2002-11-12
//
int TableUpdate (const char* buf_ptr,
const int buf_size); //update one or more record
int TableUpdate (const char* key_ptr, const char* buf_ptr,
const int buf_size, const cmnUint32 slice_no); //update one or more record
int TableUpdate (const char* buf_ptr, const int record_num,
const int record_size);
int GetDefaultRecord (char *defaut_rec_ptr);
int TableUpdate ( const int field_no, const char* buf_ptr, const int buf_size);
int TableUpdate ( vector<int> field_vec, const char* buf_ptr,
const int buf_size);
int TableUpdate ( const char* field_name, const char* buf_ptr,
const int buf_size);
int DeleteRecord (const char* key_ptr);//delete a record by key word
int DeleteRecords (const char* key_ptr, int key_num);
int DeleteAlignedRecords (const char* key_ptr, int direction = FORWARD);
//
//query by condition //aligned
//
cmnInt32 ConGet (const int con_field_no, const int con_field_value,
char* buf_ptr, const int buf_size); //one record by field(int)
cmnInt32 ConGet (const int con_field_no, const cmnInt32 con_field_value,
char** buf_ptr, cmnUint32&
buf_size); //one record by field(int)
cmnInt32 ConGet (const int con_field_no, const char* con_field_value,
char** buf_ptr, cmnUint32&
buf_size); //one record by field(string)
cmnInt32 ConGet (const int get_field_no, const int con_field_no,
const char* con_field_value, char** buf_ptr,
int& buf_size); //one field by field(string)
cmnInt32 ConGet (const int get_field_no, const int con_field_no,
const char* con_field_value, char** buf_ptr,
cmnUint32& buf_size);
cmnInt32 ConGet (const int con_field_no, const cmnInt64 con_field_value,
char **buf_ptr, int &buf_size);
cmnInt32 ConGet (const int con_field_no, const cmnInt64 con_field_value, char** buf_ptr, cmnUint32 &buf_size);
cmnInt32 ConGet (const int get_field_no, const int con_field_no,
const long con_field_value, char **buf_ptr, cmnUint32& buf_size);
int ConGet (const std::vector<int>& con_field_no_array,
const std::vector<int>& get_field_no_array, char *con_buf_ptr, char **buf_ptr,
int &buf_size);
int ConGet (const int con_field_no, const int con_field_value, char** buf_ptr,
int& buf_size); //one record by field(int)
int ConGet (const int con_field_no, const char* con_field_value, char** buf_ptr,
int& buf_size); //one record by field(string)
int ConGet (const int get_field_no, const int con_field_no,
const int con_field_value, char* buf_ptr,
const int buf_size);//one field by field(int)
int ConGet (const int get_field_no, const int con_field_no,
const cmnInt64 con_field_value, char **buf_ptr, int& buf_size);
int ConGetAreaTable (const int con_field_no, const char* con_field_value,
char** buf_ptr, int& buf_size);
int ConGetAreaTable (const int get_field_no, const int con_field_no,
const char* con_field_value, char** buf_ptr, int& buf_size);
int ConGetAreaTable (const std::vector<int>& con_field_no_array,
const std::vector<int>& get_field_no_array, char* con_buf_ptr, char** buf_ptr,
int& buf_size);
int ConGetByMeasID (const int get_field_no, const char* con_field_value,
char** buf_ptr, int& buf_size);
int ConGetByMeasID (const char* con_field_value, char** buf_ptr, int& buf_size);
int ConGetByMeasID (const std::vector<int>& get_field_no_array,
char* con_field_value, char** buf_ptr, int& buf_size);
//Added for new structure and new function for D-5000 end
//
//sort record by condition //aligned
//
int SortGet (const int field_no, char* bu_fptr, const int buf_size,
const bool is_asc = true); //one field and sorted by it
int SortGet (const char* field_name, char* bu_fptr, const int buf_size,
const bool is_asc = true); //many fields and sorted by them
int SortGet (const std::vector<int>& vec_field_no, char* buf_ptr,
const int buf_size, const bool is_asc =
true); //many fields and sorted by them
int SortGet (char* buf_ptr, const int buf_size,
const bool is_asc =
true); //get key word & index field and sorted by index
//
//SQL interface
//
int SqlUpdate (const char* str_sql);
int SqlGet (const char* str_sql, CBuffer& buf_base);
int SqlGet (const char* str_sql, char** buf_ptr, int& buf_size);
int SqlGet (const char* str_sql, char** buf_ptr, int& buf_size,
std::vector<MEMBER_DEFINITION>& vec_offset);
int FormKEYCondition(const char* column_name_eng, const RTDB_KEY_STRU& key_value, const char* op, std::string& cond_str);
public:
int GetTablePara (short& field_num, int& record_num, int& record_size);
int GetTablePara (struct TABLE_PARA& table_para);
int GetTablePara (struct STDB_FIELD_TAB* &field_para_ptr, int &buf_size);
int GetTablePara (struct TABLE_PARA& table_para,
struct STDB_FIELD_TAB* &field_para_ptr, int &buf_size);
int GetTablePara (struct TABLE_PARA& table_para,
std::vector<struct STDB_FIELD_TAB>& vec_field_para);
//int GetTablePara(std::vector<struct FIELD_PARA>& vec_field_para); // 2003-05-21
int GetTablePara (const char* str_attribute, char** field_para_ptr,
int& buf_size);
int GetTablePara (const char* str_attribute, char** field_para_ptr,
int& buf_size, std::vector<MEMBER_DEFINITION>& vec_offset); //by net daemon
#ifdef _APP_SYS_SUBSTATION
int GetTableParaAll (const char* str_attribute, char** field_para_ptr,
int& buf_size, std::vector<MEMBER_DEFINITION>& vec_offset); //by net daemon
//jinjing 2012-03-27 with virtual field
int GetTableParaAll (struct TABLE_PARA& table_para,
std::vector<struct STDB_FIELD_TAB>& vec_field_para);
int GetTableParaVir (std::vector<struct STDB_VIR_FIELD_TAB>& vec_virfield_para);
#endif
// int GetRecordNum();
// int GetKeyWordLength();
//
//field's parameter
//
int GetFieldEngNameByNo (char* field_name, const int field_no);
int GetFieldChnNameByNo (char* field_name, const int field_no);
int GetFieldNameByNo (char* field_name, const int field_no,
const bool is_eng = true);
int GetFieldNoByName (int& field_no, const char* field_name,
const bool is_eng = true); //only one
int GetFieldNoByName (std::vector<int>& vec_field_no,
const char* field_name); //many fields
int SetFieldNameByNo (const char* field_name, const int field_no);
int GetFieldNoBySql (std::vector<int>& vec_field_no, const char* str_sql);
//int GetRtNoByFieldNo(int& field_no, const int r_field_no);
//
//table's parameter
//
int GetTableNameByNo (char* table_name, const int table_no,
const bool is_eng = true);
int GetTableNoByName (int& table_no, const char* table_name,
const bool is_eng = true);
int GetTableNoByName (const char* table_name);
//
//application's parameter
//
int GetAppNameByNo (char* app_name, const int app_no);
int GetAppNoByName (int& app_no, const char* app_name);
int GetAppNoByName (const char* app_name);
int GetSubScenarioNoByName(const char* sub_scenario_name, unsigned int& sub_scenario_id) const;
int GetSubScenarioNameByNo(std::string& sub_scenario_name, const unsigned int sub_scenario_id) const;
//int GetAllOdbNoByAppName(short& app_no, std::vector<NAME_ID>& table, const char* app_name); // 2002-12-02
int GetAllOdbNoByAppName (int& app_no, std::vector<int>& table,
const char* app_name); // 2002-12-02
int GetAllOdbNoByAppNo (char* app_name, std::vector<NAME_ID>& vec_table,
const int app_no, const bool is_eng = true);
int GetAllOdbNoBySubScenarioName (int& sub_scenario_id, std::vector<int>& vec_table,
const std::string& sub_scenario, const unsigned int sub_scenario_inst,
const std::string& scenario, const unsigned int scenario_inst);
int GetAllOdbNoBySubScenarioNo (std::string& sub_scenario, std::vector<NAME_ID>& vec_table,
const int sub_scenario_id, const unsigned int sub_scenario_inst,
const int scenario_id, const unsigned int scenario_inst, const bool is_eng);
//int GetAllAppNo (std::vector<struct NAME_ID>& vec_appno);//查看本机下装的应用意义不大,通过系统管理获取本机在线的应用更有意义
int WriteTableStatus (DB_STATUS_T status);
int GetTableStatus (DB_STATUS_T &status);
int SetSemKey (const int app_no, const int r_table_no,
const short ctx_no); //for OPTLOCK
//for merge table jinjing 2015-05-28
int SetMergeTabAreaNo (const int area_no);
int GetIsDownloadBySlice(int slice_no);
int GetDownloadSliceVec(std::vector<int>& vec_slice_no);
//jinjing 2017-11-21 for rtdb_mdify
int ConGetOnlyIndex(const std::vector<int>& con_field_no_array,
const std::vector<int>& get_field_no_array,
char *con_buf_ptr, char **buf_ptr,
int &buf_size);
cmnInt32 ConGetOnlyIndex (const int get_field_no,
const int con_field_no,
char* con_field_value, char** buf_ptr, int& buf_size);
public:
struct STDB_TAB* GetCurStdbTab(); // 2003-01-18
struct STDB_FIELD_TAB* GetCurStdbFieldTab(); // 2003-03-03
const struct STDB_TAB* GetStdbTab(); // 2003-12-18
const struct STDB_FIELD_TAB* GetStdbFieldTab(); // 2003-12-03
const struct STDB_TAB* GetStdbTab (const int area_no);
int GetFieldPara (struct FIELD_BASE_INFO& field_info);
int GetFieldParaByNo (std::vector<MEMBER_DEFINITION>& vec_offset,
const std::vector<int>& vec_field_no);
int GetFieldInfo (const std::vector<int>& vec_field_no,
std::vector<struct FIELD_BASE_INFO>& vec_field);
#ifdef _APP_SYS_SUBSTATION
const struct STDB_VIR_FIELD_TAB* GetStdbVirFieldTab();
//jinjing 2012-03-28
int GetFieldParaAll (const char* str_attribute, char** field_para_ptr,
int& buf_size, std::vector<MEMBER_DEFINITION> vec_offset);
#endif
//exchange byte order for buffer data
int ExchangeData (char* buf_ptr, const int buf_size,
const std::vector<int>& vec_field, const DB_BYTE_T& remote_byte);
int ExchangeKeyData (char* buf_ptr, const int buf_size,
const DB_BYTE_T& remote_byte);
int GetDbID (int& db_id);
int SetDbID (const int db_id);
public:
int AddApp (const char *all_name, const short context_no );
int AddOneTable (const int r_table_no, const char* table_name_eng);
int AddContext ( const short context_no );
public:
//for index operation
int RebuildIndex();
private:
//sql
int GetFieldNames (const char* str_sql,
std::vector<NAME_ID>&
vec_field); //from select clause, call GetFieldNameBySelect()
bool GetFieldNameBySelect (const char* str_field,
std::vector<NAME_ID>& vec_field) const;
bool GetFieldNameByWhere (const char* str_condition,
std::vector<NAME_ID>& vec_field) const;
bool GetFieldNameByOrder (const char* str_orderby,
std::vector<SQL_SORT>& vec_field_sort) const;
int GetFieldWhere (std::vector<FIELD_STRU>& vec_field_sql,
const std::vector<NAME_ID>& vec_field_where);
int destory_field_where ( std::vector<FIELD_STRU>& vec_field_sql );
//
//sort, only used by itself
//
int SortGet (std::vector<NAME_ID>& vec_select, char** buf_ptr, int& buf_size,
const std::vector<bool>& vec_where, std::vector<SQL_SORT>& vec_order);
int SortGet (std::vector<NAME_ID>& vec_select, char** buf_ptr, int& buf_size,
const std::vector<bool>& vec_where, std::vector<SQL_SORT>& vec_order,
std::vector<MEMBER_DEFINITION>& vec_offset);
int SortGet(std::vector<NAME_ID>& vec_select, std::vector<NAME_ID>& vec_field_where,
char* str_where, char** buf_ptr, int& buf_size, std::vector<SQL_SORT>& vec_order,
std::vector<MEMBER_DEFINITION>& vec_offset);
int GetSortedKey ( std::vector<RCD_TYPE>& vec_sort,
const char* all_record_ptr,
const std::vector<int>& vec_field_no,
const struct STDB_TAB* stdb_tab_ptr,
const struct STDB_FIELD_TAB* stdb_field_tab_ptr);
bool ParseLike (const char* str_condition,
std::vector<NAME_ID>& vec_field) const;
char* CheckLike (const char* str_condition, const char* str_like) const;
int SortGetForSql (std::vector<int>& SortVecNo , char * orgBufPtr ,
char * & bufPtr , int recNum, int is_asc);
private:
int Start();
int GetScenarioID(const short context_no, unsigned int& scenario_id, unsigned int& scenario_inst_no);
//delete
//int TableDelete(struct STDB_DELETE_REQ* stdb_delete_req_ptr);
/*********Added for index begin *****************/
public:
INDEX_DEFINE_TAB* GetIdxDfnPtr();
FIELD_INDEX_DEFINE_TAB* GetFldIdxDfnPtr();
FIELDS_IN_INDEXS_DESC_TAB* GetFldsInIdxDescPtr();
FIELDS_USED_IN_INDEX_TAB* GetFldsUsedInIdxPtr();
CBaseIndex *GetIndexPtr (int
seq_no); //锟斤拷锟斤拷idx_op_ptr_array锟侥碉拷seq_no锟斤拷元锟截拷锟斤拷锟斤拷锟絪eq_no锟斤拷元锟斤拷锟斤拷NULL锟侥伙拷锟斤拷new一锟斤拷元锟截筹拷锟斤拷锟斤拷
CBaseIndex
*GetPKIndexPtr();//锟斤拷锟絧k_index_ptr锟斤拷锟斤拷锟斤拷NULL锟斤拷锟酵凤拷锟斤拷一锟斤拷pk_index_ptr锟斤拷锟斤拷锟斤拷new一锟斤拷锟铰的凤拷锟截★拷
public:
int DebugDisp (int index_no,
int type); // 锟斤拷示锟斤拷index_no锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷息锟斤拷譬锟斤拷index_no为0锟斤拷1锟斤拷......锟斤拷type为锟斤拷息锟斤拷锟斤拷细锟教度憋拷志锟斤拷
int TableDelete();
int DetachSlice(cmnUint32 slice_no);
/*********Added for index end ******************/
public: //These functions are used only for debug
int SprintKey (char *key_ptr, char *key_string);
//int Search(char *key_ptr,int &record_pointer);
public:
/*
cmnInt32 CreateOpen (const int app_no, const int table_no, const int slice_no,
const short context_no = 0);
*/
int CreateOpen (const std::string& scenario_name,
const int scenario_inst_no,
const std::string& sub_scenario_name,
const int sub_scenario_inst_no,
const int table_no);
cmnInt32 SliceCreate (const int slice_no);
cmnInt32 StartSession();
cmnInt32 CloseSession();
private:
CTableOp (const CTableOp&);
CTableOp& operator= (const CTableOp&);
TTableOpPriv *m_pPrvStru;
bool m_IsMap;
int m_slice_no;
public:
COdbSystem* GetOdbSystemPtr();
COdbTable* GetOdbTablePtr();
COdbField* GetOdbFieldPtr();
public:
const struct DB_CTRL_TAB* GetDbCtrlTabPtr();
DB_APP_TAB* GetAppTabPtr();
char* GetTableFileName();
private:
void SetAppTabPtr (DB_APP_TAB* app_tab_ptr);
protected:
COdbSystem* m_OdbSystemPtr;
COdbField* m_OdbFieldPtr;
ODB_SLICE::CLogicTable m_LogicTable;
struct ODB_SESSION m_session;
#ifdef _APP_SYS_SUBSTATION
//friend class ::CTestItem;
friend class ::CaseSearch;
friend class ::CaseConGet;
friend class ::CaseTableModifyByKey;
friend class ::CaseTableWrite;
friend class ::CaseDeleteRecord;
friend class ::CaseTableUpdate;
friend class ::CaseDeleteIndex;
friend class ::CaseHashPKDebug;
friend class ::idx_mon;
friend class Tab2Idx;
friend class ::CaseShowIndexStatus;
friend class ::CDyDownload;
friend class ::TestItem;
#endif
};
}
#endif

View File

@@ -0,0 +1,211 @@
/*******************************************************************************
ModuleName: ODB Real Time Database management system
FileName: odb_where.h
DESCRIPTION: interface to hubo
FUNCTION LIST:
COMMENT:
History:
Date Version Modifier Activities
2002-11-26 1.0 modify
================================================================================
2002-11-26 1.0 created
*******************************************************************************/
#ifndef __ODB_WHERE_H__
#define __ODB_WHERE_H__
#include <vector>
#include "odb_struct.h"
//#include "where_syntax_anls.h"
//#include "interpreter_define.h"
using namespace std;
//class FOR_WHERE::CWhereSyntaxAnalyser;
/*
#define LEFT_SIDE 0x10
#define RIGHT_SIDE 0x20
*/
#ifdef _WINDOWS64
#ifdef ODB_WHERE_EXPORTS
#define ODB_WHERE_API __declspec(dllexport)
#else
#define ODB_WHERE_API __declspec(dllimport)
#endif
#else
#define ODB_WHERE_API
#endif
/*
struct CODE_TABLE_STRU;
class CWhereSyntaxAnalyser;
class CInterpreter;
*/
namespace FOR_WHERE
{
class CWhereSyntaxAnalyser;
}
namespace ODB
{
//struct SQL_KEY_ID
//{
//// int table_no;
//// short field_no;
// int record_id;
// short column_id;
//};
//
//struct SQL_APP_ID
//{
// int app_id;
// int record_id;
//};
//
//struct SQL_APP_KEY
//{
// int app_id;
// int record_id;
// short column_id;
//};
typedef cmnInt64 SQL_KEY_ID;
typedef _RTDB_KEY_STRU SQL_RTDB_KEY;
/*
struct SQL_APP_KEY
{
int app_id;
SQL_RTDB_KEY key_id;
};
*/
typedef _APP_KEY_STRU SQL_APP_KEY;
typedef _APP_ID_STRU SQL_APP_ID;
union SQL_DATA_TYPE
{
//char to_str[40];
char to_char;
char* to_str;
short to_short;
int to_int;
cmnInt64 to_long;
unsigned int to_uint;
float to_float;
double to_double;
SQL_KEY_ID to_key;
SQL_APP_ID to_appid;
SQL_APP_KEY to_appkey;
SQL_RTDB_KEY to_rtdbkey;
SQL_RTDB_KEY to_measrtdbkey;
//binary
};
/*
#ifdef _WINDOWS64
struct ODB_WHERE_API FIELD_STRU
#else
struct FIELD_STRU
#endif
*/
struct FIELD_STRU
{
char field_name[64]; //CHN_NAME_LEN
int data_type;
std::vector<SQL_DATA_TYPE> vec_value;
// std::vector<SQL_APP_KEY> vec_stru_value;
};
struct SQLIDX_STRU
{
char field_name[64];
int data_type;
char field_no;
int is_keyword;
};
struct IDX4SEARCH_STRU
{
enum SIDE{ UNKNOW = 0x1 , LEFT_SIDE = 0x10 , RIGHT_SIDE = 0x20};
int field_no;
int data_type;
int operation_type; // == >= <=
SQL_DATA_TYPE value;
int taken_num;
SIDE side;
int is_keyword;
IDX4SEARCH_STRU()
{
this->data_type = 0;
this->taken_num = 0;
this->operation_type = -1;
this->side = UNKNOW;
this->is_keyword = 0;
}
int clear()
{
this->field_no = -1;
this->data_type = 0;
this->operation_type = -1;
this->value.to_int = -1;
this->taken_num = 0;
this->side = UNKNOW;
this->is_keyword = 0;
return 1;
}
};
class ODB_WHERE_API CWhere
{
public:
CWhere();
/* {
sql_translate = NULL;
};*/
~CWhere();
/*{
if(sql_translate)
{
delete sql_translate;
}
};*/
bool GetWhere(std::vector<bool>& vec_where, const char* where_str, const std::vector<FIELD_STRU>& vec_sql);
//jinjing 2013-5-3
bool GetWhere(std::vector<int>& vec_where, const char* where_str, const std::vector<FIELD_STRU>& vec_sql);
void Show();
int ExpressSql(char * where_str , std::vector<SQLIDX_STRU> & vec_sqlidx, std::vector<IDX4SEARCH_STRU> & idx_vec);
private:
FOR_WHERE::CWhereSyntaxAnalyser* sql_translate;
/*
private :
float real_const_tab[MAX_REALCONSTTABLE_LEN]; //实常量表
int real_const_tab_len;
char *string_tab[MAX_STRINGTABLE_LEN]; //字符串表
int string_tab_len;
CODE_TABLE_STRU* code_tab[MAX_CODETABLE_LEN]; //中间代码表
int code_tab_len;
CWhereSyntaxAnalyser* sql_translate; //语法分析器
CInterpreter* sql_itprt; //解释器
*/
};
}
#endif

View File

@@ -0,0 +1,57 @@
#ifndef __PUB_BUF_H__
#define __PUB_BUF_H__
#include <cstdlib>
#include <cstring>
#ifdef _WINDOWS64
#ifdef PUB_EXPORTS
#define PUB_LIB_API __declspec(dllexport)
#else
#define PUB_LIB_API __declspec(dllimport)
#pragma comment(lib,"libpub.lib")
#endif
#else
#define PUB_LIB_API
#endif
class PUB_LIB_API CBuffer
{
public:
CBuffer();
~CBuffer();
//
// consumer interface
//
inline char* GetBufPtr() const { return m_BufPtr; }
inline int GetLength() const { return m_DataLen; }
inline int GetBuffer(char** buf_ptr, int& buf_size) const
{
*buf_ptr = m_BufPtr;
buf_size = m_DataLen;
return 0;
}
char* Detach();
static void Free(void* pointer);
//
// producer interface
//
int SetBuffer(const char* buf_ptr, const int buf_size);
int SetLength(const int buf_size);
int AppendBuf(const char* buf_ptr, const int buf_size);
int Clear();
private:
char* m_BufPtr;
int m_BufLen;
int m_DataLen;
int m_Detached;
};
#endif

View File

@@ -0,0 +1,44 @@
#ifndef __RTDB_GRAPH_NAME_H__
#define __RTDB_GRAPH_NAME__
#ifdef _WINDOWS64
#ifdef RTDB_GRAPH_NAME_EXPORTS
#define RTDB_GRAPH_NAME_API __declspec(dllexport)
#else
#define RTDB_GRAPH_NAME_API __declspec(dllimport)
#endif
#else
#define RTDB_GRAPH_NAME_API
#endif
#ifndef _WINDOWS64
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#else
#include <winsock2.h>
#include <windows.h>
#endif
#include <iostream>
#include "servicemanage.h"
#include "system.h"
#include "sysadm/scn_service.h"
#include "pub_ctx.h"
#include "logclient.h"
class RTDB_GRAPH_NAME_API CTabGraph
{
public:
CTabGraph();
~CTabGraph();
int GetGraphNameList (const std::string& username, const std::string& keyword, \
std::map<std::string, std::map<std::string, std::string> > &listmap);
};
#endif

View File

@@ -0,0 +1,21 @@
#ifndef __SERVER_2_PROTO_H__
#define __SERVER_2_PROTO_H__
#include "db_api/odb_net_m.h"
#include "db_api/odb_prv_struct.h"
namespace RTDB_SERVER
{
void UnionDataTypeConv(const RTDB_SERVER::union_data_type & union_server, RTDB_PROTO::union_data_type * p_union_proto);
void SeqCharConv(const RTDB_SERVER::SEQ_CHAR & _server, RTDB_PROTO::SEQ_CHAR * _p_proto);
void FieldStruConv(const RTDB_SERVER::FIELD_STRU & _server, RTDB_PROTO::FIELD_STRU * _p_proto);
void SeqFieldStruConv(const RTDB_SERVER::SEQ_FIELD_STRU & _server, RTDB_PROTO::SEQ_FIELD_STRU * _p_proto);
void RspReadConv(const RTDB_SERVER::RSP_READ & _server, RTDB_PROTO::RSP_READ * _p_proto);
void RspConConv(const RTDB_SERVER::RSP_CON & _server, RTDB_PROTO::RSP_CON * _p_proto);
void GraphRealRspConv(const RTDB_SERVER::GRAPH_REAL_RSP& real_rsp_server, RTDB_PROTO::GRAPH_REAL_RSP* real_rsp_proto);
void GraphRealReqConv(const RTDB_PROTO::GRAPH_REAL_ODB_REQ& real_req_proto, RTDB_SERVER::GRAPH_REAL_REQ& real_req_server);
void GraphOrderKeyReqConv(const RTDB_PROTO::GRAPH_ORDER_KEY_REQ & _proto, ODB::GRAPH_ORDER_KEY_REQ & _odb);
void GraphOrderKeyRspConv(const ODB::GRAPH_ORDER_KEY_RSP & _odb, RTDB_PROTO::GRAPH_ORDER_KEY_RSP * _p_proto);
}
#endif

View File

@@ -0,0 +1,48 @@
//#include "odb_tableop.h"
#include "system.h"
#ifndef _TAB2IDX
#define _TAB2IDX
#ifdef _WINDOWS64
#ifdef ODB_API_LIB_EXPORTS
#define ODB_API_LIB_API __declspec(dllexport)
#else
#define ODB_API_LIB_API __declspec(dllimport)
#endif
#else
#define ODB_API_LIB_API
#endif
namespace ODB
{
#define ALL_INDEX -2
#define PK_INDEX -1
class CTableOp;
class CBaseIndex;
class ODB_API_LIB_API Tab2Idx
{
private:
Tab2Idx (Tab2Idx &orig_class);
int m_AppNo;
int m_TableNo;
short m_ContextNo;
int WriteTimeAndIdxStatusNormal(CTableOp& theTableOp,int idx_pos = ALL_INDEX);//idx_pos == -2 means all indexes including pk index, -1 means primary key index, 0 means the first index and so on.
int WriteIdxStatusInit(CTableOp &theTableOp,int idx_pos = ALL_INDEX);//idx_pos == -2 means all indexes including pk index, -1 means primary key index, 0 means the first index and so on.
CBaseIndex *GetPkIndexPtr (struct STDB_TAB* stdb_tab_ptr, int table_no);
CBaseIndex *GetIndexPtr(int seq,struct INDEX_DEFINE_TAB *idx_def_tab_ptr,struct STDB_TAB* stdb_tab_ptr,int table_no);
public:
Tab2Idx() {};
Tab2Idx (int app_no, int table_no, short ctx_no = AC_REALTIME_NO);
int SetPara (int app_no, int table_no, int ctx_no = AC_REALTIME_NO);
int CreateIdxFromTab(); //This function can create and repair all the indexes including pk index in the table
int RepairIdxFromTab(int idx_pos);//idx_pos == -1 means primary key index, 0 means the first index and so on. It is only used for repairing index , so it is not used for create index for a table not down_load or creating index for case
//int RmIdx();
int RmIdxInfo();
int CreateIdxFromAreaTab(); //This function can create and repair all the indexes including pk indexes in the area table
int RepairIdxFromAreaTab(int idx_pos);//idx_pos == -1 means primary key index, 0 means the first index and so on. It is only used for repairing index , so it is not used for create index for a table not down_load or creating index for case
int RmAreaIdxInfo();
};
}
#endif

View File

@@ -0,0 +1,57 @@
#ifndef __VL_GET_DATA_H__
#define __VL_GET_DATA_H__
#ifdef _WINDOWS64
#ifdef VL_GET_DATA_EXPORTS
#define VL_GET_DATA_API __declspec(dllexport)
#else
#define VL_GET_DATA_API __declspec(dllimport)
#endif
#else
#define VL_GET_DATA_API
#endif
#ifndef _WINDOWS64
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#else
#include <winsock2.h>
#include <windows.h>
#endif
#include <iostream>
#include "servicemanage.h"
#include "system.h"
#include "sysadm/scn_service.h"
#include "pub_ctx.h"
#include "logclient.h"
#include "db_api/vl_struct_m.h"
class VL_GET_DATA_API vl_get_data
{
public:
vl_get_data();
~vl_get_data();
int GetRealData (const vector<string>& vec_sgid_in, vector<struct RealdataValue>& vec_value_out);
int GetRtNet (const vector<string>& vec_sgid_in, vector<struct RealdataValue>& vec_value_out);
private:
//DomainInfo m_DomainInfo;
ServiceInfo m_Serviceinfo;
char m_IpAddress[64];
//int m_Port;
Handle m_Handle;
char m_HostName[64];
//int m_RequestTimeoutSeconds;
int SetServiceHost(int app_no);
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
};
#endif

View File

@@ -0,0 +1,24 @@
#include "mcode/mtypes.h"
#include"mcode/mvector.h"
typedef vector<varchar> VEC_STRING;
struct SGID_IN_STRU
{
VEC_STRING vec_sgid_in;
};
struct RealdataValue
{
float value;
int status;
};
typedef vector<RealdataValue> VEC_RealdataValue;
struct DATAVALUE_STRU
{
VEC_RealdataValue vec_value_out;
};

View File

@@ -0,0 +1,93 @@
//**************************************
// Generated by mcpp translator
// Version 1.3
//**************************************
#include"vl_struct_m.h"
#include<assert.h>
void
SGID_IN_STRU::__write(MLang::OutputStream&__os)const
{
size_t len_0=vec_sgid_in.size();
__os.write_uint(len_0);
for(size_t i_0=0;i_0<len_0;i_0++)
{
__os.write_string(vec_sgid_in[i_0].c_str());
}
}
void
SGID_IN_STRU::__read(MLang::InputStream&__is)
{
size_t len_0=__is.read_uint();
vec_sgid_in.resize(len_0);
for(size_t i_0=0;i_0<len_0;i_0++)
{
vec_sgid_in[i_0]=__is.read_string();
}
}
SGID_IN_STRU::SGID_IN_STRU()
{
}
SGID_IN_STRU::SGID_IN_STRU(const SGID_IN_STRU&__val)
:vec_sgid_in(__val.vec_sgid_in)
{
}
SGID_IN_STRU&
SGID_IN_STRU::operator=(const SGID_IN_STRU&__val)
{
if(this == &__val)
return *this;
vec_sgid_in=__val.vec_sgid_in;
return *this;
}
void
RealdataValue::__write(MLang::OutputStream&__os)const
{
__os.write_float(value);
__os.write_int(status);
}
void
RealdataValue::__read(MLang::InputStream&__is)
{
value=__is.read_float();
status=__is.read_int();
}
void
DATAVALUE_STRU::__write(MLang::OutputStream&__os)const
{
size_t len_0=vec_value_out.size();
__os.write_uint(len_0);
for(size_t i_0=0;i_0<len_0;i_0++)
{
vec_value_out[i_0].__write(__os);
}
}
void
DATAVALUE_STRU::__read(MLang::InputStream&__is)
{
size_t len_0=__is.read_uint();
vec_value_out.resize(len_0);
for(size_t i_0=0;i_0<len_0;i_0++)
{
vec_value_out[i_0].__read(__is);
}
}
DATAVALUE_STRU::DATAVALUE_STRU()
{
}
DATAVALUE_STRU::DATAVALUE_STRU(const DATAVALUE_STRU&__val)
:vec_value_out(__val.vec_value_out)
{
}
DATAVALUE_STRU&
DATAVALUE_STRU::operator=(const DATAVALUE_STRU&__val)
{
if(this == &__val)
return *this;
vec_value_out=__val.vec_value_out;
return *this;
}

View File

@@ -0,0 +1,42 @@
//**************************************
// Generated by mcpp translator
// Version 1.3
//**************************************
#ifndef __VL_STRUCT_M_H__
#define __VL_STRUCT_M_H__
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
typedef MLang::VECTOR<MLang::STRING> VEC_STRING;
struct SGID_IN_STRU
{
VEC_STRING vec_sgid_in;
SGID_IN_STRU();
SGID_IN_STRU(const SGID_IN_STRU&);
SGID_IN_STRU&operator=(const SGID_IN_STRU&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct RealdataValue
{
float value;
int status;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<RealdataValue> VEC_RealdataValue;
struct DATAVALUE_STRU
{
VEC_RealdataValue vec_value_out;
DATAVALUE_STRU();
DATAVALUE_STRU(const DATAVALUE_STRU&);
DATAVALUE_STRU&operator=(const DATAVALUE_STRU&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif