Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
DataSource Class Reference

Base class for DataSource. More...

#include <DataSource.h>

Inheritance diagram for DataSource:
Inheritance graph
[legend]
Collaboration diagram for DataSource:
Collaboration graph
[legend]

Public Types

typedef void(Observer::* Action )(const Observable *)
 The member function of the Observer that is called.
typedef std::list< Observer * > ObserverList_t
 The type of STL container to maintain list of Observer objects.

Public Member Functions

virtual int addColumn (const std::string &label, const std::vector< double > &data, const std::vector< intptr_t > &shape)
 Adds column vector.
virtual int addColumn (const std::string &label, const std::vector< double > &data)
 Adds column vector.
void addObserver (Observer *)
 Adds an Observer to the Observer list.
virtual void addRow (const std::vector< double > &row)
 Adds a row to the data source.
virtual void append (const DataSource *source)
 Appends the contents of the DataSource source.
virtual void clear ()=0
 Clears the data source.
unsigned int columns () const
 Returns the number of columns or data arrays available from this DataSource.
virtual double * doubleArrayAt (unsigned int row, unsigned int column) const
 Returns an array at row and column.
virtual bool empty () const =0
 Returns true, if DataSource is empty, i.e., has no data.
virtual void eraseRow (unsigned int index)
 Erase a row from the data source.
virtual void expandIfNeeded (const std::vector< std::string > &labels) const
 Expand the multidimension column if needed.
virtual bool fillRange (unsigned int column, Range &) const
 Fills the Range object from data indexed by column.
virtual void fillShape (std::vector< int > &v, unsigned int column) const
 Fills the vector with the shape of a column.
virtual void fillShape (std::vector< int > &v, const std::string &label) const
 Fills the vector with the shape of a column.
virtual const std::vector
< double > & 
getColumn (const std::string &name) const
 Returns the data in the column with label name.
virtual const std::vector
< double > & 
getColumn (unsigned int column) const
 Returns the data in the column with index column.
const std::vector< std::string > & getDuplicatedLabels () const
 Returns the column labels that were duplicated, or an empty vector.
virtual const std::string & getLabelAt (unsigned int index) const
 Returns the label for the column at index index.
virtual const std::vector
< std::string > & 
getLabels () const
 Returns the list of available labels.
const std::string & getName () const
 Returns the name of the data source.
const ObserverList_tgetObservers () const
 Returns the list of observers.
unsigned int getRank () const
 Returns the rank of the data source.
virtual const std::vector
< double > & 
getRow (unsigned int) const =0
 Returns a const reference to slice along the axis known as a row.
virtual const std::vector
< unsigned int > & 
getShape () const
 Returns the shape of the data elements.
virtual int indexOf (const std::string &label) const
 Returns true if the specified column labeled label has been filled.
virtual unsigned int indexOfMaxElement (unsigned int index) const
 Returns row index of the maximum element in a column for the given column.
virtual unsigned int indexOfMinElement (unsigned int index) const
 Returns row index of the minimum element in a column for the given column.
virtual bool isMultiDimensional (const std::string &column) const
 Returns true if the column contains multidimensional data.
bool isNull () const
 Returns true if the receiving objects is a null object.
virtual bool isUseable (const std::string &column) const
 Returns true if the column is usable.
bool isValidLabel (const std::string &label) const
 Returns true if label is a valid label for a column in the DataSource.
virtual void notifyObservers () const
 Notifies Observer objects of a change.
virtual double operator[] (std::vector< unsigned int > &indices) const =0
void removeObserver (Observer *)
 Removes an Observer from the Observer list.
virtual void replaceColumn (const std::string &label, const std::vector< double > &array)
 Replaces data in column label with contents of array.
virtual void replaceColumn (unsigned int index, const std::vector< double > &array)
 Replaces column at index with the contents of array.
virtual void replaceColumn (const std::string &label, const std::vector< double > &data, const std::vector< intptr_t > &shape)
 Replaces or adds column vector.
