Boost.Graph - 有 2 个简单类和一个类 - 数据类型如何创建图形?

发布于 2024-11-02 12:11:16 字数 940 浏览 1 评论 0原文

所以我有一些非常相似的简单生成器类 (指针和长度)和一个简单的服装数据类型渲染器,例如 。如何创建一个图表来帮助我将生成的数据传递到渲染器中?

目前,我做了这样的事情,将我的 Char Ptr 传递给数据生成器,然后将结果传递给渲染器:

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

但我很想看看是否可以使用 Boost Graph 将表示类的数据映射到某些类,作为某些函数的输入并返回该函数还有其他类吗?一般来说,我希望能够调用 Graph(MyInstanceOfMyDatatype) 并让 boost 将我的值(以最小的处理方式)从一个图形元素传递到另一个图形元素?

这是一个非常超级简单的示例,所以看起来图似乎有点过头了,但我希望有一个图来在我的类之间传递自动值,例如有一个生成器和 N 个渲染器 - 在这里我希望图可以帮助我,例如提供 N -1 将我的类的副本复制到除第一个之外的所有渲染器。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沙沙粒小 2024-11-09 12:11:16

看来您正在寻找的是一个框架,该框架允许您将简单的生产者-消费者模式扩展到消费者网格中,并由单个生产者同时提供。

这不是 Boost.Graph 提供的。 Boost.Graph 是在一组图概念上定义的抽象过程(算法)的集合。它假设您已经拥有一个具有图形属性(主要是顶点和边,以及它们之上的迭代器)的数据结构,并允许您对其应用其算法(最大流、最短距离等)。此外,它还附带一些简单的图形模型(邻接矩阵/列表),以防您还没有图形类。

您的用例类似于 Unix tee 命令。虽然我不知道您正在使用的特定库的 tee 实现,但实现充当所有注册子消费者的生产者的 TeeConsumer 通常并不太复杂。

这是我的一位同事的博客文章,内容涉及为 Qt 的 QIODevice 实现一个 tee 设备,这可能会帮助您入门。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文