【UE】UEC++委托代理

news2024/9/21 23:30:51

【UE】UEC++委托代理 

一、委托的声明与定义

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "DelegateGameMode.generated.h"

//
// Declare DECLARE_DELEGATE
//
DECLARE_DELEGATE(FDeclareDelegate_00);
DECLARE_DELEGATE_OneParam(FDeclareDelegate_01, bool);
DECLARE_DELEGATE_TwoParams(FDeclareDelegate_02, bool, int32);
DECLARE_DELEGATE_RetVal(bool, FDeclareDelegate_03);
DECLARE_DELEGATE_RetVal_OneParam(bool, FDeclareDelegate_04, bool);

//
// Declare DECLARE_MULTICAST_DELEGATE
//
DECLARE_MULTICAST_DELEGATE(FDeclareMulticastDelegate_00);
DECLARE_MULTICAST_DELEGATE_OneParam(FDeclareMulticastDelegate_01, int32);

//
// Declare DECLARE_DYNAMIC_DELEGATE
//
DECLARE_DYNAMIC_DELEGATE(FDeclareDynamicDelegate_00);
DECLARE_DYNAMIC_DELEGATE_OneParam(FDeclareDynamicDelegate_01, int32, iValue);
DECLARE_DYNAMIC_DELEGATE_RetVal(bool, FDeclareDynamicDelegate_02);
DECLARE_DYNAMIC_DELEGATE_RetVal_OneParam(bool, FDeclareDynamicDelegate_03, int32, iValue);

//
// Declare DECLARE_DYNAMIC_MULTICAST_DELEGATE
//
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FDeclareDynamicMulticastDelegate_00);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDeclareDynamicMulticastDelegate_01, int32, iValue);

UCLASS()
class DELEGATE_API ADelegateGameMode : public AGameModeBase
{
	GENERATED_BODY()
public:
	//
	// Define DECLARE_DELEGATE
	//
	FDeclareDelegate_00 DeclareDelegate_00;
	FDeclareDelegate_01 DeclareDelegate_01;
	FDeclareDelegate_02 DeclareDelegate_02;
	FDeclareDelegate_03 DeclareDelegate_03;
	FDeclareDelegate_04 DeclareDelegate_04;

	//
	// Define DECLARE_MULTICAST_DELEGATE
	//
	FDeclareMulticastDelegate_00 DeclareMulticastDelegate_00;
	FDeclareMulticastDelegate_01 DeclareMulticastDelegate_01;

	//
	// Define DECLARE_DYNAMIC_DELEGATE
	//
	FDeclareDynamicDelegate_00 DeclareDynamicDelegate_00;
	FDeclareDynamicDelegate_01 DeclareDynamicDelegate_01;
	FDeclareDynamicDelegate_02 DeclareDynamicDelegate_02;
	FDeclareDynamicDelegate_03 DeclareDynamicDelegate_03;

	//
	// Define DECLARE_DYNAMIC_MULTICAST_DELEGATE
	//
	FDeclareDynamicMulticastDelegate_00 DeclareDynamicMulticastDelegate_00;
	FDeclareDynamicMulticastDelegate_01 DeclareDynamicMulticastDelegate_01;
};

二、单播绑定与解绑

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "DeclareDelegate.generated.h"

UCLASS()
class DELEGATE_API ADeclareDelegate : public AActor
{
	GENERATED_BODY()
public:	
	ADeclareDelegate();
	virtual void Tick(float DeltaTime) override;
protected:
	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
public:
	UFUNCTION()
	void BindDelegate();
	UFUNCTION()
	void UnBindDelegate();
	
	UFUNCTION()
	void FunNoParam();
	UFUNCTION()
	void FunOneParam(bool bValue);
	UFUNCTION()
	void FunTwoParam(bool bValue, int32 iValue);
	UFUNCTION()
	bool FunRetValNoParam();
	UFUNCTION()
	bool FunRetValOneParam(bool bValue);
};
#include "DeclareDelegate.h"

#include "Delegate/GameMode/DelegateGameMode.h"
#include "Kismet/GameplayStatics.h"

ADeclareDelegate::ADeclareDelegate()
{
	PrimaryActorTick.bCanEverTick = false;
}

void ADeclareDelegate::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