virtual void reserve (unsigned int count)=0
 For each column, reserves enough space for the data source to grow to count rows.
virtual unsigned int rows () const =0
 Returns the number of rows.
virtual bool setLabelAt (const std::string &s, unsigned int index)
 Changes the label of a data column to s.
virtual void setLabels (const std::vector< std::string > &v)
 Assigns the label to each column from the vector of strings @ v.
void setName (const std::string &name)
 Sets the name of the data source.
virtual bool setReleventIndex (const std::string &column, const std::vector< unsigned int > &index)
 In case we are dealing with multidimensional data in rows of this column we would like to deal with on one entry of this multidimensional data.
virtual void setShape (std::vector< unsigned int > &shape)
 Sets the shape of the data elements.
virtual void setTitle (const std::string &title)
 Sets the title of the data source to title.
virtual double sum (unsigned int column) const
 Returns the sum of all the elements in the sequence of column column.
virtual void throwIfInvalidLabel (const std::string &label) const
 Throws a DataSourceException object if label is not a valid label for this DataSource.
void throwIfInvalidRowSize (const std::vector< double > &row)
 Throws a DataSourceException if the size of the row is not equal to the number of columns, otherwise does nothing.
const std::string & title () const
 Returns a const reference to the title of the data source.
virtual double valueAt (unsigned int row, unsigned int column) const =0
 Returns the value in the table in position given by the row and column indexes.
virtual double valueAtNoCache (unsigned int row, unsigned int column) const
 Returns the value in the table in position given by the row and column indexes without storing it into cache.
virtual ~DataSource ()
 The destructor.

Protected Member Functions

virtual void addLabel (const std::string &label)
 Adds a new label for a column.
virtual void checkWidth (const DataSource *source)
 Checks the number of columns.
virtual void copyPrivate (const DataSource &other)
 Copies the contents of the other DataSource.
 DataSource (const std::vector< std::string > &labels)
 A constructor taking list of array labels as argument.
 DataSource (const std::string &name)
 Constructs an DataSource object with name name.
 DataSource (const char *name)
 Constructs an DataSource object with name name.
 DataSource (const DataSource &nt)
 The copy constructor creates an data source that is a copy of an existing one.
 DataSource (bool dummy)
 A constructor for creating a null object.
 DataSource ()
 The default constructor creating an data source with 0 columns.
bool isValidColumn (unsigned int index) const
 Returns true if index is valid, otherwise throws a DataSourceException.
void notifyObservers (Action action) const
 An internal method to iterate over all observers and to send the message action.

Protected Attributes

std::vector< double > m_array
 A temporary array that can be returned by const reference.
std::vector< std::string > m_dups
 A list of labels that duplicated others in a DataSource file.
std::vector< unsigned int > m_shape
 The shape of the data.

Private Attributes

std::string m_ds_name
 The name of the data source .
bool m_is_null
 A flag to indicate the object is null.
std::vector< std::string > m_labels
 The labels of the vectors of the data.
std::string m_title
 The title.

Detailed Description

Base class for DataSource.

A data source is a class which is able to supply one or more arrays of data. Access to the arrays can be by name, called a label, or by an index. It provides translation of label to index and vice verse. It also provides a name by which it can be uniquely identified in a client application and a title for the data set. These attributes have concrete implementations in this base class.

All member functions that access the data are pure virtual functions in this class and thus must be implemented in derived classes. This class does not provide the interface for creating or modifying the data.

A DataSource can also have a shape, meaning that a single array can be seen as a multi-dimension array with different sizes of each dimension.

Todo:
Expand to data types other than double.
Author
Paul F. Kunz Paul_.nosp@m.Kunz.nosp@m.@slac.nosp@m..sta.nosp@m.nford.nosp@m..edu

Definition at line 55 of file DataSource.h.

Member Typedef Documentation

typedef void( Observer::* Action)(const Observable *)
inherited

The member function of the Observer that is called.

