The ideas of Cabinet is to be able to write programs in C++ which use Metakit without having to know the structure at compile time. The problem is that the property calls are typed. I have devised a structure based on a metaphorical filing cabinet.
Cabinet equates to storage; Drawer equates to view; Folder equates to subview.
I still use row for row, it should have been section or somesuch as a folder always belongs in a row.
The code is a set of C++ classes, of which the most important are Cabinet and Drawer. The user declares an object of class Cabinet with a filename and the data are committed in the destructor.
Cabinet data("myfile.dat");
Drawers (views) are declared by a member function of Cabinet, which returns an integer Id for the drawer which can be used to identify it.
int topDrawer = data.Drawer("header[name:S]");
Items can be added to a Drawer via another memberfunction. There are a set depending on the type of the data e.g.
char buffer[100]; gets(buffer); int topDrawerRow = data.AddItemS(topDrawer,"name",buffer);
Suppose a second drawer has a subview. In this case there a number of different index values to keep in track, the drawer number, the row number, the folder index and a row number within the folder. I put these all in a class called FolderData used as follows:
char dataName = "example"; int secondDrawer = data.Drawer("info[text:S,list[filename:S]"); gets(buffer); int secondDrawerRow = data.AddItemS(secondDrawer,"text",buffer); FolderData folderData(secondDrawer,secondDrawerRow); folderData = data.AddItemStoFolder(folderData, "list","filename",dataName);
Thus, for all actions, there is a member function of Cabinet.
I have completed a lot of actions for inputting data and am beginning members for reporting and querying the database.
Please send me any comments.
John Fletcher <[email protected]>
I haven't done much on this for a while, but now that I am into STL and Metakit I expect I can get a cleaner version going using STL. -- JPF
I now regard Cabinet as superseded by Category which uses e4Graph as a basis. (See http://e4graph.sourceforge.net/ ) Thanks to Jacob Levy for his code. JPF