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

A DataSource class implemented with std::vector<double> to store the column data. More...

#include <NTuple.h>

Inheritance diagram for NTuple:
Inheritance graph
[legend]
Collaboration diagram for NTuple:
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 &, const std::vector< double > &column)
 Adds a column to the end of the ntuple and returns the index to the added column.
virtual int addColumn (const std::string &label, const std::vector< double > &data, const std::vector< intptr_t > &shape)
 Adds column vector.
void addObserver (Observer *)
 Adds an Observer to the Observer list.
virtual void addRow (const std::vector< double > &v)
 Adds a row to the end of the ntuple.
virtual void append (const DataSource *source)
 Appends the data from the source.
virtual void clear ()
 Clears the NTuple.
double columnMax (const std::string &name) const
 Returns minimum element in a column whose label is given by name.
double columnMin (const std::string &name) const
 Returns minimum element in a column whose label is given by name.
unsigned int columns () const
 Returns the number of columns or data arrays available from this DataSource.
virtual void copy (const DataSource &rhs)
 Copies rhs data.
virtual double * doubleArrayAt (unsigned int row, unsigned int column) const
 Returns an array at row and column.
virtual bool empty () const
 Returns true, if NTuple is empty, i.e.
virtual void eraseRow (unsigned int index)
 Erases a row from the NTuple.
virtual void expandIfNeeded (const std::vector< std::string > &labels) const
 Expand the multidimension column if needed.
virtual bool fillRange (unsigned int column, Range &) const
 Returns the Range of data in the column via the argument.
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 (unsigned int index) const
 Returns the data in the column with index column.
virtual std::vector< double > & getColumn (unsigned int index)
 Returns a non-const reference to column at the index index.
const std::vector< double > & getColumn (const std::string &label) const
 Returns the data in the column with label name.
const std::vector< std::string > & getDuplicatedLabels () const
 Returns the column labels that were duplicated, or an empty vector.
unsigned int getIntervalCount () const
 Returns the current interval count.
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 index) const
 Returns a temporary vector of data elements in one 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 void insertRow (unsigned int index, const std::vector< double > &v)
 Inserts a Row.
bool isIntervalEnabled () const
 Returns true if interval counting is enabled, otherwise returns false.
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 double maxElement (unsigned int index) const
 Returns the value of the maximum element of column index.
virtual double minElement (unsigned int index) const
 Returns the value of the minimum element of column index.
virtual void notifyObservers () const
 Notifies Observer objects of a change.
 NTuple (const std::string &name)
 Constructs an NTuple object with name name.
 NTuple (const char *name)
 Constructs an NTuple object with name name.
 NTuple (const std::vector< std::string > &labels)
 Constructor taking a vector of column labels as argument.
 NTuple (const NTuple &nt)
 The copy constructor creates an ntuple that is a copy of an existing one.
 NTuple (const DataSource *ds)
 A constructor that creates an ntuple from another DataSource object.
 NTuple (unsigned int n)
 A constructor that creates an ntuple with n columns.
 NTuple (bool dummy)
 A constructor for creating a null object.
 NTuple ()
 The default constructor creating an ntuple with 0 columns.
virtual double operator[] (std::vector< unsigned int > &indices) const
void removeObserver (Observer *)
 Removes an Observer from the Observer list.
virtual void replaceColumn (unsigned int index, const std::vector< double > &data)
 Replaces the data in column col.
virtual void replaceColumn (const std::string &label, const std::vector< double > &array)
 Replaces data in column label with 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.
void replaceRow (unsigned int i, const std::vector< double > &data)
 Replaces the data in the row i.
virtual void reserve (unsigned int count)
 For each column, reserves enough space for the data source to grow to count rows.
virtual unsigned int rows () const
 Returns the number of rows.
void setIntervalCount (int number)
 Sets the interval count.
void setIntervalEnabled (bool yes=true)
 Sets interval counting to be enabled.
virtual bool setLabelAt (const std::string &s, unsigned int index)
 Changes the label of a data column to s.
