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

DataSourceController Class Reference

#include <DataSourceController.h>

Inheritance diagram for DataSourceController:

Inheritance graph
[legend]
Collaboration diagram for DataSourceController:

Collaboration graph
[legend]
List of all members.

Detailed Description

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

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

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

Definition at line 39 of file DataSourceController.h.

Public Member Functions

void changeName (const std::string &oldname, const std::string &newname)
 Changes the name of the NTuple.
DataSourcefindDataSource (const std::string &name) const throw ( DataSourceException )
 Returns the DataSource object with registered name name.
DataSourcegetDataSource (const std::string &name) const
 Returns the DataSource object with registered name name.
const std::vector< DataSource * > & getDataSources (bool all=true) const
 Returns the vector of the current DataSource objects.
const std::vector< std::string > & getNTupleNames () const
 Returns a vector of the current DataSource names.
int indexOfDataSource (const std::string &name) const
 Returns index of DataSource, or -1 if not found.
bool isSaved (const std::string &name)
 Returns true if the ntuple with name has been saved to or read from a file.
void registerDataSourceFile (DataSource *ds)
 Registers that the DataSource came from a file.
void registerNTuple (const std::string &, DataSource *ntuple)
 Register a NTuple.
std::string registerNTuple (DataSource *nt)
 Register a NTuple.
void unregisterNTuple (const DataSource *nt)
 Un-registers the NTuple.
virtual void update (const Observable *)
 Responds to the Observable having a change.
void willDelete (const Observable *observee)
 Responds to Observable being deleted.

Static Public Member Functions

static DataSourceControllerinstance ()
 Returns the pointer to the singleton instance.

Private Types

typedef std::vector< DataSource * > DataSourceList_t
 The type of STL container used to keep list of DataSource objects.

Private Member Functions

 DataSourceController (const DataSourceController &)
 A private copy constructor in order to avoid copying.
 DataSourceController ()
 A default constructor for avoiding creation except by itself.

Private Attributes

std::string m_base_name
 Base of name given to NTuple which is built in memory.
std::vector< DataSource * > m_ds_files
 The list of files that were read from a file.
std::vector< std::stringm_names
 A temporary list of DataSource names.
std::vector< DataSource * > m_ntuples
 A temporary list of DataSource objects.
int m_suffix
 Suffix added to base name given to NTuple which is built in memory.
DataSourceList_t m_tuples
 The list of registered DataSource objects.

Static Private Attributes

static DataSourceControllers_instance = 0
 The pointer to the singleton object.


Member Typedef Documentation

typedef std::vector< DataSource * > DataSourceController::DataSourceList_t [private]
 

The type of STL container used to keep list of DataSource objects.

Definition at line 57 of file DataSourceController.h.


Constructor & Destructor Documentation

DataSourceController::DataSourceController  )  [private]
 

A default constructor for avoiding creation except by itself.

Definition at line 46 of file DataSourceController.cxx.

Referenced by instance().

DataSourceController::DataSourceController const DataSourceController  )  [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 DataSourceController.cxx.


Member Function Documentation

void DataSourceController::changeName const std::string oldname,
const std::string newname
 

Changes the name of the NTuple.

Changes the name of the registered NTuple object designated by oldname, to the name newname.

Definition at line 131 of file DataSourceController.cxx.

References getDataSource().

DataSource * DataSourceController::findDataSource const std::string name  )  const throw ( DataSourceException )
 

Returns the DataSource object with registered name name.

If a object of the given name is found, returns a pointer to it, otherwise throws a DataSourceException.

Definition at line 76 of file DataSourceController.cxx.

DataSource * DataSourceController::getDataSource const std::string name  )  const
 

Returns the DataSource object with registered name name.

If the object is found, return a pointer to it. If the object is not found, return a null pointer.

Definition at line 112 of file DataSourceController.cxx.

References m_tuples, and num_util::size().

Referenced by changeName(), and registerNTuple().

const vector< DataSource * > & DataSourceController::getDataSources bool  all = true  )  const
 

Returns the vector of the current DataSource objects.

If all is true, the default, returns vector of all DataSources registered with the controller. If all is false, then only returns the DataSoruces that were not read from a file.

Definition at line 142 of file DataSourceController.cxx.

References m_tuples.

Referenced by XmlController::fillNTupleMap(), and NTupleController::saveNTuples().

const vector< string > & DataSourceController::getNTupleNames  )  const
 

Returns a vector of the current DataSource names.

Attention:
The order of the names should agree with the order from getNTuples. This is so that the application can fill a GUI with names, and access the DataSource by index.

Definition at line 147 of file DataSourceController.cxx.

References m_names, and m_tuples.

Referenced by CanvasView::exportTextTuple().

int DataSourceController::indexOfDataSource const std::string name  )  const
 

