DataSourceController.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
2 
14 #ifndef _DataSourceController_H_
15 #define _DataSourceController_H_
16 
17 #include "pattern/Observer.h"
18 
19 #ifdef _MSC_VER
20 #include <msdevstudio/MSconfig.h>
21 #pragma warning(disable:4290) // advice from MSDN article and others
22  // VC++ is not following the standard
23 #endif
24 
25 #include <stdexcept>
26 #include <vector>
27 
28 namespace hippodraw {
29 
30 class DataSource;
31 class Observable;
32 
41 {
42 
43 private:
44 
47 
50 
53 
57  typedef std::vector < DataSource * > DataSourceList_t;
58 
62 
66 
68  mutable std:: vector < std::string > m_names;
69 
71  std::string m_base_name;
72 
75  int m_suffix;
76 
80 
81 public:
82 
84  static DataSourceController * instance ();
85 
90  virtual void update ( const Observable * );
91 
95  void willDelete ( const Observable * observee );
96 
102  int indexOfDataSource ( const std::string & name ) const;
103 
111  DataSource * findDataSource ( const std::string & name )
112  const throw ( std::runtime_error );
113 
121  DataSource * getDataSource ( const std::string & name ) const;
122 
127  void changeName ( const std::string & old_name,
128  const std::string & new_name );
129 
130 
137  void getDataSources ( std::vector < DataSource * > &,
138  bool all = true ) const;
139 
145  const std::vector < std::string > & getNTupleNames () const;
146 
149  void registerDataSourceFile ( DataSource * ds );
150 
155  std::string registerNTuple ( DataSource * nt );
156 
162  void registerNTuple ( const std::string &, DataSource * source );
163 
168  void unregisterNTuple ( const DataSource * nt );
169 
173  bool isFromFile ( const DataSource * source ) const;
174 
177  DataSource * getCurrent () const;
178 
181  void setCurrentIndex ( int index );
182 
183 };
184 
185 } // namespace hippodraw
186 
187 #endif // _DataSourceController_H_
#define MDL_HIPPOPLOT_API
Definition: libhippo.h:36
Part of an implementation of the Observable-Observer pattern based on the example in the GOF Patterns...
Definition: Observable.h:39
int m_suffix
Suffix added to base name given to NTuple which is built in memory.
std::string m_base_name
Base of name given to NTuple which is built in memory.
std::vector< DataSource * > DataSourceList_t
The type of STL container used to keep list of DataSource objects.
std::vector< std::string > m_names
A temporary list of DataSource names.
DataSourceList_t m_sources
The list of registered DataSource objects.
static DataSourceController * s_instance
The pointer to the singleton object.
DataSourceList_t m_ds_files
The list of files that were read.
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...
Definition: Observer.h:34
return index
Definition: PickTable.cxx:182
int m_current_index
The current DataSource index.
Observer class interface.
Base class for DataSource.
Definition: DataSource.h:55

Generated for HippoDraw Class Library by doxygen