【UE4 反射系统】 UCLAS UFUNCTION UPROPERTY 宏简单解析 持续更新

目录

  • 0 引言
  • 1 C++如何实现反射机制
    • 1.1 使用代码生成工具实现反射机制
  • 2 UE4的反射系统
    • 2.1 ****.generated.h头文件
    • 2.2 GENERATED_BODY()
    • 2.3 反射宏 UCLASS 等
    • 2.4 UHT和UBT
  • 3 基本宏的使用
    • 3.1 UCLASS
    • 3.2 UFUNCTION
    • 3.3 UPROPERTY

请添加图片描述

  • 🙋‍♂️ 作者:海码007
  • 📜 专栏:UE虚幻引擎专栏
  • 💥 标题:【UE4 反射系统】 UCLAS USTRUCT UFUNCTION UPROPERTY 宏详解
  • ❣️ 寄语:加油,一次专注一件事!
  • 🎈 最后:文章作者技术和水平有限,如果文中出现错误,希望大家能指正,同时有问题的话,欢迎大家留言讨论。

0 引言

  • 反射系统是一种允许程序在运行时获取类型信息动态操作类和对象的机制。在C++语言中,没有内置的反射系统,但可以使用不同的库和技术实现类似的功能。(Java和C#语言都是有内置的反射机制的)
  • UE4在C++的基础上搭建了自己的一套反射机制,使用自定义的反射系统来支持蓝图编程和编辑器功能。UE4的反射系统允许在运行时访问类和对象的属性、函数和元数据,并提供了一些宏和关键字来标识和定义可被反射系统处理的内容。其中,“UCLASS”、"UFUNCTION"和"UPROPERTY"是UE4中用于反射的一些重要宏。
  • UE4的反射系统是选择加入的,只有主动标记的类型、属性、方法会被反射系统追踪,UnrealHeaderTool(UHT)会收集这些信息,生成用于支持反射机制的C++代码,然后再编译工程。

1 C++如何实现反射机制

实现C++的反射机制有多种方式。下面详细介绍其中几种常见的方法:

  1. 手动定义转换函数:这是最基础的反射实现方式。在类的定义中,手动定义转换函数,用于将类的数据成员或方法映射到字符串或其他类型。例如,可以为每个类定义一个静态成员函数,接受类的实例作为参数,并返回包含类信息的结构体。这种方法需要手动编写大量的重复代码,不够灵活。
  2. 使用宏:宏是C++中实现代码生成的一种方式。通过定义一系列宏来模拟反射机制。可以使用宏定义类的元信息,例如类名、成员变量名、函数名等。通过宏展开,可以在运行时获取类的元信息,并执行对应的操作。这种方法可以减少手动编写的代码量,但仍然需要繁琐的宏定义。
  3. 使用代码生成工具:可以编写一个代码生成工具,根据特定的标记或注释解析源代码,并生成反射所需的代码。工具可以根据类定义自动生成访问元信息的代码,避免手动编写大量重复的代码。通过将生成工具作为构建系统的一部分,可以在每次构建时自动更新反射代码。这种方法相对灵活且易于维护,但需要编写自定义的代码生成工具。(QT和UE4就是采用的该方法实现反射机制
  4. 使用第三方库:也可以使用现有的第三方库来实现C++反射。例如,"Boost.Reflection"库提供了一套用于C++的反射功能。它可以动态地获取和操作类的成员变量、函数和类型信息。这样,开发者可以在运行时获得类的元信息,从而实现动态加载和操作类的功能。

需要注意的是,C++作为静态类型语言,没有内置的反射机制。因此,以上这些方法只是模拟了反射的部分功能,无法像动态类型语言一样灵活。
总结起来,实现C++的反射机制可以通过手动定义转换函数、使用宏、编写代码生成工具或使用第三方库等方式。每种方式都有其优缺点,具体选择取决于项目需求和开发者的偏好。

1.1 使用代码生成工具实现反射机制

  • 代码生成工具通常是在构建过程中的一个独立阶段,通过解析源代码来生成反射所需的代码

简单的实现步骤:

  1. 定义注释或标记:在源代码中定义一些注释或特定的标记,用于标识需要反射的类、成员变量和方法
    例如,可以使用REFLECT_CLASS、REFLECT_MEMBER和REFLECT_METHOD等注释类、成员变量和方法
  2. 编写代码生成工具:编写一个代码生成工具,它可以读取源代码文件,并解析这些注释或标记
    例如,可以使用编译器提供的编译器前端库,如Clang的LibTooling,来辅助解析源代码。
  3. 解析源代码:使用代码生成工具解析源代码文件,并提取类、成员变量和方法的相关信息
    例如,可以获取类名成员变量的名称类型访问修饰符,以及方法的名称、参数列表和返回类型等
  4. 生成反射代码:根据解析得到的信息,代码生成工具可以生成反射所需的代码。
    例如,可以生成用于获取类的元信息的结构体或类以及用于动态访问成员变量和调用方法的函数。生成的代码可以包括类注册、获取类信息、访问成员变量、调用方法等功能。
  5. 构建生成工具将代码生成工具集成到项目的构建过程中
    例如,使用Makefile、CMake或其他构建系统。确保代码生成工具在每次构建时自动运行,以根据最新的源代码生成反射代码。
  6. 使用反射功能在运行时可以使用生成的反射代码动态地获取和操作类的成员变量和方法
    根据类的元信息,可以在不知道类的实际名称的情况下,动态创建对象、获取和修改成员变量的值,以及调用方法。

2 UE4的反射系统

在了解了C++中如何使用代码生成工具实现反射机制之后,那么再来理解 UE4 反射系统就会容易许多。

先从最简单的一个UObject子类开始分析(因为日常使用的类基本上都继承UObject),我们新建一个C++类继承UObject,UE会自动生成许多反射的代码:

// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"#include "MyObject1.generated.h"/*** */
UCLASS()
class CPP_CLASS_10_15_API UMyObject1 : public UObject
{GENERATED_BODY()public:UFUNCTION()void fun1(){UE_LOG(LogTemp, Warning, TEXT("name = %s"), *name);}UPROPERTY()FString name = "007";
};

2.1 ****.generated.h头文件

  • generate.h,其实就是UE对我们自己写的.h文件产生的反射代码文件。
  • #include "MyObject1.generated.h"需要写在头文件包含的最后。不然编译时会报错。错误如下:
error : #include found after .generated.h file - the .generated.h file should always be the last #include in a header
错误:#include在.generated.h文件之后找到-.generated.h文件应该始终是头中的最后一个#include

2.2 GENERATED_BODY()

使用GENERATED_BODY()宏自动展开为通用的成员函数接口和数据成员

2.3 反射宏 UCLASS 等

可以看到上面出现了三个宏,这些都是反射宏,下图中是UE源码中对宏的定义
在这里插入图片描述

反射宏名称作用
UCLASS告诉UE这个类是个反射类。此类必须派生自UObject(如果不用这个宏,那么成员函数和成员变量加了宏也反射不了)
UFUNCTION定义一个反射的函数
UPROPERTY定义一个反射的变量
USTRUCT可以不用派生自UObject。不支持GC,也不能包含函数
UENUM告诉UE这是一个反射的枚举类。支持enum, enum class, enum namespace
UINTERFACE定义一个反射接口类,只能包含函数
UMETA反射的一些元数据定义,可以通过标签定义一些该变量的属性
UPARAM定义函数的参数属性。主要就是显示名字和Ref属性
UDELEGATE告诉UE这是一个可反射的委托(很少用到)

2.4 UHT和UBT

由于作者目前水平有限,理解还不透彻。等学习领悟之后再来填坑。
这里放一个 参考文章 帮助大家理解

3 基本宏的使用

3.1 UCLASS

  • 如果想要使用蓝图生成C++类,则需要给UCLASS宏中添加说明符,UCLASS宏的所有说明符如下所示:
  • 最常用的就是 BlueprintType(将此类公开为可用于蓝图中变量的类型)
// These are used for syntax highlighting and to allow autocomplete hintsnamespace UC
{// valid keywords for the UCLASS macroenum {/// This keyword is used to set the actor group that the class is show in, in the editor.classGroup,/// Declares that instances of this class should always have an outer of the specified class.  This is inherited by subclasses unless overridden.Within, /* =OuterClassName *//// Exposes this class as a type that can be used for variables in blueprintsBlueprintType,/// Prevents this class from being used for variables in blueprintsNotBlueprintType,/// Exposes this class as an acceptable base class for creating blueprints. The default is NotBlueprintable, unless inherited otherwise. This is inherited by subclasses.Blueprintable,/// Specifies that this class is *NOT* an acceptable base class for creating blueprints. The default is NotBlueprintable, unless inherited otherwise. This is inherited by subclasses.NotBlueprintable,/// This keyword indicates that the class should be accessible outside of it's module, but does not need all methods exported./// It exports only the autogenerated methods required for dynamic_cast<>, etc... to work.MinimalAPI,/// Prevents automatic generation of the constructor declaration.customConstructor,/// Class was declared directly in C++ and has no boilerplate generated by UnrealHeaderTool./// DO NOT USE THIS FLAG ON NEW CLASSES.Intrinsic,/// No autogenerated code will be created for this class; the header is only provided to parse metadata from./// DO NOT USE THIS FLAG ON NEW CLASSES.noexport,/// Allow users to create and place this class in the editor.  This flag is inherited by subclasses.placeable,/// This class cannot be placed in the editor (it cancels out an inherited placeable flag).notplaceable,/// All instances of this class are considered "instanced". Instanced classes (components) are duplicated upon construction. This flag is inherited by subclasses. DefaultToInstanced,/// All properties and functions in this class are const and should be exported as const.  This flag is inherited by subclasses.Const,/// Class is abstract and can't be instantiated directly.Abstract,/// This class is deprecated and objects of this class won't be saved when serializing.  This flag is inherited by subclasses.deprecated,/// This class can't be saved; null it out at save time.  This flag is inherited by subclasses.Transient,/// This class should be saved normally (it cancels out an inherited transient flag).nonTransient,/// This class is optional and might not be available in certain context. reference from non optional data type is not allowed.Optional,/// Load object configuration at construction time.  These flags are inherited by subclasses./// Class containing config properties. Usage config=ConfigName or config=inherit (inherits config name from base class).config,/// Handle object configuration on a per-object basis, rather than per-class. perObjectConfig,/// Determine whether on serialize to configs a check should be done on the base/defaults ini'sconfigdonotcheckdefaults,/// Save object config only to Default INIs, never to local INIs.defaultconfig,/// Mark the editor config file to load from if loading into this object.EditorConfig,/// These affect the behavior of the property editor./// Class can be constructed from editinline New button.editinlinenew,/// Class can't be constructed from editinline New button.noteditinlinenew,/// Class not shown in editor drop down for class selection.hidedropdown,/// Shows the specified categories in a property viewer. Usage: showCategories=CategoryName or showCategories=(category0, category1, ...)showCategories,/// Hides the specified categories in a property viewer. Usage: hideCategories=CategoryName or hideCategories=(category0, category1, ...)hideCategories,/// Indicates that this class is a wrapper class for a component with little intrinsic functionality (this causes things like hideCategories and showCategories to be ignored if the class is subclassed in a Blueprint)ComponentWrapperClass,/// Shows the specified function in a property viewer. Usage: showFunctions=FunctionName or showFunctions=(category0, category1, ...)showFunctions,/// Hides the specified function in a property viewer. Usage: hideFunctions=FunctionName or hideFunctions=(category0, category1, ...)hideFunctions,/// Specifies which categories should be automatically expanded in a property viewer.autoExpandCategories,/// Specifies which categories should be automatically collapsed in a property viewer.autoCollapseCategories,/// Clears the list of auto collapse categories.dontAutoCollapseCategories,/// Display properties in the editor without using categories.collapseCategories,/// Display properties in the editor using categories (default behaviour).dontCollapseCategories,/// Specifies category display order, unspecified will follow default display order.prioritizeCategories,/// All the properties of the class are hidden in the main display by default, and are only shown in the advanced details section.AdvancedClassDisplay,/// A root convert limits a sub-class to only be able to convert to child classes of the first root class going up the hierarchy.ConversionRoot,/// Marks this class as 'experimental' (a totally unsupported and undocumented prototype)Experimental,/// Marks this class as an 'early access' preview (while not considered production-ready, it's a step beyond 'experimental' and is being provided as a preview of things to come)EarlyAccessPreview,/// Some properties are stored once per class in a sidecar structure and not on instances of the classSparseClassDataType,/// Specifies the struct that contains the CustomThunk implementationsCustomThunkTemplates};
}

3.2 UFUNCTION

  • 最常用的函数说明符就是 BlueprintCallable(此函数可在蓝图或关卡蓝图图表中执行)
namespace UF
{// valid keywords for the UFUNCTION and UDELEGATE macrosenum {/// This function is designed to be overridden by a blueprint.  Do not provide a body for this function;/// the autogenerated code will include a thunk that calls ProcessEvent to execute the overridden body.BlueprintImplementableEvent,/// This function is designed to be overridden by a blueprint, but also has a native implementation./// Provide a body named [FunctionName]_Implementation instead of [FunctionName]; the autogenerated/// code will include a thunk that calls the implementation method when necessary.BlueprintNativeEvent,/// This function is sealed and cannot be overridden in subclasses./// It is only a valid keyword for events; declare other methods as static or final to indicate that they are sealed.SealedEvent,/// This function is executable from the command line.Exec,/// This function is replicated, and executed on servers.  Provide a body named [FunctionName]_Implementation instead of [FunctionName];/// the autogenerated code will include a thunk that calls the implementation method when necessary.Server,/// This function is replicated, and executed on clients.  Provide a body named [FunctionName]_Implementation instead of [FunctionName];/// the autogenerated code will include a thunk that calls the implementation method when necessary.Client,/// This function is both executed locally on the server and replicated to all clients, regardless of the Actor's NetOwnerNetMulticast,/// Replication of calls to this function should be done on a reliable channel./// Only valid when used in conjunction with Client or ServerReliable,/// Replication of calls to this function can be done on an unreliable channel./// Only valid when used in conjunction with Client or ServerUnreliable,/// This function fulfills a contract of producing no side effects, and additionally implies BlueprintCallable.BlueprintPure,/// This function can be called from blueprint code and should be exposed to the user of blueprint editing tools.BlueprintCallable,/// This function is used as the get accessor for a blueprint exposed property. Implies BlueprintPure and BlueprintCallable.BlueprintGetter,/// This function is used as the set accessor for a blueprint exposed property. Implies BlueprintCallable.BlueprintSetter,/// This function will not execute from blueprint code if running on something without network authorityBlueprintAuthorityOnly,/// This function is cosmetic and will not run on dedicated serversBlueprintCosmetic,/// Indicates that a Blueprint exposed function should not be exposed to the end userBlueprintInternalUseOnly,/// This function can be called in the editor on selected instances via a button in the details panel.CallInEditor,/// The UnrealHeaderTool code generator will not produce a execFoo thunk for this function; it is up to the user to provide one.CustomThunk,/// Specifies the category of the function when displayed in blueprint editing tools./// Usage: Category=CategoryName or Category="MajorCategory,SubCategory"Category,/// This function must supply a _Validate implementationWithValidation,/// This function is RPC service requestServiceRequest,/// This function is RPC service responseServiceResponse,/// [FunctionMetadata]	Marks a UFUNCTION as accepting variadic arguments. Variadic functions may have extra terms they need to emit after the main set of function arguments///						These are all considered wildcards so no type checking will be performed on themVariadic,/// [FunctionMetadata] Indicates the display name of the return value pinReturnDisplayName, /// [FunctionMetadata] Indicates that a particular function parameter is for internal use only, which means it will be both hidden and not connectible.InternalUseParam, /// [FunctionMetadata] Indicates that the function should be ignored when considered for blueprint type promotionIgnoreTypePromotion,};
}

3.3 UPROPERTY

  • BlueprintReadWrite 可从蓝图读取或写入此属性。此说明符与 BlueprintReadOnly 说明符不兼容
namespace UP
{// valid keywords for the UPROPERTY macroenum {/// This property is const and should be exported as const.Const,/// Property should be loaded/saved to ini file as permanent profile.Config,/// Same as above but load config from base class, not subclass.GlobalConfig,/// Property should be loaded as localizable text. Implies ReadOnly.Localized,/// Property is transient: shouldn't be saved, zero-filled at load time.Transient,/// Property should always be reset to the default value during any type of duplication (copy/paste, binary duplication, etc.)DuplicateTransient,/// Property should always be reset to the default value unless it's being duplicated for a PIE session - deprecated, use NonPIEDuplicateTransient insteadNonPIETransient,/// Property should always be reset to the default value unless it's being duplicated for a PIE sessionNonPIEDuplicateTransient,/// Value is copied out after function call. Only valid on function param declaration.Ref,/// Object property can be exported with it's owner.Export,/// Hide clear (and browse) button in the editor.NoClear,/// Indicates that elements of an array can be modified, but its size cannot be changed.EditFixedSize,/// Property is relevant to network replication.Replicated,/// Property is relevant to network replication. Notify actors when a property is replicated (usage: ReplicatedUsing=FunctionName).ReplicatedUsing,/// Skip replication (only for struct members and parameters in service request functions).NotReplicated,/// Interpolatable property for use with cinematics. Always user-settable in the editor.Interp,/// Property isn't transacted.NonTransactional,/// Property is a component reference. Implies EditInline and Export.Instanced,/// MC Delegates only.  Property should be exposed for assigning in blueprints.BlueprintAssignable,/// Specifies the category of the property. Usage: Category=CategoryName.Category,/// Properties appear visible by default in a details panelSimpleDisplay,/// Properties are in the advanced dropdown in a details panelAdvancedDisplay,/// Indicates that this property can be edited by property windows in the editorEditAnywhere,/// Indicates that this property can be edited by property windows, but only on instances, not on archetypesEditInstanceOnly,/// Indicates that this property can be edited by property windows, but only on archetypesEditDefaultsOnly,/// Indicates that this property is visible in property windows, but cannot be edited at allVisibleAnywhere,/// Indicates that this property is only visible in property windows for instances, not for archetypes, and cannot be editedVisibleInstanceOnly,/// Indicates that this property is only visible in property windows for archetypes, and cannot be editedVisibleDefaultsOnly,/// This property can be read by blueprints, but not modified.BlueprintReadOnly,/// This property has an accessor to return the value. Implies BlueprintReadOnly if BlueprintSetter or BlueprintReadWrite is not specified. (usage: BlueprintGetter=FunctionName).BlueprintGetter,/// This property can be read or written from a blueprint.BlueprintReadWrite,/// This property has an accessor to set the value. Implies BlueprintReadWrite. (usage: BlueprintSetter=FunctionName).BlueprintSetter,/// The AssetRegistrySearchable keyword indicates that this property and it's value will be automatically added/// to the asset registry for any asset class instances containing this as a member variable.  It is not legal/// to use on struct properties or parameters.AssetRegistrySearchable,/// Property should be serialized for save games./// This is only checked for game-specific archives with ArIsSaveGame setSaveGame,/// MC Delegates only.  Property should be exposed for calling in blueprint codeBlueprintCallable,/// MC Delegates only. This delegate accepts (only in blueprint) only events with BlueprintAuthorityOnly.BlueprintAuthorityOnly,/// Property shouldn't be exported to text format (e.g. copy/paste)TextExportTransient,/// Property shouldn't be serialized, can still be exported to textSkipSerialization,/// If true, the self pin should not be shown or connectable regardless of purity, const, etc. similar to InternalUseParamHideSelfPin, };
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/161998.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Axure RP医疗在线挂号问诊原型图医院APP原形模板

医疗在线挂号问诊Axure RP原型图医院APP原形模板&#xff0c;是一款原创的医疗类APP&#xff0c;设计尺寸采用iPhone13&#xff08;375*812px&#xff09;&#xff0c;原型图上加入了仿真手机壳&#xff0c;使得预览效果更加逼真。 本套原型图主要功能有医疗常识科普、医院挂号…

美创科技信创数据安全「利基者」!

近日&#xff0c;第一新声研究部正式发布《2023年中国信创网络安全产品竞争力象限》&#xff08;下称“象限报告“&#xff09;。 ◼︎ 象限报告综合考虑企业占有率、在技术/应用上的成熟度、在客户方面的交付完成度及口碑、产品在市场/营销/商业模式/行业拓展等战略上的领先性…

解决Drag and drop is not supported导致无法将物理机上的文件拖入Ubuntu

问题起因 因为需要拷贝一个文件从物理机到虚拟机&#xff0c;但是我又不想用有关ftp的程序或者协议&#xff0c;但是直接拖又报错Drag and drop is not supported&#xff0c;索性上网查询了一下解决方法&#xff0c;自己记录一下。 解决方法 安装下面两个程序 sudo apt in…

python小游戏:小球碰撞

创建带图形界面的游戏通常需要使用图形库。Python有很多图形库&#xff0c;其中比较流行的包括Pygame, PyOpenGL, Panda3D等。在这里&#xff0c;我将用Pygame作为示例来编写一个简单的游戏。 在运行下面的代码之前&#xff0c;请确保你已经安装了Pygame库。你可以使用以下命令…

工控机连接Profinet转Modbus RTU网关与水泵变频器Modbus通讯配置案例

Profinet转Modbus RTU网关是一个具有高性能的通信设备&#xff0c;它能够将工控机上的Profinet协议转换成水泵变频器可识别的Modbus RTU协议&#xff0c;实现二者之间的通信。通过这种方式&#xff0c;工控机可以直接控制水泵变频器的运行状态&#xff0c;改变其工作频率&#…

美格智能SLM927智能模组,轻松打造功能丰富的智能终端

近年来&#xff0c;智能终端加速渗入各行各业&#xff0c;使用场景不断拓展&#xff0c;视觉、听觉、语音、传感等交互能力融入智能终端产品之中&#xff0c;带来涵盖工作和生活各场景的智能化浪潮。 美格智能作为全球领先的无线通信模组及解决方案提供商&#xff0c;深入洞察…

Linux网络编程系列之UDP组播

Linux网络编程系列 &#xff08;够吃&#xff0c;管饱&#xff09; 1、Linux网络编程系列之网络编程基础 2、Linux网络编程系列之TCP协议编程 3、Linux网络编程系列之UDP协议编程 4、Linux网络编程系列之UDP广播 5、Linux网络编程系列之UDP组播 6、Linux网络编程系列之服务器编…

Linux网络-UDP/TCP协议详解

Linux网络-UDP/TCP协议详解 2023/10/17 14:32:49 Linux网络-UDP/TCP协议详解 零、前言一、UDP协议二、TCP协议 1、应答机制2、序号机制3、超时重传机制4、连接管理机制 三次握手四次挥手5、理解CLOSE_WAIT状态6、理解TIME_WAIT状态7、流量控制8、滑动窗口 丢包问题9、拥塞控制…

【Qt-19】按Q退出应用程序

如何将Qt窗口应用程序改成控制台程序呢&#xff1f; 下面进入正文&#xff0c;如何控制控制台程序退出呢&#xff1f; 这里采用线程方式&#xff0c;通过单独线程监视用户输入来执行是否退出程序。 监视线程头文件thread.h #include <QThread> #include "TDRServe…

【ARM裸机】ARM入门

1.ARM成长史 2.ARM的商业模式和生态系统 ARM只设计CPU&#xff0c;但是不生产CPU 3.为什么使用三星&#xff1a;S5PV210 4.各种版本号 0. ARM和Cortex Cortex就是ARM公司一个系列处理器的名称。比如英特尔旗下处理器有酷睿&#xff0c;奔腾&#xff0c;赛扬。ARM在最初的处理器…

[BX]和Loop指令

[BX]和Loop指令 1 描述性符号: “()”2 idata常量3 [BX]4 Loop5 Debug和汇编编译器masm对指令的不同处理6 Loop和[BX]的联合应用7 段前缀 本文属于《 X86指令基础系列教程》之一&#xff0c;欢迎查看其它文章。 1 描述性符号: “()” 我们定义的描述性的符号: "()”&…

【web前端】web前端设计入门到实战第一弹——html基础精华

前端 一&#xff1a;图片属性二&#xff1a;音频标签三&#xff1a; 视频标签四&#xff1a;链接标签五&#xff1a;列表标签5.1.无序列表5.2.有序列表3.自定义列表 六&#xff1a;表格6.1合并单元格 七&#xff1a;input标签八&#xff1a;select系列九&#xff1a; 文本域标签…

python元组、拆包和装包

注意 元组不能修改元素 元组&#xff1a;如果元素为字符串且元素为1个&#xff0c;必须加一个&#xff0c; ********* t1 (aa,) 下标和切片 in not in for ... in ... 元组转为列表 拆包、装包

Android DI框架-Hilt

到底该如何理解<依赖注入> 模版代码&#xff1a;食之无味&#xff0c;弃之可惜 public class MainActivity extends Activity {Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);TextView mTextView(TextView) findVi…

游戏数据分析工具该怎样选择?有哪些选择标准?

选择游戏数据分析工具时&#xff0c;可以考虑以下标准&#xff1a; 1、功能全面性 确保工具提供全面的功能&#xff0c;包括玩家行为分析、性能监测、用户留存率、收入分析等&#xff0c;以满足不同层面的需求。 2、易用性 选择界面友好、易于使用的工具&#xff0c;以确保团…

[PyTorch]即插即用的热力图生成

先上张效果图&#xff0c;本来打算移植霹雳老师的使用Pytorch实现Grad-CAM并绘制热力图。但是看了下代码&#xff0c;需要骨干网络按照标准写法&#xff08;即将特征层封装为features数组&#xff09;&#xff0c;而我写的网络图省事并没有进行封装&#xff0c;改造网络的代价又…

【学习笔记】RabbitMQ-6 消息的可靠性投递2

参考资料 RabbitMQ官方网站RabbitMQ官方文档噼咔噼咔-动力节点教程 文章目录 十一、队列Queue的消息属性11.1 具体属性11.2 自动删除11.2 自定义参数11.2.1 **Message TTL** 消息存活时间11.2.2 **Auto expire** 队列自动到期时间11.2.3 **Overflow behaviour** 溢出行为11.2.4…

微信扫码跳转到小程序内部,浏览器扫码跳转到App 内部,如果手机上没有安装App ,跳转到下载页

第一:微信扫普通二维码跳转到小程序 第一步:登录微信公众平台,左侧点击开发管理,点击开发设置,滑到最下边,找到扫普通链接二维码打开小程序,配置对应的二维码链接,注意要拿这个链接去生成二维码,这样微信扫码才能跳转到小程序内部,还有那个校验文件,让后台放到对应的文件夹下,…

c#是不是比qt好找工作些?

c#是不是比qt好找工作些? C#和Qt都是非常流行的编程语言&#xff0c;会对你未来找工作都有一定的帮助。然而&#xff0c;就目前工作市场而言&#xff0c;C#的相关岗位可能更多一些&#xff0c;因为它被广泛用于企业应用开发和微软生态系统中。最近很多小伙伴找我&#xff0c;说…

python——loguru第三方日志管理模块

loguru第三方日志管理模块 loguru介绍日志等级日志保存日志过滤处理异常 loguru介绍 loguru是第三方库&#xff0c;拿来即用&#xff0c;不用太多的配置 安装&#xff1a;pip install loguru 日志等级 from loguru import loggerlogger.debug(这是一条调试消息&#xff01;)…