
On Fri, Jul 18, 2008 at 11:36 PM, Zeljko Vrba <zvrba@ifi.uio.no> wrote:
[snip]
The fusion manual is severely lacking in motivation, esp. when it comes to transformations, so any examples from the real world are welcome.
Hi Zeljko, I have been using Fusion extensively in the Dataflow library (http://www.dancinghacker.com/code/dataflow/), and for many of the uses I can't think of a good replacement for using fusion. Here are some examples: * components of the Dataflow.Signals layer use fusion containers with functional adapters to deal with variable numbers of parameters. Furthermore, once the parameters are received as a fusion Sequence, the component can use fusion transformations to do its job. The storage component, for example, whose job is to store the values of the arguments it receives, has to transform the Sequence vector type into something storable (if it receives fusion::vector<const float, int &> it needs to store the values in a fusion::vector<float, int>). Fusion transformations take care of the type transform, and fusion takes care of getting the values from the parameter vector to the storage vector. * the generic dataflow layer has a KeyedPort concept - which describes a port that actually contains a number of subports. The subport that gets used for a particular operation is determined by the type of the port that the keyed port is interacting with. For example, I might have a keyed port type K that has subports of type KA and type KB. KA is intended for connections with ports of type A, and KB is intended for connections with ports of type B. The keyed port takes care of resolving the right connection automatically - if I try to connect a K port to an A port, it will know to connect KA to A. If I try to connect a K port to a B port, it will know to connect KB to B. This is accomplished using a fusion map. * the components of the Dataflow.Managed layer (implemented recently) uses fusion vectors to store all of its ports (All I have to say is I want a component that consumes a bool and produces a float and an int, e.g., managed::component<bool, mpl::vector<float,int> >, and the component figures out what types of ports it needs and keeps them in a fusion vector). The problem is, the ports are not default constructible. Fusion transformations take care of getting the right argument to the constructors of the ports. These are just some of the examples that come to mind... Kind regards, Stjepan