通过多个功能发送任意数据 [英] Sending arbitrary data through several functions

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

问题描述

在制作遵循状态设计模式(正在工作的状态)时的状态系统到目前为止相当不错),我现在想知道是否有办法发送任意数据到这个系统。我认为这可能是使用刺激类。

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天全站免登陆