14 #include "msdevstudio/MSconfig.h"
29 using std::runtime_error;
33 using namespace hippodraw;
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;
Part of an implementation of the Observable-Observer pattern based on the example in the GOF Patterns...
int m_suffix
Suffix added to base name given to NTuple which is built in memory.
void setCurrentIndex(int index)
Sets the index to the current DataSource.
std::string m_base_name
Base of name given to NTuple which is built in memory.
void willDelete(const Observable *observee)
Responds to Observable being deleted.
void registerDataSourceFile(DataSource *ds)
Registers that the DataSource came from a file.
DataSource * getDataSource(const std::string &name) const
Returns the DataSource object registered as name.
std::vector< std::string > m_names
A temporary list of DataSource names.
DataSource * findDataSource(const std::string &name) const
Returns the DataSource object registered as name.
DataSourceList_t m_sources
The list of registered DataSource objects.
static DataSourceController * s_instance
The pointer to the singleton object.
DataSource * getCurrent() const
Returns a pointer to the current DataSource.
The namespace for conversion to string.
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.
virtual void update(const Observable *)
Responds to the Observable having a change.
hippodraw::DataSource class interface.
DataSourceList_t m_ds_files
The list of files that were read.
DataSourceController()
A default constructor for avoiding creation except by itself.
intp size(numeric::array arr)
string convert(int i)
Converts an integer to a string.
A singleton class that is the interface between GUI and the DataSource objects.
Part of an implementation of the Observable Observer pattern based on the example implementation in t...
void unregisterNTuple(const DataSource *nt)
Un-registers the DataSource.
void getDataSources(std::vector< DataSource * > &, bool all=true) const
Clears and fills the vector with the registered DataSource objects.
std::string registerNTuple(DataSource *nt)
Register a DataSource.
DataSourceController class interface.
void setName(const std::string &name)
Sets the name of the data source.
int m_current_index
The current DataSource index.
const std::string & getName() const
Returns the name of the data source.
const std::vector< std::string > & getNTupleNames() const
Returns a vector of the current DataSource names.
static DataSourceController * instance()
Returns the pointer to the singleton instance.
Base class for DataSource.
int indexOfDataSource(const std::string &name) const
Returns index of DataSource, or -1 if not found.
void changeName(const std::string &old_name, const std::string &new_name)
Changes the name of the DataSource.