473,657 Members | 2,430 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C++ and persistent objects

Typically C++ persistence implementations , (from the little I've seen),
boils down to something like this:

myclass {
int ivar;
float fvar;
...

saveyourself( file )
{
file.write(ivar );
file.write(fvar );
...
}

};

With this approach we always have to write the code to unwind the variables
to or from the storage media. This can be a big job for objects that involve
complex class hierarchies, and it could impact performance as well.

Another approach is to write/read binary chunks and then use inplace
activation techniques. This is better but what happens when the structure
changes ..., then you need to write conversion functions and you end up
writing code similar to the above where you need to unwind the variables
again.

I'm thinking there must be a better way. After all isn't this exactly what
COM and Corba or XML does to marshal an interface or data structure. With
these frameworks you generally don't have to do the unwinding code yourself
there is typically a tool that does it for you. Is there a way to leverage
these tools to solve the C++ persistence problem, or perhaps there is some
other code available? Am I missing something here?
Any suggestions or links?

Thanks,
Perry.


Jul 22 '05 #1
2 8026
Perry St-Germain wrote:
Typically C++ persistence implementations , (from the little I've seen),
boils down to something like this:
Ah - a favorite topic of mine ...

These are a couple of URL's to google past comp.lang.c++ posts on this
topic.

http://tinyurl.com/vgbc
http://tinyurl.com/vgbs


myclass {
int ivar;
float fvar;
...

saveyourself( file )
{
file.write(ivar );
file.write(fvar );
...
}

};

With this approach we always have to write the code to unwind the variables
to or from the storage media. This can be a big job for objects that involve
complex class hierarchies, and it could impact performance as well.

Another approach is to write/read binary chunks and then use inplace
activation techniques. This is better but what happens when the structure
changes ..., then you need to write conversion functions and you end up
writing code similar to the above where you need to unwind the variables
again.

I'm thinking there must be a better way. After all isn't this exactly what
COM and Corba or XML does to marshal an interface or data structure. With
these frameworks you generally don't have to do the unwinding code yourself
there is typically a tool that does it for you. Is there a way to leverage
these tools to solve the C++ persistence problem, or perhaps there is some
other code available? Am I missing something here?
Any suggestions or links?


I have found that the fastest form of IO on almost any platform is a
mapped file. C++ has no built-in support for mapped files so you're in
OS dependant land but this is a very thin layer.

You could theoretically make a "portable" format for mapped files that
works on a large subset of computing platforms today.
Jul 22 '05 #2

"Perry St-Germain" <px************ *@videotron.ca> wrote in message
news:yj******** *************@w agner.videotron .net...
Typically C++ persistence implementations , (from the little I've seen),
boils down to something like this:

myclass {
int ivar;
float fvar;
...

saveyourself( file )
{
file.write(ivar );
file.write(fvar );
...
}

};
This is serialization, which can be used to implement persistence. Join the
boost.org development mailing list where Robert Ramey is refining an
implementation which he is planning on submitting to boost. He's separated
the medium ( text/binary/xml/... archives ) from the serialization
machinery. His library supports both non-intrusive as well as intrusive
serialization capabilities.
With this approach we always have to write the code to unwind the variables to or from the storage media. This can be a big job for objects that involve complex class hierarchies, and it could impact performance as well.
I assume by "unwinding" you mean "load"? You may handle load/store with a
single serialize function ala:

template<class Archive>
void serialize( Archive &ar, unsigned int version )
{
ar & ivar;
ar & fvar;
}
Another approach is to write/read binary chunks and then use inplace
activation techniques. This is better but what happens when the structure
changes ..., then you need to write conversion functions and you end up
writing code similar to the above where you need to unwind the variables
again.

I'm thinking there must be a better way. After all isn't this exactly what
COM and Corba or XML does to marshal an interface or data structure. With
these frameworks you generally don't have to do the unwinding code yourself there is typically a tool that does it for you. Is there a way to leverage
these tools to solve the C++ persistence problem, or perhaps there is some
other code available? Am I missing something here?

The only systems of this ilk that I know of are:

http://www.cs.utexas.edu/users/oops/papers.html#texas

Which is a research project at university of texas. I haven't seen any work
done on this in quite some time.

http://www.objectstore.net/products/index.ssp

A commercially available system. Quite powerful/large/complex, but does what
your asking for.

What these systems generally require is some sort of external definition
language akin to COM's IDL. IMO this is a major drawback, requiring
knowledge of another language and maintenance of another set of code. Bjarne
Stroustrup has a paper on XTI - Extended Type Information Library - that
possibly could negate the need for this redundancy.

Persistence is much more complex than one first imagines. Robert Ramey's
serialization library, IMO is the most comprehensive, easiest to use and
least expensive(free) alternative that I've seen.

-----------------
Jeff Flinn
Applied Dynamics, International

Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5678
by: Daniel T. | last post by:
Can someone point me to a tutorial on object persistency in the Java language? Thanks,
16
3306
by: Paul Rubin | last post by:
I've had this recurring half-baked desire for long enough that I thought I'd post about it, even though I don't have any concrete proposals and the whole idea is fraught with hazards. Basically I wish there was a way to have persistent in-memory objects in a Python app, maybe a multi-process one. So you could have a persistent dictionary d, and if you say d = Frob(foo=9, bar=23) that creates a Frob instance and stores it in d. Then if...
4
2450
by: M?rio Amado Alves | last post by:
Will you help an outsider trying to trace the current state of persistent object technology? "I expect that there will be persistent object stores with STL-conforming interfaces fitting into the STL framework within the next year." --Alexander Stepanov, 1995 Has this happened? (In 1996 or another year.)
1
1503
by: Johan | last post by:
Hi, The problem is : You have a class A with one or more data variables. You want to store the data variables in a database for example MySQL. Also you do not want to have SQL code in your class A. Is there a way to translate the Object A to a sql independed structure. I think it is something with persistent objects or am I wrong. has anyone experience with this ?
3
4289
by: sanchita | last post by:
Hello everyone, I didn't get any response in "Security" forum hence posting here again. I am having problem with persistent cookies. Even after setting "CreatePersistentCookie" to true in "FormsAuthentication.SetAuthCookie" I'm being logged out after the specifed timeout provided in "forms" element of web.config. I read somewhere that lifetime of persistent cookies depend on the timeout
9
2673
by: mel | last post by:
Hi all, I need a persistent TCP connection with my web server over page reloads. This means that, even if the user goes to a different page (in my domain), I want to keep a TCP connection live. I know I can do something similar with globalStorage in FF, window.name & userData on IE, but those storages only hold strings.
4
2404
by: castironpi | last post by:
Some time ago, I was asking about the feasibility of a persistent deque, a double-ended queue. It runs into the typical space allocation problems. If you're storing a pickle, you have to allocate and fragment the file you've opened, since pickles can be variable-length strings; i.e. if the new data is too long, blank out its entry, and grow the file. If you're storing a data-type, you lose Python's dynamic-type advantages, as well as...
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.