Definition at line 86 of file Observable.h.

typedef std::list< Observer * > ObserverList_t
inherited

The type of STL container to maintain list of Observer objects.

Definition at line 45 of file Observable.h.

Constructor & Destructor Documentation

DataSource ( const std::vector< std::string > &  labels)
protected

A constructor taking list of array labels as argument.

Definition at line 85 of file DataSource.cxx.

DataSource ( const std::string &  name)
protected

Constructs an DataSource object with name name.

Definition at line 58 of file DataSource.cxx.

DataSource ( const char *  name)
protected

Constructs an DataSource object with name name.

Note
This constructor differs from one with std::string because that wouldn't be use by conversion of char *.

Definition at line 66 of file DataSource.cxx.

DataSource ( const DataSource nt)
protected

The copy constructor creates an data source that is a copy of an existing one.

Definition at line 74 of file DataSource.cxx.

DataSource ( bool  dummy)
protected

A constructor for creating a null object.

A null DataSource is one that is a place holder for one that got deleted while other objects were referencing it. This can happen, for example, if a user deletes an DataSource before deleting other objects that use it. Classes that reference DataSource objects can be Observer of then in order to receive the Observer::willDelete signal. When received they can replace the referenced DataSource with a null one. They can then continue to function until a valid data source is given to them. The parameter dummy is not used.

Definition at line 100 of file DataSource.cxx.

DataSource ( )
protected

The default constructor creating an data source with 0 columns.

Definition at line 92 of file DataSource.cxx.

~DataSource ( )
virtual

The destructor.

Definition at line 107 of file DataSource.cxx.

References Observable::notifyObservers(), and Observer::willDelete().

Member Function Documentation

int addColumn ( const std::string &  label,
const std::vector< double > &  data,
const std::vector< intptr_t > &  shape 
)
virtual

Adds column vector.

Adds a new column with label and returns its index. The number of rows, as defined by first element of the shape, must be the same as existing columns, if any. Not all derived classes support the notion of shape, therefore as convenience to developers, the implementation in this base class throws a std::runtime_error object.

Reimplemented in FitsNTuple.

Definition at line 400 of file DataSource.cxx.

int addColumn ( const std::string &  label,
const std::vector< double > &  data 
)
virtual

Adds column vector.

If implemented in a derived class, adds a new column with label and returns its index.

Note
Not all derived classes support the notion of adding columns. The implementation in this base class throws a std::runtime_error object if called.

Reimplemented in NTuple, RootNTuple, FitsNTuple, QtRootNTuple, and PyNTuple.

Definition at line 390 of file DataSource.cxx.

void addLabel ( const std::string &  label)
protectedvirtual

Adds a new label for a column.

Definition at line 154 of file DataSource.cxx.

References DataSource::m_labels.

Referenced by RootNTuple::addColumn(), ListTuple::addColumn(), NumArrayTuple::addColumn(), FitsNTuple::addColumn(), and NTuple::addColumn().

void addObserver ( hippodraw::Observer observer)
inherited
void addRow ( const std::vector< double > &  row)
virtual

Adds a row to the data source.

Since most derived classes are not capable of adding a row, the implementation of this member functions throws std::runtime_error.

Reimplemented in NTuple, CircularBuffer, RTuple, and PyNTuple.

Definition at line 548 of file DataSource.cxx.

Referenced by DataSource::append().

void append ( const DataSource source)
virtual

Appends the contents of the DataSource source.

Appends the contents of the DataSource source to end by adding rows.

Note
If a derived class has a more efficient way of appending, it should override this method.

Reimplemented in NTuple, and PyNTuple.

Definition at line 580 of file DataSource.cxx.

References DataSource::addRow(), DataSource::checkWidth(), DataSource::getRow(), DataSource::rows(), and num_util::size().

void checkWidth ( const DataSource source)
protectedvirtual

Checks the number of columns.