void ADeclareDelegate::BeginPlay()
{
	Super::BeginPlay();
	BindDelegate();
}

void ADeclareDelegate::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
	Super::EndPlay(EndPlayReason);
	UnBindDelegate();
}

void ADeclareDelegate::BindDelegate()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDelegateActor::BindDegelate"))
	if(GetWorld())
	{
		ADelegateGameMode* DelegateGameMode = Cast<ADelegateGameMode>(UGameplayStatics::GetGameMode(GetWorld()));

		DelegateGameMode->DeclareDelegate_00.BindUObject(this, &ThisClass::FunNoParam);
		DelegateGameMode->DeclareDelegate_01.BindUFunction(this, "FunOneParam");
		DelegateGameMode->DeclareDelegate_02.BindUObject(this, &ThisClass::FunTwoParam);
		DelegateGameMode->DeclareDelegate_03.BindUObject(this, &ThisClass::FunRetValNoParam);
		DelegateGameMode->DeclareDelegate_04.BindUFunction(this, "FunRetValOneParam");
	}
}

void ADeclareDelegate::UnBindDelegate()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDelegateActor::UnBindDegelate"))
	if(GetWorld())
	{
		ADelegateGameMode* DelegateGameMode = Cast<ADelegateGameMode>(UGameplayStatics::GetGameMode(GetWorld()));

		DelegateGameMode->DeclareDelegate_00.Unbind();
		DelegateGameMode->DeclareDelegate_01.Unbind();
		DelegateGameMode->DeclareDelegate_02.Unbind();
		DelegateGameMode->DeclareDelegate_03.Unbind();
		DelegateGameMode->DeclareDelegate_04.Unbind();
	}
}

void ADeclareDelegate::FunNoParam()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDelegateActor::FunNoParam"))
}

void ADeclareDelegate::FunOneParam(bool bValue)
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDelegateActor::FunOneParam"))
}

void ADeclareDelegate::FunTwoParam(bool bValue, int32 iValue)
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDelegateActor::FunTwoParam"))
}

bool ADeclareDelegate::FunRetValNoParam()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDelegateActor::FunRetValNoParam"))
	return false;
}

bool ADeclareDelegate::FunRetValOneParam(bool bValue)
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDelegateActor::FunRetValOneParam"))
	return bValue;
}

三、多播绑定与解绑

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "DeclareMulticastDelegate.generated.h"

UCLASS()
class DELEGATE_API ADeclareMulticastDelegate : public AActor
{
	GENERATED_BODY()
	
public:	
	ADeclareMulticastDelegate();
	virtual void Tick(float DeltaTime) override;
protected:
	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
public:
	UFUNCTION()
	void BindDelegate();
	UFUNCTION()
	void UnBindDelegate();
		
	UFUNCTION()
	void FunNoParam_One();
	UFUNCTION()
	void FunNoParam_Two();
	UFUNCTION()
	void FunOneParam_One(int32 iValue);
	UFUNCTION()
	void FunOneParam_Two(int32 iValue);
private:
	FDelegateHandle DelegateHandle;
	TArray<FDelegateHandle> DelegateHandles;
};
#include "DeclareMulticastDelegate.h"

#include "Delegate/GameMode/DelegateGameMode.h"
#include "Kismet/GameplayStatics.h"

ADeclareMulticastDelegate::ADeclareMulticastDelegate()
{
	PrimaryActorTick.bCanEverTick = false;
}

void ADeclareMulticastDelegate::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

void ADeclareMulticastDelegate::BeginPlay()
{
	Super::BeginPlay();
	BindDelegate();
}

void ADeclareMulticastDelegate::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
	Super::EndPlay(EndPlayReason);
	UnBindDelegate();
}

void ADeclareMulticastDelegate::BindDelegate()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareMulticastDelegateActor::BindDegelate"))
	if(GetWorld())
	{
		ADelegateGameMode* DelegateGameMode = Cast<ADelegateGameMode>(UGameplayStatics::GetGameMode(GetWorld()));

		DelegateGameMode->DeclareMulticastDelegate_00.AddUObject(this, &ThisClass::FunNoParam_One);
		DelegateHandle = DelegateGameMode->DeclareMulticastDelegate_00.AddUFunction(this, "FunNoParam_Two");
		DelegateHandles.Add(DelegateGameMode->DeclareMulticastDelegate_01.AddUObject(this, &ThisClass::FunOneParam_One));
		DelegateHandles.Add(DelegateGameMode->DeclareMulticastDelegate_01.AddUFunction(this, "FunOneParam_Two"));
	}
}

