Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:56

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 
0027 // The messenger class for batch plotting.
0028 // It implements commands in /analysis/plot directory.
0029 //
0030 // Author: Ivana Hrivnacova, 21/10/2015  (ivana@ipno.in2p3.fr)
0031 
0032 #ifndef G4PlotMessenger_h
0033 #define G4PlotMessenger_h 1
0034 
0035 #include "G4UImessenger.hh"
0036 #include "globals.hh"
0037 
0038 #include <memory>
0039 #include <string_view>
0040 
0041 class G4PlotParameters;
0042 class G4UIdirectory;
0043 class G4UIcommand;
0044 class G4UIcmdWithAString;
0045 class G4UIparameter;
0046 
0047 class G4PlotMessenger : public G4UImessenger
0048 {
0049   public:
0050     explicit G4PlotMessenger(G4PlotParameters* plotParameters);
0051     G4PlotMessenger() = delete;
0052     ~G4PlotMessenger() override;
0053 
0054     // Methods
0055     void SetNewValue(G4UIcommand* command, G4String value) final;
0056 
0057   private:
0058     // Helper functions
0059     template <typename CMD>
0060     std::unique_ptr<CMD> CreateCommand(G4String name, G4String guidance);
0061     void AddIntParameter(
0062       G4UIcommand& command, G4String name, G4String guidance, G4String range = "");
0063 
0064     // Functions to create commands
0065     void SetStyleCmd();
0066     void SetLayoutCmd();
0067     void SetDimensionsCmd();
0068 
0069     // constants
0070     static constexpr std::string_view fkClass { "G4PlotMessenger" };
0071 
0072     // Data members
0073     G4PlotParameters*  fPlotParameters { nullptr }; ///< Associated class
0074     std::unique_ptr<G4UIdirectory>  fDirectory;
0075 
0076     std::unique_ptr<G4UIcommand>  fSetLayoutCmd;
0077     std::unique_ptr<G4UIcommand>  fSetDimensionsCmd;
0078     std::unique_ptr<G4UIcmdWithAString>  fSetStyleCmd;
0079 };
0080 
0081 //_____________________________________________________________________________
0082 template <typename CMD>
0083 std::unique_ptr<CMD> G4PlotMessenger::CreateCommand(
0084   G4String name, G4String guidance)
0085 {
0086   G4String fullName = "/analysis/plot/" + name;
0087 
0088   auto command = std::make_unique<CMD>(fullName, this);
0089   command->SetGuidance(guidance.c_str());
0090   command->AvailableForStates(G4State_PreInit, G4State_Idle);
0091 
0092   return command;
0093 }
0094 
0095 #endif
0096