Check that the number of columns of source is the same as the receiving object. Throws a std::runtime_error if they are different, otherwise does nothing.

Definition at line 565 of file DataSource.cxx.

References DataSource::columns(), and hippodraw::Axes::convert().

Referenced by NTuple::append(), and DataSource::append().

virtual void clear ( )
pure virtual

Clears the data source.

Implemented in NumArrayTuple, NTuple, ListTuple, RootNTuple, FitsNTuple, CircularBuffer, PyNTuple, and RTuple.

Referenced by PyDataSource::clear().

unsigned int columns ( ) const
inline
void copyPrivate ( const DataSource other)
protectedvirtual

Copies the contents of the other DataSource.

For use by derived classes only.

Definition at line 114 of file DataSource.cxx.

References DataSource::m_ds_name, DataSource::m_is_null, DataSource::m_labels, DataSource::m_shape, and DataSource::m_title.

Referenced by RTuple::copy(), and NTuple::copy().

double * doubleArrayAt ( unsigned int  row,
unsigned int  column 
) const
virtual

Returns an array at row and column.

If the DataSource is capable of containing an array in a column, then returns pointer to the array for a single row, otherwise throws std::runtime_error exception.

Reimplemented in RootNTuple.

Definition at line 593 of file DataSource.cxx.

virtual bool empty ( ) const
pure virtual

Returns true, if DataSource is empty, i.e., has no data.

Implemented in NTuple, RootNTuple, FitsNTuple, NumArrayTuple, ListTuple, and RTuple.

void eraseRow ( unsigned int  index)
virtual

Erase a row from the data source.

The implementation throws std::runtime_error.

Reimplemented in NTuple.

Definition at line 556 of file DataSource.cxx.

void expandIfNeeded ( const std::vector< std::string > &  labels) const
virtual

Expand the multidimension column if needed.

Do nothing in base class. Reimplemented in RootNTuple.

Reimplemented in RootNTuple, and QtRootNTuple.

Definition at line 602 of file DataSource.cxx.

Referenced by DataRepController::createDataRep(), and DisplayController::createDisplay().

bool fillRange ( unsigned int  column,
Range range 
) const
virtual

Fills the Range object from data indexed by column.

Returns true if all the data in the column was valid, otherwise returns false. Invalid data is +/- HUGE_VAL or NAN. Invalid data is not used in setting the range.

Bug:
HUGE_VAL doesn't pass gcc on the Mac if -pedantic is used.
Requests:
use if ( x != x) to test for nan

Reimplemented in NTuple, and FitsNTuple.

Definition at line 415 of file DataSource.cxx.

References DataSource::columns(), DataSource::rows(), Range::setRange(), num_util::size(), and DataSource::valueAt().

void fillShape ( std::vector< int > &  v,
unsigned int  column 
) const
virtual

Fills the vector with the shape of a column.

Returns via the vector v, the shape of the data at column column. Most derived classes will only support a vector in a column. Thus as convenience to implementers of derived classes this base class implementation returns a shape of size 1 containing the number of rows.

Reimplemented in RootNTuple.

Definition at line 320 of file DataSource.cxx.

References DataSource::rows().

Referenced by DataSource::fillShape().

void fillShape ( std::vector< int > &  v,
const std::string &  label 
) const
virtual

Fills the vector with the shape of a column.

Returns via the vector v, the shape of the data at column column. Most derived classes will only support a vector in a column. Thus as convenience to implementers of derived classes the implementation of this base class returns a shape of size 1 containing the number of rows.

Definition at line 328 of file DataSource.cxx.

References DataSource::fillShape(), and DataSource::indexOf().

const vector< double > & getColumn ( const std::string &  name) const
virtual

Returns the data in the column with label name.

Reimplemented in NTuple, RootNTuple, and QtRootNTuple.

Definition at line 243 of file DataSource.cxx.

References DataSource::indexOf().

