当前位置:网站首页>Tar source code analysis 9
Tar source code analysis 9
2022-07-04 06:37:00 【Tao song remains the same】
How to define classes in dynamic runtime , It's also very intuitive :
#include "util/tc_dyn_object.h"
#include <string.h>
namespace tars
{
/**********************************TC_DYN_RuntimeClass Definition ***********************************/
TC_DYN_RuntimeClass* TC_DYN_RuntimeClass::pFirstClass = NULL;
TC_DYN_Object* TC_DYN_RuntimeClass::createObject()
{
if (m_pfnCreateObject == NULL)
{
return NULL;
}
TC_DYN_Object* pObject = (*m_pfnCreateObject)();
{
return pObject;
}
}
TC_DYN_RuntimeClass* TC_DYN_RuntimeClass::load(const char *szClassName)
{
TC_DYN_RuntimeClass* pClass;
for (pClass = pFirstClass; pClass != NULL; pClass = pClass->m_pNextClass)
{
if (strcmp(szClassName, pClass->m_lpszClassName) == 0)
return pClass;
}
return NULL;
}
/**********************************szTC_DYN_Object Definition ***********************************/
TC_DYN_RuntimeClass TC_DYN_Object::classTC_DYN_Object =
{
(char*)"TC_DYN_Object",
sizeof(TC_DYN_Object),
NULL,
NULL,
NULL
};
static TC_DYN_Init _init_TC_DYN_Object(&TC_DYN_Object::classTC_DYN_Object);
TC_DYN_RuntimeClass* TC_DYN_Object::GetRuntimeClass() const
{
return &TC_DYN_Object::classTC_DYN_Object;
}
bool TC_DYN_Object::isKindOf(const TC_DYN_RuntimeClass* pClass) const
{
TC_DYN_RuntimeClass* pClassThis = GetRuntimeClass();
while (pClassThis != NULL)
{
if (pClassThis == pClass)
{
return true;
}
pClassThis = pClassThis->m_pBaseClass;
}
return false;
}
}
边栏推荐
- Learning multi-level structural information for small organ segmentation
- 双色球案例
- Mysql 45讲学习笔记(十三)表数据删掉一半,表文件大小不变
- List of top ten professional skills required for data science work
- tars源码分析之2
- Notes and notes
- Matlab remainder
- Mysql 45讲学习笔记(十二)MySQL会“抖”一下
- Background and current situation of domestic CDN acceleration
- 2022.7.2-----leetcode. eight hundred and seventy-one
猜你喜欢
C language - Blue Bridge Cup - Snake filling
AWT introduction
Which water in the environment needs water quality monitoring
Cloud native - SSH article that must be read on the cloud (commonly used for remote login to ECS)
2022 where to find enterprise e-mail and which is the security of enterprise e-mail system?
Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane
《ClickHouse原理解析与应用实践》读书笔记(4)
MySQL learning notes 3 - JDBC
The solution of win11 taskbar right click without Task Manager - add win11 taskbar right click function
[Android reverse] function interception (CPU cache mechanism | CPU cache mechanism causes function interception failure)
随机推荐
Reading notes of Clickhouse principle analysis and Application Practice (4)
《国民经济行业分类GB/T 4754—2017》官网下载地址
4G wireless all network solar hydrological equipment power monitoring system bms110
Json Web token - jwt vs. Traditional session login Authentication
STC8H开发(十二): I2C驱动AT24C08,AT24C32系列EEPROM存储
The sorting in C language realizes the number sorting method from small to large
Code rant: from hard coding to configurable, rule engine, low code DSL complexity clock
C realize Snake games
tars源码分析之7
How to implement cross domain requests
Explain in one sentence what social proof is
Layoutmanager layout manager: flowlayout, borderlayout, GridLayout, gridbaglayout, CardLayout, BoxLayout
2022 Xinjiang's latest eight members (Safety Officer) simulated examination questions and answers
[March 3, 2019] MAC starts redis
Mysql 45讲学习笔记(七)行锁
InputStream/OutputStream(文件的输入输出)
Data analysis notes 09
Operator < <> > fool test case
thread priority
746. Climb stairs with minimum cost