Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b102cdbf5 | ||
|
|
7f41d85e0b |
67
README
67
README
@@ -1,15 +1,68 @@
|
||||
=========
|
||||
编译前准备:
|
||||
编译前先安装dotconf软件包。
|
||||
libman.so拷贝到/usr/lib64/下
|
||||
pkgadd dotconf#1.0.13-1.pkg.tar.gz
|
||||
|
||||
1. 编译前先安装dotconf软件包。
|
||||
* pkg格式
|
||||
pkgadd dotconf#1.0.13-1.pkg.tar.gz
|
||||
* deb格式
|
||||
dpkg -i libdotconf0_1.3-0.2_arm64.deb
|
||||
dpkg -i libdotconf-dev_1.3-0.2_arm64.deb
|
||||
* rpm格式
|
||||
|
||||
2. 安装接口libman.so库文件
|
||||
* pkg格式
|
||||
将libman.so拷贝到/usr/lib64/下
|
||||
* deb格式
|
||||
将libman.so拷贝到/usr/lib/下
|
||||
* rpm格式
|
||||
|
||||
=========
|
||||
编译说明:
|
||||
在Rocky 4.2上编译
|
||||
* Rocky 4.2上编译
|
||||
执行: sh build.sh
|
||||
将在当前的目录下生成安装包:
|
||||
sys_nicmonitor#1.9-x86_64-Linx-Rocky4.2.pkg.tar.gz
|
||||
* Linx 6.0.90上编译
|
||||
需手动编译并将编译结果手动打包
|
||||
修改源码目录下的Makefile文件
|
||||
原始文件内容:
|
||||
```
|
||||
16 nicinfo_shm.o:nicinfo_shm.c
|
||||
17 $(CC) $(CFLAGS) -fPIC -c $^
|
||||
18 test:test.c
|
||||
19 gcc -o test test.c -lnic_shm -L=./ -lpthread
|
||||
20 runtest:
|
||||
21 LD_LIBRARY_PATH=./ ./test bond0 5000 &
|
||||
```
|
||||
修改后文件内容
|
||||
```
|
||||
16 nicinfo_shm.o:nicinfo_shm.c
|
||||
17 $(CC) $(CFLAGS) -fPIC -c $^
|
||||
18 test:test.c
|
||||
19 gcc -o test test.c -lnic_shm -L./ -lpthread
|
||||
20 runtest:
|
||||
21 LD_LIBRARY_PATH=./ ./test bond0 5000 &
|
||||
```
|
||||
|
||||
arm架构修改mnic.c文件的1535行
|
||||
原始文件内容:
|
||||
```
|
||||
1533 struct passwd *user;
|
||||
1534
|
||||
1535 //#define TESTINTERVAL
|
||||
1536 #ifndef TESTINTERVAL
|
||||
1537 proc_invocation prcm;
|
||||
```
|
||||
修改后文件内容
|
||||
```
|
||||
1533 struct passwd *user;
|
||||
1534
|
||||
1535 #define TESTINTERVAL
|
||||
1536 #ifndef TESTINTERVAL
|
||||
1537 proc_invocation prcm;
|
||||
```
|
||||
|
||||
|
||||
执行: sh build.sh
|
||||
将在当前的目录下生成安装包:
|
||||
sys_nicmonitor#1.9-x86_64-Linx-Rocky4.2.pkg.tar.gz
|
||||
|
||||
========
|
||||
安装说明:
|
||||
|
||||
128
code/README
128
code/README
@@ -1,20 +1,63 @@
|
||||
--V1.14 --
|
||||
2015-12-29
|
||||
修正了common.c中对日志消息队列的操作,其中包括:交换log_prepare与log_writing>队列指针的bug;以及在写入log_prepare队列时未检查已写入消息是否大于队列长度的b
|
||||
ug。修正了log_path(即日志文件名)不会随时间改变的bug。
|
||||
--V1.13 --
|
||||
2015-12-23
|
||||
修正在记录日志中检查目录时(在函数create_dir中),由于采用线程进行日志记录,多次调用get_nic_info可能会导致的将日志文件路径名变错的问题。在get_nic_info中判断log_path是否被初始化过,如过未初始化,则到共享内存中读取。否则,为初始化过,直接使用该值,并在create_dir中使用局部变量保存该值,在create_dir中使用操作该局部变量,而不去改变该全局变量的值。
|
||||
|
||||
-V1.12 --
|
||||
2015-12-23
|
||||
修正在程序开始时对IPC变量删除的错误函数调用。
|
||||
添加配置项crazyping,当其不为零时,会在每次取网卡信息时进行ping操作。
|
||||
|
||||
|
||||
--V1.11 --
|
||||
2015-12-18
|
||||
添加在程序开始时对IPC变量是否已存在的判断,如果已存在,则将其删除。
|
||||
将宏TESTINTERVAL的定义去除,不然不会调用南瑞的库函数。
|
||||
|
||||
--V1.10 --
|
||||
2015-12-11
|
||||
修改IPC信号量的相关操作
|
||||
|
||||
1)通过对代码的分析发现:在使用信号量时存在错误。在使用进行PV原语操作时,进行了相反的操作,其中加锁操作应减少信号量的计数,而去锁应增加信号量的计数,但库中进行了相反的操作,对其进行了修改。即将get_sem中对信号量的操作改为-1,而在release_sem函数中对信号量的操作变为1(即+1)。同时在init_sem函数中将该信号量的值初始化为1。
|
||||
|
||||
2)信号量应由网卡监控程序sys_nicmonitor创建,而不应由用户程序创建,对其进行了相应的修改(在创建信号量时在flag中添加IPC_EXCL,并将用户程序引用信号量时的flag中去除IPC_CREATE)。
|
||||
|
||||
3)在对获取网卡信息函数get_nic_info中添加获取时间的操作后得知,其中对getpwdnam的调用会减慢函数的工作(该函数并非每次都减慢函数很多,多数在30~40ms左右,但在测试中曾达到2s左右)。对其修改为在sys_nicmonitor程序启动时,调用getpwdnam函数,并将得到的用户主目录名写入到一块共享内存中。当用户程序要获得该目录名时,则从该值从共享内存中读取出来,而不需要每次都通过getpwdnam来获取,故可以提高该函数的速度。
|
||||
|
||||
|
||||
=-======update 2015-11-17
|
||||
编译前,进入dep目录运行sh run.sh,安装编译依赖文件.
|
||||
|
||||
然后sh build.sh编译1.9版本的sys_nicmonitor#1.9-x86_64-Linx-Rocky4.2.pkg.tar.gz
|
||||
|
||||
调试模式下:
|
||||
cd sys_nicmonitor-1.9
|
||||
make clean
|
||||
make
|
||||
make test
|
||||
make runtest
|
||||
|
||||
版本号变更方法,更新sys_nicmonitor/version.h文件,需要同时修改//后面的和define中的,前者用于pkg包,后者用于sys_nicmonitor程序.
|
||||
制作pkg包方法: sh build.sh
|
||||
|
||||
|
||||
|
||||
=========
|
||||
编译前准备:
|
||||
* 安装dotconf相关软件包。
|
||||
* 拷贝libproc_common.so库文件到动态库中
|
||||
编译前先安装dotconf软件包。
|
||||
libman.so拷贝到/usr/lib64/下
|
||||
pkgadd dotconf#1.0.13-1.pkg.tar.gz
|
||||
|
||||
编译说明:
|
||||
在Rocky 4.2上编译
|
||||
1. 执行 sh 42/run.sh
|
||||
2 执行: sh build.sh
|
||||
|
||||
执行: sh build.sh
|
||||
将在当前的目录下生成安装包:
|
||||
sys_nicmonitor#1.9-x86_64-Linx-Rocky4.2.pkg.tar.gz
|
||||
|
||||
在Linx 90上编译
|
||||
1. 执行 sh 90/run.sh
|
||||
2. 进入到sys_nicmonitor中执行make
|
||||
将在sys_nicmonitor中生成libnic_shm.so和sys_nicmonitor
|
||||
|
||||
========
|
||||
安装说明:
|
||||
1)安装,以root的用户执行安装命令:
|
||||
@@ -32,20 +75,63 @@
|
||||
========
|
||||
|
||||
版本说明:
|
||||
详见sys_nicmonitor目录中的README
|
||||
--V1.9 --
|
||||
2013-08-12
|
||||
1)修复问题:占用内存快速累加,导致内存占用很大
|
||||
问题描述:日志线程资源退出时未回收,导致占用内存快速累加
|
||||
解决办法:修改为一个日志线程,并且线程退出时设置为自动回收。
|
||||
将日志写文件的地方放到common.c中,以便动态库和daemon程序使用一个。
|
||||
|
||||
2)修复问题:日志文件名在家目录或者var目录下,未在规定位置
|
||||
问题描述:日志文件命名在一个单独的线程进行,导致日志线程和该线程对log_path存在同时访问的情况。
|
||||
导致在换天或者换月时,日志文件名变更一半时,日志写线程此时写日志,用未更新完成的
|
||||
log_path创建日志,导致日志文件不再规定的位置。
|
||||
解决办法:增加线程互斥锁pthread_mutex对log_path进行保护,修复该问题。
|
||||
|
||||
|
||||
=-======update 2015-11-17
|
||||
编译前,进入dep目录运行sh run.sh,安装编译依赖文件.
|
||||
--V1.8.1--
|
||||
2013-06-05
|
||||
1)修改BUG:ping_gw函数当PING失败时没有尝试对余下的GW进行PING操作
|
||||
2)增加环境变量SYS_NIC_DEBUG用于调试流量抖动问题。
|
||||
|
||||
然后sh build.sh编译1.9版本的sys_nicmonitor#1.9-x86_64-Linx-Rocky4.2.pkg.tar.gz
|
||||
--V1.8 --
|
||||
2013-05-27
|
||||
对系统高磁盘IO情况下,应用如果进行IO将可能会被阻塞。本版本为此作出调整。
|
||||
cs-fes1上编译测试OK。
|
||||
|
||||
调试模式下:
|
||||
cd sys_nicmonitor-1.9
|
||||
make clean
|
||||
make
|
||||
make test
|
||||
make runtest
|
||||
1) 去掉shm和sem的实体文件
|
||||
#define SHM_PATH "$D5000_HOME/share/sys_netcard_shm_path"
|
||||
#define SEM_PATH "$D5000_HOME/share/sys_netcard_sem_path"
|
||||
|
||||
用key=0x1d5200 代替 sem
|
||||
用key=0x1d5010 代替 shm
|
||||
|
||||
|
||||
2)去掉动态库中get_nic_info接口中,判断路径的opendir调用,采用实际路径
|
||||
上层应用每秒可能调用3次这个接口,每判断一个网卡都调用一次,判断都个网卡的状态时就调用多次。
|
||||
|
||||
可改进:一次调用get_nic_info接口,可输入多个网卡,一次返回所有网卡状态信息。
|
||||
|
||||
3) record_log函数为日志函数,每次写一次,都重新打开一次文件。
|
||||
修改为线程模式,当记录日志时,不会被磁盘IO阻塞。
|
||||
|
||||
4) 安装目录为d5000用户的HOME目录下的lib和bin目录
|
||||
|
||||
----
|
||||
|
||||
|
||||
V1.6与V1.7差异
|
||||
共享内存路径修改:
|
||||
由/home/d5000/someone/tmp/sys_netcard_shm_path 改为 /home/d5000/someone/share/sys_netcard_shm_path
|
||||
信号量路径修改:
|
||||
由/home/d5000/someone/tmp/sys_netcard_sem_path 改为 /home/d5000/someone/share/sys_netcard_sem_path
|
||||
|
||||
注意:在编译过程中,需要动态看libman.so,它存放在目录 tags/下面 ,在进行编译的时候需要将其拷贝到
|
||||
/lib64/目录下,编译的基础环境是 Rocky 4.2 系统。
|
||||
|
||||
pkgmk命令的使用:
|
||||
将源代码打包成name-version.tar.gz样式,编写Pkgfile文件。
|
||||
使用命令:
|
||||
pkgmk -um #更新软件包的md5值
|
||||
pkgmk -kw #制作pkg安装包
|
||||
|
||||
版本号变更方法,更新sys_nicmonitor/version.h文件,需要同时修改//后面的和define中的,前者用于pkg包,后者用于sys_nicmonitor程序.
|
||||
制作pkg包方法: sh build.sh
|
||||
|
||||
Binary file not shown.
@@ -1,2 +0,0 @@
|
||||
pkgadd dotconf#1.0.13-1.pkg.tar.gz
|
||||
cp ../libproc_common.so /usr/lib64/
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
arch=`uname -m`
|
||||
if [ "x$arch" == "x86_64" ]; then
|
||||
dpkg -i libdotconf0_1.3-0.2_amd64.deb
|
||||
dpkg -i libdotconf-dev_1.3-0.2_amd64.deb
|
||||
elif [ "x$arch" == "aarch64" ]; then
|
||||
dpkg -i libdotconf0_1.3-0.2_arm64.deb
|
||||
dpkg -i libdotconf-dev_1.3-0.2_arm64.deb
|
||||
fi
|
||||
|
||||
cp ../libproc_common.so /usr/lib/
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,19 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include "proc_common.h"
|
||||
|
||||
|
||||
NS_SYSADMIN::CProcCommon::CProcCommon(int rw)
|
||||
{
|
||||
printf("NS_SYSADMIN::CProcCommon::CProcCommon\n");
|
||||
}
|
||||
|
||||
NS_SYSADMIN::CProcCommon::~CProcCommon()
|
||||
{
|
||||
printf("NS_SYSADMIN::CProcCommon::~CProcCommon\n");
|
||||
}
|
||||
|
||||
int NS_SYSADMIN::CProcCommon::proc_init(const char* scn_name, const char* subscn_name,char* process_name, const char* label = NULL, const char* subscn_lable = NULL)
|
||||
{
|
||||
printf("NS_SYSADMIN::CProcCommon::proc_init\n");
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
@@ -7,17 +7,16 @@ include $(DEFAULTS)
|
||||
all:sys_nicmonitor libnic_shm.so test
|
||||
|
||||
#CFLAGS += -D TESTINTERVAL -Wall -Wformat=2 -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -O0 -g
|
||||
CFLAGS += -I ./include -Wall -Wformat=2 -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -O0
|
||||
#CFLAGS += -I ./include -D USER_NUSP -Wall -Wformat=2 -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -O0
|
||||
CFLAGS += -Wall -Wformat=2 -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -O0 -g
|
||||
|
||||
sys_nicmonitor:mnic.o read_netcard.o send_alarm.o
|
||||
$(CC) $(CFLAGS) -lproc_common -ldotconf -lpthread -o $@ $^
|
||||
$(CC) -lman -ldotconf -lpthread -o $@ $^
|
||||
libnic_shm.so:nicinfo_shm.o
|
||||
$(CC) -fpic -shared -o $@ $^
|
||||
nicinfo_shm.o:nicinfo_shm.c
|
||||
$(CC) $(CFLAGS) -fPIC -c $^
|
||||
test:test.c
|
||||
gcc -o test test.c -lnic_shm -L./ -lpthread
|
||||
test:test.c
|
||||
gcc -o test test.c -lnic_shm -L=./ -lpthread
|
||||
runtest:
|
||||
LD_LIBRARY_PATH=./ ./test bond0 5000 &
|
||||
clean:
|
||||
|
||||
@@ -1,78 +1,3 @@
|
||||
========
|
||||
版本说明:
|
||||
--V1.22 --
|
||||
2020-07-09
|
||||
1)根本南瑞郭海龙要求进行接口的修改
|
||||
取消之前libman.so动态库和proc_inv.h头文件,改为新的libproc_common.so动态库,同时增加include头文件目录
|
||||
2020-10-22
|
||||
1) 修复sys_nicmonitor进程重启后,再调用get_nic_info接口时出现的大量告警日志问题
|
||||
问题描述:sys_nicmonitor进程重新启动时,调用接口程序会输出告警日志,日志的增长量和调用接口频率成正比增长
|
||||
解决办法:接口程序增加sys_nicmonitor进程状态检测,当sys_nicmonitor进程重启时,接口程序重新获取新信号量的id
|
||||
|
||||
--V1.21 --
|
||||
2019-09-05
|
||||
1)修复问题:monitor_interval参数溢出导致cpu 100%
|
||||
问题描述:当monitor_interval参数配置为1000时,出现进程cpu占用100%的问题
|
||||
解决办法:增加对monitor_interval配置的检测和限制
|
||||
|
||||
--V1.9 --
|
||||
2013-08-12
|
||||
1)修复问题:占用内存快速累加,导致内存占用很大
|
||||
问题描述:日志线程资源退出时未回收,导致占用内存快速累加
|
||||
解决办法:修改为一个日志线程,并且线程退出时设置为自动回收。
|
||||
将日志写文件的地方放到common.c中,以便动态库和daemon程序使用一个。
|
||||
|
||||
2)修复问题:日志文件名在家目录或者var目录下,未在规定位置
|
||||
问题描述:日志文件命名在一个单独的线程进行,导致日志线程和该线程对log_path存在同时访问的情况。
|
||||
导致在换天或者换月时,日志文件名变更一半时,日志写线程此时写日志,用未更新完成的
|
||||
log_path创建日志,导致日志文件不再规定的位置。
|
||||
解决办法:增加线程互斥锁pthread_mutex对log_path进行保护,修复该问题。
|
||||
|
||||
--V1.8.1 --
|
||||
2013-06-05
|
||||
1)修改BUG:ping_gw函数当PING失败时没有尝试对余下的GW进行PING操作
|
||||
2)增加环境变量SYS_NIC_DEBUG用于调试流量抖动问题。
|
||||
|
||||
--V1.8 --
|
||||
2013-05-27
|
||||
对系统高磁盘IO情况下,应用如果进行IO将可能会被阻塞。本版本为此作出调整。
|
||||
cs-fes1上编译测试OK。
|
||||
|
||||
1) 去掉shm和sem的实体文件
|
||||
#define SHM_PATH "$D5000_HOME/share/sys_netcard_shm_path"
|
||||
#define SEM_PATH "$D5000_HOME/share/sys_netcard_sem_path"
|
||||
|
||||
用key=0x1d5200 代替 sem
|
||||
用key=0x1d5010 代替 shm
|
||||
|
||||
|
||||
2)去掉动态库中get_nic_info接口中,判断路径的opendir调用,采用实际路径
|
||||
上层应用每秒可能调用3次这个接口,每判断一个网卡都调用一次,判断都个网卡的状态时就调用多次。
|
||||
|
||||
可改进:一次调用get_nic_info接口,可输入多个网卡,一次返回所有网卡状态信息。
|
||||
|
||||
3) record_log函数为日志函数,每次写一次,都重新打开一次文件。
|
||||
修改为线程模式,当记录日志时,不会被磁盘IO阻塞。
|
||||
|
||||
4) 安装目录为d5000用户的HOME目录下的lib和bin目录
|
||||
|
||||
--V1.7 --
|
||||
|
||||
V1.6与V1.7差异
|
||||
共享内存路径修改:
|
||||
由/home/d5000/someone/tmp/sys_netcard_shm_path 改为 /home/d5000/someone/share/sys_netcard_shm_path
|
||||
信号量路径修改:
|
||||
由/home/d5000/someone/tmp/sys_netcard_sem_path 改为 /home/d5000/someone/share/sys_netcard_sem_path
|
||||
|
||||
注意:在编译过程中,需要动态看libman.so,它存放在目录 tags/下面 ,在进行编译的时候需要将其拷贝到
|
||||
/lib64/目录下,编译的基础环境是 Rocky 4.2 系统。
|
||||
|
||||
pkgmk命令的使用:
|
||||
将源代码打包成name-version.tar.gz样式,编写Pkgfile文件。
|
||||
使用命令:
|
||||
pkgmk -um #更新软件包的md5值
|
||||
pkgmk -kw #制作pkg安装包
|
||||
|
||||
--V1.14 --
|
||||
2015-12-29
|
||||
修正了common.c中对日志消息队列的操作,其中包括:交换log_prepare与log_writing>队列指针的bug;以及在写入log_prepare队列时未检查已写入消息是否大于队列长度的b
|
||||
@@ -101,3 +26,118 @@ ug。修正了log_path(即日志文件名)不会随时间改变的bug。
|
||||
2)信号量应由网卡监控程序sys_nicmonitor创建,而不应由用户程序创建,对其进行了相应的修改(在创建信号量时在flag中添加IPC_EXCL,并将用户程序引用信号量时的flag中去除IPC_CREATE)。
|
||||
|
||||
3)在对获取网卡信息函数get_nic_info中添加获取时间的操作后得知,其中对getpwdnam的调用会减慢函数的工作(该函数并非每次都减慢函数很多,多数在30~40ms左右,但在测试中曾达到2s左右)。对其修改为在sys_nicmonitor程序启动时,调用getpwdnam函数,并将得到的用户主目录名写入到一块共享内存中。当用户程序要获得该目录名时,则从该值从共享内存中读取出来,而不需要每次都通过getpwdnam来获取,故可以提高该函数的速度。
|
||||
|
||||
|
||||
=-======update 2015-11-17
|
||||
编译前,进入dep目录运行sh run.sh,安装编译依赖文件.
|
||||
|
||||
然后sh build.sh编译1.9版本的sys_nicmonitor#1.9-x86_64-Linx-Rocky4.2.pkg.tar.gz
|
||||
|
||||
调试模式下:
|
||||
cd sys_nicmonitor-1.9
|
||||
make clean
|
||||
make
|
||||
make test
|
||||
make runtest
|
||||
|
||||
版本号变更方法,更新sys_nicmonitor/version.h文件,需要同时修改//后面的和define中的,前者用于pkg包,后者用于sys_nicmonitor程序.
|
||||
制作pkg包方法: sh build.sh
|
||||
|
||||
|
||||
|
||||
=========
|
||||
编译前准备:
|
||||
编译前先安装dotconf软件包。
|
||||
libman.so拷贝到/usr/lib64/下
|
||||
pkgadd dotconf#1.0.13-1.pkg.tar.gz
|
||||
|
||||
编译说明:
|
||||
在Rocky 4.2上编译
|
||||
|
||||
执行: sh build.sh
|
||||
将在当前的目录下生成安装包:
|
||||
sys_nicmonitor#1.9-x86_64-Linx-Rocky4.2.pkg.tar.gz
|
||||
|
||||
========
|
||||
安装说明:
|
||||
1)安装,以root的用户执行安装命令:
|
||||
pkgadd sys_nicmonitor#1.9-x86_64-Linx-Rocky4.2.pkg.tar.gz
|
||||
如果之前已经安装,则可先卸载旧的然后再安装,或者通过更新方式安装
|
||||
卸载命令: pkgrm sys_nicmonitor
|
||||
更新方式安装命令:
|
||||
pkgadd -u sys_nicmonitor#1.9-x86_64-Linx-Rocky4.2.pkg.tar.gz
|
||||
|
||||
2)查看安装是否成功
|
||||
pkginfo -i|grep sys_nicmonitor
|
||||
或者
|
||||
查看d5000用户的目录下lib/libnic_shm.so和bin/sys_nicmonitor的日期是否匹配
|
||||
|
||||
========
|
||||
|
||||
版本说明:
|
||||
--V1.21 --
|
||||
2019-09-05
|
||||
1)修复问题:monitor_interval参数溢出导致cpu 100%
|
||||
问题描述:当monitor_interval参数配置为1000时,出现进程cpu占用100%的问题
|
||||
解决办法:增加对monitor_interval配置的检测和限制
|
||||
|
||||
--V1.9 --
|
||||
2013-08-12
|
||||
1)修复问题:占用内存快速累加,导致内存占用很大
|
||||
问题描述:日志线程资源退出时未回收,导致占用内存快速累加
|
||||
解决办法:修改为一个日志线程,并且线程退出时设置为自动回收。
|
||||
将日志写文件的地方放到common.c中,以便动态库和daemon程序使用一个。
|
||||
|
||||
2)修复问题:日志文件名在家目录或者var目录下,未在规定位置
|
||||
问题描述:日志文件命名在一个单独的线程进行,导致日志线程和该线程对log_path存在同时访问的情况。
|
||||
导致在换天或者换月时,日志文件名变更一半时,日志写线程此时写日志,用未更新完成的
|
||||
log_path创建日志,导致日志文件不再规定的位置。
|
||||
解决办法:增加线程互斥锁pthread_mutex对log_path进行保护,修复该问题。
|
||||
|
||||
|
||||
--V1.8.1--
|
||||
2013-06-05
|
||||
1)修改BUG:ping_gw函数当PING失败时没有尝试对余下的GW进行PING操作
|
||||
2)增加环境变量SYS_NIC_DEBUG用于调试流量抖动问题。
|
||||
|
||||
--V1.8 --
|
||||
2013-05-27
|
||||
对系统高磁盘IO情况下,应用如果进行IO将可能会被阻塞。本版本为此作出调整。
|
||||
cs-fes1上编译测试OK。
|
||||
|
||||
1) 去掉shm和sem的实体文件
|
||||
#define SHM_PATH "$D5000_HOME/share/sys_netcard_shm_path"
|
||||
#define SEM_PATH "$D5000_HOME/share/sys_netcard_sem_path"
|
||||
|
||||
用key=0x1d5200 代替 sem
|
||||
用key=0x1d5010 代替 shm
|
||||
|
||||
|
||||
2)去掉动态库中get_nic_info接口中,判断路径的opendir调用,采用实际路径
|
||||
上层应用每秒可能调用3次这个接口,每判断一个网卡都调用一次,判断都个网卡的状态时就调用多次。
|
||||
|
||||
可改进:一次调用get_nic_info接口,可输入多个网卡,一次返回所有网卡状态信息。
|
||||
|
||||
3) record_log函数为日志函数,每次写一次,都重新打开一次文件。
|
||||
修改为线程模式,当记录日志时,不会被磁盘IO阻塞。
|
||||
|
||||
4) 安装目录为d5000用户的HOME目录下的lib和bin目录
|
||||
|
||||
----
|
||||
|
||||
|
||||
V1.6与V1.7差异
|
||||
共享内存路径修改:
|
||||
由/home/d5000/someone/tmp/sys_netcard_shm_path 改为 /home/d5000/someone/share/sys_netcard_shm_path
|
||||
信号量路径修改:
|
||||
由/home/d5000/someone/tmp/sys_netcard_sem_path 改为 /home/d5000/someone/share/sys_netcard_sem_path
|
||||
|
||||
注意:在编译过程中,需要动态看libman.so,它存放在目录 tags/下面 ,在进行编译的时候需要将其拷贝到
|
||||
/lib64/目录下,编译的基础环境是 Rocky 4.2 系统。
|
||||
|
||||
pkgmk命令的使用:
|
||||
将源代码打包成name-version.tar.gz样式,编写Pkgfile文件。
|
||||
使用命令:
|
||||
pkgmk -um #更新软件包的md5值
|
||||
pkgmk -kw #制作pkg安装包
|
||||
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
#ifndef _COMMON_TYPES_H
|
||||
#define _COMMON_TYPES_H
|
||||
|
||||
#ifdef _LINUX
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
//support ILP32/LLP64/LP64
|
||||
//8bit
|
||||
typedef signed char cmnInt8;
|
||||
typedef unsigned char cmnUint8;
|
||||
typedef cmnUint8 cmnByte;
|
||||
|
||||
//16bit
|
||||
typedef signed short cmnInt16;
|
||||
typedef unsigned short cmnUint16;
|
||||
typedef cmnUint16 cmnWord;
|
||||
|
||||
//32bit
|
||||
typedef int cmnInt32;
|
||||
typedef unsigned int cmnUint32;
|
||||
#define CMN_PRdINT32 "d"
|
||||
#define CMN_PRuUINT32 "u"
|
||||
#define CMN_PRxUINT32 "x"
|
||||
#define CMN_PRXUINT32 "X"
|
||||
|
||||
#ifdef _WINDOWS_
|
||||
#if _MSC_VER >= 1400
|
||||
typedef long long cmnInt64;
|
||||
typedef unsigned long long cmnUint64;
|
||||
#define CMN_PRdINT64 "lld"
|
||||
#define CMN_PRuUINT64 "llu"
|
||||
#define CMN_PRxUINT64 "llx"
|
||||
#define CMN_PRXUINT64 "llX"
|
||||
#else
|
||||
typedef __int64 cmnInt64;
|
||||
typedef unsigned __int64 cmnUint64;
|
||||
#define CMN_PRdINT64 "I64d"
|
||||
#define CMN_PRuUINT64 "I64u"
|
||||
#define CMN_PRxUINT64 "I64x"
|
||||
#define CMN_PRXUINT64 "I64X"
|
||||
#endif
|
||||
#ifdef _WIN64
|
||||
typedef cmnInt64 cmnPtInt;
|
||||
typedef cmnUint64 cmnPtUint;
|
||||
#define CMN_PRdPTINT CMN_PRdINT64
|
||||
#define CMN_PRuPTUINT CMN_PRuUINT64
|
||||
#define CMN_PRxPTUINT CMN_PRxUINT64
|
||||
#define CMN_PRXPTUINT CMN_PRXUINT64
|
||||
#else
|
||||
typedef cmnInt32 cmnPtInt;
|
||||
typedef cmnUint32 cmnPtUint;
|
||||
#define CMN_PRdPTINT CMN_PRdINT32
|
||||
#define CMN_PRuPTUINT CMN_PRuUINT32
|
||||
#define CMN_PRxPTUINT CMN_PRxUINT32
|
||||
#define CMN_PRXPTUINT CMN_PRXUINT32
|
||||
#endif
|
||||
#else
|
||||
#if defined (__LP64__) || defined (__64BIT__) || defined (_LP64) || (__WORDSIZE == 64)
|
||||
typedef long cmnInt64;
|
||||
typedef unsigned long cmnUint64;
|
||||
typedef cmnInt64 cmnPtInt;
|
||||
typedef cmnUint64 cmnPtUint;
|
||||
#define CMN_PRdINT64 "ld"
|
||||
#define CMN_PRuUINT64 "lu"
|
||||
#define CMN_PRxUINT64 "lx"
|
||||
#define CMN_PRXUINT64 "lX"
|
||||
#define CMN_PRdPTINT CMN_PRdINT64
|
||||
#define CMN_PRuPTUINT CMN_PRuUINT64
|
||||
#define CMN_PRxPTUINT CMN_PRxUINT64
|
||||
#define CMN_PRXPTUINT CMN_PRXUINT64
|
||||
#else
|
||||
typedef long long cmnInt64;
|
||||
typedef unsigned long long cmnUint64;
|
||||
typedef cmnInt32 cmnPtInt;
|
||||
typedef cmnUint32 cmnPtUint;
|
||||
#define CMN_PRdINT64 "lld"
|
||||
#define CMN_PRuUINT64 "llu"
|
||||
#define CMN_PRxUINT64 "llx"
|
||||
#define CMN_PRXUINT64 "llX"
|
||||
#define CMN_PRdPTINT CMN_PRdINT32
|
||||
#define CMN_PRuPTUINT CMN_PRuUINT32
|
||||
#define CMN_PRxPTUINT CMN_PRxUINT32
|
||||
#define CMN_PRXPTUINT CMN_PRXUINT32
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,130 +0,0 @@
|
||||
/*3.ʵʱ¿â´íÎóÂë*/
|
||||
/*ERR_RTDB_ errno of rtdb --- wj added on 20090218 */
|
||||
|
||||
#define ERR_RTDB_ERROR -1 /* error */
|
||||
#define ERR_RTDB_PARA -2 /* bad para_parameter */
|
||||
#define ERR_RTDB_CHAOS -3 /* innner error */
|
||||
|
||||
//access
|
||||
#define ERR_RTDB_ACCESSMETH -3001 /* access_meth is error */
|
||||
#define ERR_RTDB_EXIST -3002 /* Db name is exist, cannot creat */
|
||||
#define ERR_RTDB_NODB -3003 /* Db name not founded */
|
||||
#define ERR_RTDB_INVDBNO -3004 /* Db no is wrong */
|
||||
#define ERR_RTDB_INVFNAME -3005 /* Field name not founded */
|
||||
#define ERR_RTDB_HASOPENED -3006 /* The db has been opened */
|
||||
#define ERR_RTDB_FILE_NOPEN -3007 /* The file cannot open */
|
||||
#define ERR_RTDB_READ_FILE -3008 /* The file cannot read */
|
||||
#define ERR_RTDB_APP_NO_DB -3009 /* This table isn't in current application */
|
||||
#define ERR_RTDB_DB_NONE -3010 /* The table is deleted or hasn't been created*/
|
||||
|
||||
//lock
|
||||
#define ERR_RTDB_LOCK -3111 /* The db is locked */
|
||||
#define ERR_RTDB_UNLOCK -3112 /* The db isnot locked */
|
||||
#define ERR_RTDB_INVUNLOCK -3113 /* locker is not me */
|
||||
#define ERR_RTDB_NOINDEX -3114 /* havenot index */
|
||||
|
||||
#define ERR_RTDB_DIFFSIZE -3121 /* size is different */
|
||||
#define ERR_RTDB_NOTCHKEY -3122 /* ?? */
|
||||
#define ERR_RTDB_NOCACHE -3123 /* no cache block */
|
||||
#define ERR_RTDB_NOTE_NEND -3124 /* NOTE must be last field */
|
||||
|
||||
#define ERR_RTDB_CTRLFULL -3131 /* The db ctrl table is full */
|
||||
#define ERR_RTDB_DBFULL -3132 /* The db is full */
|
||||
#define ERR_RTDB_EODB -3133 /* End of Database */
|
||||
#define ERR_RTDB_INVSIZE -3134 /* The size is invalid */
|
||||
#define ERR_RTDB_DBBEGIN -3135 /* Have reach the begin of db */
|
||||
#define ERR_RTDB_DBEND -3136 /* Have reach the end of db */
|
||||
|
||||
#define ERR_RTDB_INVCCOMM -3137 /* Invalid comparition command */
|
||||
#define ERR_RTDB_TMOPEN -3138 /* Too many open */
|
||||
#define ERR_RTDB_EMPTY -3139 /* table is empty */
|
||||
|
||||
////key
|
||||
#define ERR_RTDB_KEYNOTFIND -3241 /* keyword not founded */
|
||||
#define ERR_RTDB_MULTIKEY -3242 /* Multi-keywords */
|
||||
#define ERR_RTDB_INVKEY -3243 /* The keyword is invalid */
|
||||
#define ERR_RTDB_MKEYFIELD -3244 /* The keyword field can be only one */
|
||||
#define ERR_RTDB_KEYFLEN -3245 /* The keyword length must be 4 times*/
|
||||
#define ERR_RTDB_DBTYPE -3246 /* Invalid db type */
|
||||
#define ERR_RTDB_KEYTYPE -3247 /* Invalid keyword type */
|
||||
#define ERR_RTDB_PASSWD -3248 /* Invalid passwd */
|
||||
|
||||
////table
|
||||
#define ERR_RTDB_TABLE_NO -3300 /* no match table or no*/
|
||||
#define ERR_RTDB_TABLE_STA -3301 /* table status is abnormal */
|
||||
|
||||
////record
|
||||
#define ERR_RTDB_EXISTREC -3451 /* Record existed, cannot write */
|
||||
#define ERR_RTDB_NEXISTREC -3452 /* Record not existed, cannot modify */
|
||||
#define ERR_RTDB_SUPMAX -3453 /* record value too bigger */
|
||||
#define ERR_RTDB_BELMIN -3454 /* record value too smaller */
|
||||
#define ERR_RTDB_RECSIZE -3455 /* record size wrong */
|
||||
#define ERR_RTDB_NOTERASE -3456 /* record not erased */
|
||||
#define ERR_RTDB_RECERASE -3457 /* The record is erased */
|
||||
#define ERR_RTDB_POINTER -3458 /* record_pointer error */
|
||||
#define ERR_RTDB_CONT_ERR -3459 /* condition express error */
|
||||
#define ERR_RTDB_NEED_CHK -3460 /* something wrong, need to check record state*/
|
||||
|
||||
////field
|
||||
#define ERR_RTDB_DATATYPE -3561 /* field data type is wrong */
|
||||
#define ERR_RTDB_DIFFTYPE -3562 /* type is different */
|
||||
#define ERR_RTDB_KEYFIELD -3563 /* The field is keyword */
|
||||
#define ERR_RTDB_BIGFIELDNO -3564 /* The field no is too big */
|
||||
#define ERR_RTDB_DLT_WRITE -3565 /* The direct link hash cannot write */
|
||||
#define ERR_RTDB_INVFIELDNO -3566 /* field_no is wrong */
|
||||
#define ERR_RTDB_NOTFIND -3567 /* Not find the value */
|
||||
#define ERR_RTDB_FIELD_NO -3568 /* no match field name or no */
|
||||
#define ERR_RTDB_FIELD_SIZE -3569 /* field length wrong */
|
||||
#define ERR_RTDB_NONE_FIELD -3570 /* this table has no field */
|
||||
|
||||
|
||||
//operation
|
||||
#define ERR_RTDB_INVCOMM -3601 /* Invalid db operater command */
|
||||
#define ERR_RTDB_NPERMIT -3602 /* The OP is not permit */
|
||||
|
||||
#define ERR_RTDB_CONTEXT -3620 /* no context or application */
|
||||
#define ERR_RTDB_APP_UNLOAD -3621 /* application isn't loaded */
|
||||
|
||||
|
||||
#define ERR_RTDB_SQL_COMMAND -3631 /*select error*/
|
||||
#define ERR_RTDB_SQL_FORM -3632 /*form error*/
|
||||
#define ERR_RTDB_SQL_WHERE -3633 /*where condition error*/
|
||||
#define ERR_RTDB_SQL_ORDER -3634 /*order by error*/
|
||||
|
||||
//memory
|
||||
#define ERR_RTDB_MEMORY -3700 /* Cannot malloc or calloc memory */
|
||||
#define ERR_RTDB_BUFFFULL -3701 /* Buffer is full */
|
||||
#define ERR_RTDB_MEM_NOALLOC -3702 /* The memory cannot allocation */
|
||||
|
||||
#define ERR_RTDB_MAP -3710 /* map file error */
|
||||
#define ERR_RTDB_SHM -3711 /* get shm error */
|
||||
|
||||
#define ERR_RTDB_OFLOW_MALLOC -3712 /* malloc error in overflow area */
|
||||
#define ERR_RTDB_OFLOW_FREE -3713 /* free error in overflow area */
|
||||
#define ERR_RTDB_STG_HASH_SAME_HASH_NUM -3715 /*error when INDEX_STORAGE_HASH_REC_HEAD::same_hash_num<0 */
|
||||
#define ERR_RTDB_WRONG_MEM -3716 /* shmget or mmap a wrong memory */
|
||||
#define ERR_RTDB_INDEX_MEM_ALLOC_TYPE -3717 /*wrong index memory allocation type */
|
||||
//#define ERR_RTDB_PTABFULL -10 /* process tab is full */
|
||||
|
||||
//sql
|
||||
#define ERR_RTDB_SQL -3720 /* sql syntax error */
|
||||
|
||||
#define ERR_RTDB_DBNAMENOTF -3800 /* db_name not founded */
|
||||
#define ERR_RTDB_FACNAMENOTF -3801 /* fac_name not founded */
|
||||
#define ERR_RTDB_VALNAMENOTF -3802 /* val_name not founded */
|
||||
#define ERR_RTDB_FIELDNAMENOTF -3803 /* field_name not founded */
|
||||
#define ERR_RTDB_VIEWFIELD -3901 /* view get fieldnum over error */
|
||||
#define ERR_RTDB_SYBASE -3902 /* modify sybase error */
|
||||
#define ERR_RTDB_INDEXERR -3903 /* index number error */
|
||||
#define ERR_RTDB_MODIFYSIZE -3904 /* modify bufsize error */
|
||||
#define ERR_RTDB_API_INVCOMM -3905 /* Invalid db operater command */
|
||||
#define ERR_RTDB_API_NOAPP -3906 /* App name not founded */
|
||||
#define ERR_RTDB_API_NODB -3907 /* Db name not founded */
|
||||
#define ERR_RTDB_API_INVDBNO -3908 /* Db no is wrong */
|
||||
#define ERR_RTDB_API_NODEOFF -3909 /* node is offline */
|
||||
#define ERR_RTDB_API_ERRINIT -3910 /* odbms init error */
|
||||
#define ERR_RTDB_API_NEWERR -3911 /* new space error */
|
||||
#define ERR_RTDB_API_DATAERR -3912 /* data tye error */
|
||||
#define ERR_RTDB_NOSPACE -3915 /* no space left in disk */
|
||||
|
||||
/* end of ERR_RTDB_ */
|
||||
@@ -1,102 +0,0 @@
|
||||
// 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);
|
||||
@@ -1,175 +0,0 @@
|
||||
#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
|
||||
@@ -1,61 +0,0 @@
|
||||
//**************************************
|
||||
// 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
|
||||
@@ -1,125 +0,0 @@
|
||||
#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
|
||||
@@ -1,269 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,236 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,233 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,227 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,80 +0,0 @@
|
||||
#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
|
||||
@@ -1,138 +0,0 @@
|
||||
#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
|
||||
@@ -1,54 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,64 +0,0 @@
|
||||
#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
|
||||
@@ -1,202 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
|
||||
@@ -1,563 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,84 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,72 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,73 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
#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
|
||||
@@ -1,67 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,993 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
@@ -1,193 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,66 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
//***********************************************************************************
|
||||
//
|
||||
// 本公共类作为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
|
||||
@@ -1,66 +0,0 @@
|
||||
#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
@@ -1,375 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,155 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,68 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
|
||||
@@ -1,184 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,160 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,458 +0,0 @@
|
||||
#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
|
||||
@@ -1,185 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,354 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,179 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,53 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,327 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,658 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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锟斤拷元锟截o拷锟斤拷锟斤拷锟絪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
|
||||
@@ -1,211 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
@@ -1,57 +0,0 @@
|
||||
|
||||
#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
|
||||
@@ -1,44 +0,0 @@
|
||||
#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
|
||||
@@ -1,21 +0,0 @@
|
||||
#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
|
||||
@@ -1,48 +0,0 @@
|
||||
//#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
|
||||
@@ -1,57 +0,0 @@
|
||||
#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
|
||||
@@ -1,24 +0,0 @@
|
||||
#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;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
//**************************************
|
||||
// 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;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
//**************************************
|
||||
// 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
|
||||
@@ -1,63 +0,0 @@
|
||||
#ifndef _CAPPNO_H_
|
||||
#define _CAPPNO_H_
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef CAPP_NO_EXPORTS
|
||||
#define CAPP_NO_API __declspec(dllexport)
|
||||
#else
|
||||
#define CAPP_NO_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define CAPP_NO_API
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "system.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class CAPP_NO_API CAppNo
|
||||
{
|
||||
public:
|
||||
unsigned int value_array[4];
|
||||
|
||||
public:
|
||||
CAppNo( unsigned int value1, unsigned int value2 = 0, unsigned int value3 = 0, unsigned int value4 = 0);
|
||||
CAppNo();
|
||||
~CAppNo();
|
||||
|
||||
// 重载操作符位与&、位或|、取反~、判等==(!=)、赋值(常数)、取余、整除、输出
|
||||
CAppNo operator&(const CAppNo value);
|
||||
CAppNo operator&=(const CAppNo value);
|
||||
CAppNo operator|(const CAppNo value);
|
||||
CAppNo operator|=(const CAppNo value);
|
||||
CAppNo operator~();
|
||||
bool operator==(const CAppNo value);
|
||||
bool operator ==(const unsigned int value);
|
||||
bool operator!=(const CAppNo value);
|
||||
bool operator!=(const unsigned int value);
|
||||
int operator=(const unsigned int value);
|
||||
CAppNo operator+(const CAppNo value);
|
||||
CAppNo operator+=(const CAppNo value);
|
||||
CAppNo operator-(const CAppNo value);
|
||||
CAppNo operator%(const unsigned int value);
|
||||
CAppNo operator/(const unsigned int value);
|
||||
CAppNo operator*(const unsigned int value);
|
||||
|
||||
friend CAPP_NO_API ostream& operator<<(ostream&,const CAppNo&);
|
||||
|
||||
bool any();//存在某一位为1,返回true
|
||||
bool none();//全部为0,返回true
|
||||
int count();//被设置成1的位的个数
|
||||
|
||||
CAppNo NoToCApp(int index_no);//应用号转为CAppNo
|
||||
int CAppToNo();//CAppNo转为应用号,返回最小号
|
||||
//int CAppToNo(vector<int> &appno_vec);//CAppNo转为应用号,返回最大号,appno_vec为其中所有应用号
|
||||
int AppColIndex();//返回应用号所在域
|
||||
|
||||
static bool isAppExt();//判断当前是否应用号扩展
|
||||
private:
|
||||
//static bool m_is_ext;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,72 +0,0 @@
|
||||
// CCharArray.h: interface for the CCharArray class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _CCharArray_H_
|
||||
#define _CCharArray_H_
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef PUB_TOOLS_EXPORTS
|
||||
#define PUB_TOOLS_API __declspec(dllexport)
|
||||
#else
|
||||
#define PUB_TOOLS_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define PUB_TOOLS_API
|
||||
#endif
|
||||
|
||||
class PUB_TOOLS_API CCharArray
|
||||
{
|
||||
public:
|
||||
// CCharArray();
|
||||
CCharArray(char *pChar, int nLen, bool bAutoDel = false);
|
||||
~CCharArray();
|
||||
|
||||
private:
|
||||
char *m_pChar; // 数据缓冲区
|
||||
int m_nCharLen; // m_pChar数组的长度
|
||||
int m_nCharIndex; // m_pChar数组中当前有效位置
|
||||
bool m_bAutoDelete; // 是否删除缓冲区的数据
|
||||
|
||||
private:
|
||||
void SetLen(int nIndex)
|
||||
{
|
||||
m_nCharLen = nIndex;
|
||||
}
|
||||
void SetIndex(int nIndex)
|
||||
{
|
||||
m_nCharIndex = nIndex;
|
||||
}
|
||||
int GetIndex()
|
||||
{
|
||||
return m_nCharIndex;
|
||||
}
|
||||
int CheckLen(int nLen);
|
||||
bool GetIsAutoDelete()
|
||||
{
|
||||
return m_bAutoDelete;
|
||||
}
|
||||
|
||||
public:
|
||||
int GetLen()
|
||||
{
|
||||
return m_nCharLen;
|
||||
}
|
||||
char *GetChar()
|
||||
{
|
||||
return m_pChar;
|
||||
}
|
||||
void IsAutoDelete(bool bAutoDelete = true)
|
||||
{
|
||||
m_bAutoDelete = bAutoDelete;
|
||||
}
|
||||
/*
|
||||
bool PutChar(char *pChar,int nLen);
|
||||
|
||||
bool GetChar(char *pChar,int nLen);
|
||||
|
||||
bool Skip(int nLen);
|
||||
*/
|
||||
};
|
||||
|
||||
#endif // _CCharArray_H_
|
||||
@@ -1,141 +0,0 @@
|
||||
// CDataStream.h: interface for the CDataStream class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _CDATASTREAM_H_
|
||||
#define _CDATASTREAM_H_
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef PUB_TOOLS_EXPORTS
|
||||
#define PUB_TOOLS_API __declspec(dllexport)
|
||||
#else
|
||||
#define PUB_TOOLS_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define PUB_TOOLS_API
|
||||
#endif
|
||||
|
||||
#include "common_types.h"
|
||||
#include "CCharArray.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
struct Keyid
|
||||
{
|
||||
int record_id;
|
||||
short column_id;
|
||||
};
|
||||
|
||||
typedef unsigned char byte;
|
||||
|
||||
const int DATASTREAM_NOT_CHECK = -1; //不检查传入串的长度
|
||||
const int DEFAULT_DATASTREAM_LENGTH = 255; //默认数据的长度应该大于零
|
||||
typedef struct Keyid TKEYID;
|
||||
|
||||
#define ERRMSG_LENGTH 255
|
||||
class PUB_TOOLS_API CDataStream
|
||||
{
|
||||
public:
|
||||
CDataStream();
|
||||
|
||||
~CDataStream();
|
||||
|
||||
bool Init(int nMode, bool bAutoDel = true, char *pDataStream = NULL, int nDataStreamLen = 0, int nDefaultDataStreamLen = DEFAULT_DATASTREAM_LENGTH);
|
||||
|
||||
enum
|
||||
{
|
||||
load = 0, store = 1
|
||||
};
|
||||
CDataStream& operator=(const CDataStream & strobj);
|
||||
|
||||
CDataStream(const CDataStream & strobj);
|
||||
|
||||
private:
|
||||
int m_nMode;
|
||||
char *m_pDataStream;
|
||||
int m_nDataStreamLen;
|
||||
int m_nDataStreamIndex;
|
||||
int m_nDefaultDataStreanLen; //默认的数据缓冲区的长度
|
||||
|
||||
bool m_bAutoDelete; //是否删除缓冲区的数据
|
||||
|
||||
bool m_bChangeOrder;
|
||||
|
||||
char m_chMsg[ERRMSG_LENGTH + 1];
|
||||
private:
|
||||
bool GetIsAutoDelete()
|
||||
{
|
||||
return m_bAutoDelete;
|
||||
}
|
||||
|
||||
bool IsOutofBound(int nLen);
|
||||
|
||||
int GetDataLen();
|
||||
|
||||
bool SetData(void *pData, int nLen);
|
||||
|
||||
bool GetData(void *pData, int nLen);
|
||||
|
||||
//exception * GetException(char *pMsg);
|
||||
|
||||
void SetErrMsg(char * pMsg);
|
||||
|
||||
char * GetErrMsg();
|
||||
|
||||
void ChangeOrder(short &s);
|
||||
void ChangeOrder(unsigned short &s);
|
||||
void ChangeOrder(int &i);
|
||||
void ChangeOrder(cmnInt64 &l);
|
||||
void ChangeOrder(float &f);
|
||||
void ChangeOrder(double &d);
|
||||
void ChangeOrder(cmnUint64 &dw);
|
||||
|
||||
public:
|
||||
bool IsChangeOrder()
|
||||
{
|
||||
return m_bChangeOrder;
|
||||
}
|
||||
|
||||
int GetDataStreamLen()
|
||||
{
|
||||
return m_nDataStreamIndex;
|
||||
}
|
||||
|
||||
void IsAutoDelete(bool bAutoDelete = true)
|
||||
{
|
||||
m_bAutoDelete = bAutoDelete;
|
||||
}
|
||||
|
||||
void Skip(int nLen);
|
||||
|
||||
void SkipTo(int nLen);
|
||||
|
||||
operator char *();
|
||||
|
||||
CDataStream & operator <<(char ch);
|
||||
CDataStream & operator <<(byte by);
|
||||
CDataStream & operator <<(bool b);
|
||||
CDataStream & operator <<(short s);
|
||||
CDataStream & operator <<(unsigned short s);
|
||||
CDataStream & operator <<(int Integer);
|
||||
CDataStream & operator <<(cmnInt64 l);
|
||||
CDataStream & operator <<(float f);
|
||||
CDataStream & operator <<(double d);
|
||||
CDataStream & operator <<(cmnUint64 dw);
|
||||
CDataStream & operator <<(CCharArray & CharArray);
|
||||
CDataStream & operator <<(TKEYID & keyid);
|
||||
|
||||
CDataStream & operator >>(char &ch);
|
||||
CDataStream & operator >>(byte &by);
|
||||
CDataStream & operator >>(bool &b);
|
||||
CDataStream & operator >>(short &s);
|
||||
CDataStream & operator >>(unsigned short &s);
|
||||
CDataStream & operator >>(int &Integer);
|
||||
CDataStream & operator >>(cmnInt64 &l);
|
||||
CDataStream & operator >>(float &f);
|
||||
CDataStream & operator >>(double &d);
|
||||
CDataStream & operator >>(cmnUint64 &dw);
|
||||
CDataStream & operator >>(CCharArray & CharArray);
|
||||
CDataStream & operator >>(TKEYID & keyid);
|
||||
};
|
||||
|
||||
#endif // _CDataStream_H_
|
||||
@@ -1,93 +0,0 @@
|
||||
#ifndef __CDBCOMMITCLIENT_H__
|
||||
#define __CDBCOMMITCLIENT_H__
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef DB_COMMIT_DLL_EXPORTS
|
||||
#define DB_COMMIT_DLL_API __declspec(dllexport)
|
||||
#else
|
||||
#define DB_COMMIT_DLL_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define DB_COMMIT_DLL_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 "db_commit_m.h"
|
||||
#include "servicemanage.h"
|
||||
#include "sysadm/scn_service.h"
|
||||
#include "pub_ctx.h"
|
||||
#include "system.h"
|
||||
#include "port_def.h"
|
||||
#include "logclient.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NS_SYSADMIN;
|
||||
|
||||
const int HIGH = 1;
|
||||
const int MIDDLE = 2;
|
||||
const int LOW = 3;
|
||||
const int NO_SQL_DUP = 0;
|
||||
const int SQL_DUP = 1;
|
||||
|
||||
#define OP_BIND_INSERT 1
|
||||
#define OP_BIND_UPDATE 2
|
||||
#define OP_BIND_DELETE 3
|
||||
|
||||
#define BIND_COMMIT_DATATYPE_CHR 1 /* 字符型 unsigned char */
|
||||
#define BIND_COMMIT_DATATYPE_INT 3 /* 短整型short 整形int 长整型long */
|
||||
#define BIND_COMMIT_DATATYPE_FLT 4 /* 浮点数float double */
|
||||
#define BIND_COMMIT_DATATYPE_STR 5 /* 字符串string */
|
||||
#define BIND_COMMIT_DATATYPE_ODT 156 /* 日期型date*/
|
||||
|
||||
class DB_COMMIT_DLL_API CDbCommitClient
|
||||
{
|
||||
public:
|
||||
|
||||
CDbCommitClient();
|
||||
CDbCommitClient(int sys_port);
|
||||
CDbCommitClient(int sys_port, int seconds);
|
||||
~CDbCommitClient();
|
||||
|
||||
public:
|
||||
void SetRequestTimeout(int seconds);
|
||||
short SqlCommit(TCommitStru CommitSqlStru); //1
|
||||
short SqlCommitWithNoDup(TCommitStru CommitSqlStru); //2
|
||||
short RsSqlCommit(TCommitStru CommitSqlStru); //3
|
||||
short WarnSqlCommit(TCommitStru CommitSqlStru); //4
|
||||
short LOBInsertCommit(char* sql_insert, char* sql_select, SEQCommitLOBValueType seq_lob_value); //5
|
||||
short LOBUpdateCommit(char* sql_update, char* sql_select, SEQCommitLOBValueType seq_lob_value); //6
|
||||
short SqlCommitWithBind(TCommitBindStru CommitBindStru); //7
|
||||
#ifdef _DATASRV_DIVERSION
|
||||
//DATA_SRV分模式下指定访问的应用
|
||||
//app_name = data_srv_dms 访问配网data_srv
|
||||
//其余取值访问主网data_srv
|
||||
void SetServiceApp(const char* app_name);
|
||||
void ClearServiceApp();
|
||||
#endif
|
||||
private:
|
||||
ServiceInfo m_Serviceinfo;
|
||||
char m_IpAddress[64];
|
||||
int m_Port;
|
||||
Handle m_Handle;
|
||||
char m_HostName[64];
|
||||
CScnService* m_ServicesManage;
|
||||
int m_RequestTimeoutSeconds;
|
||||
|
||||
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
|
||||
int SetServiceHost();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
//******************************************************************
|
||||
//
|
||||
// AUTHOR : ShiHaoQiu
|
||||
//
|
||||
// FUNCTION : db_monitor 进程的客户端类公用类定义
|
||||
//
|
||||
// TIME : 2011.04.09
|
||||
//
|
||||
// HISTORY :
|
||||
// Datetime Action Author Reason
|
||||
// -------------------------------------------------------------------
|
||||
// 2011.04.09 Creation ShiHaoQiu
|
||||
//
|
||||
//******************************************************************
|
||||
|
||||
#ifndef __CDBMONITORCLIENT_H__
|
||||
#define __CDBMONITORCLIENT_H__
|
||||
|
||||
#include "db_monitor_m.h"
|
||||
//#include "servicesclient.h"
|
||||
#include "sysadm/scn_service.h"
|
||||
#include "system.h"
|
||||
#include "pub_ctx.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
//#include "serviceglobal.h"
|
||||
#include "servicemanage.h"
|
||||
|
||||
|
||||
class CDbMonitorClient
|
||||
{
|
||||
public:
|
||||
CDbMonitorClient();
|
||||
CDbMonitorClient(int seconds);
|
||||
~CDbMonitorClient();
|
||||
void SetRequestTimeout(int seconds);
|
||||
short GetMasterDbInfo(TDbLoginInfo & masterDbInfo);
|
||||
short GetMasterDbInfo(const char* user_name,TDbLoginInfo & masterDbInfo);
|
||||
//short MasterDbSwitchByDbName(const char* strDbName);
|
||||
short MasterDbSwitchByDbService(const char* strDbService);
|
||||
short GetRepDbLoginInfo(const char* strDbName , TDbLoginInfo & repDbLoginInfo);
|
||||
short GetDbNum(int & nSize);
|
||||
short GetAllDbServerInfo(TDbServiceInfo & dbServerInfoSec);
|
||||
void SetLocalServiceFlag(bool flag);
|
||||
|
||||
//add for remote access
|
||||
int SetDomainInfo(const DomainInfo& domain_info); //设置远程信息(通用)
|
||||
int SetDomainInfo(const char* domain_name, const tSecLabel& sec_label, const int app_no = AP_DATA_SRV, const int ctx_no = AC_REALTIME_NO);
|
||||
int SetDomainName(const char* domain_name); //设置域名
|
||||
int SetSecLabel(tSecLabel& sec_label); //设置标签
|
||||
void ClearDomainName(); //清除域名,m_DomainName设为local_domain
|
||||
private:
|
||||
DomainInfo m_DomainInfo;
|
||||
ServiceInfo m_Serviceinfo;
|
||||
char m_IpAddress[64];
|
||||
int m_Port;
|
||||
Handle m_Handle;
|
||||
char m_HostName[64];
|
||||
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
|
||||
int SetServiceHost();
|
||||
bool m_localserviceflag;
|
||||
int m_RequestTimeoutSeconds;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
#ifndef ___CDBMONITORLOCAL_H__
|
||||
#define ___CDBMONITORLOCAL_H__
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef DB_MONITOR_DLL_LOCAL_EXPORTS
|
||||
#define DB_MONITOR_DLL_LOCAL_API __declspec(dllexport)
|
||||
#else
|
||||
#define DB_MONITOR_DLL_LOCAL_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define DB_MONITOR_DLL_LOCAL_API
|
||||
#endif
|
||||
|
||||
#include "db_com/db_monitor_define.h"
|
||||
#include "CDbMonitorShm.h"
|
||||
class DB_MONITOR_DLL_LOCAL_API CDbMonitorLocal
|
||||
{
|
||||
public:
|
||||
|
||||
CDbMonitorLocal();
|
||||
~CDbMonitorLocal();
|
||||
|
||||
int InitDbMonitorLocal();
|
||||
int GetMasterDbInfo(TLoginInfo &masterDbInfo);
|
||||
int GetMasterDbInfo(const string user_name,TLoginInfo &masterDbInfo);
|
||||
int GetRepDbLoginInfo(const string &strDbDesc , TLoginInfo &repDbLoginInfo);
|
||||
int GetRepDbLoginInfo(const string & strUserName,const string &strDbDesc , TLoginInfo &repDbLoginInfo);
|
||||
int GetDbNum(int &nSize);
|
||||
int GetAllDbServerInfo(vector<TLoginInfo> &dbServerInfoVec);
|
||||
int GetAllDbServerInfoExt(vector<TLoginInfo> & dbServerInfoVec);
|
||||
int GetUserPassword(string strUserName,string & strUserPassword);
|
||||
int GetAllUserInfo(vector<TLoginUserInfo> & userLoginVec);
|
||||
|
||||
//Add for db_warn_server by ZhangKeHeng
|
||||
int GetDbInfoByDbService(TLoginInfo &dbServiceInfo , const string strDbService);
|
||||
int GetDbInfoByDbService(TLoginInfo &dbServiceInfo , const string strDbService,const string user_name);
|
||||
//int GetDbInfoByDbName(TLoginInfo &dbServiceInfo , const string strDbName);
|
||||
int GetDbInfoByDbServiceDesc(TLoginInfo &dbServiceInfo , const string strDbDesc);
|
||||
int GetDbInfoByDbServiceDesc(TLoginInfo &dbServiceInfo , const string strDbDesc,const string user_name);
|
||||
//add fro db_warn_server db_config_ext.sys ¶ÁÈ¡
|
||||
int ReadDbConfigInfoFromFile(vector<TLoginInfo> & loginfo_vec);
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
//******************************************************************
|
||||
//
|
||||
// AUTHOR : LMJ
|
||||
//
|
||||
// FUNCTION : 数据库监视进程中操作共享内存 类方法定义
|
||||
//
|
||||
// TIME : 2003.12.8
|
||||
//
|
||||
// HISTORY :
|
||||
// Datetime Action Author Reason
|
||||
// -----------------------------------------------------------------
|
||||
// 2003.12.16 Creation LMJ
|
||||
// 2004.09.18 Modify ZhangKeHeng add interface for db_warn_server
|
||||
//******************************************************************
|
||||
|
||||
#ifndef __CDBMONITORSHM_H_
|
||||
#define __CDBMONITORSHM_H_
|
||||
#include "db_com/db_monitor_define.h"
|
||||
|
||||
|
||||
class CDbMonitorShm
|
||||
{
|
||||
|
||||
protected:
|
||||
CDbMonitorShm();
|
||||
public:
|
||||
static CDbMonitorShm & getInstance()
|
||||
{
|
||||
static CDbMonitorShm gCDbMonitorShm;
|
||||
return gCDbMonitorShm;
|
||||
}
|
||||
~CDbMonitorShm();
|
||||
private:
|
||||
|
||||
CDbShm m_DbShm;
|
||||
|
||||
TLoginInfo * m_pAllDbInfo;
|
||||
|
||||
int m_nDbNum;
|
||||
static int m_nDbAppStatusOffset;
|
||||
static int m_nMasterDbInfoOffset;
|
||||
static int m_nDbNumOffset;
|
||||
static int m_nAllDbInfoOffset;
|
||||
int m_TotalShmSize;
|
||||
|
||||
public:
|
||||
int InitDbMonitorShm();
|
||||
int SetDbAppStatusInfo(const int nStatus);
|
||||
int GetDbAppStatusInfo(int &nStatus);
|
||||
int SetMasterDbLoginInfo(const TLoginInfo &DbLoginInfo);
|
||||
int GetMasterDbLoginInfo(TLoginInfo &DbLoginInfo);
|
||||
int SetDbNum(const int nDbNum);
|
||||
int GetDbNum(int &nDbNum);
|
||||
int SetDbServiceInfo(const TLoginInfo &dbServiceInfo , int nDbSerialNo);
|
||||
int GetDbServiceInfo(TLoginInfo &dbServiceInfo , int nDbSerialNo);
|
||||
int GetDbServiceInfoByDbService(TLoginInfo &dbServiceInfo , string strDbService);
|
||||
//int GetDbServiceInfoByDbName(TLoginInfo &dbServiceInfo , string strDbName);
|
||||
int GetDbServiceInfoByDbServiceDesc(TLoginInfo &dbServiceInfo , string strDbDesc);
|
||||
int GetAllDbServiceInfo(vector<TLoginInfo> &dbServiceInfo);
|
||||
int SetAllDbServiceInfo(const vector<TLoginInfo> &dbServiceInfo);
|
||||
//int GetDbSerialNoFromDbName(vector<int> &dbSerialNoVec , string strDbName);
|
||||
int GetDbSerialNoFromDbServiceDesc(vector<int> &dbSerialNoVec,string strDbDesc);
|
||||
int GetDbSerialNoFromDbService(int &nDbSerialNo , string strDbService);
|
||||
|
||||
//Add for db_warn_server by ZhangKeHeng
|
||||
int GetDbInfoByDbService(TLoginInfo &dbServiceInfo , string strDbService);
|
||||
//int GetDbInfoByDbName(TLoginInfo &dbServiceInfo , string strDbName);
|
||||
int GetDbInfoByDbServiceDesc(TLoginInfo &dbServiceInfo , string strDbDesc);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,192 +0,0 @@
|
||||
//******************************************************************
|
||||
//
|
||||
// AUTHOR : LMJ
|
||||
//
|
||||
// FUNCTION : 复制动态库头文件
|
||||
//
|
||||
// TIME : 2003.08.30
|
||||
//
|
||||
// HISTORY :
|
||||
// Datetime Action Author Reason
|
||||
// -------------------------------------------------------------------
|
||||
// 2003.08.30 Creation LMJ
|
||||
// 2004.05.26 Add ZHANGKH Add LOB interface
|
||||
// 2004.12.20 Modify ZhangKeHeng Modify Function for Time Seq
|
||||
// 2005.12.28 Add ZhangKeHeng 部分复制
|
||||
//******************************************************************
|
||||
|
||||
#ifndef __CREPSET_H
|
||||
#define __CREPSET_H
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef DB_REP_LIB_EXPORTS
|
||||
#define DB_REP_LIB_API __declspec(dllexport)
|
||||
#else
|
||||
#define DB_REP_LIB_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define DB_REP_LIB_API
|
||||
#endif
|
||||
|
||||
#include "db_rep_lib_define.h"
|
||||
#include "database_rep_m.h"
|
||||
|
||||
#ifndef BIND_CHR
|
||||
#define BIND_CHR 1 /* 字符型 unsigned char */
|
||||
#endif
|
||||
#ifndef BIND_INT
|
||||
#define BIND_INT 3 /* 短整型short 整形int 长整型long */
|
||||
#endif
|
||||
#ifndef BIND_FLT
|
||||
#define BIND_FLT 4 /* 浮点数float double */
|
||||
#endif
|
||||
#ifndef BIND_STR
|
||||
#define BIND_STR 5 /* 字符串string */
|
||||
#endif
|
||||
#ifndef BIND_ODT
|
||||
#define BIND_ODT 156 /* 日期型date*/
|
||||
#endif
|
||||
|
||||
|
||||
const int PARTLY_REP_POLICY_NOREP = 1;
|
||||
const int PARTLY_REP_POLICY_ALLREP = 2;
|
||||
const int PARTLY_REP_POLICY_LIST_REP = 3;
|
||||
const int PARTLY_REP_POLICY_LIST_NOREP = 4;
|
||||
//进程复制策略
|
||||
const int PARTLY_REP_POLICY_NOREP_EXCEPT_PROC = 5;
|
||||
const int PARTLY_REP_POLICY_ALLREP_EXCEPT_PROC = 6;
|
||||
const int PARTLY_REP_POLICY_LIST_REP_EXCEPT_PROC = 7;
|
||||
const int PARTLY_REP_POLICY_LIST_NOREP_EXCEPT_PROC = 8;
|
||||
//进程中可被重新设定的策略(如果进程策略被设定为以下四种,则可以调用SetProcRepList重新设定进程复制策略和复制列表)
|
||||
const int PARTLY_REP_POLICY_NOREP_SET = 9;//norep_set
|
||||
const int PARTLY_REP_POLICY_ALLREP_SET = 10;//allrep_set
|
||||
const int PARTLY_REP_POLICY_LIST_REP_SET = 11;//list_rep_set
|
||||
const int PARTLY_REP_POLICY_LIST_NOREP_SET = 12;//list_norep_set
|
||||
|
||||
|
||||
const int PARTLY_REP_PROCESS_MODEL = 1;
|
||||
const int PARTLY_REP_PROCESS_WARN = 2;
|
||||
const int PARTLY_REP_PROCESS_LOB_EXE = 3;
|
||||
const int PARTLY_REP_PROCESS_LOB = 4;
|
||||
const int PARTLY_REP_PROCESS_STATICS = 5;
|
||||
const int PARTLY_REP_PROCESS_HISDB = 6;
|
||||
|
||||
struct ProcessRepInfo
|
||||
{
|
||||
int process_list_policy;
|
||||
string process_name;
|
||||
vector<string> process_table_list_vec;
|
||||
};
|
||||
|
||||
struct PartlyRepInfo
|
||||
{
|
||||
string db_service_describe;
|
||||
int sample_list_policy;
|
||||
int warn_list_policy;
|
||||
int model_list_policy;
|
||||
int statics_list_policy; //add jihy 20130328
|
||||
vector<string> warn_list_vec;
|
||||
vector<string> model_list_vec;
|
||||
vector<string> statics_list_vec;//add jihy 20130328'
|
||||
|
||||
vector<ProcessRepInfo> sample_process_repinfo;//进程信息集合
|
||||
vector<ProcessRepInfo> warn_process_repinfo;
|
||||
vector<ProcessRepInfo> model_process_repinfo;
|
||||
vector<ProcessRepInfo> statics_process_repinfo;
|
||||
};
|
||||
|
||||
|
||||
class DB_REP_LIB_API CDbRepSet
|
||||
{
|
||||
public:
|
||||
CDbRepSet();
|
||||
~CDbRepSet();
|
||||
|
||||
public:
|
||||
//初始化复制动态库 (proc_alias_name为进程别名,需要与db_partly_rep.sys中名称一致)
|
||||
int InitReplicateSet (string proc_alias_name = "");
|
||||
|
||||
//设置进程复制列表(设置进程复制策略和哪些表的语句需要复制) (默认为列表复制策略) (proc_alias_name为进程别名,需要与db_partly_rep.sys中名称一致)
|
||||
int SetProcRepList (const string &proc_alias_name,
|
||||
vector<string> &tablename_vec, const string & strUserName = "d5000",
|
||||
int rep_policy = PARTLY_REP_POLICY_LIST_REP_SET);
|
||||
|
||||
//时序要求复制(例如模型)strDbName 为 db_config_ext.sys中的db_service_describe
|
||||
int ReplicateSql (const vector<string> &strSqlVec , const string &strDbName,
|
||||
const string & strUserName = "d5000");
|
||||
//非时序要求复制(例如告警)strDbName 为 db_config_ext.sys中的db_service_describe
|
||||
int ReplicateSqlWithNoTimeSeq (const vector<string> &strSqlVec ,
|
||||
const string &strDbName , const string & strUserName = "alarm");
|
||||
//非时序要求复制(例如采样)strDbName 为 db_config_ext.sys中的db_service_describe
|
||||
int ReplicateSqlWithNoTimeSeqSample (const vector<string> &strSqlVec ,
|
||||
const string &strDbName , const string & strUserName = "hisdb");
|
||||
|
||||
//大字段复制
|
||||
int ReplicateLOB (const string &strSql , const string &strDbName,
|
||||
const string & strUserName = "d5000");
|
||||
int ReplicateLOB (const string &strSql , const string &strSqlSelect ,
|
||||
const vector<TLOBContent> &lobVec, bool is_insert, const string &strDbName,
|
||||
const string & strUserName = "d5000");
|
||||
|
||||
//绑定变量复制 add by shihaoqiu 20130313
|
||||
int ReplicateBind (const TRepBindStru &bind_stru, const string &strDbName,
|
||||
const string & strUserName = "d5000");
|
||||
|
||||
private:
|
||||
int m_nPid;
|
||||
string m_strProcName; //当前进程名
|
||||
string m_strPubPath;
|
||||
vector<string> m_strDbNameVec; //所有数据库名
|
||||
map<string, int>
|
||||
m_bPartlyRepMap; //所有数据库是否部分复制,1部分
|
||||
bool m_bRepFlag;
|
||||
map<string, PartlyRepInfo> m_PartlyRepInfoMap; //部分复制信息MAP
|
||||
vector<string> m_strPartlyRepPolicyVec; //部分复制策略字符串
|
||||
|
||||
private:
|
||||
int GetPubPath();
|
||||
int GetAllDbName();
|
||||
int GetAllPartlyRepInfo();
|
||||
int GetReplicatePath (vector<string> &strPathVec, vector<string> &strDbNameVec,
|
||||
string strDbName, string strUserName);
|
||||
string IntToStr (int nVal);
|
||||
//int WriteRepSql(const vector<string> &strSql,const vector<string> &strPathVec, const vector<string> &strDbNameVec);
|
||||
int WriteRepSql (const vector<string> &strSql, const vector<string> &strPathVec,
|
||||
const vector<string> &strDbNameVec, string strUserName);
|
||||
int WriteRepSqlWithNoTimeSeq (const vector<string> &strSql,
|
||||
const vector<string> &strPathVec, const vector<string> &strDbNameVec);
|
||||
int WriteRepSqlWithNoTimeSeqSample (const vector<string> &strSql,
|
||||
const vector<string> &strPathVec, const vector<string> &strDbNameVec);
|
||||
int MoveInFileToOutFile (const string strInFileName);
|
||||
int GetOutFileName (const string strInFileName , string &strOutFileName);
|
||||
|
||||
int WriteRepLOB (const string &strSql , const vector<string> &strPathVec,
|
||||
const vector<string> &strDbNameVec);
|
||||
int WriteRepLOB (const string &strSql , const string &strSqlSelect ,
|
||||
const vector<TLOBContent> &lobVec, bool is_insert,
|
||||
const vector<string> &strPathVec, const vector<string> &strDbNameVec);
|
||||
int GetLOBReplicatePath ( vector<string> &strPathVec,
|
||||
vector<string> &strDbNameVec, string strDbName, string strUserName);
|
||||
int MoveLOBInFileToOutFile (const string strInFileName);
|
||||
int GetLOBOutFileName (const string strInFileName , string &strOutFileName);
|
||||
|
||||
int GetBindReplicatePath ( vector<string> &strPathVec,
|
||||
vector<string> &strDbNameVec, string strDbName, string strUserName);
|
||||
int MoveBindInFileToOutFile (const string strInFileName);
|
||||
int GetBindOutFileName (const string strInFileName , string &strOutFileName);
|
||||
int WriteRepBind (const TRepBindStru &bind_stru,
|
||||
const vector<string> &strPathVec, const vector<string> &strDbNameVec);
|
||||
|
||||
int GetPartlyRepSql (const vector<string> &strSqlVec,
|
||||
vector<string> &strPartlyRepSqlVec, const string &strDbName, const int &flag);
|
||||
int GetRepSqlByList (const vector<string> &strSqlVec,
|
||||
vector<string> &strPartlyRepSqlVec, vector<string> &tablename_list_vec,
|
||||
const int &rep_policy);
|
||||
void gUsleep (const int usec);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
#ifndef __CDBSEM_H_
|
||||
#define __CDBSEM_H_
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef PUB_TOOLS_EXPORTS
|
||||
#define PUB_TOOLS_API __declspec(dllexport)
|
||||
#else
|
||||
#define PUB_TOOLS_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define PUB_TOOLS_API
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef _WINDOWS64
|
||||
#include <unistd.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <algorithm>
|
||||
#include <errno.h>
|
||||
#include <sys/sem.h>
|
||||
#include <ctype.h>
|
||||
#include <vector>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
union db_semun
|
||||
{
|
||||
int val;
|
||||
struct semid_ds *buf;
|
||||
unsigned short *array;
|
||||
};
|
||||
|
||||
class PUB_TOOLS_API CDbSem
|
||||
{
|
||||
#ifndef _WINDOWS64
|
||||
int m_nSemId;
|
||||
#else
|
||||
char m_pSemName[64];
|
||||
#endif
|
||||
public:
|
||||
CDbSem();
|
||||
~CDbSem();
|
||||
#ifndef _WINDOWS64
|
||||
int InitSem(key_t key, int nsems, int initval);
|
||||
int GetSemValue(int sem_id, int sem_num);
|
||||
int ClearSemValue(int sem_id, int sem_num);
|
||||
#else
|
||||
int InitSem(const char *sem_name);
|
||||
#endif
|
||||
int p();
|
||||
int v();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
#ifndef __CDBSEMUSE_H_
|
||||
#define __CDBSEMUSE_H_
|
||||
|
||||
#include "CDbSem.h"
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef PUB_TOOLS_EXPORTS
|
||||
#define PUB_TOOLS_API __declspec(dllexport)
|
||||
#else
|
||||
#define PUB_TOOLS_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define PUB_TOOLS_API
|
||||
#endif
|
||||
|
||||
class PUB_TOOLS_API CDbSemUse
|
||||
{
|
||||
public:
|
||||
CDbSemUse(CDbSem &sem);
|
||||
~CDbSemUse();
|
||||
|
||||
private:
|
||||
CDbSem &m_Sem;
|
||||
|
||||
int m_nPflag;
|
||||
int m_nVflag;
|
||||
|
||||
public:
|
||||
int GetPflag();
|
||||
int GetVflag();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
#ifndef __CDBSHM_H
|
||||
#define __CDBSHM_H
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef PUB_TOOLS_EXPORTS
|
||||
#define PUB_TOOLS_API __declspec(dllexport)
|
||||
#else
|
||||
#define PUB_TOOLS_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define PUB_TOOLS_API
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef _WINDOWS64
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/uio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <algorithm>
|
||||
#include <errno.h>
|
||||
#include <sys/sem.h>
|
||||
#include <ctype.h>
|
||||
#include <vector>
|
||||
#include <math.h>
|
||||
#include <sys/mman.h>
|
||||
#include <assert.h>
|
||||
#ifdef _HPUX
|
||||
#include <sys/pthread.h>
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#include <dirent.h>
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#include <windows.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
class PUB_TOOLS_API CDbShm
|
||||
{
|
||||
|
||||
public:
|
||||
CDbShm();
|
||||
~CDbShm();
|
||||
private:
|
||||
|
||||
static int m_TotalShmSize;
|
||||
|
||||
static char * m_pShm;
|
||||
public:
|
||||
#ifndef _WINDOWS64
|
||||
int InitShm(key_t key, int size);
|
||||
#else
|
||||
int InitShm(const char* file_name, const int size);
|
||||
#endif
|
||||
|
||||
static int SetShmSize(int nSize);
|
||||
|
||||
static int GetShmSize(int &nSize);
|
||||
|
||||
int WriteShm(char * inShm, int inSize, int ptrOffset);
|
||||
|
||||
int ReadShm(char * &outShm, int outSize, int ptrOffset);
|
||||
|
||||
char* MapFile(const char* file_name, const int stab_total_size);
|
||||
|
||||
int ReadShmEx(char * outShm, int outSize, int ptrOffset);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
#ifndef ___CDY_CFG_LOCAL_H__
|
||||
#define ___CDY_CFG_LOCAL_H__
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef DY_READ_CONFIG_LOCAL_EXPORTS
|
||||
#define DY_READ_CONFIG_LOCAL_API __declspec(dllexport)
|
||||
#else
|
||||
#define DY_READ_CONFIG_LOCAL_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define DY_READ_CONFIG_LOCAL_API
|
||||
#endif
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class DY_READ_CONFIG_LOCAL_API CDyCfgLocal
|
||||
{
|
||||
public:
|
||||
|
||||
CDyCfgLocal();
|
||||
~CDyCfgLocal();
|
||||
|
||||
//从dy_config.sys读取
|
||||
/************************************************************
|
||||
Description:根据dy_name获取dy应用注册应用名
|
||||
Input: dy_name
|
||||
Output:app_name
|
||||
************************************************************/
|
||||
int GetDyAppNameByDyName (const string dy_name , string& app_name);
|
||||
/************************************************************
|
||||
Description:根据dy_name获取dy应用注册应用号
|
||||
Input: dy_name
|
||||
Output:app_no
|
||||
************************************************************/
|
||||
int GetDyAppNoByDyName (const string dy_name , int& app_no);
|
||||
/************************************************************
|
||||
Description:根据dy_name、proc_name,分配当前进程端口号
|
||||
is_control只对dy_commit,dy_query_sample_server有效
|
||||
Input: dy_name,proc_name,is_control
|
||||
Output:app_no
|
||||
************************************************************/
|
||||
int GetAppPortPosByDyName (const string dy_name , const string proc_name ,
|
||||
int& proc_port, bool is_control = true);
|
||||
/************************************************************
|
||||
Description:根据dy_name获取dy应用所服务的应用名,如dy_iscada为iscada应用服务
|
||||
Input: dy_name
|
||||
Output:app_name
|
||||
************************************************************/
|
||||
int GetServedAppNameByDyName (const string dy_name , string& app_name);
|
||||
/************************************************************
|
||||
Description:根据dy_name获取dy应用所服务的应用号
|
||||
Input: dy_name
|
||||
Output:app_no
|
||||
************************************************************/
|
||||
int GetServedAppNoByDyName (const string dy_name, int& app_no);
|
||||
/************************************************************
|
||||
Description:获取所有dy_name
|
||||
Input:
|
||||
Output:vec_dy_names
|
||||
************************************************************/
|
||||
int GetAllDyNameFromCfg (vector<string>& vec_dy_names);
|
||||
/************************************************************
|
||||
Description:获取dy_name下的所有dys_name
|
||||
Input:dy_name
|
||||
Output:vec_dys_names
|
||||
************************************************************/
|
||||
int GetAllDysNameByDyNameFromCfg (const string dy_name,
|
||||
vector<string>& vec_dys_names);
|
||||
/************************************************************
|
||||
Description:获取所有使用DY应用的应用号
|
||||
Input:
|
||||
Output:vec_app_no
|
||||
************************************************************/
|
||||
int GetAllDyAppNo (vector<int>& vec_app_no);
|
||||
/************************************************************
|
||||
Description:检查app_no应用是否使用DY
|
||||
Input:app_no
|
||||
Output:-1:读取dy_config.sys配置文件出错;0:未使用DY;1:使用DY
|
||||
************************************************************/
|
||||
int CheckDyAppNo (const int app_no);
|
||||
/************************************************************
|
||||
Description:根据应用号获取dy_name,对应dy_config.sys中dy_app
|
||||
Input:app_no
|
||||
Output:dy_name
|
||||
************************************************************/
|
||||
int GetDyNameByAppNo (const int app_no, string &dy_name);
|
||||
/************************************************************
|
||||
Description:根据app_no、proc_name,分配当前进程端口号
|
||||
is_control只对dy_commit,dy_query_sample_server有效
|
||||
Input:app_no,proc_name,is_control
|
||||
Output:proc_port
|
||||
************************************************************/
|
||||
int GetAppPortPosByAppNo (const int app_no , const string proc_name ,
|
||||
int& proc_port, bool is_control = true);
|
||||
/************************************************************
|
||||
Description:根据dy应用所服务的应用号获取dy应用应用号
|
||||
Input:app_no
|
||||
Output:register_app
|
||||
************************************************************/
|
||||
int GetDyAppByServedApp (const int app_no, int ®ister_app);
|
||||
|
||||
private:
|
||||
int getIndexByServiceName (string service_name) ;
|
||||
int getIndexByDyName (const string dy_name) ;
|
||||
string gDyIntToStr (int nVal);
|
||||
int ReadDyConfigInfoLocal();
|
||||
int StringCopy (char *des, const char *src, int max_len);
|
||||
|
||||
vector<string> m_vec_dy_names;
|
||||
map<string, vector<string> > m_dy_dys_vec_map;
|
||||
vector<string> m_vec_app_name;
|
||||
vector<int> m_vec_port_pos;
|
||||
map<string, int> m_dyname_app_map;
|
||||
map<int, string> m_app_dyname_map;
|
||||
//app_name->app_no from mng_app_num_name.ini
|
||||
map<string, int> m_mng_app_name_map;
|
||||
map<int, int> m_app_dyapp_map;
|
||||
map<string, int> m_procname_port_map;
|
||||
|
||||
bool m_read_cfg;//配置文件读取成功标识
|
||||
// void gUsleep(const int usec);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
#ifndef ___CDYCOMMITCLIENT_H__
|
||||
#define ___CDYCOMMITCLIENT_H__
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef DY_COMMIT_DLL_EXPORTS
|
||||
#define DY_COMMIT_DLL_API __declspec(dllexport)
|
||||
#else
|
||||
#define DY_COMMIT_DLL_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define DY_COMMIT_DLL_API
|
||||
#endif
|
||||
|
||||
#ifndef _WINDOWS64
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
//#include <unistd.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "dy_commit_m.h"
|
||||
//#include "common_service_interface.h"
|
||||
//#include <OB/common_service_interface.h>
|
||||
#include "msg_api/message_inv.h"
|
||||
#include "sysadm/scn_service.h"
|
||||
#include "servicemanage.h"
|
||||
#include "pub_ctx.h"
|
||||
#include "system.h"
|
||||
#include "port_def.h"
|
||||
#include "db_com/CDyCfgLocal.h"
|
||||
|
||||
using namespace NS_SYSADMIN;
|
||||
//#include <sys/types.h>
|
||||
//#include <sys/socket.h>
|
||||
|
||||
/*#ifndef SERVEICE_CLASS_H
|
||||
#define SERVEICE_CLASS_H
|
||||
|
||||
class CServicesManage servicesman;
|
||||
#endif*/
|
||||
|
||||
struct TDyReCommitProp //扩展用,暂不使用
|
||||
{
|
||||
int app_no;
|
||||
};
|
||||
|
||||
class DY_COMMIT_DLL_API CDyCommitClient
|
||||
{
|
||||
public:
|
||||
CDyCommitClient (int sys_port);
|
||||
CDyCommitClient (int sys_port, int seconds);
|
||||
CDyCommitClient();//用于图形修改SCADA数据
|
||||
~CDyCommitClient();
|
||||
|
||||
//void SetAppNo(const int app_no);
|
||||
void SetRequestTimeout (int seconds);
|
||||
short VSCommit (TDyCommitVS DyCommitVSStru);
|
||||
short KVSCommit (TDyCommitKVS DyCommitKVSStru);
|
||||
|
||||
private:
|
||||
ServiceInfo m_Serviceinfo;
|
||||
CDyCfgLocal m_dy_cfg_read;
|
||||
char m_IpAddress[64];
|
||||
int m_Port;
|
||||
Handle m_Handle;
|
||||
char m_HostName[64];
|
||||
CScnService* m_ServicesManage;
|
||||
int m_RequestTimeoutSeconds;
|
||||
|
||||
int GetHostByAppNo (char* host_name, const int app_no, const short context_no);
|
||||
int SetServiceHost(int app_no);
|
||||
|
||||
bool print_env;//是否输出打印语句
|
||||
//记录应用是否需要调用总控服务
|
||||
map<int,bool> map_app_is_ctrl;
|
||||
//是否需要自动获取端口号,CDyCommitClient()下生效
|
||||
bool m_is_port_auto_set;
|
||||
|
||||
short GetIsCtrlByApp(const int app_no,bool &is_ctrl);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,80 +0,0 @@
|
||||
|
||||
#ifndef __CDYMONITORCLIENT_H__
|
||||
#define __CDYMONITORCLIENT_H__
|
||||
/*
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef DY_MONITOR_DLL_EXPORTS
|
||||
#define DY_MONITOR_DLL_API __declspec(dllexport)
|
||||
#else
|
||||
#define DY_MONITOR_DLL_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define DY_MONITOR_DLL_API
|
||||
#endif
|
||||
*/
|
||||
#include "dy_monitor_m.h"
|
||||
#include "sysadm/scn_service.h"
|
||||
#include "system.h"
|
||||
#include "pub_ctx.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include "servicemanage.h"
|
||||
//#include "common_service_interface.h"
|
||||
//#include <OB/common_service_interface.h>
|
||||
using namespace NS_SYSADMIN;
|
||||
|
||||
class CDyMonitorClient// : virtual public common_service_interface
|
||||
{
|
||||
public:
|
||||
//CDyMonitor_var m_Specify_GenerInvoke;
|
||||
//CDyMonitor_var m_GenerInvoke;
|
||||
public:
|
||||
|
||||
/*CDyMonitorClient(int app_id, char * specify_host_name, int specify_port, char * specify_server_object, short context =0 , char * orb_name = NULL)
|
||||
:common_service_interface(app_id, specify_host_name, specify_port, specify_server_object, context, orb_name){}
|
||||
|
||||
CDyMonitorClient(int app_id, int policy, int sys_port,char * server_object, short context = 0, char * orb_name = NULL)
|
||||
:common_service_interface(app_id, policy,sys_port, server_object, context , orb_name){}
|
||||
|
||||
CDyMonitorClient(int app_id, int policy, int sys_port, char * server_object,const vector<T_Corba_Props> &props_vec, short context =0, char * orb_name = NULL)
|
||||
:common_service_interface( app_id, policy, sys_port, server_object, props_vec , context , orb_name){}
|
||||
CDyMonitorClient(int app_id, char * specify_host_name, int specify_port, char * specify_server_object, const vector<T_Corba_Props> &props_vec, short context = 0, char * orb_name = NULL)
|
||||
:common_service_interface( app_id, specify_host_name, specify_port, specify_server_object, props_vec, context , orb_name){}
|
||||
*/
|
||||
CDyMonitorClient();
|
||||
CDyMonitorClient(int port);
|
||||
CDyMonitorClient(int port, int seconds);
|
||||
~CDyMonitorClient();
|
||||
void SetRequestTimeout(int seconds);
|
||||
//设置应访问的服务所属应用,默认AP_DATA_SRV_DY
|
||||
void SetAppNo(const int app_no);
|
||||
|
||||
//调用的接口函数声明在下面增加,根据IDL映射后的头文件中定义设置
|
||||
short GetMasterDyInfo(const char* strDyName,TDyLoginInfo &masterDyInfo);
|
||||
|
||||
short MasterDySwitchByDyServiceName(const char* strDyName);
|
||||
|
||||
short GetDyNum(int &nSize);
|
||||
|
||||
short GetAllDyServerInfo(TDyServiceInfo &dyServerInfoSec);
|
||||
|
||||
private:
|
||||
ServiceInfo m_Serviceinfo;
|
||||
char m_IpAddress[64];
|
||||
int m_Port;
|
||||
Handle m_Handle;
|
||||
char m_HostName[64];
|
||||
CScnService *m_ServicesManage;//modify by wuhan
|
||||
int m_RequestTimeoutSeconds;
|
||||
int m_app_no;
|
||||
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
|
||||
int SetServiceHost();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
#ifndef ___CDYMONITORLOCAL_H__
|
||||
#define ___CDYMONITORLOCAL_H__
|
||||
/*
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef DY_MONITOR_DLL_LOCAL_EXPORTS
|
||||
#define DY_MONITOR_DLL_LOCAL_API __declspec(dllexport)
|
||||
#else
|
||||
#define DY_MONITOR_DLL_LOCAL_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define DY_MONITOR_DLL_LOCAL_API
|
||||
#endif
|
||||
*/
|
||||
#include "dy_monitor_define.h"
|
||||
#include "CDyMonitorShm.h"
|
||||
|
||||
class CDyMonitorLocal
|
||||
{
|
||||
public:
|
||||
|
||||
CDyMonitorLocal();
|
||||
~CDyMonitorLocal();
|
||||
|
||||
//初始化信号量,读取dy_config.sys
|
||||
int InitDyMonitorLocal();
|
||||
//不初始化信号量,仅为读取dy_config.sys用,与InitDyMonitorLocal()只能2选1
|
||||
int InitDyLoginParaInfo();
|
||||
//get info from shm
|
||||
int GetMasterDyInfo (string strDysName, TLoginDyInfo &masterDyInfo);
|
||||
|
||||
int GetMasterDyInfo (string dy_name,string strDysName, TLoginDyInfo &masterDyInfo);
|
||||
|
||||
int GetDyNum (int &nSize);
|
||||
|
||||
int GetAllDyServerInfo (vector<TLoginDyInfo> &dyServerInfoVec);
|
||||
|
||||
int GetAllDyServerInfo (const string strDyName,vector<TLoginDyInfo> &dyServerInfoVec);
|
||||
int getIndexByServiceName (string service_name) ;
|
||||
|
||||
int getIndexByServiceName (const string dy_name,const string service_name) ;
|
||||
|
||||
//get info from dy_config.sys
|
||||
int GetAllDySNameFromCfg(string strDyName,vector<string>& dySNameVec);
|
||||
int GetAllDyNameFromCfg (vector<string>& vec_dy_names);
|
||||
int GetDyNumFromCfg(int &nSize);
|
||||
int GetDyServerInfoByIndex (const int index,TLoginDyInfo& dyServerInfo);
|
||||
|
||||
private:
|
||||
|
||||
int getIndexByDyName (const string dy_name) ;
|
||||
string gDyIntToStr (int nVal);
|
||||
int ReadDyConfigInfoLocal();
|
||||
int StringCopy (char *des, const char *src, int max_len);
|
||||
|
||||
vector<TLoginDyInfo> m_dy_config_info;
|
||||
|
||||
vector<string> m_vec_dy_names;//按配置顺序记录所有dy_name
|
||||
vector<int> m_vec_dy_pos;//记录dy_name在m_dy_config_info中对应的起始位置,对应m_vec_dy_names
|
||||
map<string,vector<string> > m_app_dys_map;
|
||||
// void gUsleep(const int usec);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
//******************************************************************
|
||||
//
|
||||
// AUTHOR : JiXueChun
|
||||
//
|
||||
// FUNCTION : 数据库监视进程中操作共享内存 类方法定义
|
||||
//
|
||||
// TIME : 2006.11.20
|
||||
//
|
||||
// HISTORY :
|
||||
// Datetime Action Author Reason
|
||||
// -----------------------------------------------------------------
|
||||
// 2006.11.20 Creation JiXueChun
|
||||
// 2008.07.29 Modify JiXueChun add support to distributed dys
|
||||
//******************************************************************
|
||||
|
||||
#ifndef __CDYMONITORSHM_H_
|
||||
#define __CDYMONITORSHM_H_
|
||||
#include "dy_monitor_define.h"
|
||||
|
||||
|
||||
class CDyMonitorShm
|
||||
{
|
||||
|
||||
protected:
|
||||
CDyMonitorShm();
|
||||
public:
|
||||
static CDyMonitorShm & getInstance()
|
||||
{
|
||||
static CDyMonitorShm gCDyMonitorShm;
|
||||
return gCDyMonitorShm;
|
||||
}
|
||||
~CDyMonitorShm();
|
||||
private:
|
||||
|
||||
CDyShm m_DbShm;
|
||||
|
||||
TLoginDyInfo * m_pAllDyInfo;
|
||||
|
||||
int m_nDyNum;
|
||||
static int m_nDyNumOffset;
|
||||
static int m_nAllDyAppStatusOffset;
|
||||
static int m_nAllDyInfoOffset;
|
||||
int m_TotalShmSize;
|
||||
|
||||
public:
|
||||
int InitDyMonitorShm();
|
||||
int SetDyAppStatusInfoByIndex (int index, int nStatus);
|
||||
int GetDyAppStatusInfoByIndex (int index, int &nStatus);
|
||||
int SetDyNum (int nDyNum);
|
||||
int GetDyNum (int &nDyNum);
|
||||
int SetDyServiceInfoByIndex (int index, const TLoginDyInfo &dyServiceInfo);
|
||||
int GetDyServiceInfoByIndex (int index, TLoginDyInfo &dyServiceInfo);
|
||||
private:
|
||||
string gDyIntToStr (int nVal);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
#ifndef __CDYSEM_H_
|
||||
#define __CDYSEM_H_
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef PUB_TOOLS_EXPORTS
|
||||
#define PUB_TOOLS_API __declspec(dllexport)
|
||||
#else
|
||||
#define PUB_TOOLS_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define PUB_TOOLS_API
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef _WINDOWS64
|
||||
#include <unistd.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <algorithm>
|
||||
#include <errno.h>
|
||||
#include <sys/sem.h>
|
||||
#include <ctype.h>
|
||||
#include <vector>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
union dy_semun
|
||||
{
|
||||
int val;
|
||||
struct semid_ds *buf;
|
||||
unsigned short *array;
|
||||
};
|
||||
|
||||
class PUB_TOOLS_API CDySem
|
||||
{
|
||||
#ifndef _WINDOWS64
|
||||
int m_nSemId;
|
||||
#else
|
||||
char m_pSemName[64];
|
||||
#endif
|
||||
public:
|
||||
CDySem();
|
||||
~CDySem();
|
||||
#ifndef _WINDOWS64
|
||||
int InitSem(key_t key, int nsems, int initval);
|
||||
int GetSemValue(int sem_id, int sem_num);
|
||||
int ClearSemValue(int sem_id, int sem_num);
|
||||
#else
|
||||
int InitSem(const char *sem_name);
|
||||
#endif
|
||||
int p();
|
||||
int v();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
#ifndef __CDYSEMUSE_H_
|
||||
#define __CDYSEMUSE_H_
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef PUB_TOOLS_EXPORTS
|
||||
#define PUB_TOOLS_API __declspec(dllexport)
|
||||
#else
|
||||
#define PUB_TOOLS_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define PUB_TOOLS_API
|
||||
#endif
|
||||
|
||||
#include "CDySem.h"
|
||||
|
||||
class PUB_TOOLS_API CDySemUse
|
||||
{
|
||||
public:
|
||||
CDySemUse(CDySem &sem);
|
||||
~CDySemUse();
|
||||
|
||||
private:
|
||||
CDySem &m_Sem;
|
||||
|
||||
int m_nPflag;
|
||||
int m_nVflag;
|
||||
|
||||
public:
|
||||
int GetPflag();
|
||||
int GetVflag();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
#ifndef __CDYSHM_H
|
||||
#define __CDYSHM_H
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef PUB_TOOLS_EXPORTS
|
||||
#define PUB_TOOLS_API __declspec(dllexport)
|
||||
#else
|
||||
#define PUB_TOOLS_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define PUB_TOOLS_API
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef _WINDOWS64
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/uio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <algorithm>
|
||||
#include <errno.h>
|
||||
#include <sys/sem.h>
|
||||
#include <ctype.h>
|
||||
#include <vector>
|
||||
#include <math.h>
|
||||
#include <sys/mman.h>
|
||||
#include <assert.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <dirent.h>
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#include <windows.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
class PUB_TOOLS_API CDyShm
|
||||
{
|
||||
|
||||
public:
|
||||
CDyShm();
|
||||
~CDyShm();
|
||||
|
||||
private:
|
||||
int m_TotalShmSize;
|
||||
char* m_pShm;
|
||||
|
||||
public:
|
||||
|
||||
#ifndef _WINDOWS64
|
||||
int InitShm(key_t key, int size);
|
||||
#else
|
||||
int InitShm(const char* file_name, const int size);
|
||||
#endif
|
||||
|
||||
int SetShmSize(int nSize);
|
||||
int GetShmSize(int &nSize);
|
||||
int WriteShm(char * inShm, int inSize, int ptrOffset);
|
||||
int ReadShm(char * &outShm, int outSize, int ptrOffset);
|
||||
char* MapFile(const char* file_name, const int stab_total_size);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,30 +0,0 @@
|
||||
//******************************************************************
|
||||
// AUTHOR : WangChangpin
|
||||
// FUNCTION : Ìṩ¶ÁÈ¡dy_get_tag.sysº¯Êý
|
||||
// TIME : 2014.11.10
|
||||
// HISTORY :
|
||||
// Datetime Action Author Reason
|
||||
// -------------------------------------------------------------------
|
||||
// 2014.11.10 Creation
|
||||
//******************************************************************
|
||||
|
||||
#ifndef _CDY_TAG_SHM_INFO_H_
|
||||
#define _CDY_TAG_SHM_INFO_H_
|
||||
|
||||
#include "paramanage.h"
|
||||
|
||||
class CDyTagShmInfo
|
||||
{
|
||||
public:
|
||||
CDyTagShmInfo();
|
||||
~CDyTagShmInfo();
|
||||
|
||||
short GetMaxWaitTime(int& wait_time);
|
||||
short GetMaxCountByDyName(const string dy_name,int& max_tag_count);
|
||||
short GetShmKeyByDyName(const string dy_name,int& shm_key);
|
||||
|
||||
private:
|
||||
CParaManage * pm;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,94 +0,0 @@
|
||||
#ifndef _CERRORLOG_H
|
||||
#define _CERRORLOG_H
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef PUB_TOOLS_EXPORTS
|
||||
#define PUB_TOOLS_API __declspec(dllexport)
|
||||
#else
|
||||
#define PUB_TOOLS_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define PUB_TOOLS_API
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#include <time.h>
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
//#include "paramanage.h"
|
||||
#include "system.h"
|
||||
#include "db_com/wholepubtools.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int ONE_DAY_TIME = 24 * 60 * 60;
|
||||
|
||||
const int MAX_ERROR_LOG_SIZE = 100;
|
||||
const int ERR_MAX_FILE_NAME = 255;
|
||||
const int ERR_MAX_PARA_NAME = 128;
|
||||
|
||||
const string ERR_IN_DIR_SEPARATOR = "/in/";
|
||||
const string ERR_OUT_DIR_SEPARATOR = "/out/";
|
||||
|
||||
//错误信息结构
|
||||
struct TDbErrorMsg
|
||||
{
|
||||
int err_no; //DBAccess错误号
|
||||
string dbaccess_err; //DBAccess错误信息
|
||||
string db_err; //数据库错误信息
|
||||
};
|
||||
|
||||
class PUB_TOOLS_API CErrorLog
|
||||
{
|
||||
private:
|
||||
|
||||
time_t m_LastTime;
|
||||
time_t m_CurTime;
|
||||
string m_strFileName;
|
||||
bool m_bReCreateFile;
|
||||
|
||||
int m_nFileNo;
|
||||
bool m_LogFlag;
|
||||
int m_nPid;
|
||||
string m_strPubPath;
|
||||
vector<string> m_strDbNameVec; //所有数据库服务器名
|
||||
time_t m_LastWriteFileTime; //最近一次写SQL语句文件的时间
|
||||
|
||||
public:
|
||||
|
||||
CErrorLog();
|
||||
~CErrorLog();
|
||||
int InitErrorLog();
|
||||
|
||||
int WriteErrorLog(string sql, vector<TDbErrorMsg> err_vec, const string strpath, string strDbName = "");
|
||||
|
||||
int WriteLog(vector<string> strLogVec, const string strpath);
|
||||
|
||||
int WriteLog(string strLog, const string strpath);
|
||||
|
||||
//zhangkeheng add for LOB
|
||||
int WriteErrorLog(string sql, string select_sql, vector<TDbErrorMsg> err_vec, const string strpath);
|
||||
|
||||
private:
|
||||
|
||||
int GetTimeStringByTime_t(const time_t seconds, string &value_string) const;
|
||||
|
||||
int CheckIfReCreateFile();
|
||||
|
||||
int GetPubPath();
|
||||
|
||||
string IntToStr(int nVal);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,143 +0,0 @@
|
||||
#ifndef _CFINDFILE_H_
|
||||
#define _CFINDFILE_H_
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef PUB_TOOLS_EXPORTS
|
||||
#define PUB_TOOLS_API __declspec(dllexport)
|
||||
#else
|
||||
#define PUB_TOOLS_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define PUB_TOOLS_API
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef _WINDOWS64
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <vector>
|
||||
#include <dirent.h>
|
||||
#include <time.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define MAXNAMLENGTH 256
|
||||
|
||||
#ifndef _WINDOWS64
|
||||
class CFindFile
|
||||
{
|
||||
public:
|
||||
CFindFile();
|
||||
~CFindFile();
|
||||
|
||||
private:
|
||||
///enum {MAXNAMLEN = 256};
|
||||
char m_chPath[MAXNAMLENGTH];
|
||||
char m_chName[MAXNAMLENGTH];
|
||||
|
||||
|
||||
DIR *m_pDir;
|
||||
dirent *m_pDirent;
|
||||
|
||||
bool IsSpecialType(int nType) const;
|
||||
|
||||
public:
|
||||
|
||||
char *GetFileName() ;
|
||||
|
||||
bool IsDirectory() const;
|
||||
bool IsFifo() const;
|
||||
bool IsChar() const;
|
||||
bool IsBlock() const;
|
||||
bool IsLink() const;
|
||||
bool IsSocket() const;
|
||||
bool IsNormal() const;
|
||||
|
||||
|
||||
void OwnerMode(bool &bRead,bool &bWrite,bool &bExec);
|
||||
|
||||
void GroupMode(bool &bRead,bool &bWrite,bool &bExec);
|
||||
|
||||
void OtherMode(bool &bRead,bool &bWrite,bool &bExec);
|
||||
|
||||
bool GetLastModifyTime(int &sec);
|
||||
|
||||
int chrcnt(const char *string,int letter);
|
||||
|
||||
|
||||
|
||||
public:
|
||||
bool FindFile(char *pPath);
|
||||
|
||||
int FindNext();
|
||||
|
||||
int RmOldFile(char* pPath , int cur_sec , int time_interval);
|
||||
|
||||
bool GetFindFileName(string &filename);
|
||||
|
||||
bool GetFindFileName(const string strPathName , vector<string> &filenameVec , int nFileNum);
|
||||
|
||||
bool GetCurFileName(string & filename) ;
|
||||
|
||||
int CheckPath(string strPathname);
|
||||
|
||||
bool CheckDirSizeOutOfMaxSize(string strPathName , int nMaxSize);
|
||||
|
||||
int RemoveDir(string strPathName);
|
||||
|
||||
//zhangkeheng add for REP
|
||||
bool GetFindFileNameByAlphaSort(string &filename);
|
||||
bool GetFindFileNameByAlphaSort(const string strPathName , vector<string> &filenameVec , int nFileNum);
|
||||
bool GetFindFileNameByAlphaSort1(string &filename , int & count);
|
||||
|
||||
//zhangkeheng add for 时序相关
|
||||
bool GetRep1FileCountByAlphaSort(string &filename , int & rep1_count, const int max_count);
|
||||
|
||||
//chenpeng add for 复制服务分目录
|
||||
bool GetFindDirNameByAlphaSort(const string strPathName , vector<string> &dirnameVec , int nDirNum);
|
||||
bool GetFindDirNameByAlphaSort(const string strPathName , string &dirname ,bool need_check = true);
|
||||
int GetFindFileNameByAlphaSort(const string strPathName , vector<string> &filenameVec , string &dirname,int nFileNum , bool need_check = true);
|
||||
bool GetFindDirNameByAlphaSort1(string &dirname , int & count);
|
||||
};
|
||||
#else
|
||||
|
||||
class PUB_TOOLS_API CFindFile
|
||||
{
|
||||
public:
|
||||
CFindFile();
|
||||
~CFindFile();
|
||||
public:
|
||||
int CheckPath(string strPathname);
|
||||
|
||||
//zhangkeheng add for REP
|
||||
bool GetFindFileNameByAlphaSort(string &filename);
|
||||
bool GetFindFileNameByAlphaSort(const string strPathName, vector<string> &filenameVec , int nFileNum);
|
||||
bool GetFindFileNameByAlphaSort1(string &filename , int & count);
|
||||
|
||||
//zhangkeheng add for 时序相关
|
||||
bool GetRep1FileCountByAlphaSort(string &filename , int & rep1_count, const int max_count);
|
||||
|
||||
//chenpeng add for 复制服务分目录
|
||||
bool GetFindDirNameByAlphaSort(const string strPathName , string &dirname ,bool need_check = true);
|
||||
int GetFindFileNameByAlphaSort(const string strPathName , vector<string> &filenameVec , string &dirname,int nFileNum , bool need_check = true);
|
||||
bool GetFindDirNameByAlphaSort1(string &dirname , int & count);
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
#ifndef __CPRECTIME_H
|
||||
#define __CPRECTIME_H
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef PUB_TOOLS_EXPORTS
|
||||
#define PUB_TOOLS_API __declspec(dllexport)
|
||||
#else
|
||||
#define PUB_TOOLS_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define PUB_TOOLS_API
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
class PUB_TOOLS_API CPrecTime
|
||||
{
|
||||
string m_strWork;
|
||||
public:
|
||||
CPrecTime (const string & strWork);
|
||||
|
||||
~CPrecTime();
|
||||
|
||||
public:
|
||||
int StartTime();
|
||||
|
||||
int FinishTime();
|
||||
|
||||
/************************************************************
|
||||
Description:»ñÈ¡¼ÆÊ±Ê±¼ä
|
||||
Input:
|
||||
Output:
|
||||
Input/Output:
|
||||
Others:
|
||||
************************************************************/
|
||||
float GetUsedTime();
|
||||
|
||||
private:
|
||||
#ifndef _WINDOWS64
|
||||
struct timeval m_TpStart, m_TpFinish;
|
||||
struct timezone m_TzpStart, m_TzpFinish;
|
||||
#else
|
||||
int m_StartMSec;
|
||||
int m_EndMSec;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* CRecordSet.h
|
||||
*
|
||||
* Created on: 2013-2-19
|
||||
* Author: drizzt
|
||||
*/
|
||||
|
||||
#ifndef CRECORDSET_H_
|
||||
#define CRECORDSET_H_
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "db_com/wholesqlsp.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class FieldValue
|
||||
{
|
||||
public:
|
||||
FieldValue(TResultDataValue *data_value);
|
||||
~FieldValue();
|
||||
|
||||
public:
|
||||
short DataType();
|
||||
bool isNull();
|
||||
string toString();
|
||||
int toInt();
|
||||
long toLong();
|
||||
float toFloat();
|
||||
|
||||
private:
|
||||
TResultDataValue *m_result_data;
|
||||
};
|
||||
|
||||
|
||||
class CRecordSet
|
||||
{
|
||||
public:
|
||||
CRecordSet();
|
||||
~CRecordSet();
|
||||
public:
|
||||
int GetQueryResult(char *query_sql);
|
||||
int GetRecordNum(); //获取查询结果记录个数
|
||||
int GetColumnNum(); //获取查询结果域个数
|
||||
template<class T>
|
||||
int GetQueryResult(char *query_sql, vector<T> &query_record_vec)
|
||||
{
|
||||
int record_num;
|
||||
SEQOutDataTypeStru data_type_seq;
|
||||
TSelectResultStru result_ptr;
|
||||
SEQDBErrorStru err_vec;
|
||||
VIndicator is_nulls;
|
||||
if (m_sql_sp_client->SelectSql(query_sql, QUERY_ALL_RESULT, data_type_seq, result_ptr, err_vec) != 0)
|
||||
{
|
||||
cout<<"GetRecordData SelectSql : "<<query_sql<<" 失败"<<endl;
|
||||
cout<<"错误信息 : "<<err_vec[0].error_msg<<endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
record_num = result_ptr.data_num;
|
||||
|
||||
CSqlResultAlignClient result_align;
|
||||
|
||||
query_record_vec.clear();
|
||||
query_record_vec.resize(record_num);
|
||||
if (record_num > 0)
|
||||
{
|
||||
T *struct_ptr = &query_record_vec[0];
|
||||
if(result_align.GetAlignResultClient(result_ptr.field_info, result_ptr.data_value_seq, is_nulls, struct_ptr, sizeof(T)) < 0)
|
||||
{
|
||||
cout<<"GetRecordData GetAlignResultClient 失败"<<endl;
|
||||
query_record_vec.clear();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public:
|
||||
FieldValue operator() (int row, int col);
|
||||
short GetFieldDataType(int column_num);
|
||||
private:
|
||||
sql_sp_client_base *m_sql_sp_client;
|
||||
int m_record_num;
|
||||
int m_field_num;
|
||||
SEQOutDataTypeStru m_data_type_seq;
|
||||
TSelectResultStru m_result_ptr;
|
||||
SEQDBErrorStru m_err_vec;
|
||||
};
|
||||
|
||||
|
||||
#endif /* CRECORDSET_H_ */
|
||||
@@ -1,40 +0,0 @@
|
||||
#ifndef __C_REDIS_ACCESS_H__
|
||||
#define __C_REDIS_ACCESS_H__
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#ifdef _REDIS_ACCESS
|
||||
#include "hiredis.h"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define REDIS_ACCESS_SUCCESS 1
|
||||
#define REDIS_ACCESS_FAIL -1
|
||||
|
||||
class CRedisAccess
|
||||
{
|
||||
public:
|
||||
CRedisAccess();
|
||||
int Connect(const char *ip, int port, string& err_str);
|
||||
int disConnect();
|
||||
int setString(const string &key, const string &value, string& err_str);
|
||||
int setString(const string & data, string& err_str);
|
||||
|
||||
int getString(const string & key, string & value, string& err_str);
|
||||
|
||||
int freeReply();
|
||||
bool isDisconnected();
|
||||
private:
|
||||
#ifdef _REDIS_ACCESS
|
||||
redisContext * _context;
|
||||
redisReply * _reply;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,405 +0,0 @@
|
||||
/*************************************************
|
||||
Copyright (C), 1988-1999, Nari Tech. Co., Ltd.
|
||||
File name: CRepSet.h
|
||||
Author: LH
|
||||
Version: 1.0
|
||||
Date: 2011.8.24
|
||||
Description: 复制动态库头文件
|
||||
Function List:
|
||||
1.int InitReplicateSet(void); 初始化复制动态库
|
||||
2.int ReplicateSql(const vector<string> &sqlVec); 复制sql请求至同步文件
|
||||
Datetime Action Author Modify
|
||||
-------------------------------------------------------------------
|
||||
2011.8.24 Creation LH
|
||||
|
||||
2014.03.25 add wp
|
||||
目前版本具有两套功能, 每套功能 的接口不能混用:
|
||||
1.复制sql请求至同步文件(原有功能)
|
||||
相关接口:
|
||||
int InitReplicateSet(void);
|
||||
int ReplicateSql(const vector<string> &sqlVec);
|
||||
int WriteRepSql(const vector<string> &sql_vector);
|
||||
int LogRepWrite(const string remote_db_name, const string &err_msg, int log_flag = 0);
|
||||
int MoveInFileToOutFile(string inFilePath, string outFilePath, string remote_db_name);
|
||||
int MoveFileToCommitDir(string &err_msg);
|
||||
int GetAllDbPubPath(void);
|
||||
int CheckCommitSysFile(string remote_db_name, string uncommit_file_path, vector<string> &commit_sql_vec);
|
||||
int isAutoRep(void);
|
||||
2.记录复制sql、回滚信息、回滚触发信息至同一个同步文件(新增功能) 可以多线程调用。
|
||||
调用顺序: 先调用InitReplicateSet初始化,GetRepFileName获取文件名,然后就可以调用函数写入RepSql、RollbackInfo和RollbackTri
|
||||
相关接口:
|
||||
int InitReplicateSet(int thread_id);
|
||||
int GetRepFileName(const string keyid, const string user_name,string & str_filename);
|
||||
int WriteRepSqlByFilename(const string rep_file_name, const vector<string> &sql_vector);
|
||||
int WriteRollbackInfoByFilename(const string rep_file_name, const vector<string> &sql_vector);
|
||||
int WriteRollbackTriByFilename(const string rep_file_name, const vector<string> &sql_vector);
|
||||
int WriteCommonInfoByFilename(const string rep_file_name, const vector<string> &sql_vector);
|
||||
int WriteOrigStatusByFilename(const string rep_file_name, const string &sql_string);
|
||||
int WriteModifiedStatusByFilename(const string rep_file_name, const string &sql_string);
|
||||
int MoveFileToCommitDir (vector<string> file_name_vec, string &err_msg);
|
||||
int MoveInFileToOutFileByFilename(string file_name);//WriteRepSqlByFilename调用此接口,来移动文件到out目录中
|
||||
int ReadRepSqlByFilename( const string file_name, vector<string> &str_sql_vec);
|
||||
int ReadRollbackInfoByFilename( const string file_name, vector<string> &rollback_info_vec);
|
||||
int ReadRollbackTriByFilename( const string file_name, vector<string> &rollback_tri_vec);
|
||||
int ReadCommonInfoByFilename( const string file_name, vector<string> &common_vec);
|
||||
int ReadOrigStatusByFilename( const string file_name, string &orig_string;
|
||||
int ReadModifiedStatusByFilename( const string file_name, string &modify_string);
|
||||
int GetAllDbPubPath(void);
|
||||
int GetAutoRepFlag(void);
|
||||
int CheckCommitSysFile(string remote_db_name, string uncommit_file_path, vector<string> &commit_sql_vec);
|
||||
int LogRepWrite(const string dir_name, const string &err_msg, int log_flag, int thread_id);
|
||||
int WriteByFilenameAndSeparator(const string file_name,const string dir_name, const string separator_begin, const string separator_end, const vector<string> &sql_vector);
|
||||
int isAutoRep(void);
|
||||
*************************************************/
|
||||
|
||||
#ifndef _CREPSET_H
|
||||
#define _CREPSET_H
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef DB_REP_LIB_EXPORTS
|
||||
#define DB_REP_LIB_API __declspec(dllexport)
|
||||
#else
|
||||
#define DB_REP_LIB_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define DB_REP_LIB_API
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "paramanage.h"
|
||||
#include "system.h"
|
||||
#include "db_com/wholepubtools.h"
|
||||
#include "db_com/server_define.h"
|
||||
|
||||
#define ROLLBACK_MAXLINE 8000
|
||||
|
||||
const int MAX_PARA_NAME = 64;
|
||||
const int MAX_FILE_NAME = 128;
|
||||
|
||||
const string FILE_SEPARATOR = "\n_NARI_D5000_NORMAL_SQL_\n";
|
||||
#ifndef _WINDOWS64
|
||||
const string FILE_END = "\n_FILE_END_\n";
|
||||
#else
|
||||
const string _FILE_END_ = "\n_FILE_END_\n";
|
||||
#define FILE_END _FILE_END_;
|
||||
#endif
|
||||
|
||||
const string REPSQL = "<RepSQL>";
|
||||
const string REPSQL_END = "</RepSQL>";
|
||||
const string ROLLBACKINFO = "<RollbackInfo>";
|
||||
const string ROLLBACKINFO_END = "</RollbackInfo>";
|
||||
const string ROLLBACKTRI = "<RollbackTriggedInfo>";
|
||||
const string ROLLBACKTRI_END = "</RollbackTriggedInfo>";
|
||||
const string COMMONINFO = "<CommonInfo>";
|
||||
const string COMMONINFO_END = "</CommonInfo>";
|
||||
const string ORIGINALSTATUS = "<OriginalStatus>";
|
||||
const string ORIGINALSTATUS_END = "</OriginalStatus>";
|
||||
const string MODIFIEDSTATUS = "<ModifiedStatus>";
|
||||
const string MODIFIEDSTATUS_END = "</ModifiedStatus>";
|
||||
|
||||
const string ROLLBACKSQL = "[ROLLBACKSQL]";
|
||||
const string COMMIT_DIR = "commit";
|
||||
|
||||
const string INTERFACE_ONE = "INTERFACE_ONE"; //第一套接口
|
||||
const string INTERFACE_TWO = "INTERFACE_TWO"; //第二套接口
|
||||
|
||||
const int SCAN_DIR_NUM_ONE_TIME = 60;
|
||||
const int SCAN_FILE_NUM_ONE_TIME = 36000;
|
||||
|
||||
class DB_REP_LIB_API CRepSet
|
||||
{
|
||||
public:
|
||||
CRepSet();
|
||||
~CRepSet();
|
||||
|
||||
public:
|
||||
|
||||
/* 初始化复制动态库*/
|
||||
int InitReplicateSet (void);
|
||||
|
||||
/*************************************************
|
||||
Function: InitReplicateSet(int)
|
||||
Description: 初始化复制动态库
|
||||
Calls: GetAllDbPubPath
|
||||
Input: void
|
||||
Output: void
|
||||
Return: 0:成功
|
||||
-1:失败
|
||||
*************************************************/
|
||||
int InitReplicateSet (int thread_id);
|
||||
|
||||
/*************************************************
|
||||
Function: GetRepFileName
|
||||
Description: 获取一个带本地时标的文件名(<128字符)。以便后续向此文件中写入复制内容。
|
||||
Input: str_filename: 文件名的字符数组名
|
||||
keyid: 设备keyid
|
||||
user_name: 用户名
|
||||
op_type: 操作类型MODIFY_OP_INSERT, MODIFY_OP_DELETE, MODIFY_OP_UPDATE, MODIFY_OP_DELALL
|
||||
Output: 将生成的文件名填充到输入参数str_filename中
|
||||
Return: 0:成功 -1:gettimeofday调用失败 -2: localtime_r调用失败
|
||||
*************************************************/
|
||||
int GetRepFileName (const string keyid, const string user_name, int op_type,
|
||||
string & str_filename);
|
||||
|
||||
/* sql请求复制至文件中
|
||||
* 返回值:1 成功
|
||||
* -1 失败
|
||||
* */
|
||||
int ReplicateSql (const vector<string> &sqlVec);
|
||||
|
||||
/*************************************************
|
||||
Function: WriteRepSqlByFilename
|
||||
Description: 写入复制sql至指定的rep_file_name同步文件
|
||||
Input: const vector<string> &sqlVec const string rep_file_name文件名
|
||||
Output: void
|
||||
Return: 0:成功
|
||||
-1:失败
|
||||
*************************************************/
|
||||
int WriteRepSqlByFilename (const string rep_file_name,
|
||||
const vector<string> &sql_vector);
|
||||
|
||||
/*************************************************
|
||||
Function: WriteRollbackInfoByFilename
|
||||
Description: 写入回滚信息至指定的rep_file_name同步文件
|
||||
Input: const vector<string> &sqlVec const string rep_file_name文件名
|
||||
Output: void
|
||||
Return: 0:成功
|
||||
-1:失败
|
||||
*************************************************/
|
||||
int WriteRollbackInfoByFilename (const string rep_file_name,
|
||||
const vector<string> &sql_vector);
|
||||
|
||||
/*************************************************
|
||||
Function: WriteRollbackTriByFilename
|
||||
Description: 写入回滚触发信息至指定的rep_file_name同步文件
|
||||
Input: const vector<string> &sqlVec const string rep_file_name文件名
|
||||
Output: void
|
||||
Return: 0:成功
|
||||
-1:失败
|
||||
*************************************************/
|
||||
int WriteRollbackTriByFilename (const string rep_file_name,
|
||||
const vector<string> &sql_vector);
|
||||
|
||||
/*************************************************
|
||||
Function: WriteCommonInfoByFilename
|
||||
Description: 写入回滚触发信息至指定的rep_file_name同步文件
|
||||
若为手动,则写入manual目录中
|
||||
Input: const string rep_file_name文件名
|
||||
sql_vector为写入的内容: 回滚信息
|
||||
Output: void
|
||||
Return: 0:成功
|
||||
-1:失败
|
||||
*************************************************/
|
||||
int WriteCommonInfoByFilename (const string rep_file_name,
|
||||
const vector<string> &sql_vector);
|
||||
|
||||
/*************************************************
|
||||
Function: WriteOrigStatusByFilename
|
||||
Description: 写入原始信息至指定的rep_file_name同步文件
|
||||
若为手动,则写入manual目录中
|
||||
Input: const string rep_file_name文件名
|
||||
sql_string为写入的内容: 原始信息
|
||||
Output: void
|
||||
Return: 0:成功
|
||||
-1:失败
|
||||
*************************************************/
|
||||
int WriteOrigStatusByFilename (const string rep_file_name,
|
||||
const string &sql_string);
|
||||
|
||||
/*************************************************
|
||||
Function: WriteModifiedStatusByFilename
|
||||
Description: 写入修改后的信息至指定的rep_file_name同步文件
|
||||
若为手动,则写入manual目录中
|
||||
Input: const string rep_file_name文件名
|
||||
sql_string为写入的内容: 修改后的信息
|
||||
Output: void
|
||||
Return: 0:成功
|
||||
-1:失败
|
||||
*************************************************/
|
||||
int WriteModifiedStatusByFilename (const string rep_file_name,
|
||||
const string &sql_string);
|
||||
|
||||
/*将SQL、commit.sys等类型文件转移至同步目录中
|
||||
* 返回值:1 成功
|
||||
* -1 失败
|
||||
* */
|
||||
int MoveFileToCommitDir (string &err_msg);
|
||||
int MoveFileToCommitDir (vector<string> file_name_vec, string &err_msg);
|
||||
|
||||
//将图形文件转移至图形专用目录中
|
||||
// int MoveGraphFileToCommitDir(vector<string> file_path_vec, string &err_msg);
|
||||
|
||||
/*************************************************
|
||||
Function: MoveInFileToOutFileByFilename
|
||||
Description: 根据文件名将in目录中同步文件移至out目录中. 根据FileName,移动所有远端数据名下的in文件
|
||||
移动之前,在文件中加入文件结束符,表示其文件完整性
|
||||
Input: string FileName
|
||||
Output: void
|
||||
Return: 0:成功
|
||||
-1:失败
|
||||
*************************************************/
|
||||
int MoveInFileToOutFileByFilename (string file_name);
|
||||
|
||||
/*************************************************
|
||||
Function: ReadRepSqlFromFile
|
||||
Description: 1.根据file_name,获取文件下所有sql
|
||||
|
||||
Calls:
|
||||
Input: 1.file_name
|
||||
Output: 1.vector<string> str_sql_vec
|
||||
|
||||
Return: 0:成功
|
||||
-1:失败
|
||||
*************************************************/
|
||||
int ReadRepSqlByFilename (const string file_name, vector<string> &str_sql_vec);
|
||||
|
||||
/*************************************************
|
||||
Function: ReadRollbackInfoByFilename
|
||||
Description: 1.根据全路径文件名file_name,获取文件下回滚信息
|
||||
Calls:
|
||||
Input: 1.file_name
|
||||
Output: 1.vector<string> rollback_info_vec回滚信息
|
||||
Return: 0:成功 -1:失败
|
||||
*************************************************/
|
||||
int ReadRollbackInfoByFilename (const string file_name,
|
||||
vector<string> &rollback_info_vec);
|
||||
|
||||
/*************************************************
|
||||
Function: ReadRollbackTriFromFile
|
||||
Description: 1.根据全路径文件名file_name,获取文件下回滚触发信息
|
||||
Calls:
|
||||
Input: 1.file_name
|
||||
Output: 1.vector<string> rollback_tri_vec回滚信息
|
||||
Return: 0:成功 -1:失败
|
||||
*************************************************/
|
||||
int ReadRollbackTriByFilename (const string file_name,
|
||||
vector<string> &rollback_tri_vec);
|
||||
|
||||
/*************************************************
|
||||
Function: ReadCommonInfoByFilename
|
||||
Description: 1.根据全路径文件名file_name,获取文件下回滚信息
|
||||
Input: 1.file_name
|
||||
Output: 1.vector<string> rollback_tri_vec回滚信息
|
||||
Return: 0:成功
|
||||
-1:失败
|
||||
*************************************************/
|
||||
int ReadCommonInfoByFilename (const string file_name,
|
||||
vector<string> &common_vec);
|
||||
|
||||
/*************************************************
|
||||
Function: ReadOrigStatusByFilename
|
||||
Description: 1.根据全路径文件名file_name,获取文件下原始信息
|
||||
Input: 1.file_name
|
||||
Output: 1.string orig_string原始信息
|
||||
Return: 0:成功
|
||||
-1:失败
|
||||
*************************************************/
|
||||
int ReadOrigStatusByFilename (const string file_name, string &orig_string);
|
||||
|
||||
/*************************************************
|
||||
Function: ReadModifiedStatusByFilename
|
||||
Description: 1.根据全路径文件名file_name,获取文件下修改后的信息
|
||||
Input: 1.file_name
|
||||
Output: 1.string modify_string修改后的信息
|
||||
Return: 0:成功
|
||||
-1:失败
|
||||
*************************************************/
|
||||
int ReadModifiedStatusByFilename (const string file_name,
|
||||
string &modify_string);
|
||||
|
||||
/*************************************************
|
||||
Function: isAutoRep
|
||||
Description: 获取同步方式:手动/自动
|
||||
Input: void
|
||||
Output: int
|
||||
Return: >=0:成功. =0手动.=1自动
|
||||
*************************************************/
|
||||
int isAutoRep (void);
|
||||
|
||||
private:
|
||||
bool m_isRepFlag;
|
||||
bool m_isAutoRep;
|
||||
int m_nPid;
|
||||
int m_nThreadid;
|
||||
string m_PubPath;
|
||||
string m_InterfaceIdentity; //标识是使用的哪一组功能接口:INTERFACE_ONE 还是INTERFACE_TWO. 调用InitReplicateSet时确定m_InterfaceIdentity的值
|
||||
//使用不同组的接口会报错。
|
||||
|
||||
vector<string> m_DbNameVec; //所有需要同步的数据库名
|
||||
map<string, string> m_remote_in_path_map;
|
||||
map<string, string> m_remote_out_path_map;
|
||||
map<string, string> m_remote_backup_path_map;
|
||||
map<string, string> m_remote_base_path_map;
|
||||
|
||||
private:
|
||||
|
||||
/*获取所有同步文件存放路径*/
|
||||
int GetAllDbPubPath (void);
|
||||
|
||||
/*************************************************
|
||||
Function: GetAutoRepFlag
|
||||
Description: 根据db_rep.sys文件读取是否自动[auto_replicate]is_auto_replicate=1的部分
|
||||
Calls: CFindFile::CheckPath()
|
||||
Input: void
|
||||
Output: void
|
||||
Return: 1:成功
|
||||
-1:失败
|
||||
*************************************************/
|
||||
int GetAutoRepFlag (void);
|
||||
|
||||
/*获取部分复制数据库信息*/
|
||||
int GetAllPartlyRepInfo (void);
|
||||
|
||||
int CheckCommitSysFile (string remote_db_name, string uncommit_file_path,
|
||||
vector<string> &commit_sql_vec);
|
||||
|
||||
string IntToStr (int value);
|
||||
|
||||
/*写同步文件*/
|
||||
int WriteRepSql (const vector<string> &sql_vector);
|
||||
|
||||
/*记录日志函数,默认log_flag为0,记录生成sql文件make日志*/
|
||||
int LogRepWrite (const string remote_db_name, const string &err_msg,
|
||||
int log_flag = 0);
|
||||
|
||||
/*************************************************
|
||||
Function: LogRepWrite(const string dir_name, const string &err_msg, int log_flag, int thread_id)
|
||||
Description: 记录日志函数,默认log_flag为0,记录生成sql文件make日志.
|
||||
多线程版本,将不同线程的日志写入不同的文件中
|
||||
Calls: CFindFile findfile;
|
||||
Input: const string &err_msg 写入的信息
|
||||
const string dir_name 目标目录名
|
||||
int log_flag,
|
||||
int thread_id 传入的线程号
|
||||
Output: void
|
||||
Return: 1:成功
|
||||
-1:失败
|
||||
*************************************************/
|
||||
int LogRepWrite (const string dir_name, const string &err_msg, int log_flag,
|
||||
int thread_id);
|
||||
|
||||
/*将同步文件从in 移送至out目录中*/
|
||||
int MoveInFileToOutFile (string inFilePath, string outFilePath,
|
||||
string remote_db_name);
|
||||
|
||||
/*************************************************
|
||||
Function: WriteByFilenameAndSeprator
|
||||
Description: 写入信息至指定的file_name文件
|
||||
Input: const vector<string> &sqlVec const string file_name文件名
|
||||
const string dir_name文件所在远端数据库名: 如huazhong . 当m_isAutoRep == false时,参数需要为manual
|
||||
const string separator_begin, const string separator_end 开始和结束的分隔符
|
||||
Output: void
|
||||
Return: 1:成功
|
||||
-1:失败
|
||||
*************************************************/
|
||||
int WriteByFilenameAndSeparator (const string file_name, const string dir_name,
|
||||
const string separator_begin, const string separator_end,
|
||||
const vector<string> &sql_vector);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
#ifndef __CSAVERECOMMITSQL_H_
|
||||
#define __CSAVERECOMMITSQL_H_
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef SAVE_SQL_EXPORTS
|
||||
#define SAVE_SQL_API __declspec(dllexport)
|
||||
#else
|
||||
#define SAVE_SQL_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define SAVE_SQL_API
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
const string FILE_SEPARATOR = "\n_NARI_RE_COMMIT_\n";
|
||||
const string IN_DIR_SEPARATOR = "/in/";
|
||||
const string OUT_DIR_SEPARATOR = "/out/";
|
||||
|
||||
const int MAX_FILE_NAME_LENGTH = 255;
|
||||
|
||||
const int R_HIGH_PRIOR = 1;
|
||||
const int R_MIDDLE_PRIOR = 2;
|
||||
const int R_LOW_PRIOR = 3;
|
||||
|
||||
const int NO_SQL_DUP_RE_COMMIT = 0;
|
||||
const int SQL_DUP_RE_COMMIT = 1;
|
||||
|
||||
const int RE_COMMIT_SAMPLE = 1;
|
||||
const int RE_COMMIT_SCADA = 2;
|
||||
const int RE_COMMIT_MODEL = 3;
|
||||
const int RE_COMMIT_STATICS = 4;
|
||||
|
||||
#include "db_com/wholepubtools.h"
|
||||
#include "system.h"
|
||||
#include "db_commit_m.h"
|
||||
|
||||
class SAVE_SQL_API CSaveReCommitSql
|
||||
{
|
||||
|
||||
public:
|
||||
CSaveReCommitSql();
|
||||
~CSaveReCommitSql();
|
||||
|
||||
public:
|
||||
int SaveCommitSqlToFile(const vector<string> & strCommitSqlVec , string strFileType , int nPrior , int nCommitType , int nDupType = SQL_DUP_RE_COMMIT );
|
||||
|
||||
int SaveSampleSqlToFile(const vector<string> & strCommitSqlVec , string strFileType , int nPrior , int nCommitType , int nDupType = SQL_DUP_RE_COMMIT );
|
||||
int SaveWarnSqlToFile(const vector<string> & strCommitSqlVec , string strFileType , int nPrior , int nCommitType , int nDupType = SQL_DUP_RE_COMMIT );
|
||||
int SaveModelSqlToFile(const vector<string> & strCommitSqlVec , string strFileType , int nPrior , int nCommitType , int nDupType = SQL_DUP_RE_COMMIT );
|
||||
int SaveStaticsSqlToFile(const vector<string> & strCommitSqlVec , string strFileType , int nPrior , int nCommitType , int nDupType = SQL_DUP_RE_COMMIT );
|
||||
int SaveBindStructToFile(const TCommitBindStru CommitBindStru, string strFileType , int nPrior , int nCommitType , int nDupType = SQL_DUP_RE_COMMIT );
|
||||
|
||||
private:
|
||||
int m_nFileNo;
|
||||
int m_LastSaveReCommitSqlTime;
|
||||
string m_strInPathName;
|
||||
string m_strOutPathName;
|
||||
string m_strInPathNameBind;
|
||||
string m_strOutPathNameBind;
|
||||
|
||||
int MoveInFileToOutFile(const string strInFileName);
|
||||
int GetOutFileName(const string strInFileName , string &strOutFileName);
|
||||
|
||||
private:
|
||||
int GetPathName();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
//******************************************************************
|
||||
// 商用库查询结果按结构对齐类
|
||||
//
|
||||
// Author liumengjue
|
||||
//
|
||||
// function: Sql Result Align Class
|
||||
//
|
||||
// time : 2003.05.27
|
||||
//
|
||||
//******************************************************************
|
||||
|
||||
#ifndef __CSQLRESULTALIGN_H
|
||||
#define __CSQLRESULTALIGN_H
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef ALIGN_EXPORTS
|
||||
#define ALIGN_API __declspec(dllexport)
|
||||
#else
|
||||
#define ALIGN_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define ALIGN_API
|
||||
#endif
|
||||
|
||||
#include "db_com/DBAccess.h"
|
||||
#include <assert.h>
|
||||
class ALIGN_API CSqlResultAlign
|
||||
{
|
||||
public:
|
||||
CSqlResultAlign();
|
||||
~CSqlResultAlign();
|
||||
|
||||
private:
|
||||
int m_nMaxDataTypeLength; //最大数据类型长度
|
||||
int m_nAlignLength; //按结构对齐以后的结果长度,与输入参数align_result_length作比较,检查错误
|
||||
|
||||
int GetDataTypeLength(int data_type); // 通过统一数据类型得到每种数据类型的长度
|
||||
|
||||
int GetMaxDataTypeLength(int data_type,int *m_nMaxLength);//通过统一数据类型得到最大数据类型的长度
|
||||
|
||||
int DoAlign(int* x, int b);
|
||||
public:
|
||||
|
||||
int GetAlignResult(const char* result_link_ptr,
|
||||
const TResultHead *result_head_ptr,
|
||||
const TFieldInfo *field_info_ptr,
|
||||
void* align_result_ptr,
|
||||
int struct_length); //得到按结构对齐以后的结果 返回align_result_ptr
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,71 +0,0 @@
|
||||
//******************************************************************
|
||||
// 商用库查询结果按结构对齐类 --- 用于客户端直接SQL和存储过程,通过CORBA调用
|
||||
//
|
||||
// Author liumengjue
|
||||
//
|
||||
// function: Sql Result Align Class for client, through CORBA
|
||||
//
|
||||
// time : 2003.05.27
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
// 由 ZhaoTiger 根据 刘孟觉 CSqlResultAlign.h 改写
|
||||
//
|
||||
// TIME :2003.06.24
|
||||
//******************************************************************
|
||||
|
||||
#ifndef __CSQLRESULTALIGNCLIENT_H
|
||||
#define __CSQLRESULTALIGNCLIENT_H
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef SQL_SP_CLIENT_EXPORTS
|
||||
#define SQL_SP_CLIENT_API __declspec(dllexport)
|
||||
#else
|
||||
#define SQL_SP_CLIENT_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define SQL_SP_CLIENT_API
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#include "common_types.h"
|
||||
#include "sql_sp_m.h"
|
||||
#include "system.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#if (defined _LINUX || defined _SUN || defined _WINDOWS64)
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#define ALIGN_TO_RTDBKEY 1
|
||||
|
||||
typedef vector<bool> VIndicator;
|
||||
|
||||
class SQL_SP_CLIENT_API CSqlResultAlignClient
|
||||
{
|
||||
public:
|
||||
CSqlResultAlignClient();
|
||||
~CSqlResultAlignClient();
|
||||
|
||||
private:
|
||||
int m_nMaxDataTypeLength; //最大数据类型长度
|
||||
int m_nAlignLength; //按结构对齐以后的结果长度,与输入参数align_result_length作比较,检查错误
|
||||
|
||||
int GetDataTypeLength(int data_type); // 通过统一数据类型得到每种数据类型的长度
|
||||
|
||||
int GetMaxDataTypeLength(int data_type, int *m_nMaxLength); //通过统一数据类型得到最大数据类型的长度
|
||||
|
||||
int DoAlign(int* x, int b);
|
||||
|
||||
public:
|
||||
|
||||
//int GetAlignResultClient(SEQResultFieldInfo & field_ptr, SEQResultDataValue & data_ptr, VIndicator & null_vec, void * align_result_ptr, int struct_length); //得到按结构对齐以后的结果 返回align_result_ptr
|
||||
int GetAlignResultClient(SEQResultFieldInfo & field_ptr, SEQResultDataValue & data_ptr, VIndicator & null_vec, void * align_result_ptr, int struct_length, int align_mode = 0); //新增将char[20]对齐到RTDB_KEY_STRU ( align_mode = ALIGN_TO_RTDBKEY)
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,55 +0,0 @@
|
||||
//******************************************************************
|
||||
// 商用库查询结果按结构对齐类 --- 用于客户端直接SQL和存储过程,通过CORBA调用
|
||||
//
|
||||
// Author liumengjue
|
||||
//
|
||||
// function: Sql Result Align Class for client, through CORBA
|
||||
//
|
||||
// time : 2003.05.27
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
// 由 ZhaoTiger 根据 刘孟觉 CSqlResultAlign.h 改写
|
||||
//
|
||||
// TIME :2003.06.24
|
||||
//******************************************************************
|
||||
|
||||
|
||||
#ifndef __CSQLRESULTALIGNCLIENT_H
|
||||
#define __CSQLRESULTALIGNCLIENT_H
|
||||
|
||||
#include <vector>
|
||||
#include "model_query_m.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef vector<bool> VIndicator;
|
||||
|
||||
class CSqlResultAlignClient
|
||||
{
|
||||
public:
|
||||
CSqlResultAlignClient();
|
||||
~CSqlResultAlignClient();
|
||||
|
||||
private:
|
||||
int m_nMaxDataTypeLength; //最大数据类型长度
|
||||
int m_nAlignLength; //按结构对齐以后的结果长度,与输入参数align_result_length作比较,检查错误
|
||||
|
||||
int GetDataTypeLength(int data_type); // 通过统一数据类型得到每种数据类型的长度
|
||||
|
||||
int GetMaxDataTypeLength(int data_type,int *m_nMaxLength);//通过统一数据类型得到最大数据类型的长度
|
||||
|
||||
int DoAlign(int* x, int b);
|
||||
|
||||
public:
|
||||
|
||||
int GetAlignResultClient(SEQResultFieldInfo & field_ptr,
|
||||
SEQResultDataValue & data_ptr,
|
||||
VIndicator & null_vec,
|
||||
void * align_result_ptr,
|
||||
int struct_length); //得到按结构对齐以后的结果 返回align_result_ptr
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,103 +0,0 @@
|
||||
//******************************************************************
|
||||
//
|
||||
// AUTHOR : ShiHaoQiu
|
||||
//
|
||||
// FUNCTION : 将编解码函数封装形成的动态库,可进行AES加解密、获取数据的MD5值。
|
||||
//
|
||||
// TIME : 2014.05.14
|
||||
//
|
||||
// HISTORY :
|
||||
// Datetime Action Author Reason
|
||||
// -------------------------------------------------------------------
|
||||
// 2014.05.14 Creation ShiHaoQiu
|
||||
//******************************************************************
|
||||
|
||||
#ifndef DBCIPHER_H
|
||||
#define DBCIPHER_H
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#ifdef DB_CIPHER_EXPORTS
|
||||
#define DB_CIPHER_DLL __declspec(dllexport)
|
||||
#else
|
||||
#define DB_CIPHER_DLL __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define DB_CIPHER_DLL
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class DB_CIPHER_DLL DBCipher
|
||||
{
|
||||
public:
|
||||
DBCipher(unsigned char* key);
|
||||
//key为128位的秘钥,构造时指定
|
||||
|
||||
virtual ~DBCipher();
|
||||
|
||||
//AES 加解密(加密结果通过BASE64编码)
|
||||
//最大支持对明文char[15]的加密
|
||||
unsigned char* AESCipher(unsigned char* input); //加密
|
||||
unsigned char* AESInvCipher(unsigned char* input); //解密
|
||||
void* AESCipher(void* input, int length=0);
|
||||
void* AESInvCipher(void* input, int length);
|
||||
|
||||
//MD5
|
||||
string GetMD5Value(const unsigned char* input,size_t length); //获取MD5值
|
||||
|
||||
|
||||
//BASE64 编解码函数
|
||||
/*编码
|
||||
DataByte
|
||||
[in]输入的数据长度,以字节为单位
|
||||
*/
|
||||
string Base64Encode(const unsigned char* Data,int DataByte);
|
||||
|
||||
/*解码
|
||||
DataByte
|
||||
[in]输入的数据长度,以字节为单位
|
||||
OutByte
|
||||
[out]输出的数据长度,以字节为单位,请不要通过返回值计算
|
||||
输出数据的长度
|
||||
*/
|
||||
string Base64Decode(const char* Data,int DataByte,int& OutByte);
|
||||
|
||||
private:
|
||||
//AES加解密相关成员 begin
|
||||
unsigned char Sbox[256];
|
||||
unsigned char InvSbox[256];
|
||||
unsigned char w[11][4][4];
|
||||
|
||||
void KeyExpansion(unsigned char* key, unsigned char w[][4][4]);
|
||||
unsigned char FFmul(unsigned char a, unsigned char b);
|
||||
|
||||
void SubBytes(unsigned char state[][4]);
|
||||
void ShiftRows(unsigned char state[][4]);
|
||||
void MixColumns(unsigned char state[][4]);
|
||||
void AddRoundKey(unsigned char state[][4], unsigned char k[][4]);
|
||||
|
||||
void InvSubBytes(unsigned char state[][4]);
|
||||
void InvShiftRows(unsigned char state[][4]);
|
||||
void InvMixColumns(unsigned char state[][4]);
|
||||
//AES加解密相关成员 end
|
||||
|
||||
//MD5计算相关成员 begin
|
||||
unsigned long _state[4]; /* state (ABCD) */
|
||||
unsigned long _count[2]; /* number of bits, modulo 2^64 (low-order word first) */
|
||||
unsigned char _buffer[64]; /* input buffer */
|
||||
unsigned char _digest[16]; /* message digest */
|
||||
bool _finished; /* calculate finished ? */
|
||||
|
||||
void transform(const unsigned char block[64]);
|
||||
void final();
|
||||
const unsigned char* digest();
|
||||
void encode(const unsigned long *input, unsigned char *output, size_t length);
|
||||
void decode(const unsigned char *input, unsigned long *output, size_t length);
|
||||
string bytesToHexString(const unsigned char *input, size_t length);
|
||||
void update(const unsigned char *input, size_t length);
|
||||
//MD5计算相关成员 end
|
||||
};
|
||||
|
||||
#endif // DBCIPHER_H
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* DBConnectPool.h
|
||||
*
|
||||
* Created on: 2013-6-17
|
||||
* Author: lihao
|
||||
*/
|
||||
|
||||
#ifndef DBCONNECTPOOL_H_
|
||||
#define DBCONNECTPOOL_H_
|
||||
|
||||
#include "ThreadKit/ThreadKit.h"
|
||||
#include "db_com/DBAccess.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <deque>
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct TDBConnInfo
|
||||
{
|
||||
char user_name[16];
|
||||
char passwd[16];
|
||||
char db_server_name[16];
|
||||
};
|
||||
/*
|
||||
* 工作任务类
|
||||
*/
|
||||
class ThreadTask : public THREADKIT::RefCount
|
||||
{
|
||||
public:
|
||||
ThreadTask()
|
||||
{
|
||||
m_pdbaccess = NULL;
|
||||
m_requestBuffer = NULL;
|
||||
m_requestlen = 0;
|
||||
m_responseBuffer = NULL;
|
||||
m_responselen = NULL;
|
||||
m_p_db_info= NULL;
|
||||
}
|
||||
virtual ~ThreadTask(){}
|
||||
|
||||
virtual void SetCurDBConnection(CDbAccess* pDbAccess, TDBConnInfo* last_db_info, unsigned int pid){}
|
||||
// {
|
||||
// m_pdbaccess = pDbAccess;
|
||||
// m_pid = pid;
|
||||
// }
|
||||
virtual void ProcessOneTask(){}
|
||||
|
||||
virtual void Wait(){}
|
||||
protected:
|
||||
virtual void Signal(){}
|
||||
protected:
|
||||
CDbAccess *m_pdbaccess;
|
||||
char *m_requestBuffer;
|
||||
int m_requestlen;
|
||||
char **m_responseBuffer;
|
||||
int *m_responselen;
|
||||
unsigned int m_pid;
|
||||
bool m_can_start, m_is_stopped;
|
||||
TDBConnInfo* m_p_db_info;
|
||||
string err_msg;
|
||||
};
|
||||
|
||||
typedef THREADKIT::Handle<ThreadTask> ThreadTaskHandle;
|
||||
|
||||
class DBConnectThread; // 单个线程类
|
||||
class DBConnectPoolImpl; // 线程池实体类
|
||||
|
||||
//
|
||||
class DBConnectPool
|
||||
{
|
||||
public:
|
||||
/*
|
||||
* 创建一个包含threadPoolNum个线程的线程池
|
||||
*/
|
||||
DBConnectPool(unsigned int threadPoolNum);
|
||||
virtual ~DBConnectPool();
|
||||
|
||||
//int initAllConnect(const char* user_name, const char* passwd, const char* db_service_name, string &err_msg);
|
||||
|
||||
// 启动所有线程工作
|
||||
int start(string &err_msg);
|
||||
|
||||
//获取线程池中当前线程个数
|
||||
unsigned int getThreadCount();
|
||||
|
||||
//停止所有线程
|
||||
void stop();
|
||||
|
||||
//等待所有工作队列任务都完成
|
||||
bool wait();
|
||||
|
||||
//msec时间内,等待所有工作队列任务都完成
|
||||
//如果所有任务都完成,则返回true
|
||||
bool waitTimeout(unsigned long msec);
|
||||
|
||||
//在线程池中加入一个工作任务
|
||||
void postWork(ThreadTaskHandle task);
|
||||
|
||||
//处理线程中的异常
|
||||
virtual void uncaughtException(THREADKIT::Thread* t);
|
||||
|
||||
virtual void uncaughtException(THREADKIT::Thread* t, const THREADKIT::Exception &e);
|
||||
private:
|
||||
friend class DBConnectThread;
|
||||
int m_can_start; //
|
||||
ThreadTaskHandle waitForTask(); //获取队列头部任务
|
||||
void finishThisWork();
|
||||
DBConnectPoolImpl* m_pool_impl;
|
||||
DECLARE_NO_ASSIGN_CLASS(DBConnectPool)
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* DBCONNECTPOOL_H_ */
|
||||
@@ -1,154 +0,0 @@
|
||||
/*
|
||||
* CDbFileNetIf.h
|
||||
*
|
||||
* Created on: 2012-8-1
|
||||
* Author: ThinkPad
|
||||
*/
|
||||
|
||||
#ifndef CDBFILENETIF_H_
|
||||
#define CDBFILENETIF_H_
|
||||
|
||||
#ifdef _WIN64
|
||||
# ifdef NET_IF_EXPORTS
|
||||
# define NET_IF_API __declspec(dllexport)
|
||||
# else
|
||||
# define NET_IF_API __declspec(dllimport)
|
||||
# endif
|
||||
# pragma warning(disable : 4251)
|
||||
#else
|
||||
# define NET_IF_API
|
||||
#endif
|
||||
|
||||
#include "db_com/DBAccess.h"
|
||||
|
||||
/**
|
||||
@brief 文件名信息数据
|
||||
*/
|
||||
struct FileNameData{
|
||||
union{
|
||||
long idx;
|
||||
long keyWord;
|
||||
};
|
||||
///文件名
|
||||
char name[128];
|
||||
///文件子类型
|
||||
long idxFileSubType;
|
||||
///版本号
|
||||
int iVersion;
|
||||
///文件大小
|
||||
int iSize;
|
||||
///文件修改时刻
|
||||
long tmModify;
|
||||
///加锁状态
|
||||
bool isLocked;
|
||||
///当前用户索引号
|
||||
long idxUserName;
|
||||
///加锁的应用类型
|
||||
long idxAppType;
|
||||
///加锁结点
|
||||
long idxLockNode;
|
||||
///加锁时刻
|
||||
long tmLock;
|
||||
///所属厂站 =NS::NOEXIST表示全部厂站
|
||||
long idxFactoryName;
|
||||
|
||||
FileNameData(){ SetDefaultData(); }
|
||||
|
||||
void SetDefaultData(){
|
||||
memset(this, 0, sizeof(*this));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// 查询时需要用到的结果指针结构
|
||||
struct TQueryResultPtr
|
||||
{
|
||||
char *result_link_ptr;
|
||||
char *result_data_ptr;
|
||||
short *result_indicator_ptr;
|
||||
TResultHead *result_head_ptr;
|
||||
TFieldInfo *field_info_ptr;
|
||||
};
|
||||
|
||||
// 查询包含LOB字段的SQL时需要用到的结果指针结构
|
||||
struct TLOBQueryResultPtr
|
||||
{
|
||||
char *result_link_ptr;
|
||||
char *result_data_ptr;
|
||||
short *result_indicator_ptr;
|
||||
TLOBResultHead *result_head_ptr;
|
||||
TLOBFieldInfo *field_info_ptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class NET_IF_API CDbFileNetIf //: public CDbFileIf
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@brief 构造函数
|
||||
*/
|
||||
CDbFileNetIf();
|
||||
|
||||
///析构函数
|
||||
~CDbFileNetIf();
|
||||
|
||||
public:
|
||||
/**
|
||||
@brief 单个文件读取, 读文件(包括文件头信息), 返回文件的实际大小
|
||||
@param fileIdx 文件记录索引号
|
||||
@param pFileNameData1 文件头指针
|
||||
@param pReadBuf1 读取缓冲区,此参数必需为空时,接口自动分配内存,由调用方使用free释放
|
||||
@param len1 缓冲区大小
|
||||
@retval 成功返回NS::RETURN_OK,否则返回<0
|
||||
*/
|
||||
int Read( const long fileIdx, FileNameData *pFileNameData1,
|
||||
char* &pReadBuf, int &file_len, int mode = 0);
|
||||
|
||||
|
||||
/**
|
||||
@brief 更新文件信息,文件版本号自动加1,如果文件不存在自动创建
|
||||
@param FileNameData stFileNameData 文件头
|
||||
@param pWriteBuf1 文件内容指针
|
||||
@retval 成功返回NS::RETURN_OK,否则返回<0
|
||||
*/
|
||||
int Update( FileNameData &stFileNameData, const char* pWriteBuf, int mode = 0);
|
||||
|
||||
|
||||
/**
|
||||
@brief 删除单个文件信息
|
||||
@param idFile1 文件信息记录索引
|
||||
@retval 成功返回NS::RETURN_OK,否则返回<0
|
||||
*/
|
||||
int DeleteSingleFile( const long fileIdx, int mode = 0);
|
||||
|
||||
/**
|
||||
@brief 锁定文件信息
|
||||
@param strUserName1 使用者名称
|
||||
@param idHostNode1 节点号
|
||||
@retval 成功返回NS::RETURN_OK,否则返回<0
|
||||
*/
|
||||
// INT32 Lock(const INT32 idFile1, const INT32 idUser1, const INT32 idHostNode1,INT32 mode = 0);
|
||||
|
||||
/**
|
||||
@brief 解锁文件信息
|
||||
@param strUserName11 使用者名称
|
||||
@param idHostNode1 节点号
|
||||
@param operMachineType1 操作机器类型,缺省为本地优先
|
||||
@retval 成功返回NS::RETURN_OK,否则返回<0
|
||||
*/
|
||||
// INT32 Unlock(const INT32 idFile1, const INT32 idUser1, const INT32 idHostNode1,INT32 mode = 0);
|
||||
|
||||
private:
|
||||
CDbAccess m_db_access;
|
||||
|
||||
private:
|
||||
void NewQueryResultPtr(TQueryResultPtr &query_result_ptr_stru);
|
||||
void DeleteQueryResultPtr(TQueryResultPtr & query_result_ptr_stru);
|
||||
|
||||
void NewLOBQueryResultPtr(TLOBQueryResultPtr & query_result_ptr_stru);
|
||||
void DeleteLOBQueryResultPtr(TLOBQueryResultPtr & query_result_ptr_stru);
|
||||
};
|
||||
|
||||
|
||||
#endif /* CDBFILENETIF_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user