void ADeclareMulticastDelegate::UnBindDelegate()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareMulticastDelegateActor::UnBindDelegate"))
	if(GetWorld())
	{
		ADelegateGameMode* DelegateGameMode = Cast<ADelegateGameMode>(UGameplayStatics::GetGameMode(GetWorld()));

		DelegateGameMode->DeclareMulticastDelegate_00.RemoveAll(this);
		
		for(FDelegateHandle Handle : DelegateHandles)
		{
			DelegateGameMode->DeclareMulticastDelegate_01.Remove(Handle);
		}
	}
}

void ADeclareMulticastDelegate::FunNoParam_One()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareMulticastDelegateActor::FunNoParam_One"))
}

void ADeclareMulticastDelegate::FunNoParam_Two()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareMulticastDelegateActor::FunNoParam_Two"))
	
	if(GetWorld())
	{
		ADelegateGameMode* DelegateGameMode = Cast<ADelegateGameMode>(UGameplayStatics::GetGameMode(GetWorld()));
		DelegateGameMode->DeclareMulticastDelegate_00.Remove(DelegateHandle);
	}
}

void ADeclareMulticastDelegate::FunOneParam_One(int32 iValue)
{
	UE_LOG(LogTemp,Log,TEXT("DeclareMulticastDelegateActor::FunOneParam_One"))
}

void ADeclareMulticastDelegate::FunOneParam_Two(int32 iValue)
{
	UE_LOG(LogTemp,Log,TEXT("DeclareMulticastDelegateActor::FunOneParam_Two"))
}

四、动态单播绑定与解绑

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "DeclareDynamicDelegate.generated.h"

UCLASS()
class DELEGATE_API ADeclareDynamicDelegate : public AActor
{
	GENERATED_BODY()
public:	
	ADeclareDynamicDelegate();
	virtual void Tick(float DeltaTime) override;
protected:
	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
public:	
	UFUNCTION()
	void BindDelegate();
	UFUNCTION()
	void UnBindDelegate();

	UFUNCTION()
	void FunNoParam();
	UFUNCTION()
	void FunOneParam(int32 iValue);
	UFUNCTION()
	bool FunRetValNoParam();
	UFUNCTION()
	bool FunRetValOneParam(int32 iValue);
};
#include "DeclareDynamicDelegate.h"

#include "Delegate/GameMode/DelegateGameMode.h"
#include "Kismet/GameplayStatics.h"

ADeclareDynamicDelegate::ADeclareDynamicDelegate()
{
	PrimaryActorTick.bCanEverTick = false;
}

void ADeclareDynamicDelegate::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

void ADeclareDynamicDelegate::BeginPlay()
{
	Super::BeginPlay();
	BindDelegate();
}

void ADeclareDynamicDelegate::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
	Super::EndPlay(EndPlayReason);
	UnBindDelegate();
}

void ADeclareDynamicDelegate::BindDelegate()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDynamicDelegate::BindDelegate"))
	if(GetWorld())
	{
		ADelegateGameMode* DelegateGameMode = Cast<ADelegateGameMode>(UGameplayStatics::GetGameMode(GetWorld()));

		DelegateGameMode->DeclareDynamicDelegate_00.BindDynamic(this, &ThisClass::FunNoParam);
		DelegateGameMode->DeclareDynamicDelegate_01.BindUFunction(this, "FunOneParam");
		DelegateGameMode->DeclareDynamicDelegate_02.BindDynamic(this, &ThisClass::FunRetValNoParam);
		DelegateGameMode->DeclareDynamicDelegate_03.BindUFunction(this, "FunRetValOneParam");
	}
}

void ADeclareDynamicDelegate::UnBindDelegate()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDynamicDelegate::UnBindDelegate"))
	if(GetWorld())
	{
		ADelegateGameMode* DelegateGameMode = Cast<ADelegateGameMode>(UGameplayStatics::GetGameMode(GetWorld()));

		DelegateGameMode->DeclareDynamicDelegate_00.Clear();
		DelegateGameMode->DeclareDynamicDelegate_01.Unbind();
		DelegateGameMode->DeclareDynamicDelegate_02.Clear();
		DelegateGameMode->DeclareDynamicDelegate_03.Unbind();
	}
}