void setLabels (const std::vector< std::string > &v)
 Assigns the label to each column from the vector of strings.
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
 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 ~NTuple ()
 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.
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 Member Functions

NTupleoperator= (const NTuple &rhs)
 The assignment operator is private to avoid use of it.
void resizeColumns (size_t new_size)
 Resizes the the number of columns of the NTuple.

Private Attributes

std::vector< std::vector
< double > * > 
m_data
 The data columns of the data source table.
int m_i_count
 The interval count.
int m_i_current
 The current interval count.
bool m_i_enabled
 The interval flag.
std::vector< double > m_row
 A temporary vector corresponding to data elements of one row.

Detailed Description

A DataSource class implemented with std::vector<double> to store the column data.

Requests:
@ Besides interval count, need interval timer.
Author
Paul F. Kunz Paul_.nosp@m.Kunz.nosp@m.@slac.nosp@m..sta.nosp@m.nford.nosp@m..edu

Definition at line 33 of file NTuple.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

NTuple ( const std::string &  name)
explicit

Constructs an NTuple object with name name.

Definition at line 44 of file NTuple.cxx.

NTuple ( const char *  name)
explicit

Constructs an NTuple object with name name.

Note
because explicit is used, this method is different from the one that take std::string & argument"

Definition at line 51 of file NTuple.cxx.

NTuple ( const std::vector< std::string > &  labels)
explicit

Constructor taking a vector of column labels as argument.

Definition at line 59 of file NTuple.cxx.

References NTuple::m_data, and num_util::size().

NTuple ( const NTuple nt)
explicit

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

Definition at line 72 of file NTuple.cxx.

References NTuple::copy().

NTuple ( const DataSource ds)
explicit

A constructor that creates an ntuple from another DataSource object.

Definition at line 82 of file NTuple.cxx.

References NTuple::copy().

NTuple ( unsigned int  n)
explicit

A constructor that creates an ntuple with n columns.

Creates an NTuple with n columns. The objects will be empty, i.e. 0 rows.

Definition at line 91 of file NTuple.cxx.

References NTuple::m_data, and NTuple::setLabels().

NTuple ( bool  dummy)
explicit

A constructor for creating a null object.

A null NTuple 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 NTuple before deleting other objects that use it. Classes that reference NTuple objects can be Observer of then in order to receive the Observer::willDelete signal. When received they can replace the referenced NTuple with a null one. They can then continue to function until a valid ntuple is given to them. The parameter dummy is not used.

Definition at line 115 of file NTuple.cxx.

NTuple ( )

The default constructor creating an ntuple with 0 columns.

Definition at line 107 of file NTuple.cxx.

~NTuple ( )
virtual

The destructor.

Definition at line 123 of file NTuple.cxx.

References NTuple::m_data, NTuple::notifyObservers(), and Observer::willDelete().

Member Function Documentation

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

Adds a column to the end of the ntuple and returns the index to the added column.

If the size of the input vector is the same as the size of the existing columns adds a copy of the input vector to then end of the NTuple. Gives the column the label label. Returns the index of the newly created column. If the size of the input vector differs from the size of existing columns, then throws a std::runtime_error object.

Reimplemented from DataSource.

Reimplemented in PyNTuple.

Definition at line 405 of file NTuple.cxx.

References DataSource::addLabel(), hippodraw::Axes::convert(), DataSource::indexOf(), NTuple::m_data, NTuple::rows(), and num_util::size().

Referenced by PyDataSource::addColumn(), DisplayController::createNTupleDiff(), and PyDataSource::saveColumnFromNumArray().

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

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.

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

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 > &  v)
virtual

Adds a row to the end of the ntuple.

If the size of the input vector is the same as the width of the ntuple, adds the row to the end of the ntuple and notifies its Observer objects. Otherwise, throws a std::runtime_error object.

Reimplemented from DataSource.

Reimplemented in CircularBuffer, and PyNTuple.

Definition at line 266 of file NTuple.cxx.

References NTuple::m_data, NTuple::notifyObservers(), num_util::size(), and DataSource::throwIfInvalidRowSize().

