Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

NTupleController Class Reference

#include <NTupleController.h>

Collaboration diagram for NTupleController:

Collaboration graph
[legend]
List of all members.

Detailed Description

A singleton class that is the interface between GUI and the NTuple objects.

It frequently implements the application logic which should neither be in the GUI nor in the NTuple objects.

Todo:
This class should probably inherit from DataSource controller as it delegates some member functions to that class and uses it often.
However, DataSourceController wants to be singleton, so can we have derived classes of singleton?

Author:
Paul F. Kunz <Paul_Kunz@slac.stanford.edu>

Definition at line 40 of file NTupleController.h.

Public Member Functions

void changeName (DataSource *source, const std::string &newname)
 Changes the name of the DataSource object.
CircularBuffercreateCircularBuffer ()
 Creates and registers an empty CircularBuffer.
CircularBuffercreateCircularBuffer (unsigned int columns)
 Creates and registers an empty CircularBuffer.
CircularBuffercreateCircularBuffer (const std::vector< std::string > &labels)
 Creates and registers an empty CircularBuffer.
NTuplecreateNTuple ()
 Creates and registers an empty NTuple.
NTuplecreateNTuple (unsigned int columns)
 Creates and registers an empty NTuple.
NTuplecreateNTuple (const std::vector< std::string > &labels)
 Creates and registers an empty NTuple.
DataSourcecreateNTuple (const std::string &filename)
 Creates and registers an NTuple from data in file filename.
DataSourcefindDataSource (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 NTupleControllerinstance ()
 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.

Static Private Attributes

static NTupleControllers_instance = 0
 The pointer to the singleton object.


Constructor & Destructor Documentation

NTupleController::NTupleController  )  [private]
 

A default constructor for avoiding creation except by itself.

Definition at line 48 of file NTupleController.cxx.

Referenced by instance().

NTupleController::NTupleController const NTupleController  )  [private]
 

A private copy constructor in order to avoid copying.

Only needed for SIP interface and should never be called.

Definition at line 54 of file NTupleController.cxx.


Member Function Documentation

void NTupleController::changeName DataSource source,
const std::string newname
 

Changes the name of the DataSource object.

Deprecated:
.
This method is deprecated. There's no need to call this member function.

Definition at line 307 of file NTupleController.cxx.

Referenced by hippodraw::Python::export_NTupleController(), and saveNTuples().

CircularBuffer * NTupleController::createCircularBuffer  ) 
 

Creates and registers an empty CircularBuffer.

Creates an empty CircularBuffer with no columns or rows.

Note:
This method is deprecated. Create the CircularBuffer and registered it explicitly instead.

Definition at line 287 of file NTupleController.cxx.

References DataSourceController::instance(), and registerNTuple().

Referenced by hippodraw::Python::export_NTupleController().

CircularBuffer * NTupleController::createCircularBuffer unsigned int  columns  ) 
 

Creates and registers an empty CircularBuffer.

Creates an empty CircularBuffer with columns columns.

Note:
This method is deprecated. Create the CircularBuffer and registered it explicitly instead.

Definition at line 265 of file NTupleController.cxx.

References DataSourceController::instance(), and registerNTuple().

CircularBuffer * NTupleController::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 243 of file NTupleController.cxx.

References DataSourceController::instance(), and registerNTuple().

NTuple * NTupleController::createNTuple  ) 
 

Creates and registers an empty NTuple.

Creates an empty NTuple with no columns or rows.

Definition at line 276 of file NTupleController.cxx.

References DataSourceController::instance(), and registerNTuple().

Referenced by hippodraw::Python::export_NTupleController().

NTuple * NTupleController::createNTuple unsigned int  columns  ) 
 

Creates and registers an empty NTuple.

Creates an empty NTuple with columns columns.

Note:
This method is deprecated. Create the Ntuple and registered it explicitly instead.

Definition at line 254 of file NTupleController.cxx.

References DataSourceController::instance(), and registerNTuple().

NTuple * NTupleController::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.

Note:
This method is deprecated. Create the Ntuple and registered it explicitly instead.

Definition at line 232 of file NTupleController.cxx.

References DataSourceController::instance(), and registerNTuple().

DataSource * NTupleController::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.

Note:
This method is deprecated. Create the Ntuple and registered it explicitly instead.

Definition at line 194 of file NTupleController.cxx.

References DataSourceController::instance(), readAsciiNTuple(), registerNTuple(), and DataSource::setName().

Referenced by HiNTupleXML::getObject(), and main().

DataSource * NTupleController::findDataSource const std::string name  )  const
 

Returns the DataSource object with name name.

Deprecated:
This method is deprecated.
Use the DataSourceController methods instead.

Definition at line 298 of file NTupleController.cxx.

References DataSourceController::instance().

Referenced by hippodraw::Python::export_NTupleController(), and writeNTupleToFile().

string::size_type NTupleController::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 69 of file NTupleController.cxx.

Referenced by readAsciiNTuple().

NTupleController * NTupleController::instance  )  [static]
 

Returns the pointer to the singleton instance.

Definition at line 59 of file NTupleController.cxx.

References NTupleController(), and s_instance.

Referenced by hippodraw::Python::export_NTupleController(), CanvasView::exportTextTuple(), HiNTupleXML::getObject(), main(), QtFileDialog::openTextTuple(), CanvasWindow::saveAllAs(), and saveNTuples().

int NTupleController::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 101 of file NTupleController.cxx.

References NTuple::addRow(), findWhite(), NTuple::setLabels(), DataSource::setTitle(), num_util::shape(), and num_util::size().

Referenced by createNTuple().

void NTupleController::registerNTuple const std::string ,
DataSource ntuple
 

Register a NTuple.

Deprecated:
This method is deprecated.
Use DataSourceController::registerNTuple(const std::string &,DataSource *) instead.

Definition at line 418 of file NTupleController.cxx.

References DataSourceController::instance(), and registerNTuple().

string NTupleController::registerNTuple DataSource nt  ) 
 

Register a NTuple.

Deprecated:
This method is deprecated.
Use DataSourceController::registerNTuple(DataSource *) instead.

Definition at line 408 of file NTupleController.cxx.

References DataSourceController::instance().

Referenced by createCircularBuffer(), createNTuple(), hippodraw::Python::export_NTupleController(), and registerNTuple().

void NTupleController::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 372 of file NTupleController.cxx.

References changeName(), DataSourceController::getDataSources(), DataSource::getName(), instance(), DataSourceController::instance(), num_util::size(), and writeNTupleToFile().

int NTupleController::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 314 of file NTupleController.cxx.

References findDataSource(), DataSourceController::instance(), and writeNTupleToFile().

int NTupleController::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 328 of file NTupleController.cxx.

References DataSource::getLabels(), DataSource::getRow(), DataSource::rows(), and DataSource::title().

Referenced by hippodraw::Python::export_NTupleController(), CanvasView::exportTextTuple(), saveNTuples(), and writeNTupleToFile().


Member Data Documentation

NTupleController * NTupleController::s_instance = 0 [static, private]
 

The pointer to the singleton object.

Definition at line 46 of file NTupleController.cxx.

Referenced by instance().


The documentation for this class was generated from the following files:
Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3