[odb-users] custom containers or not: boost::multi_array

MM finjulhich at gmail.com
Thu Jun 28 16:43:36 EDT 2018


On 26 June 2018 at 18:45, MM <finjulhich at gmail.com> wrote:

> Hello
>
>
> class EL {
>     std::uint32_t                          id_;
>     std::vector<date>                  dates_;
>     boost::multi_array<entry, 2> entries_;
> };
> /// dates_.size() == number or rows of entries_
> /// number of cols of entries_ = N
> /// entry is a struct that maps to a composite value type
>
> My object target tables look like:
>
> table "EL"
> id
> -------------
> .
> .
> .
>
>
> table "EL_rows"
> ELid      date         entrycols
> --------------------------------------
> 1             d1             entry11
> 1             d1             entry12
> ...
> 1             d1             entry1N
>
> 1             d2             entry21
> 1             d2             entry22
> ...
> 1             d2             entry2N
>
> ...
>
> 1             dM             entryM1
> 1             dM             entryM2
> ...
> 1             dM             entryMN
> ...
> and so on for ELid 2 ....
>
> If the class EL is constrainted in its definition, is the way to use a
> custom container as explained in chapter 5.5?
>
> The relationship that the row entries_[x] corresponds the date  dates_[x]
> would have to be implemented somehow.
>
> I'm at a loss as how to implement this really?
>


This use case boils down to just 2 dimensions for multi_array.
If the multi_array container has N rows and M columns, and all the cells
are of the same simple value type, is it possible to store as M*N rows in a
SQL table?
Is it possible to load M*N rows back into it?

To use the container_traits, I suppose this would be a ordered container.
The Index type would be a pair of integers for both dimensions?
The value_type would be "entry"

rds,


More information about the odb-users mailing list