Referenced by NTupleController::createNTuple().

void append ( const DataSource source)
virtual

Appends the data from the source.

Reimplemented from DataSource.

Reimplemented in PyNTuple.

Definition at line 189 of file NTuple.cxx.

References DataSource::checkWidth(), NTuple::copy(), and NTuple::m_data.

void checkWidth ( const DataSource source)
protectedvirtualinherited

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().

void clear ( )
virtual

Clears the NTuple.

Clears all the data elements of the NTuple. On return, the number of rows is zero. Does not change the other attributes or capacity.

Implements DataSource.

Reimplemented in CircularBuffer, and PyNTuple.

Definition at line 211 of file NTuple.cxx.

References NTuple::m_data, and NTuple::notifyObservers().

Referenced by NTupleSorter::clear().

double columnMax ( const std::string &  name) const

Returns minimum element in a column whose label is given by name.

Definition at line 567 of file NTuple.cxx.

References NTuple::getColumn().

double columnMin ( const std::string &  name) const

Returns minimum element in a column whose label is given by name.

Definition at line 561 of file NTuple.cxx.

References NTuple::getColumn().

unsigned int columns ( ) const
inlineinherited
void copy ( const DataSource rhs)
virtual
void copyPrivate ( const DataSource other)
protectedvirtualinherited

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
virtualinherited

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.

bool empty ( ) const
virtual

Returns true, if NTuple is empty, i.e.

has no rows.

Implements DataSource.

Definition at line 223 of file NTuple.cxx.

References NTuple::m_data.

Referenced by CircularBuffer::reserve(), and NTuple::rows().

void eraseRow ( unsigned int  index)
virtual

Erases a row from the NTuple.

Removes the row index from the NTuple. Rows beyond the removal point move forward to fill the space. If index is out of range, and exception is thrown.

Reimplemented from DataSource.

Definition at line 308 of file NTuple.cxx.

References NTuple::m_data, NTuple::notifyObservers(), and NTuple::rows().

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

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

Returns the Range of data in the column via the argument.

Always returns true, i.e. does not check for valid data.

Reimplemented from DataSource.

Definition at line 615 of file NTuple.cxx.

References NTuple::m_data, and Range::setRange().

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

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
virtualinherited

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 ( unsigned int  column) const
virtual

Returns the data in the column with index column.

Reimplemented from DataSource.

Definition at line 493 of file NTuple.cxx.

References DataSource::isValidColumn(), and NTuple::m_data.

Referenced by NTupleSorter::addRow(), NTuple::columnMax(), NTuple::columnMin(), NTuple::indexOfMaxElement(), and NTuple::indexOfMinElement().

vector< double > & getColumn ( unsigned int  index)
virtual

Returns a non-const reference to column at the index index.

index is in a valid range, returns a reference to the the column at index index. If index is not in a valid range, throws a DataSourceException object.

Definition at line 500 of file NTuple.cxx.

References DataSource::columns(), NTuple::m_data, and num_util::size().

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

Returns the data in the column with label name.

Reimplemented from DataSource.

Definition at line 511 of file NTuple.cxx.

References DataSource::indexOf(), NTuple::m_data, and DataSource::throwIfInvalidLabel().

const vector< string > & getDuplicatedLabels ( ) const
inherited

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

Definition at line 534 of file DataSource.cxx.

References DataSource::m_dups.

unsigned int getIntervalCount ( ) const

Returns the current interval count.

Definition at line 608 of file NTuple.cxx.

References NTuple::m_i_count.

Referenced by Inspector::updatePlotTab().

const string & getLabelAt ( unsigned int  index) const
virtualinherited

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
virtualinherited
const string & getName ( ) const
inherited
const Observable::ObserverList_t & getObservers ( ) const
inherited

Returns the list of observers.

Definition at line 60 of file Observable.cxx.

unsigned int getRank ( ) const
inherited

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().

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

Returns a temporary vector of data elements in one row.

