[odb-users] composite value type

MM finjulhich at gmail.com
Mon Jun 2 10:47:50 EDT 2014


On 2 June 2014 15:19, Boris Kolpackov <boris at codesynthesis.com> wrote:

> Hi,
>
> MM <finjulhich at gmail.com> writes:
>
> >   std::vector<
> >     std::tuple< boost::gregorian::year_based_generator*,
> >                      boost::gregorian::year_based_generator**,*
> >                      boost::posix_time::time_period[5u]
> >     >
> >   >  data_;
> >
> > Now for data_, I am not too sure what this maps to.
>
> Me neither. I don't even understand the semantics of this let alone
> what a sensible representation for it might be in the database.
>
>
> > But the V part of the row cannot map simply as a couple of columns.
>
> Normally, std::vector (and other containers) is mapped to a separate
> table (container table) that stores the entries for all the objects (See
> Chapter 5).
>
>
> > Secondly, for the boost profile, I cannot see any mappings for the types
> I
> > use here (time_period, year_based_generator). What kind of solution can
> > I go for?
>
> You cannot store a pointer to year_based_generator in a database. In fact,
> to me, it seems like year_based_generator is not something that would
> be stored in the database at all.
>
> So if I were you I would first try to understand what it is this data
> describes semantically and what a sensible persistent representation
> for it might be (ODB cannot auto-magically do it for you).


Thanks for taking the time to answer. Apologies that I I haven't described
well enough.
The type boost::gregorian::year_based_generator comes from the date_time
library, and is the base class of all date generators. For eg., 1 of the
concrete types lets you say:

1st monday of April

An object of type boost::gregorian::first_day_of_the_week_in_month (which
derives from boost::gregorian::year_based_generator) can hold this value.
You then pass the year say 2014, and it gives you the exact date that
matches this.

My vector encodes a list of periods through the year

< 1st monday of jan, 2nd tuesday of apr,  array of 5 timeperiods >
< 2nd tuesday of apr, 1rd friday of aug,  array of 5 timeperiods >

a timeperiod is say 8am to 5pm

I can come up with some encoding from these date_time types to std::string,
to store and load, which i can then store to db.
I was hoping the date_time profile included a direct representation of this.

Would you advise to try to extend the odb boost profile to add more types
from date_time, or rather pass by std::string?

Thanks again,


More information about the odb-users mailing list