void ADeclareDynamicDelegate::FunNoParam()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDynamicDelegate::FunNoParam"))
}

void ADeclareDynamicDelegate::FunOneParam(int32 iValue)
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDynamicDelegate::FunOneParam"))
}

bool ADeclareDynamicDelegate::FunRetValNoParam()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDynamicDelegate::FunRetValNoParam"))
	return false;
}

bool ADeclareDynamicDelegate::FunRetValOneParam(int32 iValue)
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDynamicDelegate::FunRetValOneParam"))
	return false;
}

五、动态多播绑定与解绑

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "DeclareDynamicMulticastDelegate.generated.h"

UCLASS()
class DELEGATE_API ADeclareDynamicMulticastDelegate : public AActor
{
	GENERATED_BODY()
public:	
	ADeclareDynamicMulticastDelegate();
	virtual void Tick(float DeltaTime) override;
protected:
	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
public:
	UFUNCTION()
	void BindDelegate();
	UFUNCTION()
	void UnBindDelegate();
	
	UFUNCTION()
	void FunNoParam_One();
	UFUNCTION()
	void FunNoParam_Two();
	UFUNCTION()
	void FunOneParam_One(int32 iValue);
	UFUNCTION()
	void FunOneParam_Two(int32 iValue);
};
#include "DeclareDynamicMulticastDelegate.h"

#include "Delegate/GameMode/DelegateGameMode.h"
#include "Kismet/GameplayStatics.h"

ADeclareDynamicMulticastDelegate::ADeclareDynamicMulticastDelegate()
{
	PrimaryActorTick.bCanEverTick = false;
}

void ADeclareDynamicMulticastDelegate::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

void ADeclareDynamicMulticastDelegate::BeginPlay()
{
	Super::BeginPlay();
	BindDelegate();
}

void ADeclareDynamicMulticastDelegate::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
	Super::EndPlay(EndPlayReason);
	UnBindDelegate();
}

void ADeclareDynamicMulticastDelegate::BindDelegate()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDynamicMulticastDelegate::BindDelegate"))
	if(GetWorld())
	{
		ADelegateGameMode* DelegateGameMode = Cast<ADelegateGameMode>(UGameplayStatics::GetGameMode(GetWorld()));

		DelegateGameMode->DeclareDynamicMulticastDelegate_00.AddDynamic(this, &ThisClass::FunNoParam_One);
		DelegateGameMode->DeclareDynamicMulticastDelegate_00.AddUniqueDynamic(this, &ThisClass::FunNoParam_Two);
		DelegateGameMode->DeclareDynamicMulticastDelegate_01.AddDynamic(this, &ThisClass::FunOneParam_One);
		DelegateGameMode->DeclareDynamicMulticastDelegate_01.AddUniqueDynamic(this, &ThisClass::FunOneParam_Two);
	}
}

void ADeclareDynamicMulticastDelegate::UnBindDelegate()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDynamicMulticastDelegate::UnBindDelegate"))
	if(GetWorld())
	{
		ADelegateGameMode* DelegateGameMode = Cast<ADelegateGameMode>(UGameplayStatics::GetGameMode(GetWorld()));

		DelegateGameMode->DeclareDynamicMulticastDelegate_00.Remove(this, "FunNoParam_One");
		DelegateGameMode->DeclareDynamicMulticastDelegate_00.RemoveDynamic(this, &ThisClass::FunNoParam_Two);
		DelegateGameMode->DeclareDynamicMulticastDelegate_01.RemoveAll(this);
	}
}

void ADeclareDynamicMulticastDelegate::FunNoParam_One()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDynamicMulticastDelegate::FunNoParam_One"))
}

void ADeclareDynamicMulticastDelegate::FunNoParam_Two()
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDynamicMulticastDelegate::FunNoParam_Two"))
}

void ADeclareDynamicMulticastDelegate::FunOneParam_One(int32 iValue)
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDynamicMulticastDelegate::FunOneParam_One"))
}

