当前位置:网站首页>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
- Detectron: train your own data set -- convert your own data format to coco format
- leetcode 310. Minimum Height Trees
- Realize IIC data / instruction interaction with micro batg135
- Overview of convolutional neural network structure optimization
- C # symmetric encryption (AES encryption) ciphertext results generated each time, different ideas, code sharing
- Learn about the Internet of things protocol WiFi ZigBee Bluetooth, etc. --- WiFi and WiFi protocols start from WiFi. What do we need to know about WiFi protocol itself?
- tars源码分析之6
- After the festival, a large number of people change careers. Is it still time to be 30? Listen to the experience of the past people
- Tsinghua University product: penalty gradient norm improves generalization of deep learning model
猜你喜欢

MySQL installation and configuration

C实现贪吃蛇小游戏

what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
![[March 3, 2019] MAC starts redis](/img/ff/88638fcdc8d24dc268781c224e8195.jpg)
[March 3, 2019] MAC starts redis

Uniapp custom environment variables

Learn about the Internet of things protocol WiFi ZigBee Bluetooth, etc. --- WiFi and WiFi protocols start from WiFi. What do we need to know about WiFi protocol itself?

2022 Xinjiang's latest eight members (Safety Officer) simulated examination questions and answers

Variables d'environnement personnalisées uniapp

云原生——上云必读之SSH篇(常用于远程登录云服务器)

C實現貪吃蛇小遊戲
随机推荐
ABAP:OOALV实现增删改查功能
Invalid bound statement (not found): com. example. mapper. TblUserRecordMapper. login
Background and current situation of domestic CDN acceleration
7. Agency mode
How to help others effectively
Realize IIC data / instruction interaction with micro batg135
Download kicad on Alibaba cloud image station
Operator < <> > fool test case
2022.7.2-----leetcode.871
The solution of win11 taskbar right click without Task Manager - add win11 taskbar right click function
Common JS tool Libraries
C language exercises (recursion)
Layoutmanager layout manager: flowlayout, borderlayout, GridLayout, gridbaglayout, CardLayout, BoxLayout
树形dp
[MySQL] introduction, function, creation, view, deletion and modification of database view (with exercises)
InputStream/OutputStream(文件的输入输出)
2022年,或许是未来10年经济最好的一年,2022年你毕业了吗?毕业后是怎么计划的?
Mysql 45讲学习笔记(七)行锁
如何实现视频平台会员多账号登录
List of top ten professional skills required for data science work