当前位置:网站首页>tars源码分析之9
tars源码分析之9
2022-07-04 06:33:00 【涛歌依旧】
动态运行时的类怎么定义,也很直观了:
#include "util/tc_dyn_object.h"
#include <string.h>
namespace tars
{
/**********************************TC_DYN_RuntimeClass定义***********************************/
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定义***********************************/
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;
}
}
边栏推荐
- [openvino+paddle] paddle detection / OCR / SEG export based on paddle2onnx
- AWT introduction
- What is the sheji principle?
- Appium foundation - appium installation (II)
- What is a spotlight effect?
- C # symmetric encryption (AES encryption) ciphertext results generated each time, different ideas, code sharing
- Abap:ooalv realizes the function of adding, deleting, modifying and checking
- 70000 words of detailed explanation of the whole process of pad openvino [CPU] - from environment configuration to model deployment
- [Chongqing Guangdong education] electronic circuit homework question bank of RTVU secondary school
- 《ClickHouse原理解析与应用实践》读书笔记(4)
猜你喜欢

树形dp

C实现贪吃蛇小游戏

C language - Blue Bridge Cup - Snake filling

How does apscheduler set tasks not to be concurrent (that is, execute the next task after the first one)?

如何避免 JVM 内存泄漏?
![[number theory] fast power (Euler power)](/img/1e/5d032c8f2e43f553b4543d28ea2a2d.jpg)
[number theory] fast power (Euler power)

Appium基础 — APPium安装(二)

Distributed cap theory

【MySQL】数据库视图的介绍、作用、创建、查看、删除和修改(附练习题)

颈椎、脚气
随机推荐
Average two numbers
如何避免 JVM 内存泄漏?
Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
[March 3, 2019] MAC starts redis
[untitled]
[backpack DP] backpack problem
Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane
Learning multi-level structural information for small organ segmentation
STM32 单片机ADC 电压计算
如何实现视频平台会员多账号登录
A little understanding of GSLB (global server load balance) technology
17-18. Dependency scope and life cycle plug-ins
MySQL installation and configuration
ABCD four sequential execution methods, extended application
对List进行排序工具类,可以对字符串排序
Uniapp custom environment variables
7. Agency mode
Abap:ooalv realizes the function of adding, deleting, modifying and checking
Arcpy uses the updatelayer function to change the symbol system of the layer
[openvino+paddle] paddle detection / OCR / SEG export based on paddle2onnx