通过几个函数发送任意数据 [英] Sending arbitrary data through several functions

查看:141
本文介绍了通过几个函数发送任意数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在制作遵循状态设计模式的状态系统时(该模式工作正常到目前为止),我现在想知道是否有一种方法来发送任意数据到这个系统。我认为这可能是使用Stimulus类。

While making a state system that follows the state design pattern (which is working quite well so far) and I am now wondering if there is a way to send arbitrary data to this system. I was thinking that this might be possible using a Stimulus class.

系统本身被合成到另一个可以响应刺激的对象,状态机和状态本身也可以有刺激,并且它们将通过函数调用从外层传递到内层。问题是,刺激需要携带任意数据到这些不同的级别,我不能想到一个简单的方法来得到它。

The system itself is composited into another object that can respond to the stimuli, and both the state machine and the states themselves can have stimuli as well, and they will be passed from the outer to the inner levels via function calls. The problem being that the stimuli need to carry arbitrary data to these different levels, and I can't think of a simple way to get it out.

我在想可能使用 dynamic_cast ,但我想知道是否可能有更好的方法。

I was thinking that it might be possible using a dynamic_cast, but I was wondering if there might be a better way.

推荐答案

boost :: any可能对你有用,取决于你在做什么。

boost::any might be of use to you depending on what you are doing.

这篇关于通过几个函数发送任意数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