14 #include "msdevstudio/MSconfig.h" 29 using std::runtime_error;
38 : m_base_name (
"in-memory" ),
40 m_current_index ( -1 )
72 throw ( runtime_error )
77 string what (
"DataSourceController: No NTuple with name `" );
79 what +=
"' has been registered";
80 throw runtime_error ( what );
92 DataSourceList_t::size_type i = 0;
94 for ( ; i <
size; i++ ) {
96 const string & ds_name = ds -> getName ();
97 if ( ds_name == name ) {
123 const std::string & new_name )
127 ntuple -> setName ( new_name );
135 DataSourceList_t::const_iterator first
149 for (
unsigned int i = 0; i <
size; i++ ) {
151 if ( all ==
false ) {
155 sources.push_back ( ds );
160 const vector < string > &
166 DataSourceList_t::const_iterator i =
m_sources.begin ();
169 const string & name = source -> getName ();
181 if ( text.empty () ) {
198 ntuple -> setName ( key );
199 ntuple -> addObserver (
this );
208 DataSourceList_t::iterator i
230 = dynamic_cast <
const DataSource * > ( observee );
231 if ( ntuple == 0 )
return;
static DataSourceController * instance()
Returns the pointer to the singleton instance.
Part of an implementation of the Observable-Observer pattern based on the example in the GOF Patterns...
void willDelete(const Observable *observee)
Responds to Observable being deleted.
DataSourceController()
A default constructor for avoiding creation except by itself.
void unregisterNTuple(const DataSource *nt)
Un-registers the DataSource.
void changeName(const std::string &old_name, const std::string &new_name)
Changes the name of the DataSource.
DataSourceList_t m_ds_files
The list of files that were read.
int m_suffix
Suffix added to base name given to NTuple which is built in memory.
DataSource * getCurrent() const
Returns a pointer to the current DataSource.
std::string registerNTuple(DataSource *nt)
Register a DataSource.
void registerDataSourceFile(DataSource *ds)
Registers that the DataSource came from a file.
DataSource * findDataSource(const std::string &name) const
Returns the DataSource object registered as name.
DataSourceController class interface.
void setName(const std::string &name)
Sets the name of the data source.
The namespace for conversion to string.
Base class for DataSource.
DataSource * getDataSource(const std::string &name) const
Returns the DataSource object registered as name.
intp size(numeric::array arr)
void setCurrentIndex(int index)
Sets the index to the current DataSource.
int m_current_index
The current DataSource index.
const std::vector< std::string > & getNTupleNames() const
Returns a vector of the current DataSource names.
static DataSourceController * s_instance
The pointer to the singleton object.
void getDataSources(std::vector< DataSource * > &, bool all=true) const
Clears and fills the vector with the registered DataSource objects.
hippodraw::DataSource class interface.
std::vector< std::string > m_names
A temporary list of DataSource names.
const std::string & getName() const
Returns the name of the data source.
virtual void update(const Observable *)
Responds to the Observable having a change.
int indexOfDataSource(const std::string &name) const
Returns index of DataSource, or -1 if not found.
A singleton class that is the interface between GUI and the DataSource objects.
string convert(int i)
Converts an integer to a string.
std::string m_base_name
Base of name given to NTuple which is built in memory.
bool isFromFile(const DataSource *source) const
Returns true if the DataSource object was created from a file or was saved to a file, otherwise returns false.
Part of an implementation of the Observable Observer pattern based on the example implementation in t...
DataSourceList_t m_sources
The list of registered DataSource objects.