musrfit 1.10.0
PStartupHandler.h
Go to the documentation of this file.
1/***************************************************************************
2
3 PStartupHandler.h
4
5 Author: Andreas Suter
6 e-mail: andreas.suter@psi.ch
7
8***************************************************************************/
9
10/***************************************************************************
11 * Copyright (C) 2007-2026 by Andreas Suter *
12 * andreas.suter@psi.ch *
13 * *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. *
18 * *
19 * This program is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 * GNU General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU General Public License *
25 * along with this program; if not, write to the *
26 * Free Software Foundation, Inc., *
27 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28 ***************************************************************************/
29
30#ifndef _PSTARTUPHANDLER_H_
31#define _PSTARTUPHANDLER_H_
32
33#include <TObject.h>
34#include <TQObject.h>
35#include <TList.h>
36#include <TString.h>
37#include <TSAXParser.h>
38
39#include "PMusr.h"
40
41//--------------------------------------------------------------------------
42// This function is a replacement for the ParseFile method of TSAXParser.
43//--------------------------------------------------------------------------
61int parseXmlFile(TSAXParser*, const char*);
62
162class PStartupHandler : public TObject, public TQObject
163{
164 public:
185 PStartupHandler(bool reset_startup_file=false);
186
196 virtual ~PStartupHandler();
197
200 virtual void OnStartDocument(); // SLOT
201
204 virtual void OnEndDocument(); // SLOT
205
209 virtual void OnStartElement(const Char_t*, const TList*); // SLOT
210
213 virtual void OnEndElement(const Char_t*); // SLOT
214
217 virtual void OnCharacters(const Char_t*); // SLOT
218
221 virtual void OnComment(const Char_t*); // SLOT
222
225 virtual void OnWarning(const Char_t*); // SLOT
226
229 virtual void OnError(const Char_t*); // SLOT
230
233 virtual void OnFatalError(const Char_t*); // SLOT
234
238 virtual void OnCdataBlock(const Char_t*, Int_t); // SLOT
239
244 virtual Bool_t StartupFileFound() { return fStartupFileFound; }
245
251 virtual TString GetStartupFilePath() { return fStartupFilePath; }
252
262 virtual void CheckLists();
263
269
275
280 virtual const PStringVector GetDataPathList() const { return fDataPathList; }
281
286 virtual const PIntVector GetMarkerList() const { return fMarkerList; }
287
292 virtual const PIntVector GetColorList() const { return fColorList; }
293
294 private:
320
330
336 Bool_t StartupFileExists(Char_t *fln);
337
351 Bool_t WriteDefaultStartupFile(bool reset_startup_file=false);
352
353 ClassDef(PStartupHandler, 1)
354};
355
356#endif // _PSTARTUPHANDLER_H_
357
std::vector< PRunNameTemplate > PRunNameTemplateList
Definition PMusr.h:1454
std::vector< Int_t > PIntVector
Definition PMusr.h:367
std::vector< TString > PStringVector
Definition PMusr.h:403
int parseXmlFile(TSAXParser *, const char *)
Replacement function for TSAXParser::ParseFile().
PRunNameTemplateList fRunNameTemplate
List of instrument-specific run name patterns.
PStartupHandler(bool reset_startup_file=false)
Constructor that locates and parses the musrfit startup configuration file.
virtual void CheckLists()
Validates configuration lists and fills missing entries with defaults.
virtual TString GetStartupFilePath()
Returns the full path to the located startup configuration file.
virtual void OnComment(const Char_t *)
SAX callback: Called when XML comment is found (unused).
virtual Bool_t StartupFileFound()
Checks if the startup configuration file was successfully located.
virtual const PRunNameTemplateList GetRunNameTemplateList()
Returns the list of instrument-specific run name templates.
PIntVector fColorList
List of ROOT TColor codes (from RGB) for plotting.
PStringVector fDataPathList
List of directories to search for data files.
Bool_t fStartupFileFound
True if musrfit_startup.xml was located.
virtual void OnWarning(const Char_t *)
SAX callback: Called when XML parser issues a warning.
virtual void OnError(const Char_t *)
SAX callback: Called when XML parser encounters an error.
virtual void OnFatalError(const Char_t *)
SAX callback: Called when XML parser encounters a fatal error.
EKeyWords fKey
Current XML element type (SAX parser state)
TString fStartupFilePath
Full path to located startup file (empty if not found)
EKeyWords
Enumeration of XML element types for SAX parser state machine.
@ eApodization
Inside <apodization> element (none/weak/medium/strong)
@ eFourierPower
Inside <fourier_power> element (0-20)
@ eOptions
Inside <options> element (reserved)
@ eRootSettings
Inside <root_settings> container.
@ eEmpty
No active element (between elements or unknown)
@ eFourierSettings
Inside <fourier_settings> container.
@ eMarker
Inside <marker> element (ROOT marker code)
@ ePhaseIncrement
Inside <phase_increment> element (degrees per step)
@ eUnits
Inside <units> element (Gauss/Tesla/MHz/Mc/s)
@ eMarkerList
Inside <marker_list> container.
@ ePhase
Inside <phase> element (degrees)
@ ePlot
Inside <plot> element (real/imag/real_and_imag/power/phase)
@ eColor
Inside <color> element (RGB comma-separated)
@ eComment
Inside <comment> element.
@ eRunNameTemplate
Inside <run_name_template> element.
@ eColorList
Inside <color_list> container.
@ eDataPath
Inside <data_path> element.
TString fCurrentInstrumentName
Instrument name from run_name_template inst attribute.
virtual void OnEndElement(const Char_t *)
SAX callback: Called when an XML end element is encountered.
virtual void OnCharacters(const Char_t *)
SAX callback: Called with element text content.
PIntVector fMarkerList
List of ROOT TMarker style codes for plotting.
virtual ~PStartupHandler()
Destructor releasing allocated resources.
virtual void OnEndDocument()
SAX callback: Called when XML document parsing ends. Triggers CheckLists() to ensure all required set...
Bool_t WriteDefaultStartupFile(bool reset_startup_file=false)
Creates or overwrites a startup file with default configuration.
virtual void OnCdataBlock(const Char_t *, Int_t)
SAX callback: Called for CDATA blocks (unused).
PMsrFourierStructure fFourierDefaults
Fourier transform default settings structure.
virtual void OnStartElement(const Char_t *, const TList *)
SAX callback: Called when an XML start element is encountered.
virtual const PStringVector GetDataPathList() const
Returns the list of data file search paths.
virtual void OnStartDocument()
SAX callback: Called when XML document parsing begins. Initializes all configuration variables to def...
virtual const PIntVector GetColorList() const
Returns the list of ROOT color codes for plotting.
Bool_t StartupFileExists(Char_t *fln)
Checks if a file exists at the specified path.
virtual PMsrFourierStructure GetFourierDefaults()
Returns Fourier transform default settings.
virtual const PIntVector GetMarkerList() const
Returns the list of ROOT marker codes for plotting.