Referenced by PyDataSource::columnAsNumArray(), NTupleXML::createChildren2D(), NTupleProjector::fillColumnAfterCuts(), PyDataSource::getColumn(), and ProjectorBase::getZValues().

const vector< double > & getColumn ( unsigned int  column) const
virtual

Returns the data in the column with index column.

Reimplemented in NTuple, RootNTuple, FitsNTuple, and QtRootNTuple.

Definition at line 228 of file DataSource.cxx.

References DataSource::isValidColumn(), DataSource::m_array, DataSource::rows(), num_util::size(), and DataSource::valueAt().

const vector< string > & getDuplicatedLabels ( ) const

Returns the column labels that were duplicated, or an empty vector.

Definition at line 534 of file DataSource.cxx.

References DataSource::m_dups.

const string & getLabelAt ( unsigned int  index) const
virtual

Returns the label for the column at index index.

Returns the label for the column at index index, or throws a DataSourceException if index is out of range.

Definition at line 179 of file DataSource.cxx.

References DataSource::isNull(), DataSource::m_labels, and DataSource::title().

Referenced by NTupleXML::createChildren2D(), NTupleProjector::getAxisBindings(), NTupleProjector::getXLabel(), Map1Projector::getYLabel(), NTupleProjector::getYLabel(), Map3Projector::getZLabel(), MeshProjector::getZLabel(), Profile2DProjector::getZLabel(), and MapMatrixProjector::getZLabel().

const vector< string > & getLabels ( ) const
virtual
const string & getName ( ) const
const Observable::ObserverList_t & getObservers ( ) const
inherited

Returns the list of observers.

Definition at line 60 of file Observable.cxx.

unsigned int getRank ( ) const

Returns the rank of the data source.

Returns the number of axes of the data source, i.e the rank.

Definition at line 343 of file DataSource.cxx.

References DataSource::m_shape.

Referenced by RTuple::operator[](), NTuple::operator[](), and RootNTuple::smartExpandRootNTuple().

virtual const std::vector< double >& getRow ( unsigned  int) const
pure virtual

Returns a const reference to slice along the axis known as a row.

Implemented in RootNTuple, NTuple, FitsNTuple, NumArrayTuple, ListTuple, RTuple, and QtRootNTuple.

Referenced by DataSource::append(), RTuple::copy(), NTuple::copy(), and NTupleController::writeNTupleToFile().

const vector< unsigned int > & getShape ( ) const
virtual

Returns the shape of the data elements.

Reimplemented in RootNTuple, FitsNTuple, NumArrayTuple, and ListTuple.

Definition at line 313 of file DataSource.cxx.

References DataSource::m_shape.

Referenced by ProjectorBase::getShape().

int indexOf ( const std::string &  label) const
virtual
unsigned int indexOfMaxElement ( unsigned int  index) const
virtual

Returns row index of the maximum element in a column for the given column.

Reimplemented in NTuple.

Definition at line 476 of file DataSource.cxx.

References DataSource::columns(), DataSource::rows(), num_util::size(), and DataSource::valueAt().

unsigned int indexOfMinElement ( unsigned int  index) const
virtual

Returns row index of the minimum element in a column for the given column.

Reimplemented in NTuple.

Definition at line 497 of file DataSource.cxx.

References DataSource::columns(), DataSource::rows(), num_util::size(), and DataSource::valueAt().

bool isMultiDimensional ( const std::string &  column) const
virtual

Returns true if the column contains multidimensional data.

Returns false. Derived classes should return true if the column contains multidimensional data.

Reimplemented in RootNTuple, and QtRootNTuple.

Definition at line 451 of file DataSource.cxx.

bool isNull ( ) const
bool isUseable ( const std::string &  column) const
virtual

Returns true if the column is usable.

Returns true. Derived classes should return false if the column is not usable in the context of a DataSource.

Reimplemented in RootNTuple.

Definition at line 458 of file DataSource.cxx.

bool isValidColumn ( unsigned int  index) const
protected

Returns true if index is valid, otherwise throws a DataSourceException.

