当前位置:网站首页>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;
}
}
边栏推荐
- QT qtablewidget table column top requirements ideas and codes
- Native Cloud - SSH articles must be read on Cloud (used for Remote Login to Cloud Server)
- [Android reverse] function interception (CPU cache mechanism | CPU cache mechanism causes function interception failure)
- Arcpy uses the updatelayer function to change the symbol system of the layer
- C语言中的排序,实现从小到大的数字排序法
- Uniapp custom environment variables
- Tf/pytorch/cafe-cv/nlp/ audio - practical demonstration of full ecosystem CPU deployment - Intel openvino tool suite course summary (Part 2)
- 采用中微BATG135实现IIC数据/指令交互
- Inputstream/outputstream (input and output of file)
- Learning multi-level structural information for small organ segmentation
猜你喜欢
Weekly summary (*63): about positive energy
Learning multi-level structural information for small organ segmentation
High performance parallel programming and optimization | lesson 02 homework at home
双色球案例
Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane
C language - Blue Bridge Cup - Snake filling
Reading notes of Clickhouse principle analysis and Application Practice (4)
746. Climb stairs with minimum cost
测试岗的中年危机该如何选择?是坚守还是另寻出路?且看下文
云原生——上云必读之SSH篇(常用于远程登录云服务器)
随机推荐
Matlab remainder
ES6 模块化
Reading notes of Clickhouse principle analysis and Application Practice (4)
ABCD four sequential execution methods, extended application
QT qtablewidget table column top requirements ideas and codes
What is Gibson's law?
Sleep quality today 78 points
Weekly summary (*63): about positive energy
Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
C语言中的函数(详解)
Detectron: train your own data set -- convert your own data format to coco format
C # symmetric encryption (AES encryption) ciphertext results generated each time, different ideas, code sharing
运算符<< >>傻瓜式测试用例
70000 words of detailed explanation of the whole process of pad openvino [CPU] - from environment configuration to model deployment
[number theory] fast power (Euler power)
Modify TCP timestamp to optimize transmission performance
Arcpy 利用updatelayer函数改变图层的符号系统
AWT introduction
How to realize multi account login of video platform members
Summary of leetcode BFS question brushing