0

So I have some simple generator class that is much alike this a datatype like this (pointer and length) and a simple costume datatype renderer like this. How to create a graph that would help me pass generated data into my renderer?

Currently I do something like this to pass my Char Ptr to data generator and than result to renderer:

     renderer->renderCastedData(producer->updateData(CharPtr));

But I would love to see if it is possible to use Boost Graph to map a Data representing class to some classes as input to some functions and returns of that functions some other classes? Generally having a "Graph" I want to be capable to call Graph(MyInstanceOfMyDatatype) and have boost pass my value (with minimal coping) from one graph element to another?

This is quite super simple sample so it may seem graph is overkill but I want to have graph for automated values passing between my classes in case for example of having one generator and N renderers - here I want graph to help me with for example providing N-1 copys of my class to all renderers except first.

Rella
  • 65,003
  • 109
  • 363
  • 636

1 Answers1

1

It seems that what you're looking for is a framework that allows you to extend the simple producer-consumer pattern into a mesh of consumers, concurrently fed by a single producer.

This is not what Boost.Graph provides. Boost.Graph is a collection of abstract procedures (algorithms) defined on a set of graph concepts. It assumes you already have a data structure that has graph properties (vertexes and edges, and iterators over them, mostly), and lets you apply its algorithms (maximum flow, shortest distance, etc) to it. In addition, it comes with some simple graph models (adjacency matrix/list) in case you don't already have graph classes.

Your usecase is similar to the Unix tee command. While I don't know a tee implementation for the particular library you are using, it's usually not too complicated to implement a TeeConsumer that acts as a producer for all its registered child consumers.

Here's a blog post of a colleague of mine about implementing a tee device for Qt's QIODevice, which might help you get started.

Marc Mutz - mmutz
  • 24,485
  • 12
  • 80
  • 90