void ADeclareDynamicMulticastDelegate::FunOneParam_Two(int32 iValue)
{
	UE_LOG(LogTemp,Log,TEXT("DeclareDynamicMulticastDelegate::FunOneParam_Two"))
}

六、委托的调用

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "DelegateController.generated.h"

UCLASS()
class DELEGATE_API ADelegateController : public APlayerController
{
	GENERATED_BODY()
public:
	virtual void SetupInputComponent() override;
	//
	//	Call Declare Delegate
	//
	UFUNCTION()
	void CallDeclareDelegate();
	//
	//	Call Declare Multicast Delegate
	//
	UFUNCTION()
	void CallDeclareMulticastDelegate();
	//
	//	Call Declare Dynamic Delegate
	//
	UFUNCTION()
	void CallDeclareDynamicDelegate();
	//
	//	Call Declare Dynamic Multicast Delegate
	//
	UFUNCTION()
	void CallDeclareDynamicMulticastDelegate();
};
#include "DelegateController.h"

#include "DelegateGameMode.h"
#include "Kismet/GameplayStatics.h"

void ADelegateController::SetupInputComponent()
{
	Super::SetupInputComponent();
	InputComponent->BindAction("DeclareDelegate", IE_Pressed, this, &ThisClass::CallDeclareDelegate);
	InputComponent->BindAction("DeclareMulticastDelegate", IE_Pressed, this, &ThisClass::CallDeclareMulticastDelegate);
	InputComponent->BindAction("DeclareDynamicDelegate", IE_Pressed, this, &ThisClass::CallDeclareDynamicDelegate);
	InputComponent->BindAction("DeclareDynamicMulticastDelegate", IE_Pressed, this, &ThisClass::CallDeclareDynamicMulticastDelegate);
}

void ADelegateController::CallDeclareDelegate()
{
	if(GetWorld() == nullptr) return;
	
	const ADelegateGameMode* DelegateGameMode = Cast<ADelegateGameMode>(UGameplayStatics::GetGameMode(GetWorld()));
	if(DelegateGameMode == nullptr) return;
	
	if(DelegateGameMode->DeclareDelegate_00.IsBound())
	{
		DelegateGameMode->DeclareDelegate_00.Execute();
	}
	DelegateGameMode->DeclareDelegate_01.ExecuteIfBound(true);
	DelegateGameMode->DeclareDelegate_02.ExecuteIfBound(true, 11);
	if(DelegateGameMode->DeclareDelegate_03.IsBound())
	{
		bool bValue = DelegateGameMode->DeclareDelegate_03.Execute();
	}
	if(DelegateGameMode->DeclareDelegate_04.IsBound())
	{
		bool bValue = DelegateGameMode->DeclareDelegate_04.Execute(true);
	}
}

void ADelegateController::CallDeclareMulticastDelegate()
{
	if(GetWorld() == nullptr) return;
	
	const ADelegateGameMode* DelegateGameMode = Cast<ADelegateGameMode>(UGameplayStatics::GetGameMode(GetWorld()));
	if(DelegateGameMode == nullptr) return;
	
	if(DelegateGameMode->DeclareMulticastDelegate_00.IsBound())
	{
		DelegateGameMode->DeclareMulticastDelegate_00.Broadcast();
	}
	if(DelegateGameMode->DeclareMulticastDelegate_01.IsBound())
	{
		DelegateGameMode->DeclareMulticastDelegate_01.Broadcast(11);
	}
}

void ADelegateController::CallDeclareDynamicDelegate()
{
	if(GetWorld() == nullptr) return;
	
	const ADelegateGameMode* DelegateGameMode = Cast<ADelegateGameMode>(UGameplayStatics::GetGameMode(GetWorld()));
	if(DelegateGameMode == nullptr) return;
	
	if(DelegateGameMode->DeclareDynamicDelegate_00.IsBound())
	{
		DelegateGameMode->DeclareDynamicDelegate_00.Execute();
	}
	DelegateGameMode->DeclareDynamicDelegate_01.ExecuteIfBound(11);
	if(DelegateGameMode->DeclareDynamicDelegate_02.IsBound())
	{
		bool bValue = DelegateGameMode->DeclareDynamicDelegate_02.Execute();
	}
	if(DelegateGameMode->DeclareDynamicDelegate_03.IsBound())
	{
		bool bValue = DelegateGameMode->DeclareDynamicDelegate_03.Execute(11);
	}
}