Returns a temporary vector with data elements copied from the NTuple row indexed by index. If index is out of range, throws a DataSourceException object.

Implements DataSource.

Definition at line 327 of file NTuple.cxx.

References DataSource::columns(), hippodraw::Axes::convert(), NTuple::m_data, NTuple::m_row, and NTuple::rows().

Referenced by NTupleSorter::getRow().

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

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
virtualinherited
unsigned int indexOfMaxElement ( unsigned int  index) const
virtual

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

Reimplemented from DataSource.

Definition at line 542 of file NTuple.cxx.

References NTuple::getColumn().

unsigned int indexOfMinElement ( unsigned int  index) const
virtual

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

Reimplemented from DataSource.

Definition at line 521 of file NTuple.cxx.

References NTuple::getColumn().

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

Inserts a Row.

Adds a row before the existing row specified by index from the elements of v.

Definition at line 280 of file NTuple.cxx.

References NTuple::m_data, NTuple::notifyObservers(), and NTuple::rows().

Referenced by NTupleSorter::addRow().

bool isIntervalEnabled ( ) const

Returns true if interval counting is enabled, otherwise returns false.

Definition at line 597 of file NTuple.cxx.

References NTuple::m_i_enabled.

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

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
inherited
bool isUseable ( const std::string &  column) const
virtualinherited

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
protectedinherited

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
inherited

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().

double maxElement ( unsigned int  index) const
virtual

Returns the value of the maximum element of column index.

Definition at line 554 of file NTuple.cxx.

References NTuple::m_data.

double minElement ( unsigned int  index) const
virtual

Returns the value of the minimum element of column index.

Definition at line 533 of file NTuple.cxx.

References NTuple::m_data.

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.

void notifyObservers ( ) const
virtual

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 from Observable.

Definition at line 574 of file NTuple.cxx.

References NTuple::m_i_count, NTuple::m_i_current, and NTuple::m_i_enabled.

Referenced by NTuple::addRow(), NTuple::clear(), NTuple::eraseRow(), NTuple::insertRow(), NTuple::replaceColumn(), NTuple::replaceRow(), NTuple::setIntervalEnabled(), NTupleSorter::sort(), and NTuple::~NTuple().

NTuple& operator= ( const NTuple rhs)
private

The assignment operator is private to avoid use of it.

double operator[] ( std::vector< unsigned int > &  indices) const
virtual

Implements DataSource.

Definition at line 348 of file NTuple.cxx.

References DataSource::getRank(), NTuple::m_data, DataSource::m_shape, num_util::rank(), and num_util::size().

Referenced by NTuple::valueAt().

void removeObserver ( hippodraw::Observer observer)
inherited
void replaceColumn ( unsigned int  index,
const std::vector< double > &  data 
)
virtual

Replaces the data in column col.

If index is in a valid range and if the size of data is the same as the existing column, then replaces the elements of the specified column with a copy of @ data elements. If index is not a valid range or the sizes differ, then throws a std::runtime_error object.

Reimplemented from DataSource.

Reimplemented in PyNTuple.

Definition at line 440 of file NTuple.cxx.

References DataSource::columns(), hippodraw::Axes::convert(), NTuple::copy(), NTuple::m_data, NTuple::notifyObservers(), NTuple::rows(), and num_util::size().

Referenced by PyDataSource::saveColumnFromNumArray().

void replaceColumn ( const std::string &  label,
const std::vector< double > &  array 
)
virtualinherited

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 ( const std::string &  label,
const std::vector< double > &  data,
const std::vector< intptr_t > &  shape 
)
virtualinherited

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.

void replaceRow ( unsigned int  i,
const std::vector< double > &  data 
)

Replaces the data in the row i.

If index is in a valid range and if the size of data is the same as the existing column, then replaces the elements of the specified column with a copy of @ data elements. If index is not a valid range or the sizes differ, then throws a DataSourceException object

Definition at line 244 of file NTuple.cxx.

References NTuple::m_data, NTuple::notifyObservers(), NTuple::rows(), and DataSource::throwIfInvalidRowSize().

