经历一个A4Solution [英] going through an A4Solution
问题描述
我目前使用合金API在我的项目,我需要显示A4Solutions.I可以与vizualiser合金提供(vizGUI)做到这一点很容易,但它是我的目的有点太有限了。所以,我愿意来生成自己的图形(使用任何其他图形API)从A4Solution对象。
I am currently using the Alloy api in my project, and I need to display A4Solutions.I can do that easily with the vizualiser Alloy provides (vizGUI) , but it is a bit too limited for my purpose. So I am willing to generate my own graphs ( using any other graph api ) from an A4Solution objects.
我能获得原子没有任何问题(这是pretty直线前进),但我实在看不出如何检索这些原子之间的关系。
I was able to get the Atoms without any problems (that was pretty straight forward ) but I can't really see how to retrieve the relations between those atoms.
我在网上找了有关如何解析A4Solution一些例子,但一无所获可惜。
I looked online for some example about how to parse an A4Solution, but found nothing unfortunately.
推荐答案
关系,或字段,你可以从SIGS检索,然后你就可以对其进行评估,以获得具体的原子,这样的事情:
Relations, or fields, you can retrieve from sigs, and then you can evaluate them to obtains concrete atoms, something like this:
A4Solution sol = ...;
SafeList<Sig> sigs = sol.getAllReachableSigs();
for (Sig sig : sigs) {
SafeList<Field> fields = sig.getFields();
for (Field field : fields) {
A4TupleSet ts = (A4TupleSet)(sol.eval(field));
for(A4Tuple t: ts)
for(int i=0; i<t.arity(); i++)
t.atom(i);
}
}
这篇关于经历一个A4Solution的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!