[odb-users] std::map<Entity, int>

Adnan RIHAN axel50397 at gmail.com
Thu Nov 27 07:21:21 EST 2014


Hello,

On 27 novembre 2014 at 12:54:43, Boris Kolpackov (boris at codesynthesis.com(mailto:boris at codesynthesis.com)) wrote:

> Uh, read this three times and I still can't wrap my head around it.
> What happened to keeping things simple?

Me happened ;)
I’ve attached a representation of my classes to help you understand.

My “cart” has 3 fields: invoice_id, offer_id, quantity

Using a map seems to be a better option for me, because it “guarantees” me uniqueness of the keys. But a workaround was needed because of the key (I needed a shared pointer as key), no big deal here.
I tried the “QSet” approach because my current table models can handle an entity (introspection is used for the headers) but not a map.

If you have other approach or structures, advices are welcome (you and from others)
--  
Cordialement, Adnan RIHAN.
Directeur-Gérant de Eolis-Software, société de services informatiques.  

GPG: 5675-62BA (https://keybase.io/max13/key.asc)
-> Si vous n'utilisez pas GPG mais souhaitez quand même m’envoyer un e-mail chiffré: (https://encrypt.to/0x567562BA).
-------------- next part --------------
class Product
{
    [...]
};

class Offer
{
    Product m_product;
    uint    m_price;

    [...]
};

// ---

struct CartId {
    QWeakPointer<Invoice>   i;
    QSharedPointer<Offer>   o;
};

class Cart
{
    CartId  m_id;
    uint    m_quantity;

    [...]
};

class Invoice
{
    QSet<QSharedPointer<Cart> > m_cart;

    [...]
};


More information about the odb-users mailing list