[hdf-forum] How best to model objects that have lists of sub objects.
Richard Corden
richard.corden at gmail.com
Tue Jun 23 11:34:41 EDT 2009
Hi Quincey,
Quincey Koziol wrote:
> Hi Richard,
>
> On Jun 18, 2009, at 3:36 PM, Richard Corden wrote:
>
>> Hi,
>>
>> I am unable to find a satisfactory way to model object hierarchies,
>> specifically something as follows:
>>
>> class B { ... };
>>
>> class A {
>> std::vector <B> m_b;
>> };
>>
>>
>> Here are some of my requirements:
>> * The number of B's is relatively small, probably lower than 10
>> * There's no upper bound
>> * It needs to be possible to append data later
>> * The order the items are written needs to be preserved
>>
[...]
> Have you tried creating a group for each 'A' and making each 'B' a
> dataset with an unlimited 1-D dimension, with a datatype that matches
> 'B' in memory? Then, each vector of 'B' elements can be easily
> extended and appended to in an independent way.
I haven't tried this yet, but it will have to be a last resort as I've
invested quite a bit of time designing a framework based on HDF5 where
each object is a dataset row. (FYI, I've written reader/writer objects
where the interface uses tuples from the boost library (www.boost.org).
Each part of the tuple has an identifier and a value, which write out as
if it was a HDF Compound type).
I've managed to work around the size problem by storing the start and
end indexes rather than references. I always know the dataset that it
refers to so that information wasn't required. So far, read/write times
are good and file size is good too.
Thanks for your help!
Cheers,
Richard
>
> Quincey
>
----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe at hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe at hdfgroup.org.
More information about the Hdf-forum
mailing list