Definition at line 212 of file DataSource.cxx.

References DataSource::columns(), hippodraw::Axes::convert(), and num_util::size().

Referenced by FitsNTuple::getColumn(), RootNTuple::getColumn(), NTuple::getColumn(), and DataSource::getColumn().

bool isValidLabel ( const std::string &  label) const

Returns true if label is a valid label for a column in the DataSource.

The search is case sensitive. If the label is not found, returns false.

Definition at line 257 of file DataSource.cxx.

References DataSource::m_labels.

Referenced by FitsNTuple::checkLabel(), and DataSource::throwIfInvalidLabel().

void notifyObservers ( ) const
virtualinherited

Notifies Observer objects of a change.

If interval counting is disabled, then Observer::Update is sent immediately. If interval counting is enabled, then the current count is incremented. If the current count is equal to the interval count, then the Observer::update message is sent and the current count reset to 0.

Reimplemented in NTuple, RootNTuple, NumArrayTuple, ListTuple, and FitsNTuple.

Definition at line 93 of file Observable.cxx.

References Observer::update().

Referenced by XyPlotter::addDataRep(), XyPlotter::addDataRepStacked(), FunctionController::addFunctionRep(), StHist1DProjector::addValues(), StHist2DProjector::addValues(), XyPlotter::autoScale(), Inspector::contourLevelsTextBox_returnPressed(), Inspector::contourSlider_valueChanged(), Inspector::contourTextBox_returnPressed(), FunctionRep::fitFunction(), XyPlotter::removeDataRep(), FunctionRep::restoreParameters(), DataRep::set(), CutPlotter::setActive(), PlotterBase::setAspectRatio(), XyPlotter::setAutoRanging(), XyPlotter::setBoxEdge(), QtDisplay::setContourLevels(), CutPlotter::setCutColor(), XyPlotter::setCutEnabled(), XyPlotter::setCutInverted(), XyPlotter::setCutRangeAt(), ProjectorBase::setDirty(), DataRep::setErrorDisplay(), XyPlotter::setHighRange(), PlotterBase::setLabel(), XyPlotter::setLabel(), DataSource::setLabelAt(), DataSource::setLabels(), XyPlotter::setLowRange(), DataSource::setName(), DisplayController::setNTuple(), FunctionRep::setParameters(), DyHistogram::setPointRep(), DyHistogramEqualEntries::setPointRep(), DataRep::setPointRep(), TextPlotter::setRepColor(), DataRep::setRepColor(), DataRep::setRepSize(), DataRep::setRepStyle(), XyPlotter::setReverse(), XyPlotter::setScaling(), XyPlotter::setShowGrid(), DataSource::setTitle(), PlotterBase::setTitle(), XyPlotter::setTransform(), XyPlotter::setValueRep(), NTupleProjector::update(), BinningProjector::update(), DataRep::update(), PlotterBase::update(), CutPlotter::update(), CutPlotter::updateTargets(), DataRep::~DataRep(), DataSource::~DataSource(), PlotterBase::~PlotterBase(), and RTuple::~RTuple().

void notifyObservers ( Action  action) const
protectedinherited

An internal method to iterate over all observers and to send the message action.

Definition at line 72 of file Observable.cxx.

virtual double operator[] ( std::vector< unsigned int > &  indices) const
pure virtual
void removeObserver ( hippodraw::Observer observer)
inherited
void replaceColumn ( const std::string &  label,
const std::vector< double > &  array 
)
virtual

Replaces data in column label with contents of array.

If column label label exists, replace it contents with array, otherwise throw std::runtime_error.

Note
Not all derived classes support replacing a column and this base class implementation throws a std::runtime_error if called.

Reimplemented in PyNTuple.

Definition at line 360 of file DataSource.cxx.

References DataSource::indexOf().

Referenced by PyDataSource::saveColumnFromNumArray().

void replaceColumn ( unsigned int  index,
const std::vector< double > &  array 
)
virtual

