Template:CD: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
<onlyinclude>{| class="wikitable" align="right" style="clear:right; margin-left:2em"
<onlyinclude>{| class="wikitable" align="right" style="clear:right; margin-left:2em"
|-
|-
!{{cpp}} [[{{#switch: {{language}}
!{{cpp}} [[Class hierarchy {{#if:{{{goldsrc|}}}|(GoldSrc)}}{{!}}{{#switch: {{language}}
| #default = Class hierarchy {{#if:{{{goldsrc|}}}|(GoldSrc)}}{{!}}Class hierarchy
| #default = Class hierarchy
| zh = Class hierarchy {{#if:{{{goldsrc|}}}|(GoldSrc)}}{{!}}类层级
| zh = 类层级
}}]]
}}]]
{{#if:{{{game|}}}|{{!}}-
{{#if:{{{game|}}}
!{{{game|}}}}}
| {{!}}-
<!-- -->!{{{game}}}
}}
|-
|-
|[[{{{1|???}}} {{#if:{{{goldsrc|}}}|(GoldSrc){{!}}{{{1|???}}}}}]]  
|[[{{{1|???}}} {{#if:{{{goldsrc|}}}|(GoldSrc){{!}}{{{1|???}}}}}]]  
{{:Category:CD {{#if:{{{base|}}}|{{{base}}}|{{CD/superclass{{#if:{{{goldsrc|}}}|/hl}}|{{{1|???}}}}}}} {{#if:{{{goldsrc|}}}|(GoldSrc)}}|:}}<!--
{{:Category:CD {{#if:{{{base|}}}
-->{{#ifeq: {{{1|???}}} | ??? |[[Category:Unknown Classname]]|}}
| {{{base}}}
|-
| {{CD/superclass{{#if:{{{goldsrc|}}}|/hl}}|{{{1|???}}}}}}} {{#if:{{{goldsrc|}}}|(GoldSrc)}}|:}}
{{#if: {{{file1|}}} <!--
{{#if: {{{nolink|}}}
-->  | {{!}}-
| <!-- file1 is dumb param name and at this point it stays just for backwards compatibility -->
!<small>{{cpp}}<code><i>{{#if: {{{nolink|}}}|{{{file1}}}|{{CD/classlink|{{{1|???}}}|{{{file1}}}}}}}</i></code></small> <!--
| {{#if: {{{file1|}}}{{{goldsrc|}}}
-->  | {{#if:{{{goldsrc|}}}
| {{!}}-
        | {{!}}-
<!-- -->!<small>{{cpp}}<code><i>{{#if:{{{goldsrc|}}}
!<small>{{cpp}}<code><i>{{#if: {{{nolink|}}}|{{{goldsrc}}}|{{CD/classlink/hl|{{{1|???}}}|{{{goldsrc}}}}}}}</i></code></small>}} }}
| {{CD/classlink/hl|{{{1|???}}}|{{{goldsrc}}}}}
|}{{#if:{{NAMESPACE}}||{{#ifeq:{{pagelang}}|en|[[Category:CD {{{base|{{CD/superclass{{#if:{{{goldsrc|}}}|/hl}}|{{{1|???}}}}}}}} {{#if:{{{goldsrc|}}}|(GoldSrc)}}|{{SUBPAGENAME}}]]}}}}</onlyinclude>
| {{CD/classlink|{{{1|???}}}|{{{file1}}}}}
}}</i></code></small>
}}
}}{{#if:{{{files|}}}
| {{#if: {{{file1|}}}{{{goldsrc|}}}
|<nowiki>
</nowiki><small><code><i>{{{files}}}</i></code></small>
| {{!}}-
!<small>{{cpp}}<code><i>{{{files}}}</i></code></small>
}}
}}
|}{{#if:{{NAMESPACE}}
|  
| {{#ifeq:{{pagelang}}|en
| [[Category:CD {{{base|{{CD/superclass{{#if:{{{goldsrc|}}}|/hl}}|{{{1|???}}}}}}}} {{#if:{{{goldsrc|}}}|(GoldSrc)}}|{{SUBPAGENAME}}]]
}}
}}{{#ifeq: {{{1|???}}} | ??? |[[Category:Unknown Classname]]}}</onlyinclude>


</includeonly>
</includeonly>


[[Category:CD template]]
[[Category:CD template]]

Revision as of 11:15, 9 August 2024

English (en)Deutsch (de)Esperanto (eo)Español (es)Français (fr)Suomi (fi)Hrvatski (hr)Magyar (hu)Italiano (it)日本語 (ja)한국어 (ko)Nederlands (nl)Polski (pl)Português (pt)Português do Brasil (pt-br)Русский (ru)Slovenčina (sk)Svenska (sv)Türkçe (tr)Українська (uk)Tiếng Việt (vi)中文 (zh)中文(臺灣) (zh-tw)
Curly brackets white.pngTemplate Documentation [view] [edit]
Icon-translate.png Available doc translations
View
Page history

This template is used to generate class hierarchy for an entity.

Usage

{{CD|<entity_class>|file1=<file_where_the_class_is_defined_in>}}

Tip.pngTip:If the template fails for some classname try using Template:CD2 (usage same as shown above)
  • If {{{file1}}} param is specified there will be a lookup using the classname specified in {{{1}}} into Template:CD/classlink (lookup fallbacks into Template:CD/classlink/asw) to automatically link to Valve Source SDK 2013 githup repo (multiplayer files are linked).
  • {{{goldsrc}}} - should be used instead of {{{file1}}} when adding class hierarchy for GoldSrc entities. It adds ' (GoldSrc)' to all links and the lookup for file link will use Template:CD/classlink/hl.
Icon-Important.pngImportant:If nothing is found during the file link lookup mentioned above or {{{nolink}}} is specified then {{{file1}}} or {{{goldsrc}}} params are shown as they were specified. If neither file1 or goldsrc params were specified then automatic file link lookup won't be done at all.
  • {{{base}}} can be specified to explicitly choose the superclass which can be useful in case there isn't the desired class in Template:CD/superclass or it is defined there but it's already used for something else.

Examples and Parameters

Tip.pngTip:The arrow symbol left to the class is a separate link that is linking to category representing subclasses of the given class
{{CD|CGasCan|file1=somefile.cpp}}
C++ Class hierarchy
CGasCan
CCarriedPropWeapon
CCarriedProp
CBaseBackpackItem
CTerrorWeapon
CWeaponCSBase
CBaseCombatWeapon
CBaseAnimating
CBaseEntity
C++somefile.cpp
{{CD|CPhysicsProp|file1=1}}
C++ Class hierarchy
CPhysicsProp
CBreakableProp
CBaseProp
CBaseAnimating
CBaseEntity
C++props.cpp
{{CD|???|base=CDynamicProp}}
C++ Class hierarchy
???
CDynamicProp
CBreakableProp
CBaseProp
CBaseAnimating
CBaseEntity

Template performance

CD2 repeatedly calls Template:CD/superclass to build the hierarchy

CD calls that once and then builds the rest from smaller defined templates like Template:CD CPointEntity

specifying the base parameter avoids the first Template:CD/superclass call which makes it stuff even faster

Tests:

{{CD2|Hunter}} CPU time: ~0.26s

{{CD|Hunter}} CPU time: ~0.1s

{{CD|Hunter|base=BossZombiePlayerBot}} CPU time: ~0.03s

Hunter class hierarchy
C++ Class hierarchy
Hunter
BossZombiePlayerBot
NextBotPlayer
CTerrorPlayer
CCSPlayer
CBaseMultiplayerPlayer
CBasePlayer
CBaseCombatCharacter
CBaseFlex
CBaseAnimatingOverlay
CBaseAnimating
CBaseEntity

See Also