00001 #ifndef FITTER_H 00002 #define FITTER_H 00003 00004 #include <is/isinfo.h> 00005 #include <ipc/object.h> 00006 #include <ipc/server.h> 00007 00008 #include <string> 00009 #include <memory> 00010 00011 #include <boost/thread.hpp> 00012 00013 #include "FitterInterface.hh" 00014 #include "FitterArguments.h" 00015 #include "Sct/Exception.h" 00016 #include "Sct/ConfigurationException.h" 00017 #include "Sct/LogicErrors.h" 00018 #include "Sct/IoExceptions.h" 00019 00020 class TH1; 00021 class TF1; 00022 00023 using namespace Sct; 00024 00028 namespace SctFitter { 00029 class FitStrategy; 00030 class FitterWorkerGroup; 00031 00041 class Fitter: 00042 public IPCNamedObject<POA_FitterI::FitterInterface, 00043 ipc::multi_thread>, 00044 private boost::noncopyable { 00045 private: 00047 void shutdown(); 00049 Fitter(FitterArguments args) throw(ConfigurationException); 00051 ~Fitter() throw(); 00052 static Fitter* fitter; 00053 00054 public: 00059 static Fitter& instance(); 00060 00066 static Fitter& initialize(FitterArguments args) throw(ConfigurationException); 00067 00071 void go() throw(IsException); 00072 private: 00073 // INTERNAL METHODS: 00077 const char* internal_status() const throw(); 00081 const char* internal_lastScan() const throw(); 00083 public: 00084 FitStrategy& internal_getFitStrategy() const throw(LogicError) ; 00085 private: 00086 void internal_setFitOptions(const string & opt) throw(LogicError) ; 00091 void internal_setFitStrategy(const string & name) throw(LogicError) ; 00095 long internal_nFitsDone() const throw(); 00099 long internal_nFitErrors() const throw(); 00103 bool internal_isUsingAnalyticAlgorithm() const; 00111 static void doFits(ISCallbackInfo * isc) throw(IsException, LogicError); 00112 00113 public: 00114 // CORBA METHODS: 00119 virtual char* status() throw(); 00123 char* lastScan() throw(); 00127 virtual char* getFitOptions() throw() ; 00131 virtual char* getFitStrategy() throw() ; 00139 00140 virtual void setFitOptions(const char* opt) throw() ; 00147 virtual void setFitStrategy(const char* strategy) throw() ; 00148 // Fit all RawScanResults currently in IS. 00149 void fitAll() throw(); 00151 void fit(const char* name) throw(); 00153 long busy(); 00155 long queueLength(); 00159 long nFitsDone() throw(); 00163 long nFitErrors() throw(); 00167 void useAnalyticAlgorithm (CORBA::Boolean use); 00171 CORBA::Boolean isUsingAnalyticAlgorithm(); 00175 void setFifo(bool); 00179 bool isFifo(); 00181 public: 00185 void incrementFitErrors() throw(); 00186 00190 void incrementFitsDone() throw(); 00191 00195 void scanDone(double time) throw(); 00196 00201 void addIOTime(double time) throw(); 00202 00206 double getAverageTimePerScan() const throw(); 00207 00211 std::string getOutputIsServer() const; 00212 00216 static IPCServer& getFitterServer() throw(); 00217 00218 private: 00219 00220 /* 00221 * counters: 00222 */ 00223 long m_nFitsDone; 00224 long m_nFitErrors; 00225 long m_nScans; 00226 double m_scanTimeTaken; 00227 double m_ioTimeTaken; 00229 mutable boost::recursive_mutex counterMutex; 00230 00231 /* 00232 * name of the last scan attempted. 00233 */ 00234 string m_scan; 00238 mutable string m_status; 00242 FitStrategy* m_fitStrategy; 00244 FitterWorkerGroup* workergroup; 00248 std::auto_ptr<ISInfoReceiver> m_infoReceiver; 00249 00251 void setLastScanName(const std::string& name){ 00252 m_scan = name; 00253 } 00254 00255 void updateSubscriptions(); 00256 00258 friend class FitterWorkerGroup; 00259 FitterArguments m_args; 00260 } 00261 ; // end of definition of class Fitter; 00262 }// end of namespace SctFitter 00263 #endif // #ifndef FITTER_H