NTuple
From DANSE
The NTuple class is the basic data abstraction used in HippoDraw. It allows the user to associate zero or more arrays of data ("columns") with one another. The columns are owned by the NTuple. A row is a vector with one element from each column. For purposes of insertion, a row may be considered any number of elements, however for extraction, a row is considered a single element.
Pros:
- Based on STL--no homebrewed misery.
- Designed to make visualization easy.
- Add/remove rows and columns to ends, insert rows anywhere.
- Fair amount of std::vector functionality exposed: reserve, resizeRows, erase, insert, add (like push_back). These should maintain STL performance requirements (e.g. add should be a constant-time operation).
Cons:
- All columns have same shape: no way to associate histogram axes, for instance.
- No clear way to asssociate attributes.
- Storage is not fully separate from interface: I do not see how to use an NTuple as a view of pre-existing chunks of memory.
- getRow() constructs a vector which is stored internally by an NTuple, and returns a reference. The next call overwrites this vector.
- getRow() is really designed for 1-d datasets; their are no accessors for higher dim, so something would have to be added.
Here is NTuple's inheritance diagram, borrowed from http://www.slac.stanford.edu/grp/ek/hippodraw/classNTuple.html:
|
|
| Inheritance diagram for NTuple | Part of the interface and attributes of NTuple |
Observable (http://www.slac.stanford.edu/grp/ek/hippodraw/classObservable.html) (link to SLAC...HippoDraw) allows DataSources (and thus NTuple) to participate in the Observer pattern. Clients can register Observers with an Observable, and Observers will receive a notice when the Observable has changed.
DataSource (http://www.slac.stanford.edu/grp/ek/hippodraw/classDataSource.html) (link to SLAC...HippoDraw) is an abstract base class for classes that provide access to data arrays. It provides much of the interface for NTuple, including access to arrays by name or index. DataSources have a shape and a rank, so the user can indicate the dimensions associated with the arrays; note that the arrays (called columns) are assumed to all have the same shape. DataSource provides some concrete implementations of things that, at first glance, seem strange. For instance, getColumn( i) is defined by copying the ith column into the private vector m_array using the pure virtual valueAt() function, and then returning a reference to m_array. NTuple overrides this with the more obvious behavior of just returning a reference to the specified std::vector< double>.
So NTuple is the primary class meant to model data. The NTuple owns a number of identically shaped datasets called columns. In principle, the shape allows one to work with multidimensional arrays, but at first glance support for this seems lacking.



