Let’s assume that I have such a simple database scheme:
CREATE TABLE tbl(key INTEGER PRIMARY KEY, cap TEXT NOT NULL);
I want to show at least three independent GUI windows. One window (window A
) with list of items, if I choose one item it should be possible to open window B
, that allow delete or update item. Also it should be possible to open window B
to create new item. Ordinary task for many applications I suppose. But I want to make window B
to be not modal dialog, plus allow to create several window B
type dialogs.
How should I make coherent content of these windows?
For example if I create:
struct Record { int64_t id; std::string text; };
and class Db
that encapsulate simple update
, select
, insert
and delete
SQL
statements it would be not enough.
Because of for example I can open window B
with last item in tbl
, maximum value of key
column, that open again it in other window B
, and delete it, after that create new item, and this item will get that same key
value as deleted one. So I have two window B
with the same key
, but different cap
.
Should I create in Db
class cache with std::shared_ptr<Record>
? And add possibility to subscribe on std::shared_ptr<Record>
changes?
Or may be there is other standard way to handle situation like this?