Replaces column at index with the contents of array.

Note
Not all derived classes support replacing a column and a std::runtime_error may be thrown if called.

Reimplemented in NTuple, RootNTuple, FitsNTuple, and PyNTuple.

Definition at line 350 of file DataSource.cxx.

void replaceColumn ( const std::string &  label,
const std::vector< double > &  data,
const std::vector< intptr_t > &  shape 
)
virtual

Replaces or adds column vector.

If column label exists, replaces that column with data, otherwise adds a new column with label. In both cases, the number of rows, as defined by first element of the shape, must be the same as existing columns, if any. Not all derived classes support the notion of shape, therefore as convenience to developers, the implementation in this base class throws a std::runtime_error object.

Reimplemented in FitsNTuple.

Definition at line 378 of file DataSource.cxx.

virtual void reserve ( unsigned int  count)
pure virtual

For each column, reserves enough space for the data source to grow to count rows.

Implemented in NTuple, NumArrayTuple, ListTuple, RootNTuple, FitsNTuple, CircularBuffer, and RTuple.

virtual unsigned int rows ( ) const
pure virtual
bool setLabelAt ( const std::string &  s,
unsigned int  index 
)
virtual

Changes the label of a data column to s.

Parameters
sthe new label.
indexthe column number starting at zero.
Returns
true if index is less than the width of the data source; otherwise, it does nothing and returns false.

Definition at line 161 of file DataSource.cxx.

References DataSource::m_labels, and Observable::notifyObservers().

void setLabels ( const std::vector< std::string > &  v)
virtual

Assigns the label to each column from the vector of strings @ v.

Reimplemented in NTuple.

Definition at line 297 of file DataSource.cxx.

References DataSource::m_labels, and Observable::notifyObservers().

Referenced by RTuple::RTuple().

void setName ( const std::string &  name)

Sets the name of the data source.

See Also
m_ds_name.

Definition at line 130 of file DataSource.cxx.

References DataSource::m_ds_name, and Observable::notifyObservers().

Referenced by DataSourceController::registerNTuple(), PyDataSource::registerNTuple(), and PyDataSource::setName().

bool setReleventIndex ( const std::string &  column,
const std::vector< unsigned int > &  index 
)
virtual

In case we are dealing with multidimensional data in rows of this column we would like to deal with on one entry of this multidimensional data.

So here we set index of this relevant entry.

Reimplemented in RootNTuple.

Definition at line 465 of file DataSource.cxx.

void setShape ( std::vector< unsigned int > &  shape)
virtual

Sets the shape of the data elements.

Sets the shape data elements from the vector shape. The rank is given by the size of the vector. A rank of 2 correspond to table. If the total number of elements in the DataSource is not equal to the product of the shape, then an assertion is raised.

Reimplemented in RootNTuple, FitsNTuple, NumArrayTuple, and ListTuple.

Definition at line 306 of file DataSource.cxx.

References DataSource::m_shape, and num_util::shape().

void setTitle ( const std::string &  title)
virtual

Sets the title of the data source to title.

Reimplemented in PyNTuple.

Definition at line 146 of file DataSource.cxx.

References DataSource::m_title, Observable::notifyObservers(), and DataSource::title().

Referenced by NTupleController::readAsciiNTuple(), and PyDataSource::setTitle().

double sum ( unsigned int  column) const
virtual

Returns the sum of all the elements in the sequence of column column.

Reimplemented in NTuple.

Definition at line 518 of file DataSource.cxx.

References DataSource::columns(), DataSource::rows(), num_util::size(), and DataSource::valueAt().

void throwIfInvalidLabel ( const std::string &  label) const
virtual

Throws a DataSourceException object if label is not a valid label for this DataSource.

The exception object contains a message that the label is invalid. Derived classes may over-ride this method with more information on why the label is invalid.

Definition at line 268 of file DataSource.cxx.

References DataSource::isValidLabel().