Returns index of DataSource, or -1 if not found.

Definition at line 93 of file DataSourceController.cxx.

References m_tuples, and num_util::size().

DataSourceController * DataSourceController::instance  )  [static]
 

Returns the pointer to the singleton instance.

Definition at line 59 of file DataSourceController.cxx.

References DataSourceController(), and s_instance.

Referenced by Inspector::addDataRepButton_clicked(), DisplayController::areDataSourcesSaved(), Inspector::availPlotTypesActivated(), Inspector::changeNTupleName(), NTupleController::createCircularBuffer(), QtRootController::createNTuple(), NTupleController::createNTuple(), RootController::createNTuple(), FitsController::createNTuple(), DisplayController::createNTuple(), FunctionController::createResidualsDisplay(), FunctionController::ellipsoidNTuple(), CanvasView::exportTextTuple(), XmlController::fillNTupleMap(), NTupleController::findDataSource(), Inspector::getSelectedDataSourceName(), Inspector::newPlotButton_clicked(), Inspector::ntupleChanged(), PickTable::PickTable(), QtDisplay::QtDisplay(), PyDataSource::registerNTuple(), NTupleController::registerNTuple(), NTupleController::saveNTuples(), Inspector::setNewPlotNTuple(), Inspector::updateNewPlotControls(), Inspector::updateSelectedPlotDataSource(), and NTupleController::writeNTupleToFile().

bool DataSourceController::isSaved const std::string name  ) 
 

Returns true if the ntuple with name has been saved to or read from a file.

Definition at line 229 of file DataSourceController.cxx.

References m_base_name.

Referenced by DisplayController::areDataSourcesSaved().

void DataSourceController::registerDataSourceFile DataSource ds  ) 
 

Registers that the DataSource came from a file.

Definition at line 69 of file DataSourceController.cxx.

References m_ds_files.

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

Register a NTuple.

Register NTuple object ntuple using the name key for later lookup. NTuple objects need to be registered in order to be visible application wide using this singleton controller.

Definition at line 185 of file DataSourceController.cxx.

References getDataSource(), and m_tuples.

string DataSourceController::registerNTuple DataSource nt  ) 
 

Register a NTuple.

A unique name will be generated for the NTuple. Alternately, the programmer could use one of this class's createNTuple methods.

See also:
registerNTuple( const std::string &, NTuple * ).

Definition at line 163 of file DataSourceController.cxx.

References DataSource::getName(), m_base_name, m_suffix, and DataSource::setName().

Referenced by PickTable::PickTable(), and PyDataSource::registerNTuple().

void DataSourceController::unregisterNTuple const DataSource nt  ) 
 

Un-registers the NTuple.

Un-registers the NTuple from the list of available NTuple objects. If the object is not found, does nothing.

Definition at line 201 of file DataSourceController.cxx.

References std::find(), and m_tuples.

Referenced by willDelete().

void DataSourceController::update const Observable  )  [virtual]
 

Responds to the Observable having a change.

This implementation does noting. The implementation is required because of the pure virtual function in the base class.

Implements hippodraw::Observer.

Definition at line 212 of file DataSourceController.cxx.

void DataSourceController::willDelete const Observable observee  )  [virtual]
 

Responds to Observable being deleted.

If observer is an object derived from NTuple, then unregisters it.

Reimplemented from hippodraw::Observer.

Definition at line 218 of file DataSourceController.cxx.

References unregisterNTuple().


Member Data Documentation

std::string DataSourceController::m_base_name [private]
 

Base of name given to NTuple which is built in memory.

Definition at line 76 of file DataSourceController.h.

Referenced by isSaved(), and registerNTuple().

std::vector< DataSource * > DataSourceController::m_ds_files [private]
 

The list of files that were read from a file.

Definition at line 64 of file DataSourceController.h.

Referenced by registerDataSourceFile().

std:: vector< std::string > DataSourceController::m_names [mutable, private]
 

A temporary list of DataSource names.

Definition at line 67 of file DataSourceController.h.

Referenced by getNTupleNames().

std::vector< DataSource * > DataSourceController::m_ntuples [mutable, private]
 

A temporary list of DataSource objects.

Todo:
This member can be eventually removed.
See also:
getNTuples().

Definition at line 73 of file DataSourceController.h.

int DataSourceController::m_suffix [private]
 

Suffix added to base name given to NTuple which is built in memory.

Definition at line 80 of file DataSourceController.h.

Referenced by registerNTuple().

DataSourceList_t DataSourceController::m_tuples [private]
 

The list of registered DataSource objects.

Definition at line 61 of file DataSourceController.h.

Referenced by getDataSource(), getDataSources(), getNTupleNames(), indexOfDataSource(), registerNTuple(), and unregisterNTuple().

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

The pointer to the singleton object.

Definition at line 44 of file DataSourceController.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