void ADelegateController::CallDeclareDynamicMulticastDelegate()
{
	if(GetWorld() == nullptr) return;
	
	const ADelegateGameMode* DelegateGameMode = Cast<ADelegateGameMode>(UGameplayStatics::GetGameMode(GetWorld()));
	if(DelegateGameMode == nullptr) return;
	
	if(DelegateGameMode->DeclareDynamicMulticastDelegate_00.IsBound())
	{
		DelegateGameMode->DeclareDynamicMulticastDelegate_00.Broadcast();
	}
	if(DelegateGameMode->DeclareDynamicMulticastDelegate_01.IsBound())
	{
		DelegateGameMode->DeclareDynamicMulticastDelegate_01.Broadcast(11);
	}
}

七、运行结果

1、运行开始

2、调用单播

3、调用多播

再次调用

4、调用动态单播

5、调用动态多播

6、运行结束

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Python中的Slice函数:灵活而强大的序列切片技术

更多资料获取 &#x1f4da; 个人网站&#xff1a;ipengtao.com Python中的Slice函数是一种强大且灵活的序列切片技术&#xff0c;用于从字符串、列表、元组等序列类型中提取子集。本文将深入研究Slice函数的功能和用法&#xff0c;提供详细的示例代码和解释&#xff0c;帮助读…

java操作windows系统功能案例(一)

下面是一个Java操作Windows系统功能的简单案例&#xff1a; 获取系统信息&#xff1a; import java.util.Properties;public class SystemInfo {public static void main(String[] args) {Properties properties System.getProperties();properties.list(System.out);} }该程…

【智能家居】三、添加语音识别模块的串口读取功能点

语音识别模块SU-03T 串口通信线程控制代码 inputCommand.h&#xff08;输入控制指令&#xff09;voiceControl.c&#xff08;语音控制模块指令&#xff09;main.c&#xff08;主函数&#xff09;编译运行结果 语音识别模块SU-03T AI智能语音识别模块离线语音控制模块语音识别…

以STM32CubeMX创建DSP库工程方法一

以STM32CubeMX创建DSP库工程方法 略过时钟树的分配和UART的创建等&#xff0c;直接进入主题生成工程文件 它们中的文件功能如下&#xff1a; 1&#xff09;BasicMathFunctions 基本数学函数&#xff1a;提供浮点数的各种基本运算函数&#xff0c;如向量加减乘除等运算。 2&…

基于SSM框架的餐馆点餐系统的设计

末尾获取源码 开发语言&#xff1a;Java Java开发工具&#xff1a;JDK1.8 后端框架&#xff1a;SSM 前端&#xff1a;Vue 数据库&#xff1a;MySQL5.7和Navicat管理工具结合 服务器&#xff1a;Tomcat8.5 开发软件&#xff1a;IDEA / Eclipse 是否Maven项目&#xff1a;是 目录…

11.30 C++类特殊成员函数

#include <iostream>using namespace std; class Per { private:string name;int age;double *high;double weight; public://构造函数Per(string name,int age,double high,double weight):name(name),age(age),high(new double(high)),weight(weight){cout << &q…

ECONGU4280 Corporate Finance

ECONGU4280 Corporate Finance WeChat: zh6-86

Linux系统编程 day07 信号

Linux系统编程 day07 信号 1. 信号的介绍以及信号的机制2. 信号相关函数2.1 signal2.2 kill2.3 abort和raise2.4 alarm2.5 setitimer 3. 信号集4. 信号捕捉函数6. SIGCHLD信号7. SIGUSR1与SIGUSR2 1. 信号的介绍以及信号的机制 信号是信息的载体&#xff0c;在Linux/Unix环境下…

对话 AI for Science 先行者,如何抓住科研范式新机遇?丨和鲸社区2023年度科研闭门会

2023年3月&#xff0c;科技部会同自然科学基金委启动了 AI for Science 的专项部署工作。数据驱动的科学研究长期以来面临着诸多困境&#xff0c;针对传统科研工作流中过度依赖人类专家经验与体力的局限性&#xff0c;AI for Science 旨在基于科学数据与算力支撑&#xff0c;通…

香港高端人才通行证计划入围高校名单公布,如何申请?

