mirror of
https://github.com/HEYAHONG/HCppBox.git
synced 2025-05-12 09:54:58 +08:00
50 lines
1.5 KiB
C++
50 lines
1.5 KiB
C++
#ifndef __HCPPOBJECTPOOL_H__
|
||
#define __HCPPOBJECTPOOL_H__
|
||
#ifdef __cplusplus
|
||
#include "HCPPObject.h"
|
||
#include <string>
|
||
#include <vector>
|
||
#include <functional>
|
||
|
||
/** \brief 将HCPPObject对象指针放入对象池
|
||
*
|
||
* \param id std::string id标识,必须具有唯一性(由用户自行确保)
|
||
* \param obj HCPPObject* HCPPObject对象指针
|
||
*
|
||
*/
|
||
void HCPPObjectPool_Set(std::string id,HCPPObject *obj);
|
||
|
||
/** \brief 从对象池获取HCPPObject对象指针
|
||
*
|
||
* \param id std::string id标识,必须具有唯一性(由用户自行确保)
|
||
* \return HCPPObject* HCPPObject对象指针
|
||
*
|
||
*/
|
||
HCPPObject *HCPPObjectPool_Get(std::string id);
|
||
|
||
/** \brief id子字符串列表转化为id字符串,将忽略空id子字符串。
|
||
*
|
||
* \param id_List std::vector<std::string> id子字符串列表
|
||
* \return std::string id字符串(用.连接)
|
||
*
|
||
*/
|
||
std::string HCPPObjectPool_Id_Helper(std::vector<std::string> id_list);
|
||
|
||
/** \brief id字符串转化为id子字符串列表
|
||
*
|
||
* \param id std::string id字符串
|
||
* \return std::vector<std::string> id子字符串列表(用.分割)
|
||
*
|
||
*/
|
||
std::vector<std::string> HCPPObjectPool_Id_Helper(std::string id);
|
||
|
||
/** \brief 对象池枚举
|
||
*
|
||
* \param on_enum std::function<void(std::string,HCPPObject *)>,枚举回调,第一个参数为id字符串,第二个参数为HCPPObject对象指针
|
||
*
|
||
*/
|
||
void HCPPObjectPool_Enum(std::function<void(std::string,HCPPObject *)> on_enum);
|
||
|
||
#endif // __cplusplus
|
||
#endif // CPPOBJECTPOOL_H
|