470,870 Members | 1,431 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,870 developers. It's quick & easy.

Reg C++ implementation for in memory database

Hi,
I have a container that holds objects of same type (user defined
class), where each object has multiple attributes. These objects have
primary key (similar to a database) formed by combination of two
attributes, but I want to support multiple views of data by looking at
different combination of attributes and in some cases I might want to
combine these. For instance, lets say the class has four attributes
a1,a2,a3,a4; and primary key is a1+a4, now I can construct a view that
has subset of objects of this class by doing a search on these objects
that have specific values for attribute a3, and this can give me back
multiple objects and I want to combine the objects that have same
value for a2 into one ; this looks like a classic database
implementation but I dont have real database in my case, instead I have
set of objects and the query I am doing is on these objects based on
combination of attributes of the class. Any pointers on how to do this
using STL classes would be appreciated. I am looking into using
associative containers.. Is this already implemented by someone? I dont
care too much about efficiency since I wont have more than 100 of these
objects...
Thanks,
Sunil.

May 7 '06 #1
10 5073
Try a STL map type, keyed on an object that is a combination of a1 and
a4.

May 8 '06 #2
sunil wrote:
I have a container that holds objects of same type (user defined
class), where each object has multiple attributes. These objects have
primary key (similar to a database) formed by combination of two
attributes, but I want to support multiple views of data by looking at
different combination of attributes and in some cases I might want to
combine these. For instance, lets say the class has four attributes
a1,a2,a3,a4; and primary key is a1+a4...


sqlite is trivial to install and run. It works off a data file and can do
arbitrarily complex SQL statements, such as joins.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
May 8 '06 #3
sunil wrote:
Hi,
I have a container that holds objects of same type (user defined
class), where each object has multiple attributes. These objects have
primary key (similar to a database) formed by combination of two
attributes, but I want to support multiple views of data by looking at
different combination of attributes and in some cases I might want to
combine these.
[...]
this looks like a classic database
implementation but I dont have real database in my case, instead I have
set of objects and the query I am doing is on these objects based on
combination of attributes of the class. Any pointers on how to do this
using STL classes would be appreciated. I am looking into using
associative containers.. Is this already implemented by someone? I dont
care too much about efficiency since I wont have more than 100 of these
objects...
Thanks,
Sunil.


Boost.MultiIndex library can do this sort of thing:
http://www.boost.org/libs/multi_index/doc/index.html

Also there is relational Template Library (RTL) in boost sandbox:
http://tinyurl.com/zwe2o

regards
Andy Little

May 8 '06 #4

an**@servocomm.freeserve.co.uk wrote:
Boost.MultiIndex library can do this sort of thing:
http://www.boost.org/libs/multi_index/doc/index.html

Also there is relational Template Library (RTL) in boost sandbox:
http://tinyurl.com/zwe2o


Also forgot about fusion, though you would need to implement your data
as tuples for this library:

http://spirit.sourceforge.net/dl_mor...tml/index.html

regards
Andy Little

May 8 '06 #5
On 8 May 2006 01:39:13 -0700, an**@servocomm.freeserve.co.uk wrote:
an**@servocomm.freeserve.co.uk wrote:
Boost.MultiIndex library can do this sort of thing:
http://www.boost.org/libs/multi_index/doc/index.html
Also there is relational Template Library (RTL) in boost sandbox:
http://tinyurl.com/zwe2o

Also forgot about fusion, though you would need to implement your data
as tuples for this library:
http://spirit.sourceforge.net/dl_mor...tml/index.html


Have you actually used one of those libraries?
May 10 '06 #6
On Tue, 09 May 2006 17:56:39 GMT, I waved a wand and this message
magically appeared from Roland Pibinger:

[ Boost stuff snipped ]
Have you actually used one of those libraries?


All I got was a headache!
--
http://www.munted.org.uk

Take a nap, it saves lives.
May 10 '06 #7

Roland Pibinger wrote:
On 8 May 2006 01:39:13 -0700, an**@servocomm.freeserve.co.uk wrote:
an**@servocomm.freeserve.co.uk wrote:
Boost.MultiIndex library can do this sort of thing:
http://www.boost.org/libs/multi_index/doc/index.html
Also there is relational Template Library (RTL) in boost sandbox:
http://tinyurl.com/zwe2o

Also forgot about fusion, though you would need to implement your data
as tuples for this library:
http://spirit.sourceforge.net/dl_mor...tml/index.html


Have you actually used one of those libraries?


No.

regards
Andy Little

May 10 '06 #8
Roland Pibinger wrote:
On 8 May 2006 01:39:13 -0700, an**@servocomm.freeserve.co.uk wrote:
an**@servocomm.freeserve.co.uk wrote:
Boost.MultiIndex library can do this sort of thing:
http://www.boost.org/libs/multi_index/doc/index.html
Also there is relational Template Library (RTL) in boost sandbox:
http://tinyurl.com/zwe2o

Also forgot about fusion, though you would need to implement your
data as tuples for this library:
http://spirit.sourceforge.net/dl_mor...tml/index.html


Have you actually used one of those libraries?


Yes, those and many more.

Jeff Flinn
May 10 '06 #9
Thank you all for input, I looked at boost multi-index library and they
seem to have done a nice job. I cannot use it though due to some
restrictions on third party software. I think I can implement for my
case using maps and multimaps.....
Sunil

May 11 '06 #10
sunil wrote:
Thank you all for input, I looked at boost multi-index library and they
seem to have done a nice job. I cannot use it though due to some
restrictions on third party software.


Excuse me? Boost's license is free with no restrictions. Our lawyer just
recently approved it for our shrink-wrap and turn-key solutions.

Maybe your boss likes paying expensive programmers to sit around reinventing
wheels all day. How's your C++ compiler coming along?

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
May 12 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Yves Dhondt | last post: by
22 posts views Thread by xixi | last post: by
8 posts views Thread by Strange Cat | last post: by
6 posts views Thread by Ralph | last post: by
5 posts views Thread by iaminsik | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.