香港高端人才通行证计划入围高校名单公布&#xff0c;如何申请&#xff1f; 高端人才通行证计划&#xff08;英语&#xff1a;Top Talent Pass Scheme (TTPS)&#xff09;&#xff0c;简称“高才通计划”&#xff0c;是香港为了吸引世界各地具备丰富工作经验及高学历的高端人才…

力扣题:单词-11.20

力扣题-11.20 [力扣刷题攻略] Re&#xff1a;从零开始的力扣刷题生活 力扣题1&#xff1a;58. 最后一个单词的长度 解题思想&#xff1a;按空格划分&#xff0c;然后统计单词长度即可 class Solution(object):def lengthOfLastWord(self, s):""":type s: str…

2021年6月23日 Go生态洞察:Stack Overflow上的Go集体

&#x1f337;&#x1f341; 博主猫头虎&#xff08;&#x1f405;&#x1f43e;&#xff09;带您 Go to New World✨&#x1f341; &#x1f984; 博客首页——&#x1f405;&#x1f43e;猫头虎的博客&#x1f390; &#x1f433; 《面试题大全专栏》 &#x1f995; 文章图文…

安全高效的PostgreSQL数据库迁移解决方案

PostgreSQL数据库是一款高度可扩展的开源数据库系统&#xff0c;支持复杂的查询、事务完整性和多种数据类型&#xff0c;这使得它成为企业中处理大规模和多样化数据需求的理想选择。在很多企业中&#xff0c;PostgreSQL不仅处理大量的交易数据&#xff0c;还支持复杂的数据分析…

java开发之基于个微群聊二次开发

请求URL&#xff1a; http://域名地址/getGroupQrCode 请求方式&#xff1a; POST 请求头Headers&#xff1a; Content-Type&#xff1a;application/jsonAuthorization&#xff1a;login接口返回 参数&#xff1a; 参数名必选类型说明wId是String登录实例标识chatRoomI…

C++ 单词拆分

题目1&#xff1a;139 单词拆分 题目链接&#xff1a;单词拆分 对题目的理解 字符串列表wordDict作为字典&#xff0c;判断是否可以利用字典中出现的单词拼接出字符串s&#xff0c;字典中的单词可以重复使用&#xff0c;题目中字符串s的长度至少为1&#xff0c;不存在空字符…

YOLOv5独家原创改进: AKConv(可改变核卷积),即插即用的卷积,效果秒杀DSConv | 2023年11月最新发表

💡💡💡本文全网首发独家改进:可改变核卷积(AKConv),赋予卷积核任意数量的参数和任意采样形状,为网络开销和性能之间的权衡提供更丰富的选择,解决具有固定样本形状和正方形的卷积核不能很好地适应不断变化的目标的问题点,效果秒殺DSConv 1)AKConv替代标准卷积进行…

Attacking Fake News Detectors via Manipulating News Social Engagement(2023 WWW)

Attacking Fake News Detectors via Manipulating News Social Engagement----《通过操纵新闻社交互动来攻击假新闻检测器》 摘要 在年轻一代中&#xff0c;获取新闻的主要来源之一是社交媒体。随着新闻在各种社交媒体平台上日益流行&#xff0c;虚假信息和毫无根据的言论的传…

GPU逻辑管线

文章目录 前言一、渲染流水线二、英伟达显卡简化概念图&#xff08;GPU&#xff09;1、我们的Shader会调用英伟达提供的 API2、调用API后&#xff0c;把Shader用到的指令存储在Pushbuffer中3、然后图元分配器&#xff0c;会把 模型数据 和 Shader 指令传入GPU中4、这个SM是每个…

VGN S99快捷键,说明书

VGN S99快捷键-说明书 按键说明灯光效果常见疑难 按键说明 切换关闭电量指示灯&#xff1a;Fn home 灯光效果 常见疑难

GAN:WGAN

论文&#xff1a;https://arxiv.org/pdf/1701.07875.pdf 发表&#xff1a;2017 WGAN 算法流程 从GAN 到 WGAN 的转变 相比于原始 GAN&#xff0c;WGAN 只需要修改以下几点&#xff0c;就能使得训练更稳定&#xff0c;生成质量更高&#xff1a; 1. 此时的判别器相当于做回归…