Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6584251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:30:47+00:00 2026-05-25T16:30:47+00:00

In C++ I have the following two classes that I expose (using Boost) to

  • 0

In C++ I have the following two classes that I expose (using Boost) to Python:

struct Foo {
    // Empty
};

struct FooContainer {
    // I use boost::shared_ptr for compatibility with Boost.Python
    vector<boost::shared_ptr<Foo>> foos_;
};

In the Python side I might create a special type of Foo that actually does something instead of being just an empty class, and then add it to a FooContainer:

class Useful(Foo):
    def __init__(self, a, b):
        self.a = a
        self.b = b

x = Useful(3, 5);
# Add 'x' to a `FooContainer`

Back in the C++ side, the FooContainer now has some Foos, but it doesn’t know or care that they are from Python. The application runs for a while and the data in the Foo objects changes…

Then I decide I want to save the state of my program so I can load it at a later time. But the problem is that FooContainer doesn’t know much about its Foo objects, it doesn’t even know that they come from Python and I wouldn’t want to pollute my FooContainer with data that doesn’t really belong in it (single-responsibility principle and all that).

Do you have any advice on how I should organize my application such that saving and loading data, as well as loading fresh data (ie. not from a state that I saved in the past) can be done in a clear way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:30:48+00:00Added an answer on May 25, 2026 at 4:30 pm

    You can use boost::python/pickle, and save the data from python. I only have limited experience with the pickling suite, but it should work provided you override appropriate pickling methods in your classes derived in python (see my answer to this question).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

assume that I have the following two template classes : template <class _A> class
I have the following issue. I have two classes that manipulate information but they
Lets say that I have the two following classes public class OtherClass { public
I have the following two classes, one inherits from the other Class A{ void
I have the following two classes: public class Address { public string AddressLine1 {
I'm learning C# and I encountered the following problem. I have two classes: base
I have two entity classes annotated in the following way @Entity class A {
Consider the following example. I have an interface MyInterface, and then two abstract classes
Suppose we have following two classes: class Temp{ public: char a; char b; };
Say i have the following two classes: public class User { public int ID

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.