Referenced by CircularBuffer::addRow().

void reserve ( unsigned int  count)
virtual

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

Implements DataSource.

Reimplemented in CircularBuffer.

Definition at line 395 of file NTuple.cxx.

References NTuple::m_data.

void resizeColumns ( size_t  new_size)
private

Resizes the the number of columns of the NTuple.

If new_size is greater then the current number of rows, then the appropriate number of columns containing empty vectors are added. If new_size is less then the current number of rows, then the appropriate number of columns are erased.

Definition at line 133 of file NTuple.cxx.

References NTuple::m_data.

Referenced by NTuple::setLabels().

unsigned int rows ( ) const
virtual
void setIntervalCount ( int  number)

Sets the interval count.

One needs to call setIntervalEnabled for this to have effect. When interval counting is enabled, then only each number notifyObsevers messages will trigger an Observer::update message to the list of Observer objects.

Definition at line 602 of file NTuple.cxx.

References NTuple::m_i_count, and NTuple::m_i_current.

Referenced by DisplayController::setIntervalCount().

void setIntervalEnabled ( bool  yes = true)

Sets interval counting to be enabled.

If yes is false, then a notifyObservers is immediately issued.

Definition at line 589 of file NTuple.cxx.

References NTuple::m_i_current, NTuple::m_i_enabled, and NTuple::notifyObservers().

Referenced by DisplayController::setAllIntervalEnabled(), and DisplayController::setIntervalEnabled().

bool setLabelAt ( const std::string &  s,
unsigned int  index 
)
virtualinherited

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.

If the vector is the same size as the width of the ntuple, then it sets the label and returns true; otherwise, it throws a DataSourceException. If the NTuple is empty, i.e. has no rows, then changes the NTuple's number of columns to the size of the vector.

Reimplemented from DataSource.

Definition at line 471 of file NTuple.cxx.

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

Referenced by NTupleProjector::createEmptyNTuple(), Map2Projector::createNTuple(), MeshProjector::createNTuple(), Map1Projector::createNTuple(), EqualEntriesHist1DProjector::createNTuple(), NTuple::NTuple(), Bins1DBase::prepareNTuple(), and NTupleController::readAsciiNTuple().

void setName ( const std::string &  name)
inherited

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 
)
virtualinherited

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)
virtualinherited

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)
virtualinherited

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 from DataSource.

Definition at line 626 of file NTuple.cxx.

References num_util::data(), and NTuple::m_data.

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

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)
inherited

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
inherited

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().

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

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

Implements DataSource.

Definition at line 388 of file NTuple.cxx.

References NTuple::m_data, and NTuple::operator[]().

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

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
mutableprotectedinherited

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::vector< std::vector<double> *> m_data
private
std::vector< std::string > m_dups
protectedinherited

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().

int m_i_count
private

The interval count.

When used, the number of NotifyObserver messages that are received before an update is passed to this object's observers.

Definition at line 42 of file NTuple.h.

Referenced by NTuple::copy(), NTuple::getIntervalCount(), NTuple::notifyObservers(), and NTuple::setIntervalCount().

int m_i_current
mutableprivate

The current interval count.

When used, this is the current count of NotifyObserver messages received since the last update was sent to Observer object of this object.

Definition at line 48 of file NTuple.h.

Referenced by NTuple::copy(), NTuple::notifyObservers(), NTuple::setIntervalCount(), and NTuple::setIntervalEnabled().

bool m_i_enabled
private

The interval flag.

When true, interval counting is enabled.

Definition at line 52 of file NTuple.h.

Referenced by NTuple::copy(), NTuple::isIntervalEnabled(), NTuple::notifyObservers(), and NTuple::setIntervalEnabled().

std::vector< double > m_row
mutableprivate

A temporary vector corresponding to data elements of one row.

See Also
getRow.

Definition at line 63 of file NTuple.h.

Referenced by NTuple::getRow().

std::vector< unsigned int > m_shape
protectedinherited

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().


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

Generated for HippoDraw Class Library by doxygen