"Dr Ann Huxtable" <an*********@research.de.edu> wrote in message
news:co**********@sparta.btinternet.com...
Hello,
I am trying to design an abstract data type (lets call it an HTable) which
mimics a heirarchical rcordset (ala ADO 2.0). I have got this far:
1). Data will be stored in a vector of vectors
2). The HTable Constructor will specify the datatypes for the columns -
and this cannot be changed later - ensuring all row columns are of the
same data types
3). Create a Row object that returns a vector "horizontal" slice at the
appropriate "row" in the vector of vectors
4). Create a Column object that returns a vector "vertical" slice at the
appropriate "column" in the vector of vectors
This it seems will work for a flat (2D) table. However, I can't seem to
work out how to make it heirarchical, i.e. specifiy a column that is of
type HTable.
Is there a library out there that already does this kind of thing (save me
reinventing the whel), or can someone please provide some helpful links or
sample code that shows how to do this?
Thanks very much
Ann
One way would be to derive all objects (including HTable itself) from a base
object. Then you could dynamically create the objects to go into your
table, storing pointers instead of objects in the table(s). You'd probably
want the HTable object to manage the creation and deletion of the actual
objects, so that you don't have both Columns and Rows trying to delete the
same object.
You ask about making an HTable as a column type. In my scheme, since you
have a column of pointers and not objects stored there, you are free to
store whatever you need. You can either make the HTable a descendant of the
base class, like any other data type, or you can make a kind of "link"
object descendant class whose pointers are stored there, and have that link
class do any work you need in accessing a separate, externally stored HTable
object. In either case, your tables contain only pointers to base class
objects (where each is instantiated as the specific object required by the
column it is in).
Hope this helps...
-Howard