00001 /* -*- mode: c++ -*- */ 00002 00014 #ifndef _DataSourceController_H_ 00015 #define _DataSourceController_H_ 00016 00017 #include "DataSourceException.h" 00018 00019 #include "pattern/Observer.h" 00020 00021 #ifdef _MSC_VER 00022 #include <msdevstudio/MSconfig.h> 00023 #endif 00024 00025 #include <map> 00026 #include <string> 00027 #include <vector> 00028 00029 class DataSource; 00030 class Observable; 00031 00039 class MDL_HIPPOPLOT_API DataSourceController : private hippodraw::Observer 00040 { 00041 00042 private: 00043 00045 static DataSourceController * s_instance; 00046 00047 00049 DataSourceController(); 00050 00052 DataSourceController ( const DataSourceController & ); 00053 00057 typedef std::vector < DataSource * > DataSourceList_t; 00058 00061 DataSourceList_t m_tuples; 00062 00064 std::vector < DataSource * > m_ds_files; 00065 00067 mutable std:: vector < std::string > m_names; 00068 00073 mutable std::vector < DataSource * > m_ntuples; 00074 00076 std::string m_base_name; 00077 00080 int m_suffix; 00081 00082 public: 00083 00085 static DataSourceController * instance (); 00086 00091 virtual void update ( const Observable * ); 00092 00096 void willDelete ( const Observable * observee ); 00097 00100 int indexOfDataSource ( const std::string & name ) const; 00101 00106 DataSource * findDataSource ( const std::string & name ) 00107 const throw ( DataSourceException ); 00108 00113 DataSource * getDataSource ( const std::string & name ) const; 00114 00119 void changeName ( const std::string & oldname, 00120 const std::string & newname ); 00121 00122 00128 const std::vector < DataSource * > & 00129 getDataSources ( bool all = true ) const; 00130 00135 const std::vector < std::string > & getNTupleNames () const; 00136 00139 void registerDataSourceFile ( DataSource * ds ); 00140 00147 std::string registerNTuple ( DataSource * nt ); 00148 00154 void registerNTuple ( const std::string &, DataSource * ntuple ); 00155 00160 void unregisterNTuple ( const DataSource * nt ); 00161 00164 bool isSaved ( const std::string & name ); 00165 00166 }; 00167 00168 #endif // _DataSourceController_H_