当前位置:网站首页>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;
}
}
边栏推荐
- P26-P34 third_ template
- Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
- Variables d'environnement personnalisées uniapp
- Reading notes of Clickhouse principle analysis and Application Practice (4)
- What is the sheji principle?
- 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?
- Is the insurance annuity product worth buying? Is there a hole?
- How to choose the middle-aged crisis of the testing post? Stick to it or find another way out? See below
- 198. House raiding
- tars源码分析之8
猜你喜欢

C language - Blue Bridge Cup - Snake filling

ABAP:OOALV实现增删改查功能

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

C # symmetric encryption (AES encryption) ciphertext results generated each time, different ideas, code sharing

Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane

QT QTableWidget 表格列置顶需求的思路和代码

Download kicad on Alibaba cloud image station

uniapp 自定義環境變量

C realize Snake games

2022 where to find enterprise e-mail and which is the security of enterprise e-mail system?
随机推荐
金盾视频播放器拦截的软件关键词和进程信息
树形dp
[untitled]
C language - Blue Bridge Cup - Snake filling
tars源码分析之4
4G wireless all network solar hydrological equipment power monitoring system bms110
Common usage of time library
Mysql 45讲学习笔记(十二)MySQL会“抖”一下
What is Gibson's law?
thread priority
ORICO ORICO outdoor power experience, lightweight and portable, the most convenient office charging station
2022.7.2-----leetcode.871
云原生——上云必读之SSH篇(常用于远程登录云服务器)
【问题记录】03 连接MySQL数据库提示:1040 Too many connections
Mysql 45讲学习笔记(六)全局锁
leetcode 310. Minimum Height Trees
2022年,或許是未來10年經濟最好的一年,2022年你畢業了嗎?畢業後是怎麼計劃的?
How to use multithreading to export excel under massive data? Source code attached!
Average two numbers
Tree DP