00001
00002
00014 #ifndef _DataSourceController_H_
00015 #define _DataSourceController_H_
00016
00017 #include "pattern/Observer.h"
00018
00019 #ifdef _MSC_VER
00020 #include <msdevstudio/MSconfig.h>
00021 #pragma warning(disable:4290) // advice from MSDN article and others
00022
00023 #endif
00024
00025 #include <stdexcept>
00026 #include <vector>
00027
00028 namespace hippodraw {
00029
00030 class DataSource;
00031 class Observable;
00032
00040 class MDL_HIPPOPLOT_API DataSourceController : private hippodraw::Observer
00041 {
00042
00043 private:
00044
00046 static DataSourceController * s_instance;
00047
00049 DataSourceController();
00050
00052 DataSourceController ( const DataSourceController & );
00053
00057 typedef std::vector < DataSource * > DataSourceList_t;
00058
00061 DataSourceList_t m_sources;
00062
00065 DataSourceList_t m_ds_files;
00066
00068 mutable std:: vector < std::string > m_names;
00069
00071 std::string m_base_name;
00072
00075 int m_suffix;
00076
00079 int m_current_index;
00080
00081 public:
00082
00084 static DataSourceController * instance ();
00085
00090 virtual void update ( const Observable * );
00091
00095 void willDelete ( const Observable * observee );
00096
00102 int indexOfDataSource ( const std::string & name ) const;
00103
00111 DataSource * findDataSource ( const std::string & name )
00112 const throw ( std::runtime_error );
00113
00121 DataSource * getDataSource ( const std::string & name ) const;
00122
00127 void changeName ( const std::string & old_name,
00128 const std::string & new_name );
00129
00130
00137 void getDataSources ( std::vector < DataSource * > &,
00138 bool all = true ) const;
00139
00145 const std::vector < std::string > & getNTupleNames () const;
00146
00149 void registerDataSourceFile ( DataSource * ds );
00150
00155 std::string registerNTuple ( DataSource * nt );
00156
00162 void registerNTuple ( const std::string &, DataSource * source );
00163
00168 void unregisterNTuple ( const DataSource * nt );
00169
00173 bool isFromFile ( const DataSource * source ) const;
00174
00177 DataSource * getCurrent () const;
00178
00181 void setCurrentIndex ( int index );
00182
00183 };
00184
00185 }
00186
00187 #endif // _DataSourceController_H_