简体   繁体   中英

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 . 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 ...) . 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 )

I would need to find a way to share the data of some classes inside system shared memory areas (POD data).

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. 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 的实用程序以及相当复杂的概念。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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