#include <NTupleController.h>
Collaboration diagram for NTupleController:
It frequently implements the application logic which should neither be in the GUI nor in the NTuple objects.
Definition at line 42 of file NTupleController.h.
Public Member Functions | |
void | changeName (DataSource *source, const std::string &newname) |
Changes the name of the DataSource object. | |
CircularBuffer * | createCircularBuffer () |
Creates and registers an empty CircularBuffer. | |
CircularBuffer * | createCircularBuffer (unsigned int columns) |
Creates and registers an empty CircularBuffer. | |
CircularBuffer * | createCircularBuffer (const std::vector< std::string > &labels) |
Creates and registers an empty CircularBuffer. | |
NTuple * | createNTuple (const std::vector< std::string > &column_list, const std::vector< const TupleCut * > &cut_list, DataSource *ds) |
Create NTuple with column list and cut list. | |
NTuple * | createNTuple () |
Creates and registers an empty NTuple. | |
NTuple * | createNTuple (unsigned int columns) |
Creates and registers an empty NTuple. | |
NTuple * | createNTuple (const std::vector< std::string > &labels) |
Creates and registers an empty NTuple. | |
DataSource * | createNTuple (const std::string &filename) |
Creates and registers an NTuple from data in file filename. | |
int | createNTupleToFile (const std::vector< std::string > &column_list, const std::vector< const TupleCut * > &cut_list, DataSource *ds, const std::string &filename, const std::string &dsname) |
Create NTuple with column list and cut list and save to a file. | |
void | fillFromFile (const std::string &file, NTuple *source) |
Fills the empty NTuple source from reading data from the file. | |
DataSource * | findDataSource (const std::string &name) const |
Returns the DataSource object with name name. | |
void | registerNTuple (const std::string &, DataSource *ntuple) |
Register a NTuple. | |
std::string | registerNTuple (DataSource *nt) |
Register a NTuple. | |
void | saveNTuples (const std::string &prefix, const std::string &suffix) |
Saves all the NTuple. | |
int | writeNTupleToFile (const std::string &name, const std::string &filename) |
Writes the NTuple named name to the file filename. | |
int | writeNTupleToFile (DataSource *source, const std::string &filename) |
Writes the DataSource source to a file given by filename. | |
Static Public Member Functions | |
static NTupleController * | instance () |
Returns the pointer to the singleton instance. | |
Private Member Functions | |
std::string::size_type | findWhite (const std::string &line, unsigned int left=0, bool tabs_only=false) |
Find and return position of white space. | |
NTupleController (const NTupleController &) | |
A private copy constructor in order to avoid copying. | |
NTupleController () | |
A default constructor for avoiding creation except by itself. | |
int | readAsciiNTuple (NTuple *ntuple, const std::string &filename) |
Reads ASCII formatted file and fills the NTuple. | |
void | splitAndFill (const std::string &line, std::vector< std::string > &values) |
Splits the line at white space and fills values with strings found. | |
Static Private Attributes | |
static NTupleController * | s_instance = 0 |
The pointer to the singleton object. |
NTupleController | ( | ) | [private] |
A default constructor for avoiding creation except by itself.
Definition at line 44 of file NTupleController.cxx.
Referenced by NTupleController::instance().
NTupleController | ( | const NTupleController & | ) | [private] |
A private copy constructor in order to avoid copying.
Definition at line 50 of file NTupleController.cxx.
void changeName | ( | DataSource * | source, | |
const std::string & | newname | |||
) |
Changes the name of the DataSource object.
Definition at line 368 of file NTupleController.cxx.
Referenced by NTupleController::saveNTuples().
CircularBuffer * createCircularBuffer | ( | ) |
Creates and registers an empty CircularBuffer.
Creates an empty CircularBuffer with no columns or rows.
Definition at line 348 of file NTupleController.cxx.
References DataSourceController::instance(), and NTupleController::registerNTuple().
CircularBuffer * createCircularBuffer | ( | unsigned int | columns | ) |
Creates and registers an empty CircularBuffer.
Creates an empty CircularBuffer with columns columns.
Definition at line 326 of file NTupleController.cxx.
References DataSourceController::instance(), and NTupleController::registerNTuple().
CircularBuffer * createCircularBuffer | ( | const std::vector< std::string > & | labels | ) |
Creates and registers an empty CircularBuffer.
Creates an empty CircularBuffer with the number of columns equal to the length of the vector labels. The labels for the columns is taken from the elements of the vector labels.
Definition at line 304 of file NTupleController.cxx.
References DataSourceController::instance(), and NTupleController::registerNTuple().
NTuple * createNTuple | ( | const std::vector< std::string > & | column_list, | |
const std::vector< const TupleCut * > & | cut_list, | |||
DataSource * | ds | |||
) |
Create NTuple with column list and cut list.
Definition at line 485 of file NTupleController.cxx.
References NTuple::addRow(), DataSource::indexOf(), DataSource::rows(), num_util::size(), and DataSource::valueAtNoCache().
NTuple * createNTuple | ( | ) |
Creates and registers an empty NTuple.
Creates an empty NTuple with no columns or rows.
Definition at line 337 of file NTupleController.cxx.
References DataSourceController::instance(), and NTupleController::registerNTuple().
NTuple * createNTuple | ( | unsigned int | columns | ) |
Creates and registers an empty NTuple.
Creates an empty NTuple with columns columns.
Definition at line 315 of file NTupleController.cxx.
References DataSourceController::instance(), and NTupleController::registerNTuple().
NTuple * createNTuple | ( | const std::vector< std::string > & | labels | ) |
Creates and registers an empty NTuple.
Creates an empty NTuple with the number of columns equal to the length of the vector labels. The labels for the columns is taken from the elements of the vector labels.
Definition at line 293 of file NTupleController.cxx.
References DataSourceController::instance(), and NTupleController::registerNTuple().
DataSource * createNTuple | ( | const std::string & | filename | ) |
Creates and registers an NTuple from data in file filename.
If file has already been opened, return pointer to the existing NTuple. Otherwise attempts to read the file as NTuple and if successful returns a pointer to the created NTuple object. If file was not found, or could not be parsed, then throws a DataSourceException with an explanation.
Definition at line 247 of file NTupleController.cxx.
References NTupleController::fillFromFile().
Referenced by CreateNTuple::createButtonClicked(), QtCut::createNTuple(), and HiNTupleXML::getObject().
int createNTupleToFile | ( | const std::vector< std::string > & | column_list, | |
const std::vector< const TupleCut * > & | cut_list, | |||
DataSource * | ds, | |||
const std::string & | filename, | |||
const std::string & | dsname | |||
) |
Create NTuple with column list and cut list and save to a file.
Definition at line 528 of file NTupleController.cxx.
References DataSource::rows(), and num_util::size().
Referenced by CreateNTuple::createFileButtonClicked(), and QtCut::createTnt().
void fillFromFile | ( | const std::string & | file, | |
NTuple * | source | |||
) |
Fills the empty NTuple source from reading data from the file.
Definition at line 264 of file NTupleController.cxx.
References DataSourceController::instance(), NTupleController::readAsciiNTuple(), and NTupleController::registerNTuple().
Referenced by NTupleController::createNTuple().
DataSource * findDataSource | ( | const std::string & | name | ) | const |
Returns the DataSource object with name name.
Definition at line 359 of file NTupleController.cxx.
References DataSourceController::instance().
Referenced by NTupleController::writeNTupleToFile().
string::size_type findWhite | ( | const std::string & | line, | |
unsigned int | left = 0 , |
|||
bool | tabs_only = false | |||
) | [private] |
Find and return position of white space.
The argument left is the starting position. If tabs_only is true
, then only tabs are excepted as white space.
Definition at line 65 of file NTupleController.cxx.
Referenced by NTupleController::readAsciiNTuple().
NTupleController * instance | ( | ) | [static] |
Returns the pointer to the singleton instance.
Definition at line 55 of file NTupleController.cxx.
References NTupleController::NTupleController(), and NTupleController::s_instance.
Referenced by CreateNTuple::createButtonClicked(), CreateNTuple::createFileButtonClicked(), QtCut::createNTuple(), QtCut::createTnt(), CanvasView::exportTextTuple(), HiNTupleXML::getObject(), PyNTupleController::instance(), QtFileDialog::openTextTuple(), CanvasWindow::saveAllAs(), and QtFileDialog::saveTextTuple().
int readAsciiNTuple | ( | NTuple * | ntuple, | |
const std::string & | filename | |||
) | [private] |
Reads ASCII formatted file and fills the NTuple.
Returns -1
if file could not be opened. Returns -2 file if there was an error reading the file. Otherwise, returns 0.
Definition at line 114 of file NTupleController.cxx.
References hippodraw::String::convert(), NTupleController::findWhite(), NTuple::setLabels(), DataSource::setTitle(), num_util::shape(), num_util::size(), and NTupleController::splitAndFill().
Referenced by NTupleController::fillFromFile().
void registerNTuple | ( | const std::string & | , | |
DataSource * | ntuple | |||
) |
Register a NTuple.
Definition at line 476 of file NTupleController.cxx.
References DataSourceController::instance(), and NTupleController::registerNTuple().
string registerNTuple | ( | DataSource * | nt | ) |
Register a NTuple.
Definition at line 466 of file NTupleController.cxx.
References DataSourceController::instance().
Referenced by NTupleController::createCircularBuffer(), NTupleController::createNTuple(), NTupleController::fillFromFile(), and NTupleController::registerNTuple().
void saveNTuples | ( | const std::string & | prefix, | |
const std::string & | suffix | |||
) |
Saves all the NTuple.
Saves all the NTuple objects of the application with the file name prefixed by prefix followed by index number and a suffix suffix. After the file is saved, the the file name part of prefix is used to set the NTuple name.
Definition at line 437 of file NTupleController.cxx.
References NTupleController::changeName(), hippodraw::String::convert(), DataSourceController::getDataSources(), DataSourceController::instance(), num_util::size(), and NTupleController::writeNTupleToFile().
void splitAndFill | ( | const std::string & | line, | |
std::vector< std::string > & | values | |||
) | [private] |
Splits the line at white space and fills values with strings found.
Definition at line 80 of file NTupleController.cxx.
Referenced by NTupleController::readAsciiNTuple().
int writeNTupleToFile | ( | const std::string & | name, | |
const std::string & | filename | |||
) |
Writes the NTuple named name to the file filename.
Returns 0
if successful, otherwise returns a yet to be determined return code.
Definition at line 375 of file NTupleController.cxx.
References NTupleController::findDataSource(), DataSourceController::instance(), and NTupleController::writeNTupleToFile().
int writeNTupleToFile | ( | DataSource * | source, | |
const std::string & | filename | |||
) |
Writes the DataSource source to a file given by filename.
Returns 0
if successful, otherwise returns a yet to be determined return code.
Definition at line 390 of file NTupleController.cxx.
References DataSource::getLabels(), DataSource::getRow(), DataSourceController::instance(), DataSource::rows(), and DataSource::title().
Referenced by CanvasView::exportTextTuple(), NTupleController::saveNTuples(), QtFileDialog::saveTextTuple(), and NTupleController::writeNTupleToFile().
NTupleController * s_instance = 0 [static, private] |
The pointer to the singleton object.
Definition at line 48 of file NTupleController.h.
Referenced by NTupleController::instance().