当前位置:网站首页>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;
}
}
边栏推荐
- 分布式CAP理论
- 198. House raiding
- Wechat applet scroll view component scrollable view area
- Tsinghua University product: penalty gradient norm improves generalization of deep learning model
- ADC voltage calculation of STM32 single chip microcomputer
- Another company raised the price of SAIC Roewe new energy products from March 1
- 17-18. Dependency scope and life cycle plug-ins
- Layoutmanager layout manager: flowlayout, borderlayout, GridLayout, gridbaglayout, CardLayout, BoxLayout
- C实现贪吃蛇小游戏
- Download kicad on Alibaba cloud image station
猜你喜欢
Functions in C language (detailed explanation)
Detectron: train your own data set -- convert your own data format to coco format
GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式
ABAP:OOALV实现增删改查功能
Notes and notes
树形dp
R统计绘图-随机森林分类分析及物种丰度差异检验组合图
[number theory] fast power (Euler power)
leetcode 310. Minimum Height Trees
Uniapp custom environment variables
随机推荐
Average two numbers
What is a spotlight effect?
2022.7.3-----leetcode.556
Mysql 45讲学习笔记(十二)MySQL会“抖”一下
内卷怎么破?
雲原生——上雲必讀之SSH篇(常用於遠程登錄雲服務器)
Shopping malls, storerooms, flat display, user-defined maps can also be played like this!
Arcpy 利用updatelayer函数改变图层的符号系统
ORICO ORICO outdoor power experience, lightweight and portable, the most convenient office charging station
Bicolor case
Download kicad on Alibaba cloud image station
uniapp 自定义环境变量
JSON Web Token----JWT和傳統session登錄認證對比
Distributed cap theory
What is the "relative dilemma" in cognitive fallacy?
SQL join, left join, right join usage
Invalid bound statement (not found): com. example. mapper. TblUserRecordMapper. login
Operator < <> > fool test case
金盾视频播放器拦截的软件关键词和进程信息
1、 Relevant theories and tools of network security penetration testing