Boost logo

Boost Users :

Subject: [Boost-users] Boost.Interprocess with complex/nested classes
From: Rick Hullinger (rhullinger_at_[hidden])
Date: 2010-08-11 15:33:25


I think I finally have a grasp on the basics of the boost:interprocess
library, and I've been using it successfully when dealing with
relatively simple classes that contain a few member variables that are
all standard data types.

However, I am now faced with the problem of pushing a rather complex
class out into interprocess shared memory and I'm having no luck at
all. I'm hoping someone here can help (or can steer me towards an
alternate solution). Stripping it down to what I hope are the basics,
I have something along these lines:

// these first two structures are from the Gnu Scientific Library, so I can't
// (or won't) be able to mess with the definition of these structures.
typedef struct
{
    size_t size1;
    size_t size2;
    size_t tda;
    double * data;
    gsl_block * block;
    int owner;
} gsl_matrix;

typedef struct
{
    size_t size1;
    size_t size2;
    size_t tda;
    int * data;
    gsl_block_int * block;
    int owner;
} gsl_matrix_int;

// pointers to matricies and other data
class MyMatrixClass
{
    gsl_matrix_int* m_pIntMatrix;
    gsl_matrix*     m_pDblMatrix;
    unsigned int iVal1;
    unsigned int iVal2;
}

// some other data-filled class
class MyOtherDataClass
{
    std::vector<int> m_vInputs;
    std::vector<double> m_vOutputs;
    std::string m_sTitle;
    bool m_bCorrect;
}

// and finally, the class that encapsulates the above classes, and
// the one that I want to be able to share across processes
class SharedClass
{
    MyMatrixClass* m_pNumbers;
    std::vector<double> m_vDblData;
    std::vector<MyOtherDataClass> m_vOtherData;
}

What I need to do is create a vector of SharedClass objects in the
interprocess memory space so that multiple processes can access the
data. No matter what I try, I cannot seem to find a solution. I

It seems like there should be an easier way than making every single
member variable along the way an interprocess version
(interprocess::vector, interprocess::string, offset_ptr, etc), but
maybe not. And even then, I'm not sure how to deal with all the
allocators and such, not to mention the GSL library structures.

Any help that can be provided will be greatly appreciated. Thank you!


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net