简体   繁体   English

实现主C ++程序与嵌入式ECL之间的通信

[英]Achieving communication between main c++ program and embedded ECL

I'm trying to extend a c++ 3d simulation I'm working on with a second language (at the moment ECL) to dynamically influence it at runtime. 我正在尝试使用第二种语言(目前为ECL)扩展我正在使用的c ++ 3d仿真,以在运行时动态地影响它。 That is, I want to be able to have a script like this evaluated: (move object xy) that will move "object" to the position (x,y). 也就是说,我希望能够有一个这样的脚本进行评估:(移动对象xy),它将“对象”移动到位置(x,y)。

The problem is that in order for this to work the ECL environment needs to call some c++ member function of eg an instance of the corresponding node of the object to move it. 问题是,为了使它起作用,ECL环境需要调用某些c ++成员函数(例如,对象的相应节点的实例)来移动它。 Now I know how to embed for example ECL and have arbitrary code evaluated and also how to call plain c functions from some library, but I don't see how I can tell the ECL environment about specific instances and how to call their methods. 现在,我知道如何嵌入例如ECL并评估任意代码,以及如何从某个库中调用纯c函数,但是我看不到如何向ECL环境告知特定实例以及如何调用其方法。

I suppose this a common thing (if not with ECL) to do and yet I haven't been able to find any information how to do this when the main program is written in c++ and uses some OO. 我想这是很平常的事情(如果没有使用ECL的话),但是当主程序用c ++编写并使用一些OO时,我仍然找不到任何信息来做到这一点。

You could make a command line interface for the C++ application and then communicate via pipe. 您可以为C ++应用程序创建命令行界面,然后通过管道进行通信。 That is what I do. 那就是我所做的。 Its straightforward and for me it is fast enough. 它简单明了,对我来说它足够快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM