客户端码表管理实现


1.码表管理支持
common下新增文件:
.base_code_table.h:定义码表元素和码表资源名称
.code_table_mgr.h:码表管理器模板定义
template <class T,class Key> class CCodeTableMgr : public ICodeTableMgr<T,Key> {
    CAutoVector<T*> data_;
.i_code_table_mgr.h:码表管理器接口定义;
template <class T,class Key=int> class ICodeTableMgr {
public:
    ///< 增加一个对象
    virtual int Add(T* obj) = 0;
    ///< 获取对象总数
    virtual unsigned int GetSize() const = 0;
    ///< 获取指定索引的对象
    virtual T* operator[](unsigned int index) = 0;
    ///< 根据Key查找对象
    virtual T* Find(Key key) = 0;
    ///< 删除指定Key的对象
    virtual void Remove(Key key) = 0;
};    


2.实现
const char CODE_TABLE_DB[] = "CodeTable.db"; ///< 码表数据库名称
class CGDSNSup_Plugin {
    int Prepare();
private:
    ///< 码表管理器
    CCodeTableMgr<CTaxRate> tax_rate_code_table_mgr_;
    CCodeTableMgr<CSaleUnit> sale_unit_code_table_mgr_;
    CCodeTableMgr<CCountry> country_code_table_mgr_;
    CCodeTableMgr<CGpc> gpc_code_table_mgr_;

    ///< 初始化码表数据(仅用于测试数据准备)
    int init_code_table(); ///< 每个表的建表操作,表初始数据写入

    ///< 加载码表
    int LoadTaxRate();
    int LoadSaleUnit();
    int LoadCountry();
    int LoadGPC();
};


///< 共享码表资源
int CGDSNSup_Plugin::Prepare() {
    parent::Prepare();
    CPluginHelper::ShareResource(&tax_rate_code_table_mgr_,TAXRATE_CODETABLE_MGR,this);
    CPluginHelper::ShareResource(&sale_unit_code_table_mgr_,SALEUNIT_CODETABLE_MGR,this);
    CPluginHelper::ShareResource(&country_code_table_mgr_,COUNTRY_CODETABLE_MGR,this);
    CPluginHelper::ShareResource(&gpc_code_table_mgr_,GPC_CODETABLE,this);

    return 0;
}


3.使用
如需要在TForm或者其它插件中访问税率码表,获取接口然后使用接口方法.
   ICodeTableMgr<CTaxRate> *mgr = (ICodeTableMgr*)CPluginHelper::GetResource(TAXRATE_CODETABLE_MGR);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值