Referenced by RootNTuple::getColumn(), NTuple::getColumn(), and QtRootNTuple::valueAt().

void throwIfInvalidRowSize ( const std::vector< double > &  row)

Throws a DataSourceException if the size of the row is not equal to the number of columns, otherwise does nothing.

Definition at line 281 of file DataSource.cxx.

References DataSource::columns(), hippodraw::Axes::convert(), and num_util::size().

Referenced by RTuple::addRow(), NTuple::addRow(), and NTuple::replaceRow().

const string & title ( ) const

Returns a const reference to the title of the data source.

Definition at line 141 of file DataSource.cxx.

References DataSource::m_title.

Referenced by DataSource::getLabelAt(), PyDataSource::getTitle(), NTupleProjector::getTitle(), DataSource::setTitle(), and NTupleController::writeNTupleToFile().

virtual double valueAt ( unsigned int  row,
unsigned int  column 
) const
pure virtual

Returns the value in the table in position given by the row and column indexes.

Implemented in NTuple, RootNTuple, FitsNTuple, NumArrayTuple, RTuple, and ListTuple.

Referenced by DataSource::fillRange(), DataSource::getColumn(), DataSource::indexOfMaxElement(), DataSource::indexOfMinElement(), DataSource::sum(), and DataSource::valueAtNoCache().

double valueAtNoCache ( unsigned int  row,
unsigned int  column 
) const
virtual

Returns the value in the table in position given by the row and column indexes without storing it into cache.

Reimplemented in RootNTuple.

Definition at line 541 of file DataSource.cxx.

References DataSource::valueAt().

Referenced by NTupleController::createNTuple().

Member Data Documentation

std::vector< double > m_array
mutableprotected

A temporary array that can be returned by const reference.

Definition at line 88 of file DataSource.h.

Referenced by DataSource::getColumn(), FitsNTuple::getRow(), and RootNTuple::getRow().

std::string m_ds_name
private

The name of the data source .

Although the use of this data member is optional, the suggested use within an application is as follows.

  • If the data source is associated with a file, then it is the file name.
  • If the data source was created in memory by an application, then it is some unique string created by the application.

Definition at line 66 of file DataSource.h.

Referenced by DataSource::copyPrivate(), DataSource::getName(), and DataSource::setName().

std::vector< std::string > m_dups
protected

A list of labels that duplicated others in a DataSource file.

Definition at line 100 of file DataSource.h.

Referenced by DataSource::getDuplicatedLabels(), RootNTuple::initBranches(), and FitsNTuple::initColumns().

bool m_is_null
private

A flag to indicate the object is null.

A null object is a place holder so that classes that use this class can continue to function after their valid object has been deleted. This can happen, for example, if the user deletes his data source without first deleting objects that use it.

Definition at line 82 of file DataSource.h.

Referenced by DataSource::copyPrivate(), and DataSource::isNull().

std::vector<std::string> m_labels
private
std::vector< unsigned int > m_shape
protected

The shape of the data.

The elements the DataSource can have an arbitrary number of dimensions, called rank. An ordinary table has rank of 2 and the shape is number of columns and number of rows. That is m_shape[0] is number of columns and m_share[1] is number of rows.

Definition at line 96 of file DataSource.h.

Referenced by DataSource::copyPrivate(), DataSource::getRank(), ListTuple::getShape(), NumArrayTuple::getShape(), FitsNTuple::getShape(), RootNTuple::getShape(), DataSource::getShape(), RTuple::operator[](), NTuple::operator[](), ListTuple::setShape(), NumArrayTuple::setShape(), FitsNTuple::setShape(), RootNTuple::setShape(), and DataSource::setShape().

std::string m_title
private

The title.

The title is descriptive of the data source.

Definition at line 70 of file DataSource.h.

Referenced by DataSource::copyPrivate(), DataSource::setTitle(), and DataSource::title().


The documentation for this class was generated from the following files:

Generated for HippoDraw Class Library by doxygen