简体   繁体   English

模块化 C++ 应用程序设计和 shm 共享内存

[英]modular c++ application design and shm shared memory

I need to refactor an industrial process application in order to be very easily modular/customisable.我需要重构一个工业过程应用程序,以便非常容易地模块化/可定制。

This application will use module/plugins .此应用程序将使用 module/plugins 。 each module contains a func available to drive an unit (imagine it like a 3D printer, I have XY unit , head heating unit, wire feeding unit ...) .每个模块都包含一个可用于驱动一个单元的功能(把它想象成一台 3D 打印机,我有 XY 单元、头部加热单元、送丝单元......)。 But my application is really bigger than that ...但我的应用程序真的比那更大......

Each of these plugins must share data resources through shared memory areas in the system (for gui processes )这些插件中的每一个都必须通过系统中的共享内存区域共享数据资源(对于 gui 进程)

I would need to find a way to share the data of some classes inside system shared memory areas (POD data).我需要找到一种方法来共享系统共享内存区域(POD 数据)内某些类的数据。

The challenge is to find a way to implement it in the easiest possible way.挑战在于找到一种以最简单的方式实施它的方法。 templates, namespaces... or other c++17 features may be welcome.模板、命名空间...或其他 c++17 特性可能会受到欢迎。 It may involve complete thinking/refactoring of the existing application.它可能涉及对现有应用程序的完整思考/重构。 At the moment, this means I have some class with a struct containing data :目前,这意味着我有一个包含数据结构的类:

typedef struct mydata {
   int data1;
   float data2;
} T_mydata; 


struct{
   // some data ...
   ...
   // ptr to class struct data 
   T_mydata a_ptr;
   // some other data ...
}
*shmptr;

class A {
T_mydata *data_ptr; // will point *shmptr->a_ptr;
... 
};

为了实现共享内存、通信等, boost::interprocess库具有用于 simpel 的实用程序以及相当复杂的概念。

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

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