lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] product_editor .db4 files and TDBDictionary public interface (/sin


From: Evgeniy Tarassov
Subject: [lmi] product_editor .db4 files and TDBDictionary public interface (/singleton)
Date: Wed, 15 Feb 2006 12:42:40 +0100

Hello, Greg!
To implement .db4 files editing in new product_editor i've used
TDBDictionary class (from ihs_dbdict.hpp) but i was forced to use some
nasty workaround. The class itself is supposed to be singleton and has
no public method to dump the data from memory to a file. I've managed
to workaround those issues:
1. to have more than one .db4 file open at the same time (class is a signleton)
To read the data from a file i create anew dict_map (container used to
store elements from the dictionary), then i swap it with the
dictionary container, then read the data from file and swap again.
dict_map myMap;
TDBDictionary::instance().GetDictionary().swap( myMap );
TDBDictionary::instance().Init( myFilename ); // reading data
TDBDictionary::instance().swap( myMap );
I need also to clean the cached filename to make it work correctly.

2. To access private methods (WriteDB) to write the data back to the file
There is a friend declaration with a class DatabaseDocument which does
not exist. To acces those internal functions of dictionary i've added
class with that name, derived from it, etc.

Do you think that this approach is appropriate? It does work, but i
don't think it should be the final solution.
While 1 could be considered correct from a point of view
(TDBDictionary is treated like a factory-gateway class), the 2 is more
lika a hack. Do you think that i should modify the interface of the
TDBDictionary to expose some needed functionality? (like mkaing
WriteDB to be public and adding a couple of function to purge cached
file name, etc)?

Thank you in advance!
--
ET




reply via email to

[Prev in Thread] Current Thread [Next in Thread]