当前位置:网站首页>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;
}
}
边栏推荐
- Distributed cap theory
- Option (024) - do all objects have prototypes?
- Displaying currency in Indian numbering format
- Reading notes of Clickhouse principle analysis and Application Practice (4)
- C realize Snake games
- 2022 wechat enterprise mailbox login entry introduction, how to open and register enterprise wechat enterprise mailbox?
- Vant --- detailed explanation and use of list component in vant
- MySQL information_ Schema database
- Another company raised the price of SAIC Roewe new energy products from March 1
- 《ClickHouse原理解析与应用实践》读书笔记(4)
猜你喜欢

Distributed cap theory

27-31. Dependency transitivity, principle

Layoutmanager layout manager: flowlayout, borderlayout, GridLayout, gridbaglayout, CardLayout, BoxLayout

List of top ten professional skills required for data science work

C réaliser des jeux de serpents gourmands
![[Android reverse] function interception (CPU cache mechanism | CPU cache mechanism causes function interception failure)](/img/7e/02bb01480257cd56537914a7247733.jpg)
[Android reverse] function interception (CPU cache mechanism | CPU cache mechanism causes function interception failure)

How to realize multi account login of video platform members

Uniapp custom environment variables

【无标题】

分布式CAP理论
随机推荐
P26-P34 third_ template
C language exercises (recursion)
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
thread priority
测试岗的中年危机该如何选择?是坚守还是另寻出路?且看下文
Background and current situation of domestic CDN acceleration
C # symmetric encryption (AES encryption) ciphertext results generated each time, different ideas, code sharing
Tree DP
Inputstream/outputstream (input and output of file)
【无标题】
C实现贪吃蛇小游戏
STC8H开发(十二): I2C驱动AT24C08,AT24C32系列EEPROM存储
Practical gadget instructions
Vant --- detailed explanation and use of list component in vant
The sorting in C language realizes the number sorting method from small to large
Arcpy uses the updatelayer function to change the symbol system of the layer
What is tweeman's law?
ORICO ORICO outdoor power experience, lightweight and portable, the most convenient office charging station
Another company raised the price of SAIC Roewe new energy products from March 1
2022.7.2-----leetcode.871